function α(x)
global Lmin, Lnom, Lmax, α_0 # values calculated outside
a = 0.0019727939
b = 0.0078887
if Lmin <= x < Lnom
return a * (x-Lnom)^2 + α_0
elseif Lnom <= x <= Lmax
return (b * (x-Lnom)^2 + α_0)
end
end
model = Model(Ipopt.Optimizer) @variable(model, Lmax>=x[1:2]>=Lmin) @constraint(model, sum(x)==1) @objective(model, Min, α(x))
optimize!(model)
I have two decision variables: x[1], x[2].
How to implement α(x) in JuMP and solve this optimization?
Can you write it as a single expression with a dummy variable?
(a*(x<Lnom) + b*(x>=Lnom)) *(x-Lnom)^2 + α_0
EDIT: Also it looks like x is a vector but your objective function is treating it as a scalar so I’m not certain you’re giving a clear picture of your actual problem.