mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
refactors gain optimised slightly
This commit is contained in:
parent
6005387314
commit
d40d20497f
1 changed files with 8 additions and 7 deletions
|
|
@ -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])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue