@@ -104,7 +104,7 @@ cdef class GLPKBackend(GenericBackend):
104
104
Traceback (most recent call last):
105
105
...
106
106
ValueError: ...
107
- sage: p.add_variable(name='x',obj=1.0)
107
+ sage: p.add_variable(name='x', obj=1.0)
108
108
3
109
109
sage: p.col_name(3)
110
110
'x'
@@ -1395,33 +1395,62 @@ cdef class GLPKBackend(GenericBackend):
1395
1395
sage: P.set_max(x, 0)
1396
1396
sage: P.get_max(x)
1397
1397
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
1398
1417
"""
1399
1418
cdef double x
1400
1419
cdef double min
1420
+ cdef double dvalue
1401
1421
1402
1422
if value is False :
1423
+ sig_on()
1403
1424
x = glp_get_col_ub(self .lp, index + 1 )
1425
+ sig_off()
1404
1426
if x == DBL_MAX:
1405
1427
return None
1406
1428
else :
1407
1429
return x
1408
1430
else :
1431
+ sig_on()
1409
1432
min = glp_get_col_lb(self .lp, index + 1 )
1433
+ sig_off()
1410
1434
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
1419
1444
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)
1422
1448
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()
1425
1454
1426
1455
cpdef variable_lower_bound(self , int index, value = False ):
1427
1456
"""
@@ -1457,33 +1486,62 @@ cdef class GLPKBackend(GenericBackend):
1457
1486
sage: P.set_min(x, 0)
1458
1487
sage: P.get_min(x)
1459
1488
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
1460
1508
"""
1461
1509
cdef double x
1462
1510
cdef double max
1511
+ cdef double dvalue
1463
1512
1464
1513
if value is False :
1514
+ sig_on()
1465
1515
x = glp_get_col_lb(self .lp, index + 1 )
1516
+ sig_off()
1466
1517
if x == - DBL_MAX:
1467
1518
return None
1468
1519
else :
1469
1520
return x
1470
1521
else :
1522
+ sig_on()
1471
1523
max = glp_get_col_ub(self .lp, index + 1 )
1524
+ sig_off()
1472
1525
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()
1484
1533
1485
1534
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()
1487
1545
1488
1546
cpdef write_lp(self , char * filename):
1489
1547
"""
0 commit comments