77EPS = 10e-4
88SOLVER = GUROBI
99
10+ def get_pricing (m , w , L ):
11+ # creating the pricing problem
12+ pricing = Model (SOLVER )
13+
14+ # creating pricing variables
15+ a = []
16+ for i in range (m ):
17+ a .append (pricing .add_var (obj = 0 , var_type = INTEGER , name = 'a_%d' % (i + 1 )))
18+
19+ # creating pricing constraint
20+ pricing .add_constr (xsum (w [i ] * a [i ] for i in range (m )) <= L , 'bar_length' )
21+
22+ pricing .write ('pricing.lp' )
23+
24+ return a , pricing
1025
1126def cg ():
1227 """
@@ -32,19 +47,6 @@ def cg():
3247 for i in range (m ):
3348 constraints .append (master .add_constr (lambdas [i ] >= b [i ], name = 'i_%d' % (i + 1 )))
3449
35- # creating the pricing problem
36- pricing = Model (SOLVER )
37-
38- # creating pricing variables
39- a = []
40- for i in range (m ):
41- a .append (pricing .add_var (obj = 0 , var_type = INTEGER , name = 'a_%d' % (i + 1 )))
42-
43- # creating pricing constraint
44- pricing .add_constr (xsum (w [i ] * a [i ] for i in range (m )) <= L , 'bar_length' )
45-
46- pricing .write ('pricing.lp' )
47-
4850 new_vars = True
4951 while new_vars :
5052
@@ -65,6 +67,8 @@ def cg():
6567 # STEP 2: updating pricing objective with dual values from master
6668 ##########
6769
70+ a , pricing = get_pricing (m , w , L )
71+
6872 pricing .objective = 1
6973 for i in range (m ):
7074 a [i ].obj = - constraints [i ].pi
0 commit comments