JuMP + Alpine: Handling scalar functions with vector input using @NLexpression

Hi @smallpondtom, welcome to the forum!

I expect this to work for @NLexpression

It does not work, which is why I rewrote JuMP’s nonlinear support last year :smile: See ANN: JuMP v1.15 is released for details.

The answer of what to do depends greatly on what V and V_dot are.

I would use Nonlinear Modeling · JuMP and write your model as:

using JuMP, Ipopt, LinearAlgebra

function LEDOA(V::Function, V_dot::Function, N::Int)
    model = Model(Ipopt.Optimizer)
    @variable(model, x[1:N])
    @variable(model, c >= 1e-8)
    @objective(model, Min, c)
    @constraint(model, V(x) - c == 0)
    @constraint(model, V_dot(x) == 0)
    optimize!(model)
    @assert is_solved_and_feasible(model)
    return value(c), value.(x)
end

A = [-2.0 0.0; 0.0 -1.0]
H = [0.0 0.5 0.5 0.0; 0.0 0.5 0.5 0.0]
P = [0.02078 0; 0 0.01292]
V(x) = x' * P * x
V_dot(x) = x' * P * A * x + x' * P * H * kron(x, x)
c, x = LEDOA(V, V_dot, 2)