refactor of model targets and constraints, addition of new constraint types and constraint construction process

This commit is contained in:
Joshua Burman
2023-11-12 18:32:48 -05:00
parent 07af0ac0ac
commit f1fa519f31
16 changed files with 140 additions and 86 deletions

View File

@ -2,10 +2,11 @@ from __future__ import annotations
from pydantic import BaseModel
from typing import Dict, List, AnyStr
from pulp import lpSum
from models.tif_target import TifTarget
from models.tcc_target import TccTarget
from models.targets.tif_target import TifTarget
from models.targets.tcc_target import TccTarget
from models.problem import Problem
class ObjectiveFunction(BaseModel):
# minimizing tif/tcc target value is only option currently
@ -17,6 +18,15 @@ class ObjectiveFunction(BaseModel):
objective: AnyStr = "minimize"
weight: Dict = {'tif': 1, 'tcc': 1}
def for_problem(self, problem_handler: Problem) -> None:
problem_handler.problem += lpSum([
bundle.count * problem_handler.solver_bundles_var[bundle.id]
for bundle in problem_handler.bundles
] + [
problem_handler.solver_items_var[item.id]
for item in problem_handler.items
])
def increment_targets_drift(self,
limit: float or bool,
all: bool = False,