@@ -92,15 +92,17 @@ def init(self):
92
92
def add_bin (self , min_bound ):
93
93
assert not self .initialized
94
94
index = len (self .bins )
95
- self .bins += [Bin (min_bound , index )]
96
- return index
95
+ bin = Bin (min_bound , index )
96
+ self .bins += [bin ]
97
+ return bin
97
98
98
99
def add_item (self , weight ):
99
100
assert not self .initialized
100
101
assert weight > 0
101
102
index = len (self .items )
102
- self .items += [Item (weight , index )]
103
- return index
103
+ item = Item (weight , index )
104
+ self .items += [item ]
105
+ return item
104
106
105
107
def num_items (self ):
106
108
return len (self .items )
@@ -243,7 +245,13 @@ def __init__(self):
243
245
self .bin_solver = BinCoverSolver (self .solver )
244
246
self .mss_solver = MaximalSatisfyingSubset (self .solver )
245
247
248
+ #
246
249
# Facilities to set up solver
250
+ # First add items and bins.
251
+ # Keep references to the returned objects.
252
+ # Then call init
253
+ # Then add any other custom constraints to the "solver" object.
254
+ #
247
255
def init (self ):
248
256
self .bin_solver .init ()
249
257
@@ -253,12 +261,6 @@ def add_item(self, weight):
253
261
def add_bin (self , min_bound ):
254
262
return self .bin_solver .add_bin (min_bound )
255
263
256
- def item_index2item (self , index ):
257
- return self .bin_solver .items [index ]
258
-
259
- def bin_index2bin (self , index ):
260
- return self .bin_solver .bins [index ]
261
-
262
264
def optimize (self ):
263
265
self .init ()
264
266
mss = self .mss_solver .get_mss ([bin .var for bin in self .bin_solver .bins ])
0 commit comments