First: Lnom, xLdf, yLdf are not defined in your example, but I am assuming you have them somewhere.
Second: your α doesn’t give any value if x is smaller than Lmin or larger than Lmax. You start the optization with x=0.5 <Lmin=0.8, so it will not run. Even if you start somewhere else, like x=1, then Ipopt may run into trouble when solving the problem.
This runs:
using JuMP, Ipopt
const R0 = 0.1803
Lmin, Lmax = 0.8, 3.5
Lnom = 2.0
w1 = 0.4
w2 = 0.6
Rfc1 = 0.1803 + 0.01
Rfc2 = 0.1803
L11, L21 = 2.1, 2.1
Dindf = repeat([250], 2)
Ldf = [5, 4]
function α(x)
a = 0.0019727939
b = 0.0078887
α_0 = 0.006226
if Lmin <= x < Lnom
return a * (x - Lnom)^2 + α_0
elseif Lnom <= x <= Lmax
return b * (x - Lnom)^2 + α_0
else
return 0.0 ##New part here
end
end
function obj(x, y)
f0dL = (w1 * (Ldf[1] - L11)^2 + w2 * (Ldf[1] - L21)^2) * 1 * 3600
return (w1 * α(x)) * Dindf[1] + f0dL
end
model = Model(Ipopt.Optimizer)
lb = maximum(Lmin ./ Ldf)
ub = minimum(Lmax ./ Ldf)
@variable(model, lb <= x <= ub, start = 1.0)
@variable(model, lb <= y <= ub, start = 1.0)
@NLconstraint(model, x + y == 1)
register(model, :obj, 2, obj; autodiff = true)
@NLobjective(model, Min, obj(x, y))
optimize!(model)
(I created the missing values)
I think you α needs work outside Julia. How is it possible to require x>=0.8, y>=0.8 in α(x),α(y) and then enforce constraint x+y=1?