# solver_parameter('timelimit') doesnt work

Hi,

I have an MILP problem and trying to solve it with Sage, GLPK solver. As I want to terminate the problem before getting the optimum answer, I am using the p.solver_parameter("timelimit", 60). I have also used

    try:
p.solve()
except MIPSolverException:
b = p.get_backend()
print('best known opjective bound', b.best_known_objective_bound())


However, the solver doesn't stop!!! It keeps runing. I guess the time limit part doesn't work. Its interesting that the p.solver_parameter("time limit") its affected, as I am printing its value before passing the p.solve(). I have also tried p.solver_parameter( backend.glp_simplex_or_intopt, backend.glp_intopt_only) and printed the p.solver_parameter("time limit_intopt"). It's printing 60000 which is right. I have no idea why it keeps running.

Could anyone help me with this issue?

Cheers, Aissan

edit retag close merge delete

Sort by » oldest newest most voted

Its working but its based on computation time, NOT execution time. However, still not sure about the relation between these two!

more

Could you show us a minimal working example of what you do? If you tell me that you set the time limit and that the time limit is not respect, then it is a bug.

more

I am actually printing the timelimit and it affected. However, it keeps running unless I manually interrupt it.

Here is my code:

p = MixedIntegerLinearProgram(maximization=False, solver = "GLPK")

p.solver_parameter( "timelimit", 60)

Z =    p.new_variable ( binary= True)

#### defining all the variables and constrains here #####

p.set_objective(   p.sum(COSTPenalty * (1-Z[k])   for k in   Requests.keys()))

b= p.get_backend()

print (p.solver_parameter( 'timelimit'))

try :

p.solve()

return (p.get_objective_value() )

except MIPSolverException:

b= p.get_backend()

print ('the best known objective bound is ',b.best_known_objective_bound())

return b.best_known_objective_bound()


Thanks a lot!

( 2015-11-03 20:49:27 -0500 )edit