refactor of model targets and constraints, addition of new constraint types and constraint construction process
This commit is contained in:
31
app/models/targets/target.py
Normal file
31
app/models/targets/target.py
Normal file
@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
|
||||
from pulp import lpSum
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from models.solver_run import SolverRun
|
||||
from models.problem import Problem
|
||||
|
||||
class Target(BaseModel):
|
||||
theta: float
|
||||
value: float
|
||||
result: Optional[float] = None
|
||||
drift: float = 0.0
|
||||
|
||||
@classmethod
|
||||
def max_drift(cls) -> int:
|
||||
return 15
|
||||
|
||||
@classmethod
|
||||
def max_drift_increment(cls) -> int:
|
||||
return 1 # 10%
|
||||
|
||||
def minimum(self) -> float:
|
||||
return self.value - (self.value * self.drift)
|
||||
|
||||
def maximum(self) -> float:
|
||||
return self.value + (self.value * self.drift)
|
Reference in New Issue
Block a user