more extensive logging
This commit is contained in:
parent
f15f9e604e
commit
3f7b3cc0b6
@ -17,6 +17,7 @@ def build_constraints(solver_run, problem, items, bundles):
|
||||
max = constraint.maximum
|
||||
|
||||
if attribute.type == 'metadata':
|
||||
logging.info('Metadata Constraint Generating...')
|
||||
con = dict(zip([item.id for item in solver_run.items],
|
||||
[item.attribute_exists(attribute)
|
||||
for item in solver_run.items]))
|
||||
@ -27,10 +28,9 @@ def build_constraints(solver_run, problem, items, bundles):
|
||||
* items[item.id]
|
||||
for item in solver_run.items]) <= round(total_form_items * (max / 100)), f'{attribute.id} - {attribute.value} - max'
|
||||
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 solver_run.bundles != None:
|
||||
# total_bundles = randint(constraint.minimum, constraint.maximum)
|
||||
# selected_bundles = sample(solver_run.bundles, total_bundles, solver_run.bundles)
|
||||
total_bundle_items = 0
|
||||
selected_bundles = get_random_bundles(solver_run.total_form_items, solver_run.bundles, int(constraint.minimum), int(constraint.maximum))
|
||||
|
||||
@ -62,6 +62,7 @@ def get_random_bundles(total_form_items: int, bundles: list[Bundle], min: int ,
|
||||
selected_bundles = None
|
||||
total_bundle_items = 0
|
||||
total_bundles = randint(min, max)
|
||||
logging.info(f'Selecting Bundles (total of {total_bundles})...')
|
||||
|
||||
while found_bundles == False:
|
||||
selected_bundles = sample(bundles, total_bundles)
|
||||
|
@ -88,6 +88,7 @@ class LoftService(Base):
|
||||
problem = solver_helper.build_constraints(self.solver_run, problem, items, bundles)
|
||||
|
||||
# multi-objective constraints
|
||||
logging.info('Creating TIF and TCC constraints')
|
||||
for target in self.solver_run.objective_function.tif_targets:
|
||||
problem += lpSum([item.iif(self.solver_run, target.theta)*items[item.id]
|
||||
for item in self.solver_run.items]) >= target.value - 8, f'max tif theta ({target.theta}) target value {target.value}'
|
||||
@ -101,13 +102,16 @@ class LoftService(Base):
|
||||
for item in self.solver_run.items]) <= target.value + 20, f'min tcc theta ({target.theta}) target value {target.value}'
|
||||
|
||||
# solve problem
|
||||
logging.info('Solving...')
|
||||
problem.solve()
|
||||
logging.info('Solved...generating form and adding to solution')
|
||||
|
||||
# add return items and create as a form
|
||||
form_items = service_helper.solution_items(problem.variables(), self.solver_run)
|
||||
|
||||
# add form to solution
|
||||
solution.forms.append(Form.create(form_items, self.solver_run, LpStatus[problem.status]))
|
||||
logging.info('Form generated and added to solution...')
|
||||
|
||||
# successfull form, increment
|
||||
f += 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user