The error is because you are attempting to combine the new NonlinearExpr
syntax in JuMP with the old @NL
expression syntax.
See ANN: JuMP v1.15 is released
Here’s how I would write your model
using JuMP, Ipopt
const n = 80
const g = 9.81
const m = 1
const l = 1
f(θ, ω, u) = [ω, -g / l * sin(θ) + 1 / (m * l^2) * u]
A = [0 0; 1 0]
b = [0.5, 0.5]
model = Model(Ipopt.Optimizer)
@variables(model, begin
x[1:n+1, 1:2]
u[1:n]
Δt[1:n]
end)
@expressions(model, begin
k1[j in 1:n], f(x[j,1], x[j,2], u[j])
y[j in 1:n, i in 1:2], x[j,i] + Δt[j] * A[2,1] * k1[j][i]
k2[j in 1:n], f(y[j,1], y[j,2], u[j])
xₕ[j in 2:n+1, i in 1:2],
x[j-1, i] + Δt[j-1] * (b[1] * k1[j-1][i] + b[2] * k2[j-1][i])
end)
@constraint(model, [j in 2:n+1, i in 1:2], x[j,i] == xₕ[j,i])