I'm solving this Multi-Objective problem
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?
答案 0 :(得分:1)
我遇到了类似的事情,但是在整数编程中。不过,当我寻找答案将我带到这里时,这似乎是分享我的想法的好地方。
在我看来,解决此问题的方法是先解决系统,然后添加一个约束,使以前找到的解决方案现在不可行。我的想法是按照以下内容进行添加:
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))")
对于整数编程,我已经在循环内完成了相同的工作,即将最后几行包装在while solve(m) == :Optimal
中,以查找更多选项。