4

I'm solving this Multi-Objective problem

enter image description here

    f1(x,y) = x
    f2(x,y) = (2.0-exp(-((y-0.2)/0.004)^2)-0.8*exp(-((y-0.6)/0.4)^2) )/x

    isdefined(:f1) || JuMP.register(:f1, 2, f1, autodiff=true)
    isdefined(:f2) || JuMP.register(:f2, 2, f2, autodiff=true)

    m = Model(solver=IpoptSolver(print_level=0))
@variable(m, 0.1 <= x <= 1.0)
@variable(m, 0.0 <= y <= 1.0)
@variable(m, alpha1)
@variable(m, alpha2)
@NLobjective(m, Min, alpha1 + alpha2)
@constraint(m, f1(x,y) - z1_id >= -alpha1)
@constraint(m, f1(x,y) - z1_id <= alpha1)

@NLconstraint(m, f2(x,y) - z2_id >= -alpha2)
@NLconstraint(m, f2(x,y) - z2_id <= alpha2)
solve(m)
x_opt = getvalue(x)
y_opt = getvalue(y)

println("GOAL Programming (p=1): F1 = $(f1(x_opt, y_opt)), F2 = $(f2(x_opt, y_opt))")

It should have two solutions. I get only the first one with getvalue(x), how can I get all the others?

sparkle
  • 7,530
  • 22
  • 69
  • 131
  • 1
    Not a `JuMP` user, but aren't the constraints on `alpha1` (and `alpha2`) too restrictive? Maybe a minus sign is missing in one of them? – Dan Getz Jul 12 '16 at 18:53
  • You're right. Anyway, still getting one solution – sparkle Jul 12 '16 at 20:25
  • 2
    First of all, you would need a solver that returns multiple solutions. None of the nonlinear solvers connected to JuMP currently return multiple solutions. – mlubin Jul 12 '16 at 23:43

1 Answers1

1

I ran into something similar, but in integer programming. Nevertheless, as my search for an answer to took me here, this seems like a good place to share my ideas.

To me it seems the way to go about this is to first solve the system and then add a constraint that the previously found solution is now unfeasible. My idea would be to append as per the following:

solve(m)
x_opt = getvalue(x)
y_opt = getvalue(y)
println("GOAL Programming (p=1): F1 = $(f1(x_opt, y_opt)), F2 = $(f2(x_opt, y_opt))")

eps = 1.e-15
@constraint(m, x - x_opt <= eps)
@constraint(m, x - x_opt >= eps)
@constraint(m, y - y_opt <= eps)
@constraint(m, y - y_opt >= eps)
solve(m)
println("GOAL Programming (p=1): F1 = $(f1(x_opt, y_opt)), F2 = $(f2(x_opt, y_opt))")

I've done the same within a loop for my integer programming, i.e. wrapping the last lines in while solve(m) == :Optimal, for finding more options.

KeithWM
  • 1,295
  • 10
  • 19
  • Is it still how you do it in 2020? – JKHA May 17 '20 at 13:16
  • To be honest, I'm surprised at my own suggestion, how can `x - x_opt` be both greater than and less that eps? I think I paraphrased my own code badly there. The idea should still work. It will depend on (interface of the) the backends whether there's a smarter way in 2020. – KeithWM May 19 '20 at 15:52