refactor of model targets and constraints, addition of new constraint types and constraint construction process
This commit is contained in:
15
app/models/constraints/bundle_constraint.py
Normal file
15
app/models/constraints/bundle_constraint.py
Normal 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'
|
Reference in New Issue
Block a user