Output results of sage MixedIntegerLinearProgram solution are not as expected

asked 2013-12-12 16:01:29 +0200

subbu gravatar image

For the problem below

#!/usr/bin/sage -python

from sage.all import *
import sys

problem = MixedIntegerLinearProgram(maximization=False, solver = "GLPK")
y = problem.new_variable(real=True, name='y')

constraints_1 = [(0.0, 6769.0),
                 (8260.0, 6812.0),
                 (12390.0, 7105.0),
                 (16520.0, 7448.0),
                 (20650.0, 7924.0),
                 (24780.0, 8289.0),
                 (28910.0, 8630.0),
                 (33040.0, 9000.0)]
sos_var_1 = problem.new_variable(name='sos2_var')
eq1_1 = 0.0
eq1_2 = 0.0
eq1_3 = 0.0
for i in range(len(constraints_1)):
    eq1_1 += sos_var_1[i]*constraints_1[i][0]
    eq1_2 += sos_var_1[i]*constraints_1[i][1]
    eq1_3 += sos_var_1[i]
problem.add_constraint(eq1_1 == 23450)
problem.add_constraint(eq1_2 == y[0])
problem.add_constraint(eq1_3 == 1)

problem.set_objective(y[0])
print problem.solve()

I am expecting the result to be 8136 but I am getting

8099.05084746

Can anyone help or explain why this is happening?

edit retag flag offensive close merge delete

Comments

I tried with GLPK, PPL and Coin solvers, and all of them lead to 8099.05084746. Are you sure that 8136 is the right solution ?

tmonteil gravatar imagetmonteil ( 2013-12-12 20:44:52 +0200 )edit

Yes, I am sure. I checked on paper and even with other LP solver LINDO.

subbu gravatar imagesubbu ( 2013-12-13 09:58:06 +0200 )edit