jump-dev / AmplNLWriter.jl

A Julia interface to AMPL-enabled solvers
http://ampl.com/products/solvers/all-solvers-for-ampl/
MIT License
67 stars 18 forks source link

Support MOI.TimeLimitSec #165

Closed mzy2240 closed 1 year ago

mzy2240 commented 1 year ago
model = Model(() -> AmplNLWriter.Optimizer("/Users/xxx/Downloads/AMPL/gurobi"))
set_time_limit_sec(model, 600.0)

When using gurobi with AMPL, set_time_limit_sec will raise

MathOptInterface.UnsupportedAttribute{MathOptInterface.TimeLimitSec}: Attribute MathOptInterface.TimeLimitSec() is not supported by the model

Considering many users may actually use Gurobi/CPLEX/XPRESS/COPT with AMPL license, can we provide a generic attribute TimeLimitSec similar to COPT.jl Gurobi.jl?

mzy2240 commented 1 year ago

Of course I could check the native attribute name for each solvers (most of them are just timelimit), but I am thinking those work might be duplicated (when creating wrappers like COPT.jl and Gurobi.jl you probably already went through the same process).

odow commented 1 year ago

We can't do this in AmplNLWriter because there is no way to set this uniformly across solvers via the AMPL interface.

You'll need to use set_optimizer_attribute(model, "xxx", value) where xxx is the solver-specific string.