diff --git a/app/helpers/solver_helper.py b/app/helpers/solver_helper.py index e5f2009..d21e2ce 100644 --- a/app/helpers/solver_helper.py +++ b/app/helpers/solver_helper.py @@ -72,6 +72,7 @@ def get_random_bundles(total_form_items: int, total_bundles: int, bundles: list[ else: return get_random_bundles(total_form_items, total_bundles - 1, bundles) +# legacy solution, keep because it may be usefull def valid_bundle_combinations(total_form_items: int, total_bundles: int, min_bundles: int, bundles: list[Bundle], selected_bundle_combinations: list[list[Bundle]] = []) -> list[list[Bundle]]: if total_bundles < min_bundles: return selected_bundle_combinations diff --git a/app/services/loft_service.py b/app/services/loft_service.py index fc391d1..2032ae9 100644 --- a/app/services/loft_service.py +++ b/app/services/loft_service.py @@ -77,25 +77,8 @@ class LoftService(Base): # initiate problem problem = None - count = 0 if bundle_constraint: - # # generate valid bundle combinations - # bundle_combinations = solver_helper.valid_bundle_combinations( - # self.solver_run.total_form_items, - # int(bundle_constraint.maximum), - # int(bundle_constraint.minimum), - # self.solver_run.bundles) - - # # scramble bundle_combinations to ensure distinctiveness for each form generated - # random.shuffle(bundle_combinations) - - # for bundles in bundle_combinations: - # problem = self.solve(items, bundles) - - # # if optimal solution found, break loop - # if LpStatus[problem.status] == 'Optimal': - # break bundles_amount = random.randint(int(bundle_constraint.minimum), int(bundle_constraint.maximum)) problem = self.recursive_solve(items, bundles_amount) else: # no bundles @@ -120,7 +103,7 @@ class LoftService(Base): problem = self.solve(items, selected_bundles) - # if optimal solution found, break loop + # if optimal solution found, end recursion if LpStatus[problem.status] == 'Optimal' or attempts == 0: return problem else: