cleanup and < 3 bundle pre-filter
This commit is contained in:
@ -26,18 +26,13 @@ def build_constraints(solver_run: SolverRun, problem: LpProblem,
|
||||
|
||||
if attribute.type == 'metadata':
|
||||
logging.info('Metadata Constraint Generating...')
|
||||
con = dict(
|
||||
zip([item.id for item in solver_run.items], [
|
||||
boolean_to_int(item.attribute_exists(attribute))
|
||||
for item in solver_run.items
|
||||
]))
|
||||
|
||||
problem += lpSum(
|
||||
[
|
||||
len(bundle.items_with_attribute(attribute)) * bundles[bundle.id] for bundle in solver_run.bundles
|
||||
] +
|
||||
[
|
||||
con[item.id] * items[item.id] for item in solver_run.unbundled_items()
|
||||
item.attribute_exists(attribute).real * items[item.id] for item in solver_run.unbundled_items()
|
||||
]
|
||||
) >= round(total_form_items * (min / 100)), f'{attribute.id} - {attribute.value} - min'
|
||||
|
||||
@ -46,7 +41,7 @@ def build_constraints(solver_run: SolverRun, problem: LpProblem,
|
||||
len(bundle.items_with_attribute(attribute)) * bundles[bundle.id] for bundle in solver_run.bundles
|
||||
] +
|
||||
[
|
||||
con[item.id] * items[item.id] for item in solver_run.unbundled_items()
|
||||
item.attribute_exists(attribute).real * items[item.id] for item in solver_run.unbundled_items()
|
||||
]
|
||||
) <= round(total_form_items * (max / 100)), f'{attribute.id} - {attribute.value} - max'
|
||||
elif attribute.type == 'bundle':
|
||||
|
Reference in New Issue
Block a user