refactor of model targets and constraints, addition of new constraint types and constraint construction process
This commit is contained in:
31
app/models/targets/tif_target.py
Normal file
31
app/models/targets/tif_target.py
Normal file
@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from models.targets.target import *
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from models.problem import Problem
|
||||
|
||||
class TifTarget(Target):
|
||||
def constraints(self, problem_handler: Problem, solver_run: SolverRun):
|
||||
problem_handler.problem += lpSum([
|
||||
bundle.tif(solver_run.irt_model, self.theta)
|
||||
* problem_handler.solver_bundles_var[bundle.id]
|
||||
for bundle in problem_handler.bundles
|
||||
] + [
|
||||
item.iif(solver_run.irt_model, self.theta) *
|
||||
problem_handler.solver_items_var[item.id]
|
||||
for item in problem_handler.items
|
||||
]) >= self.minimum(
|
||||
), f'Min TIF theta({self.theta}) at target {self.value} with a drift % of {self.drift}'
|
||||
|
||||
problem_handler.problem += lpSum([
|
||||
bundle.tif(solver_run.irt_model, self.theta)
|
||||
* problem_handler.solver_bundles_var[bundle.id]
|
||||
for bundle in problem_handler.bundles
|
||||
] + [
|
||||
item.iif(solver_run.irt_model, self.theta) *
|
||||
problem_handler.solver_items_var[item.id]
|
||||
for item in problem_handler.items
|
||||
]) <= self.maximum(
|
||||
), f'Max TIF theta({self.theta}) at target {self.value} with a drift % of {self.drift}'
|
Reference in New Issue
Block a user