Unable to add objectives in vector form using JuMP

Hi,

I was trying to test multi-objective support of JuMP

(MOO) pkg> st
     Project MOO v0.0.1
      Status `~/Desktop/MOO.jl/Project.toml`
  [60bf3e95] GLPK v1.1.0
  [4076af6c] JuMP v1.7.0 `https://github.com/jump-dev/JuMP.jl.git#od/vector-optimization`
  [b8f27783] MathOptInterface v1.11.5
  [44cfe95a] Pkg

Running the following snippet

using JuMP, MOO, GLPK

model = JuMP.Model()

p1 = [77, 94, 71, 63, 96, 82, 85, 75, 72, 91, 99, 63, 84, 87, 79, 94, 90]
p2 = [65, 90, 90, 77, 95, 84, 70, 94, 66, 92, 74, 97, 60, 60, 65, 97, 93]
w = [80, 87, 68, 72, 66, 77, 99, 85, 70, 93, 98, 72, 100, 89, 67, 86, 91]
model = Model()
set_silent(model)
@variable(model, x[1:length(w)], Bin)
@objective(model, Max, [p1' * x, p2' * x])
@constraint(model, w' * x <= 900)
model

I get the following error:

ERROR: TypeError: in ObjectiveFunction, in F, expected F<:MathOptInterface.AbstractScalarFunction, got Type{MathOptInterface.VectorAffineFunction{Float64}}
Stacktrace:
 [1] set_objective_function(model::Model, func::MathOptInterface.VectorAffineFunction{Float64})
   @ JuMP ~/anaconda3/share/julia/packages/JuMP/3qle2/src/objective.jl:104
 [2] set_objective_function(model::Model, func::Vector{AffExpr})
   @ JuMP ~/anaconda3/share/julia/packages/JuMP/3qle2/src/objective.jl:143
 [3] set_objective(model::Model, sense::MathOptInterface.OptimizationSense, func::Vector{AffExpr})
   @ JuMP ~/anaconda3/share/julia/packages/JuMP/3qle2/src/objective.jl:172
 [4] macro expansion
   @ ~/anaconda3/share/julia/packages/JuMP/3qle2/src/macros.jl:1297 [inlined]
 [5] top-level scope
   @ ~/Desktop/MOO.jl/ttt.jl:11

Is Julia still trying to use the default version of JuMP?

1 Like

You need to follow the installation instructions:

You need the master branch of MathOptInterface.

Thanks! With the master branch of MOI, it works. I skipped that part I think.

1 Like

Great. This is still in development so let me know if you have any feedback or suggestions.

Thanks so much! I am actually trying to add some MODO algorithms from the literature into the package. I have implementations in Julia but it is a back and forth between JuMP and other steps of the algorithms. Trying to adapt it to work with MOI.

Okay, great! Feel free to make a pull request, even if it is only half working, and we can go from there.

Each algorithm needs a file like this:

The main part is a struct that subtypes AbstractAlgorithm:

Then you need to implement

and return a vector of Pareto solutions:

They also need a corresponding test file:

1 Like