@@ -183,7 +183,7 @@ def __init__(self, c, A_ineq, b_ineq, A_eq, b_eq, lb, ub, vtype, indic_constr, M
183
183
glp_add_rows (self .glpk , A_ineq .shape [0 ] + A_eq .shape [0 ] + A_indic .shape [0 ])
184
184
eq_type = [GLP_UP ] * len (b_ineq ) + [GLP_FX ] * len (b_eq ) + [GLP_UP ] * len (b_indic )
185
185
for i , t , b in zip (range (len (b_ineq + b_eq + b_indic )), eq_type , b_ineq + b_eq + b_indic ):
186
- glp_set_row_bnds (self .glpk , i + 1 , t , b , b )
186
+ glp_set_row_bnds (self .glpk , i + 1 , t , float ( b ), float ( b ) )
187
187
188
188
A = sparse .vstack ((A_ineq , A_eq , A_indic ), 'coo' )
189
189
ia = intArray (A .nnz + 1 )
@@ -201,7 +201,7 @@ def __init__(self, c, A_ineq, b_ineq, A_eq, b_eq, lb, ub, vtype, indic_constr, M
201
201
self .lp_params = glp_smcp ()
202
202
glp_init_smcp (self .lp_params )
203
203
self .max_tlim = self .lp_params .tm_lim
204
- self .lp_params .tol_bnd = 1e-9
204
+ # self.lp_params.tol_bnd = 1e-9
205
205
self .lp_params .msg_lev = 0
206
206
# MILP parameters
207
207
if self .ismilp :
@@ -368,13 +368,13 @@ def set_ub(self, ub):
368
368
type = [glp_get_col_type (self .glpk , i + 1 ) for i in setvars ]
369
369
for i , l , u , t in zip (setvars , lb , ub , type ):
370
370
if t in [GLP_FR , GLP_LO ] and isinf (u ):
371
- glp_set_col_bnds (self .glpk , i + 1 , t , l , u )
371
+ glp_set_col_bnds (self .glpk , i + 1 , t , float ( l ), float ( u ) )
372
372
elif t == GLP_UP and isinf (u ):
373
- glp_set_col_bnds (self .glpk , i + 1 , GLP_FR , l , u )
373
+ glp_set_col_bnds (self .glpk , i + 1 , GLP_FR , float ( l ), float ( u ) )
374
374
elif t in [GLP_LO , GLP_DB , GLP_FX ] and not isinf (u ) and l < u :
375
- glp_set_col_bnds (self .glpk , i + 1 , GLP_DB , l , u )
375
+ glp_set_col_bnds (self .glpk , i + 1 , GLP_DB , float ( l ), float ( u ) )
376
376
elif t in [GLP_LO , GLP_DB , GLP_FX ] and not isinf (u ) and l == u :
377
- glp_set_col_bnds (self .glpk , i + 1 , GLP_FX , l , u )
377
+ glp_set_col_bnds (self .glpk , i + 1 , GLP_FX , float ( l ), float ( u ) )
378
378
379
379
def set_time_limit (self , t ):
380
380
"""Set the computation time limit (in seconds)"""
@@ -413,9 +413,9 @@ def add_ineq_constraints(self, A_ineq, b_ineq):
413
413
val [i + 1 ] = float (v )
414
414
glp_set_mat_row (self .glpk , numrows + j + 1 , numvars , col , val )
415
415
if isinf (b_ineq [j ]):
416
- glp_set_row_bnds (self .glpk , numrows + j + 1 , GLP_FR , - inf , b_ineq [j ])
416
+ glp_set_row_bnds (self .glpk , numrows + j + 1 , GLP_FR , - inf , float ( b_ineq [j ]) )
417
417
else :
418
- glp_set_row_bnds (self .glpk , numrows + j + 1 , GLP_UP , - inf , b_ineq [j ])
418
+ glp_set_row_bnds (self .glpk , numrows + j + 1 , GLP_UP , - inf , float ( b_ineq [j ]) )
419
419
420
420
def add_eq_constraints (self , A_eq , b_eq ):
421
421
"""Add equality constraints to the model
@@ -442,7 +442,7 @@ def add_eq_constraints(self, A_eq, b_eq):
442
442
col [i + 1 ] = i + 1
443
443
val [i + 1 ] = float (v )
444
444
glp_set_mat_row (self .glpk , numrows + j + 1 , numvars , col , val )
445
- glp_set_row_bnds (self .glpk , numrows + j + 1 , GLP_FX , b_eq [j ], b_eq [j ])
445
+ glp_set_row_bnds (self .glpk , numrows + j + 1 , GLP_FX , float ( b_eq [j ]), float ( b_eq [j ]) )
446
446
447
447
def set_ineq_constraint (self , idx , a_ineq , b_ineq ):
448
448
"""Replace a specific inequality constraint
@@ -467,9 +467,9 @@ def set_ineq_constraint(self, idx, a_ineq, b_ineq):
467
467
val [i + 1 ] = float (v )
468
468
glp_set_mat_row (self .glpk , idx + 1 , numvars , col , val )
469
469
if isinf (b_ineq ):
470
- glp_set_row_bnds (self .glpk , idx + 1 , GLP_FR , - inf , b_ineq )
470
+ glp_set_row_bnds (self .glpk , idx + 1 , GLP_FR , - inf , float ( b_ineq ) )
471
471
else :
472
- glp_set_row_bnds (self .glpk , idx + 1 , GLP_UP , - inf , b_ineq )
472
+ glp_set_row_bnds (self .glpk , idx + 1 , GLP_UP , - inf , float ( b_ineq ) )
473
473
474
474
def getSolution (self , status ) -> list :
475
475
"""Retrieve solution from GLPK backend"""
0 commit comments