Modifying MultiObjective Parameters
Currently the multi-objective implementation uses individual functions to set/get attributes. However, currently only weigth and priority are implemented. Some other important parameters like objnabstol, or objnrelstol cannot be set as the functions are missing. I would suggest something like the following structs and overloads, to have a more universal approach:
struct MultiObjectiveAttr <: MOI.AbstractModelAttribute
index::Int
attr::String
end
function MOI.get(model::Gurobi.Optimizer, attr::MultiObjectiveAttr)
env = GRBgetenv(model)
ret = GRBsetintparam(env, "ObjNumber", attr.index - 1)
_check_ret(env, ret)
val = Ref{Cdouble}()
ret = GRBgetdblattr(model, attr.attr, val)
_check_ret(model, ret)
return val[]
end
function MOI.set(
model::Gurobi.Optimizer,
attr::MultiObjectiveAttr,
value::Float64,
)
env = GRBgetenv(model)
ret = GRBsetintparam(env, "ObjNumber", attr.index - 1)
_check_ret(env, ret)
ret = GRBsetdblattr(model, attr.attr, value)
_check_ret(model, ret)
_require_update(model)
return
end
I'll review a pull request to add these with tests if you want to make one :)
Source goes here: https://github.com/jump-dev/Gurobi.jl/blob/master/src/MOI_wrapper/MOI_multi_objective.jl
For the tests, write a new function here: https://github.com/jump-dev/Gurobi.jl/blob/master/test/MOI/MOI_multiobjective.jl
Hi guys, a few days ago I had to use GRBsetstrattr to set the objective names for better readability. So it would be nice to include this case as well. 🙂