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.Tue, 03 Nov 2015 07:47:45 +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,
AissanAissan DalvandiTue, 03 Nov 2015 07:47:45 +0100https://ask.sagemath.org/question/30420/best_known_objective_bound()https://ask.sagemath.org/question/30366/best_known_objective_bound/ Hi,
I am using sage Version 6.5, Release Date: 2015-02-17. I have MILP problem and trying to solve it. However, I defined time limit and used try and except to get the best_known_objective_bound(). Unfortunately, I am getting AttributeError: 'sage.numerical.backends.glpk_backend.GLPKBackend' object has no attribute 'best_known_objective_bound'
I even tried the following simple example (posted here
http://doc.sagemath.org/html/en/reference/numerical/sage/numerical/backends/glpk_backend.html#sage.numerical.backends.glpk_backend.GLPKBackend.best_known_objective_bound). However, I am facing the same issue for the example as well.
sage: g = graphs.CubeGraph(9)
sage: p = MixedIntegerLinearProgram(solver="GLPK")
sage: p.solver_parameter("mip_gap_tolerance",100)
sage: b = p.new_variable(binary=True)
sage: p.set_objective(p.sum(b[v] for v in g))
sage: for v in g:
....: p.add_constraint(b[v]+p.sum(b[u] for u in g.neighbors(v)) <= 1)
sage: p.add_constraint(b[v] == 1) # Force an easy non-0 solution
sage: p.solve() # rel tol 100
1.0
sage: backend = p.get_backend()
sage: backend.best_known_objective_bound() # random
AttributeError: 'sage.numerical.backends.glpk_backend.GLPKBackend' object has no attribute 'best_known_objective_bound'
What I want is to get the best known optimum answer by time limit.
Anyone knows how should i get it?
Thanks a lot!
Cheers,
Aissan Aissan DalvandiSat, 31 Oct 2015 05:55:14 +0100https://ask.sagemath.org/question/30366/