Ask Your Question

setting default LP solver

asked 2015-01-09 20:34:34 +0100

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?)

edit retag flag offensive close merge delete


About your comment on coloring algorithms: it heavily depend on the LP solver that you use, and then it depends on the graphs themselves.

Nathann gravatar imageNathann ( 2015-01-10 05:43:57 +0100 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-01-09 21:38:09 +0100

tmonteil gravatar image

By 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")


sage: default_mip_solver("GLPK")

The doc can be found here.

edit flag offensive delete link more

answered 2015-01-10 05:42:43 +0100

Nathann gravatar image

The 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)


edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-01-09 20:34:34 +0100

Seen: 632 times

Last updated: Jan 10 '15