Specifying JuMP solvers for function-wrapped optimization models

I am building a package based around a specific optimization problem, implemented in JuMP. My code builds an optimization model based on input data, with most everything automated behind the scenes for user-friendliness. I would like to allow users to select whichever solver they would like (and are able to access) but have no idea how to implement this.

Ideally, something like this

using CustomPackage
using Gurobi

sol = CustomPackageFunction(DataDirectory, Solver=Gurobi)

where Solver is an optional keyword argument allowing a user to select a solver, and if not specified, defaulting to an open-source option.

A trivial option might be to use keywords and if statements, and have all the JuMP.model() calls pre-defined, but I would imagine there is a better solution that would allow an arbitrary solver to be passed in.

Does this tutorial help?


1 Like