refactors gain optimised slightly

This commit is contained in:
Khalim Conn-Kowlessar 2023-06-26 09:48:59 +01:00
parent 6005387314
commit d40d20497f

View file

@ -33,13 +33,6 @@ C = 4000
# group all the parts
groups = [wall, floor, roof]
# Get the selected items
total_gain = m.objective.x
actual_cost = sum([component['cost'] for component in selected_items])
print("Selected items:", selected_items)
class GainOptimiser:
"""
@ -52,6 +45,9 @@ class GainOptimiser:
self.variables = []
self.solution = []
self.solution_gain = None
self.solution_cost = None
def setup(self):
# Initialize Model
self.m = Model("knapsack")
@ -95,3 +91,8 @@ class GainOptimiser:
item for group, group_vars in zip(groups, self.variables) for item, var in zip(group, group_vars) if
var.x >= 0.99
]
# Get the selected items
solution_gain = self.m.objective.x
solution_cost = sum([component['cost'] for component in self.solution])