Hi,
I am solving optimization problems like find max x1 in [a1,b1] : f(x1,x2,x3...)<=0
plus I know that at initial point f(a1,a2,a3...)<=0
.
Sometimes my model f
(based on experimental data) isn’t sensitive to x1
(like in the example below), so I want to stop the optimizer when it reaches b1
but it seems stopval
doesn’t work this way:
f_ineq_constr(x::Vector, g::Vector) = 0.0*x[1] + (x[2]-1.0)^2 -2.0
global count = 0
function f_optim(x::Vector, g::Vector)
global count
count::Int += 1
println("f_$count($x)")
x[1]
end
using NLopt
opt = Opt(:LN_AUGLAG, 2)
max_objective!(opt, f_optim)
local_opt = Opt(:LN_SBPLX, 2)
lower_bounds!(opt, [0.0, -Inf])
upper_bounds!(opt, [9.0, +Inf])
xtol_abs!(opt, 1e-3)
stopval!(opt, 9.0)
inequality_constraint!(opt, f_ineq_constr, 1e-5)
(minf, minx, ret) = optimize(opt, zeros(2))
f_23035([8.9965, 0.0])
f_23036([9.0, 0.0])
f_23037([9.0, 0.0])
...
Finally it reaches MAXEVAL_REACHED
.
Could you please help me understand how stopval
should work and what is a good choice of a termination criteria here?