-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
For the following 2IP problem:
max z_1 = x_1 + x_2
min z_2 = x_1 + 3x_2
s.t.
2x_1 + 3x_2 <= 30
3x_1 + 2x_2 <= 30
x_1 + x_2 <= 5.5
x_1 , x_2 \in \mathbb{N}
The lexicographic algorithm returns only one solution, the x=(0,0) corresponding to z=(0,0) is missing.
The code is the following:
using JuMP
import MultiObjectiveAlgorithms as MOA
using GLPK
using Printf
# Setup the model ------------------------------------------------------------
model = Model( )
# Define the variables
@variable(model, x1≥0, Int)
@variable(model, x2≥0, Int)
# Define the objectives
@expression(model, fct1, x1 + x2) # to maximize
@expression(model, fct2, x1 + 3 * x2) # to minimize
@objective(model, Max, [fct1, (-1) * fct2])
# Define the constraints
@constraint(model, 2*x1 + 3*x2 ≤ 30)
@constraint(model, 3*x1 + 2*x2 ≤ 30)
@constraint(model, x1 - x2 ≤ 5.5)
# Setup the solver (lexicographic method) ------------------------------
set_optimizer(model,()->MOA.Optimizer(GLPK.Optimizer))
set_attribute(model, MOA.Algorithm(), MOA.Lexicographic())
# Solve and display results ---------------------------------------------------
optimize!(model)
for i in 1:result_count(model)
z1_opt = objective_value(model; result = i)[1]
z2_opt = -1 * objective_value(model; result = i)[2]
x1_opt = value(x1; result = i)
x2_opt = value(x2; result = i)
@printf( "%2d : z = [%3.0f ,%3.0f] | x1 =%2.0f x2 =%2.0f\n", i, z1_opt, z2_opt, x1_opt, x2_opt )
end
returns:
1 : z = [ 12 , 24] | x1 = 6 x2 = 6
The decision space and the objective space for this 2IP are:
Metadata
Metadata
Assignees
Labels
No labels