-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Description
The following error is raised on the following line (see code 3 and code 4 below), but no for codes 1 and 2 (who use the same definition of the expression):
julia> @objective(model, Max, [objective1, objective2])
ERROR: The solver does not support an objective function of type MathOptInterface.VectorAffineFunction{Float64}.
This happens with a variable JuMP with two indexes and MOA+GLPK.
The problem does not appear with HiGHS, or without solver.
My configuration:
julia v"1.10.5"
JuMP v1.23.6
MultiObjectiveAlgorithms v1.3.5
GLPK v1.2.1
HiGHS v1.13.0
Codes:
using JuMP
using GLPK
import MultiObjectiveAlgorithms as MOA
m=2; n=3
p1 = rand(1:10,m,n)
p2 = rand(1:10,m,n)
w = rand(1:10,m,n)
b = Vector{Int64}(undef,m)
for i=1:m
b[i] = floor(Int64,sum(w[i,:])/2.0)
end
# CODE 1 (single objective GAP with objective1): no problem
model = Model(GLPK.Optimizer)
@variable(model, x[1:m, 1:n], Bin)
@expression(model, objective1, sum(p1[i,j]*x[i,j] for i in 1:m, j in 1:n) )
@expression(model, objective2, sum(p2[i,j]*x[i,j] for i in 1:m, j in 1:n) )
@objective(model, Max, objective1)
@constraint(model, [i=1:m], sum(w[i,j]*x[i,j] for j = 1:n) <= b[i])
@constraint(model, [j=1:n], sum(x[i,j] for i = 1:m) == 1)
optimize!(model)
# CODE 2 (single objective GAP with objective2): no problem
model = Model(GLPK.Optimizer)
@variable(model, x[1:m, 1:n], Bin)
@expression(model, objective1, sum(p1[i,j]*x[i,j] for i in 1:m, j in 1:n) )
@expression(model, objective2, sum(p2[i,j]*x[i,j] for i in 1:m, j in 1:n) )
@objective(model, Max, objective2)
@constraint(model, [i=1:m], sum(w[i,j]*x[i,j] for j = 1:n) <= b[i])
@constraint(model, [j=1:n], sum(x[i,j] for i = 1:m) == 1)
optimize!(model)
# CODE 3 (bi-objective GAP with [objective1,objective2] ): error raised
model = Model(GLPK.Optimizer)
@variable(model, x[1:m, 1:n], Bin)
@expression(model, objective1, sum(p1[i,j]*x[i,j] for i in 1:m, j in 1:n) )
@expression(model, objective2, sum(p2[i,j]*x[i,j] for i in 1:m, j in 1:n) )
@objective(model, Max, [objective1, objective2])
@constraint(model, [i=1:m], sum(w[i,j]*x[i,j] for j = 1:n) <= b[i])
@constraint(model, [j=1:n], sum(x[i,j] for i = 1:m) == 1)
# CODE 4: error raised
model = Model(GLPK.Optimizer)
@variable(model, x[1:2, 1:2], Bin)
@expression(model, objective1, x[1,1]+x[1,2] )
@expression(model, objective2, x[2,1]+x[2,2] )
@objective(model, Max, [objective1, objective2])Metadata
Metadata
Assignees
Labels
No labels