@@ -104,7 +104,7 @@ cdef class GLPKBackend(GenericBackend):
104104 Traceback (most recent call last):
105105 ...
106106 ValueError: ...
107- sage: p.add_variable(name='x',obj=1.0)
107+ sage: p.add_variable(name='x', obj=1.0)
108108 3
109109 sage: p.col_name(3)
110110 'x'
@@ -1395,33 +1395,62 @@ cdef class GLPKBackend(GenericBackend):
13951395 sage: P.set_max(x, 0)
13961396 sage: P.get_max(x)
13971397 0.0
1398+
1399+ Check that :trac:`10232` is fixed::
1400+
1401+ sage: p = get_solver(solver="GLPK")
1402+ sage: p.variable_upper_bound(2)
1403+ Traceback (most recent call last):
1404+ ...
1405+ GLPKError: ...
1406+ sage: p.variable_upper_bound(3, 5)
1407+ Traceback (most recent call last):
1408+ ...
1409+ GLPKError: ...
1410+
1411+ sage: p.add_variable()
1412+ 0
1413+ sage: p.variable_upper_bound(0, 'hey!')
1414+ Traceback (most recent call last):
1415+ ...
1416+ TypeError: a float is required
13981417 """
13991418 cdef double x
14001419 cdef double min
1420+ cdef double dvalue
14011421
14021422 if value is False :
1423+ sig_on()
14031424 x = glp_get_col_ub(self .lp, index + 1 )
1425+ sig_off()
14041426 if x == DBL_MAX:
14051427 return None
14061428 else :
14071429 return x
14081430 else :
1431+ sig_on()
14091432 min = glp_get_col_lb(self .lp, index + 1 )
1433+ sig_off()
14101434
1411- if value is None and min == - DBL_MAX:
1412- glp_set_col_bnds(self .lp, index + 1 , GLP_FR, 0 , 0 )
1413-
1414- elif value is None :
1415- glp_set_col_bnds(self .lp, index + 1 , GLP_LO, min , 0 )
1416-
1417- elif min == - DBL_MAX:
1418- glp_set_col_bnds(self .lp, index + 1 , GLP_UP, 0 , value)
1435+ if value is None :
1436+ sig_on()
1437+ if min == - DBL_MAX:
1438+ glp_set_col_bnds(self .lp, index + 1 , GLP_FR, 0 , 0 )
1439+ else :
1440+ glp_set_col_bnds(self .lp, index + 1 , GLP_LO, min , 0 )
1441+ sig_off()
1442+ else :
1443+ dvalue = < double ?> value
14191444
1420- elif min == value:
1421- glp_set_col_bnds(self .lp, index + 1 , GLP_FX, value, value)
1445+ sig_on()
1446+ if min == - DBL_MAX:
1447+ glp_set_col_bnds(self .lp, index + 1 , GLP_UP, 0 , dvalue)
14221448
1423- else :
1424- glp_set_col_bnds(self .lp, index + 1 , GLP_DB, min , value)
1449+ elif min == dvalue:
1450+ glp_set_col_bnds(self .lp, index + 1 , GLP_FX, dvalue, dvalue)
1451+ else :
1452+ glp_set_col_bnds(self .lp, index + 1 , GLP_DB, min , dvalue)
1453+ sig_off()
14251454
14261455 cpdef variable_lower_bound(self , int index, value = False ):
14271456 """
@@ -1457,33 +1486,62 @@ cdef class GLPKBackend(GenericBackend):
14571486 sage: P.set_min(x, 0)
14581487 sage: P.get_min(x)
14591488 0.0
1489+
1490+ Check that :trac:`10232` is fixed::
1491+
1492+ sage: p = get_solver(solver="GLPK")
1493+ sage: p.variable_lower_bound(2)
1494+ Traceback (most recent call last):
1495+ ...
1496+ GLPKError: ...
1497+ sage: p.variable_lower_bound(3, 5)
1498+ Traceback (most recent call last):
1499+ ...
1500+ GLPKError: ...
1501+
1502+ sage: p.add_variable()
1503+ 0
1504+ sage: p.variable_lower_bound(0, 'hey!')
1505+ Traceback (most recent call last):
1506+ ...
1507+ TypeError: a float is required
14601508 """
14611509 cdef double x
14621510 cdef double max
1511+ cdef double dvalue
14631512
14641513 if value is False :
1514+ sig_on()
14651515 x = glp_get_col_lb(self .lp, index + 1 )
1516+ sig_off()
14661517 if x == - DBL_MAX:
14671518 return None
14681519 else :
14691520 return x
14701521 else :
1522+ sig_on()
14711523 max = glp_get_col_ub(self .lp, index + 1 )
1524+ sig_off()
14721525
1473- if value is None and max == DBL_MAX:
1474- glp_set_col_bnds(self .lp, index + 1 , GLP_FR, 0.0 , 0.0 )
1475-
1476- elif value is None :
1477- glp_set_col_bnds(self .lp, index + 1 , GLP_UP, 0.0 , max )
1478-
1479- elif max == DBL_MAX:
1480- glp_set_col_bnds(self .lp, index + 1 , GLP_LO, value, 0.0 )
1481-
1482- elif max == value:
1483- glp_set_col_bnds(self .lp, index + 1 , GLP_FX, value, value)
1526+ if value is None :
1527+ sig_on()
1528+ if max == DBL_MAX:
1529+ glp_set_col_bnds(self .lp, index + 1 , GLP_FR, 0.0 , 0.0 )
1530+ else :
1531+ glp_set_col_bnds(self .lp, index + 1 , GLP_UP, 0.0 , max )
1532+ sig_off()
14841533
14851534 else :
1486- glp_set_col_bnds(self .lp, index + 1 , GLP_DB, value, max )
1535+ dvalue = < double ?> value
1536+
1537+ sig_on()
1538+ if max == DBL_MAX:
1539+ glp_set_col_bnds(self .lp, index + 1 , GLP_LO, value, 0.0 )
1540+ elif max == value:
1541+ glp_set_col_bnds(self .lp, index + 1 , GLP_FX, value, value)
1542+ else :
1543+ glp_set_col_bnds(self .lp, index + 1 , GLP_DB, value, max )
1544+ sig_off()
14871545
14881546 cpdef write_lp(self , char * filename):
14891547 """
0 commit comments