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.Sat, 10 Jan 2015 05:43:57 +0100setting default LP solverhttps://ask.sagemath.org/question/25455/setting-default-lp-solver/I installed Gurobi, and have gotten Sage to recognize it. So when I use a command such as vertex_coloring(G,solver="GUROBI") everything works fine.
But what if I want to use instead a command such as G.chromatic_number(algorithm="MILP"). How do I make sure that the LP solver that Sage is using is Gurobi, rather than GLPK? Is there one place I can tell Sage that it should always default to Gurobi as its LP solver, or is it possible that Sage is smart enough that once Gurobi is installed it does that anyway?
(Also, peripherally: does anyone have any idea whether chromatic_number or vertex_coloring is more efficient for large graphs?)
Fri, 09 Jan 2015 20:34:34 +0100https://ask.sagemath.org/question/25455/setting-default-lp-solver/Comment by Nathann for <p>I installed Gurobi, and have gotten Sage to recognize it. So when I use a command such as vertex_coloring(G,solver="GUROBI") everything works fine.</p>
<p>But what if I want to use instead a command such as G.chromatic_number(algorithm="MILP"). How do I make sure that the LP solver that Sage is using is Gurobi, rather than GLPK? Is there one place I can tell Sage that it should always default to Gurobi as its LP solver, or is it possible that Sage is smart enough that once Gurobi is installed it does that anyway?</p>
<p>(Also, peripherally: does anyone have any idea whether chromatic_number or vertex_coloring is more efficient for large graphs?)</p>
https://ask.sagemath.org/question/25455/setting-default-lp-solver/?comment=25459#post-id-25459About your comment on coloring algorithms: it heavily depend on the LP solver that you use, and then it depends on the graphs themselves.Sat, 10 Jan 2015 05:43:57 +0100https://ask.sagemath.org/question/25455/setting-default-lp-solver/?comment=25459#post-id-25459Answer by Nathann for <p>I installed Gurobi, and have gotten Sage to recognize it. So when I use a command such as vertex_coloring(G,solver="GUROBI") everything works fine.</p>
<p>But what if I want to use instead a command such as G.chromatic_number(algorithm="MILP"). How do I make sure that the LP solver that Sage is using is Gurobi, rather than GLPK? Is there one place I can tell Sage that it should always default to Gurobi as its LP solver, or is it possible that Sage is smart enough that once Gurobi is installed it does that anyway?</p>
<p>(Also, peripherally: does anyone have any idea whether chromatic_number or vertex_coloring is more efficient for large graphs?)</p>
https://ask.sagemath.org/question/25455/setting-default-lp-solver/?answer=25458#post-id-25458The best answer was given by Thierry, but there is another 'trick': all solvers have a different way to be verbose about their computations, so you can see what MILP solver is used by calling that:
sage: graphs.PetersenGraph().chromatic_number(algorithm="MILP",verbose=2)
NathannSat, 10 Jan 2015 05:42:43 +0100https://ask.sagemath.org/question/25455/setting-default-lp-solver/?answer=25458#post-id-25458Answer by tmonteil for <p>I installed Gurobi, and have gotten Sage to recognize it. So when I use a command such as vertex_coloring(G,solver="GUROBI") everything works fine.</p>
<p>But what if I want to use instead a command such as G.chromatic_number(algorithm="MILP"). How do I make sure that the LP solver that Sage is using is Gurobi, rather than GLPK? Is there one place I can tell Sage that it should always default to Gurobi as its LP solver, or is it possible that Sage is smart enough that once Gurobi is installed it does that anyway?</p>
<p>(Also, peripherally: does anyone have any idea whether chromatic_number or vertex_coloring is more efficient for large graphs?)</p>
https://ask.sagemath.org/question/25455/setting-default-lp-solver/?answer=25457#post-id-25457By default Sage choses what it considers fastest among installed solvers, hence in your case gurobi should have been selected by default. You can check by typing:
sage: default_mip_solver()
and see the result. You can also use this function to reset the default solver (this can be useful e.g. for benchmarking):
sage: default_mip_solver("GUROBI")
or
sage: default_mip_solver("GLPK")
The doc can be found [here](http://www.sagemath.org/doc/reference/numerical/sage/numerical/backends/generic_backend.html#sage.numerical.backends.generic_backend.default_mip_solver).
Fri, 09 Jan 2015 21:38:09 +0100https://ask.sagemath.org/question/25455/setting-default-lp-solver/?answer=25457#post-id-25457