Hey folks, I was trying to resolve a problem using MTK and GalacticOptim to solve a simple optimization problem. The issue is that I am no really getting an error message that tells me where the problem is.
Here is the code:
using ModelingToolkit, GalacticOptim
using LinearAlgebra
@variables x[1:4]
@parameters Q, R
A = [1 1 1 1; 1 2 3 4; 1 3 6 10; 1 4 10 20]
B = [1 1 1 1; 1 2 3 4; 1 3 6 10; 1 4 10 20]
loss_quad = x'*Q*x + x'*R*x
u1 = [1.,1.,1.,1.]
p = [
Q => A,
R => B
]
sys2 = OptimizationSystem(loss_quad,[x],[Q, R])
prob2 = OptimizationProblem(sys2, u1, p ,grad=true,hess=true)
solve(prob2,Newton())
But the error message I get is just.:
ERROR: syntax: invalid let syntax around /xxx/.julia/packages/SymbolicUtils/JmtMa/src/code.jl:283
Stacktrace:
[1] top-level scope
@ REPL[52]:100:
I tried looking around for other examples. My guess is that it has to do with how u1
or p
are specified, but not sure. If anyone has a suggestion it would be appreciated.