# Help with multi-objective, non-linear JuMP problem

**URL:** https://discourse.julialang.org/t/help-with-multi-objective-non-linear-jump-problem/98487
**Category:** Optimization (Mathematical)
**Tags:** jump
**Created:** [May 8, 2023, 3:30pm UTC](https://discourse.julialang.org/t/help-with-multi-objective-non-linear-jump-problem/98487 "2023-05-08T15:30:41Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [May 8, 2023, 3:30pm UTC](https://discourse.julialang.org/t/help-with-multi-objective-non-linear-jump-problem/98487/1 "2023-05-08T15:30:42Z")

</div>

This single objective version below works just fine:

```julia
    using JuMP
    using Ipopt

	S, L, U = 1000, 15, 40
	N = 54
	r = rand(54, 2)
	model = Model(Ipopt.Optimizer)
	@variable(model, s[i=1:N], start=14)
	@NLexpression(model, obj1, sum( r[i,1] / s[i] for i in 1:N))
	@NLexpression(model, obj2, sum( r[i,2] / s[i] for i in 1:N))
	@NLobjective(
		model,
		Min,
	 	obj1 + obj2
	)
	@constraint(model, L .≤ s .≤ U)
	@constraint(model, sum(s) ≤ S)
	JuMP.optimize!(model)
	value.(s)

```

If I change the objective to this:

```julia
	@NLobjective(
		model,
		Min,
	 	[obj1, obj2]
	)

```

I get an `Unsupported expression` error. Is it because of the solver I’m using? If someone can point me in the right direction, it would be very much appreciated!

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [May 8, 2023, 5:31pm UTC](https://discourse.julialang.org/t/help-with-multi-objective-non-linear-jump-problem/98487/2 "2023-05-08T17:31:30Z")

</div>

I think Ipopt is a single-objective solver. Have you tried explicitly multi-objective ones like [jump-dev/MultiObjectiveAlgorithms.jl · JuMP](https://jump.dev/JuMP.jl/stable/packages/MultiObjectiveAlgorithms/) ?

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [May 8, 2023, 6:06pm UTC](https://discourse.julialang.org/t/help-with-multi-objective-non-linear-jump-problem/98487/3 "2023-05-08T18:06:23Z")

</div>

I did try that but I don’t understand it well enough to know if what I’m doing should even be expected to work. I tried the following two variations and they both produce the same `Unsupported expression` error:

```julia
	import HiGHS
	import MultiObjectiveAlgorithms as MOA
	model = JuMP.Model(() -> MOA.Optimizer(HiGHS.Optimizer))

```

```julia
model = JuMP.Model(() -> MOA.Optimizer(Ipopt.Optimizer))

```

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [May 8, 2023, 6:13pm UTC](https://discourse.julialang.org/t/help-with-multi-objective-non-linear-jump-problem/98487/4 "2023-05-08T18:13:57Z")

</div>

I haven’t tried multi-objective JuMP yet, but the tutorials ([Simple multi-objective examples · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/linear/multi_objective_examples/)) seem to suggest that there is an additional step which looks somewhat like this

```julia
set_attribute(model, MOA.Algorithm(), MOA.EpsilonConstraint())

```

Basically you need to tell the solver how to prioritize the objectives

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [May 8, 2023, 9:13pm UTC](https://discourse.julialang.org/t/help-with-multi-objective-non-linear-jump-problem/98487/5 "2023-05-08T21:13:29Z")

</div>

Vector-valued nonlinear objectives are currently not supported. But you can work-around this by introducing an intermediate variable:

```julia
julia> using JuMP

julia> import Ipopt

julia> import MultiObjectiveAlgorithms as MOA

julia> S, L, U, N = 1000, 15, 40, 54
(1000, 15, 40, 54)

julia> r = rand(54, 2);

julia> model = Model(() -> MOA.Optimizer(Ipopt.Optimizer))
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: MOA[algorithm=MultiObjectiveAlgorithms.Lexicographic, optimizer=Ipopt]

julia> set_silent(model)

julia> set_attribute(model, MOA.Algorithm(), MOA.Dichotomy())

julia> set_attribute(model, MOA.SolutionLimit(), 10)

julia> @variable(model, L <= s[1:N] <= U, start = 14);

julia> @constraint(model, sum(s) <= S);

julia> @variable(model, obj[1:2])
2-element Vector{VariableRef}:
 obj[1]
 obj[2]

julia> @NLconstraint(model, [i=1:2], obj[i] == sum(r[j, i] / s[j] for j in 1:N));

julia> @objective(model, Min, obj)
2-element Vector{VariableRef}:
 obj[1]
 obj[2]

julia> optimize!(model)

julia> for i in 1:result_count(model)
           println("Solution $i")
           println(" Objective = ", objective_value(model; result = i))
           # println(value.(s; result = i))
       end
Solution 1
  Objective = [1.301662920394281, 1.4623640207630741]
Solution 2
  Objective = [1.3055226089750172, 1.42828408366959]
Solution 3
  Objective = [1.316550684889867, 1.3920126114808964]
Solution 4
  Objective = [1.333160463352082, 1.3592565385479682]
Solution 5
  Objective = [1.3545043825902743, 1.3305717489020021]
Solution 6
  Objective = [1.3800656024907705, 1.3066224590810092]
Solution 7
  Objective = [1.407792737347257, 1.2893101957186606]
Solution 8
  Objective = [1.43828364753188, 1.2782264523557885]
Solution 9
  Objective = [1.4544662674597648, 1.2751661435451191]
Solution 10
  Objective = [1.469182305027906, 1.2741557079126375]

```
