bundle models have arrived
This commit is contained in:
@ -2,7 +2,7 @@ import csv
|
||||
import io
|
||||
import re
|
||||
|
||||
def items_csv_to_dict(items_csv_reader, irt_model):
|
||||
def items_csv_to_dict(items_csv_reader):
|
||||
items = []
|
||||
headers = []
|
||||
|
||||
|
@ -25,12 +25,12 @@ def build_constraints(solver_run, problem, items):
|
||||
* 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':
|
||||
bundles = solver_run.bundles(attribute.id)
|
||||
# TODO: account for many different bundle types, since the id condition in L33 could yield duplicates
|
||||
total_bundles = randint(constraint.minimum, constraint.maximum)
|
||||
selected_bundles = sample(bundles, total_bundles)
|
||||
selected_bundles = sample(solver_run.bundles, total_bundles)
|
||||
|
||||
for bundle in selected_bundles:
|
||||
problem += lpSum([items[item.id] for item in solver_run.items if getattr(item, bundle["type"], None) == bundle['id']]) == bundle['count'], f'Bundle constraint for {bundle["type"]} ({bundle["id"]})'
|
||||
problem += lpSum([items[item.id] for item in solver_run.items if getattr(item, bundle.type, None) == bundle.id]) == bundle.count, f'Bundle constraint for {bundle.type} ({bundle.id})'
|
||||
|
||||
|
||||
return problem
|
||||
|
Reference in New Issue
Block a user