Nonlinear programming function calls involving sine and cosine

To use a user-defined function in a nonlinear expression, you first need to register it:
https://jump.dev/JuMP.jl/stable/manual/nlp/#User-defined-Functions

But even then, all functions must be symbols, so you can’t look up a function using cons[1].

I’d strongly suggest you re-structure your code to write out the expressions instead of using the cons vector (just like you did in the second example).

But if you must, you can use the (advanced) capability to construct the expressions:
https://jump.dev/JuMP.jl/stable/manual/nlp/#More-complicated-examples

1 Like