just update the Target drift attribute to so we dont have to inject the drift_percent every single time
This commit is contained in:
parent
e4f51b8a3f
commit
bd61fb7e81
@ -30,6 +30,12 @@ class ObjectiveFunction(BaseModel):
|
|||||||
print(self.tcc_targets)
|
print(self.tcc_targets)
|
||||||
return amount
|
return amount
|
||||||
|
|
||||||
|
def update_targets_drift(self, amount: float = 0.0):
|
||||||
|
for target in self.tif_targets:
|
||||||
|
target.drift = round(amount, 2)
|
||||||
|
for target in self.tcc_targets:
|
||||||
|
target.drift = round(amount, 2)
|
||||||
|
|
||||||
def minimum_drift(self) -> float:
|
def minimum_drift(self) -> float:
|
||||||
minimum_drift = 0.0
|
minimum_drift = 0.0
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ class Target(BaseModel):
|
|||||||
def max_drift_increment(cls) -> int:
|
def max_drift_increment(cls) -> int:
|
||||||
return 1 # 10%
|
return 1 # 10%
|
||||||
|
|
||||||
def minimum(self, drift_percent = 0.0) -> float:
|
def minimum(self) -> float:
|
||||||
return self.value - (self.value * drift_percent)
|
return self.value - (self.value * self.drift)
|
||||||
|
|
||||||
def maximum(self, drift_percent = 0.0) -> float:
|
def maximum(self) -> float:
|
||||||
return self.value + (self.value * drift_percent)
|
return self.value + (self.value * self.drift)
|
||||||
|
@ -80,6 +80,7 @@ class LoftService(Base):
|
|||||||
|
|
||||||
while current_drift <= Target.max_drift():
|
while current_drift <= Target.max_drift():
|
||||||
drift_percent = current_drift / 100
|
drift_percent = current_drift / 100
|
||||||
|
self.solver_run.objective_function.update_targets_drift(drift_percent)
|
||||||
|
|
||||||
# create problem
|
# create problem
|
||||||
problem = LpProblem('ata-form-generate', LpMinimize)
|
problem = LpProblem('ata-form-generate', LpMinimize)
|
||||||
@ -120,7 +121,7 @@ class LoftService(Base):
|
|||||||
item.iif(self.solver_run, tif_target.theta) * items[item.id]
|
item.iif(self.solver_run, tif_target.theta) * items[item.id]
|
||||||
for item in self.solver_run.unbundled_items()
|
for item in self.solver_run.unbundled_items()
|
||||||
]
|
]
|
||||||
) >= tif_target.minimum(drift_percent), f'Min TIF theta({tif_target.theta}) at target {tif_target.value} drift at {current_drift}%'
|
) >= tif_target.minimum(), f'Min TIF theta({tif_target.theta}) at target {tif_target.value} drift at {current_drift}%'
|
||||||
problem += lpSum(
|
problem += lpSum(
|
||||||
[
|
[
|
||||||
bundle.tif(self.solver_run.irt_model, tif_target.theta) * bundles[bundle.id]
|
bundle.tif(self.solver_run.irt_model, tif_target.theta) * bundles[bundle.id]
|
||||||
@ -130,7 +131,7 @@ class LoftService(Base):
|
|||||||
item.iif(self.solver_run, tif_target.theta) * items[item.id]
|
item.iif(self.solver_run, tif_target.theta) * items[item.id]
|
||||||
for item in self.solver_run.unbundled_items()
|
for item in self.solver_run.unbundled_items()
|
||||||
]
|
]
|
||||||
) <= tif_target.maximum(drift_percent), f'Max TIF theta({tif_target.theta}) at target {tif_target.value} drift at {current_drift}%'
|
) <= tif_target.maximum(), f'Max TIF theta({tif_target.theta}) at target {tif_target.value} drift at {current_drift}%'
|
||||||
|
|
||||||
for tcc_target in self.solver_run.objective_function.tcc_targets:
|
for tcc_target in self.solver_run.objective_function.tcc_targets:
|
||||||
problem += lpSum(
|
problem += lpSum(
|
||||||
@ -142,7 +143,7 @@ class LoftService(Base):
|
|||||||
item.irf(self.solver_run, tcc_target.theta) * items[item.id]
|
item.irf(self.solver_run, tcc_target.theta) * items[item.id]
|
||||||
for item in self.solver_run.unbundled_items()
|
for item in self.solver_run.unbundled_items()
|
||||||
]
|
]
|
||||||
) >= tcc_target.minimum(drift_percent), f'Min TCC theta({tcc_target.theta}) at target {tcc_target.value} drift at {current_drift}%'
|
) >= tcc_target.minimum(), f'Min TCC theta({tcc_target.theta}) at target {tcc_target.value} drift at {current_drift}%'
|
||||||
problem += lpSum(
|
problem += lpSum(
|
||||||
[
|
[
|
||||||
bundle.trf(self.solver_run.irt_model, tcc_target.theta) * bundles[bundle.id]
|
bundle.trf(self.solver_run.irt_model, tcc_target.theta) * bundles[bundle.id]
|
||||||
@ -152,7 +153,7 @@ class LoftService(Base):
|
|||||||
item.irf(self.solver_run, tcc_target.theta) * items[item.id]
|
item.irf(self.solver_run, tcc_target.theta) * items[item.id]
|
||||||
for item in self.solver_run.unbundled_items()
|
for item in self.solver_run.unbundled_items()
|
||||||
]
|
]
|
||||||
) <= tcc_target.maximum(drift_percent), f'Max TCC theta({tcc_target.theta}) at target {tcc_target.value} drift at {current_drift}%'
|
) <= tcc_target.maximum(), f'Max TCC theta({tcc_target.theta}) at target {tcc_target.value} drift at {current_drift}%'
|
||||||
|
|
||||||
logging.info(f'Solving for Form {form_number} with a drift of {current_drift}%')
|
logging.info(f'Solving for Form {form_number} with a drift of {current_drift}%')
|
||||||
problem.solve()
|
problem.solve()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user