ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 06 Nov 2015 06:47:16 +0100solver_parameter('timelimit') doesnt workhttps://ask.sagemath.org/question/30420/solver_parametertimelimit-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?
Thanks in advance,
Cheers,
AissanTue, 03 Nov 2015 07:47:45 +0100https://ask.sagemath.org/question/30420/solver_parametertimelimit-doesnt-work/Answer by Nathann for <p>Hi, </p>
<p>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 <code>p.solver_parameter("timelimit", 60)</code>. I have also used</p>
<pre><code> try:
p.solve()
except MIPSolverException:
b = p.get_backend()
print('best known opjective bound', b.best_known_objective_bound())
</code></pre>
<p>However, the solver doesn't stop!!! It keeps runing. I guess the <code>time limit</code> part doesn't work.
Its interesting that the <code>p.solver_parameter("time limit")</code> its affected, as I am printing its value before passing the <code>p.solve()</code>. I have also tried <code>p.solver_parameter( backend.glp_simplex_or_intopt, backend.glp_intopt_only)</code> and printed the <code>p.solver_parameter("time limit_intopt")</code>. It's printing <code>60000</code> which is right.
I have no idea why it keeps running. </p>
<p>Could anyone help me with this issue?</p>
<p>Thanks in advance,</p>
<p>Cheers,
Aissan</p>
https://ask.sagemath.org/question/30420/solver_parametertimelimit-doesnt-work/?answer=30431#post-id-30431Could 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. Tue, 03 Nov 2015 16:08:50 +0100https://ask.sagemath.org/question/30420/solver_parametertimelimit-doesnt-work/?answer=30431#post-id-30431Comment by Aissan Dalvandi for <p>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. </p>
https://ask.sagemath.org/question/30420/solver_parametertimelimit-doesnt-work/?comment=30445#post-id-30445I 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!Wed, 04 Nov 2015 03:49:27 +0100https://ask.sagemath.org/question/30420/solver_parametertimelimit-doesnt-work/?comment=30445#post-id-30445Answer by Aissan Dalvandi for <p>Hi, </p>
<p>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 <code>p.solver_parameter("timelimit", 60)</code>. I have also used</p>
<pre><code> try:
p.solve()
except MIPSolverException:
b = p.get_backend()
print('best known opjective bound', b.best_known_objective_bound())
</code></pre>
<p>However, the solver doesn't stop!!! It keeps runing. I guess the <code>time limit</code> part doesn't work.
Its interesting that the <code>p.solver_parameter("time limit")</code> its affected, as I am printing its value before passing the <code>p.solve()</code>. I have also tried <code>p.solver_parameter( backend.glp_simplex_or_intopt, backend.glp_intopt_only)</code> and printed the <code>p.solver_parameter("time limit_intopt")</code>. It's printing <code>60000</code> which is right.
I have no idea why it keeps running. </p>
<p>Could anyone help me with this issue?</p>
<p>Thanks in advance,</p>
<p>Cheers,
Aissan</p>
https://ask.sagemath.org/question/30420/solver_parametertimelimit-doesnt-work/?answer=30498#post-id-30498Its working but its based on `computation` time, NOT `execution` time. However, still not sure about the relation between these two! Fri, 06 Nov 2015 06:47:16 +0100https://ask.sagemath.org/question/30420/solver_parametertimelimit-doesnt-work/?answer=30498#post-id-30498