MOA-HiGHS Unsupported Objective Function

Hi all. I’m pretty new to Julia optimization. I have this problem:

model = Model(HiGHS.Optimizer)
@variable(model, x[1:n] >= 0)
@constraint(model, A' * x .>= f)
@objective(model, Min, b' * x)

which works perfectly when using the HiGHS optimizer alone, but I want to find multiple solutions, so I’ve been trying to use MOA as follows

model = Model()
@variable(model, x[1:n] >= 0)
@constraint(model, A' * x .>= f)
@objective(model, Min, b' * x)

set_optimizer(model, () -> MOA.Optimizer(HiGHS.Optimizer))
set_attribute(model, MOA.Algorithm(), MOA.Dichotomy())
set_attribute(model, MOA.SolutionLimit(), 2)

but when I call optimize, I get the following error

ERROR: MathOptInterface.UnsupportedAttribute{MathOptInterface.ObjectiveFunction{MathOptInterface.ScalarAffineFunction{Float64}}}: Attribute MathOptInterface.ObjectiveFunction{MathOptInterface.ScalarAffineFunction{Float64}}() is not supported by the model.
Stacktrace:
  [1] bridge_type(b::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, F::Type{…})
    @ MathOptInterface.Bridges C:\Users\JHANNY\.julia\packages\MathOptInterface\2CULs\src\Bridges\lazy_bridge_optimizer.jl:520
  [2] concrete_bridge_type(b::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, F::Type{…})
    @ MathOptInterface.Bridges.Objective C:\Users\JHANNY\.julia\packages\MathOptInterface\2CULs\src\Bridges\Objective\bridge.jl:68
  [3] set(b::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, attr::MathOptInterface.ObjectiveFunction{…}, func::MathOptInterface.ScalarAffineFunction{…})
    @ MathOptInterface.Bridges C:\Users\JHANNY\.julia\packages\MathOptInterface\2CULs\src\Bridges\bridge_optimizer.jl:1187
  [4] _pass_attribute(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, src::MathOptInterface.Utilities.UniversalFallback{…}, index_map::MathOptInterface.Utilities.IndexMap, attr::MathOptInterface.ObjectiveFunction{…})
    @ MathOptInterface.Utilities C:\Users\JHANNY\.julia\packages\MathOptInterface\2CULs\src\Utilities\copy.jl:51
  [5] pass_attributes(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, src::MathOptInterface.Utilities.UniversalFallback{…}, index_map::MathOptInterface.Utilities.IndexMap)
    @ MathOptInterface.Utilities C:\Users\JHANNY\.julia\packages\MathOptInterface\2CULs\src\Utilities\copy.jl:38
  [6] default_copy_to(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, src::MathOptInterface.Utilities.UniversalFallback{…})
    @ MathOptInterface.Utilities C:\Users\JHANNY\.julia\packages\MathOptInterface\2CULs\src\Utilities\copy.jl:503
  [7] copy_to
    @ C:\Users\JHANNY\.julia\packages\MathOptInterface\2CULs\src\Bridges\bridge_optimizer.jl:455 [inlined]
  [8] optimize!
    @ C:\Users\JHANNY\.julia\packages\MathOptInterface\2CULs\src\MathOptInterface.jl:84 [inlined]
  [9] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{…})
    @ MathOptInterface.Utilities C:\Users\JHANNY\.julia\packages\MathOptInterface\2CULs\src\Utilities\cachingoptimizer.jl:316
 [10] optimize!(model::Model; ignore_optimize_hook::Bool, _differentiation_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::@Kwargs{})
    @ JuMP C:\Users\JHANNY\.julia\packages\JuMP\Gwn88\src\optimizer_interface.jl:457
 [11] optimize!
    @ C:\Users\JHANNY\.julia\packages\JuMP\Gwn88\src\optimizer_interface.jl:409 [inlined]

which I think doesn’t really make sense since HiGHS does support ScalarAffineFunction{Float64}, and the problem can be solved perfectly fine without using MOA.

Thanks for the help!

The MultiObjectiveAlgorithms.jl package (MOA) is for problems with more than one objective but your optimization problem only has a single objective. In the examples using MOA, the 3rd argument to @objective is a vector of objectives: Simple multi-objective examples · JuMP

1 Like

Ah I see. Is there some way that I can find multiple solutions from a single objective if the optimal solution is non-unique?

Hmm, if you have access to Gurobi or CPLEX it seems like those solvers support a solution pool: Finding multiple feasible solutions | JuMP

I’m not sure if any of the common open source solvers support such a feature.

3 Likes

Hi @jhannyj, welcome to the forum :smile:

MOA is for solving multi-objective (vector-valued) optimization problems, not for finding multiple solutions to a scalar-valued optimization problem.

HiGHS does not support finding multiple solutions.

You could do something like this, where you solve once, add a constraint on optimal objective value, and then try to find a diversity of solutions:

using JuMP, HiGHS
import MultiObjectiveAlgorithms as MOA
model = Model(HiGHS.Optimizer)
@variable(model, x[1:n] >= 0)
@constraint(model, A' * x .>= f)
@objective(model, Min, b' * x)
optimize!(model)
@constraint(model, b' * x == objective_value(model))
@objective(model, Min, x)  # objective is now a vector
set_optimizer(model, () -> MOA.Optimizer(HiGHS.Optimizer))
optimize!(model)
[value(x; result = i) for i in 1:result_count(model)]