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

@ -0,0 +1,15 @@
from random import randint
from models.constraints.generic_constraint import *
class BundleConstraint(GenericConstraint):
def build(self, problem_handler: Problem, **kwargs) -> None:
logging.info('Bundles Constraint Generating...')
# TODO: account for many different bundle types, since the id condition in L33 could yield duplicates
if problem_handler.bundles != None and len(problem_handler.bundles) > 0:
# make sure the total bundles used in generated form is limited between min-max set
problem_handler.problem += lpSum([
problem_handler.solver_bundles_var[bundle.id] for bundle in problem_handler.bundles
]) == randint(int(self.minimum),
int(self.maximum)), f'Allowing min - max bundles'