moved constraints to objects
This commit is contained in:
@ -48,7 +48,7 @@ def build_constraints(solver_run: SolverRun, problem: LpProblem,
|
||||
elif attribute.type == 'bundle':
|
||||
logging.info('Bundles Constraint Generating...')
|
||||
# TODO: account for many different bundle types, since the id condition in L33 could yield duplicates
|
||||
if selected_bundles != None and selected_bundles > 0:
|
||||
if selected_bundles != None and len(selected_bundles) > 0:
|
||||
# make sure the total bundles used in generated form is limited between min-max set
|
||||
problem += lpSum([
|
||||
bundles[bundle.id] for bundle in selected_bundles
|
||||
@ -56,7 +56,7 @@ def build_constraints(solver_run: SolverRun, problem: LpProblem,
|
||||
int(constraint.maximum))
|
||||
|
||||
logging.info('Constraints Created...')
|
||||
|
||||
|
||||
# Behold our very own Elastic constraints!
|
||||
for tif_target in solver_run.objective_function.tif_targets:
|
||||
problem += lpSum([
|
||||
@ -101,7 +101,7 @@ def build_constraints(solver_run: SolverRun, problem: LpProblem,
|
||||
for item in selected_items
|
||||
]) <= tcc_target.maximum(
|
||||
), f'Max TCC theta({tcc_target.theta}) at target {tcc_target.value} drift at {current_drift}%'
|
||||
|
||||
|
||||
return problem
|
||||
except ValueError as error:
|
||||
logging.error(error)
|
||||
|
Reference in New Issue
Block a user