Hi, I have confronted with something amazing !

I was trying **parameter estimation on Lotka-volterra example** in DiffeqParamEstim which uses **DifferentialEquations.jl** model specification and parameter estimation using **LeastSquaresOptim.jl.** That went pretty smooth. But the same example using **ModelingToolkit** specification and **LeastSquaresOptim**.jl fails throwing Bounds Error and asking for large maxiters. Increasing maxiters didn’t worked yet.

Another fact is that both produced similar simulation output. And without adding noise, same data is used for parameter estimation in both cases.

I would like to integrate aforementioned methods to my model and thats why I keep exploring all the many ways! Can someone help me out? Is that an issue internally with calling optimization in LeastSquaresOptim?

Here goes the package versions and code I have tried…

DiffEqParamEstim v1.23.1

DifferentialEquations v7.1.0

LeastSquaresOptim v0.8.3

ModelingToolkit v8.14.0

RecursiveArrayTools v2.29.2

using DifferentialEquations.jl :

```
using Random
Random.seed!(1234)
function f2(du,u,p,t)
du[1] = dx = p[1]*u[1] - p[2]*u[1]*u[2]
du[2] = dy = -p[3]*u[2] + p[4]*u[1]*u[2]
end
u0 = [1.0;1.0]
tspan = (0.0,10.0)
p = [1.5,1.0,3.0,1.0]
prob = ODEProblem(f2,u0,tspan,p)
sol = solve(prob,Tsit5())
t = collect(range(0,stop=10,length=200))
randomized = VectorOfArray([(sol(t[i]) + 0.0randn(2)) for i in 1:length(t)])
data = convert(Array,randomized)
cost_function = build_lsoptim_objective(prob,t,data,Tsit5())
x = [1.3,0.8,2.8,1.2]
res = optimize!(LeastSquaresProblem(x = x, f! = cost_function,
output_length = length(t)*length(prob.u0)),
LeastSquaresOptim.Dogleg(LeastSquaresOptim.LSMR()))
```

using ModelingToolkit.jl :

```
using Random
Random.seed!(1234)
@parameters t, p1, p2, p3, p4
D= Differential(t)
@variables x1(t), x2(t)
eqs = [
D(x1) ~ p1*x1 - p2*x1*x2,
D(x2) ~ -(p3*x2) + p4*x1*x2
]
@named sys = ODESystem(eqs)
simplified_sys=structural_simplify(sys)
u0=[ x1 => 1.0, x2 =>1.0]
p=[p1 =>1.5, p2 => 1.0, p3 => 3.0 , p4 => 1.0]
prob = ODEProblem(simplified_sys,u0,(0.0,10.0),p)
sol = solve(prob,Tsit5())
t = collect(range(0,stop=10,length=200))
randomized = VectorOfArray([(sol(t[i]) + 0.00randn(2)) for i in 1:length(t)])
data = convert(Array,randomized)
cost_function = build_lsoptim_objective(prob,t,data,Tsit5())
x = [1.3,0.8,2.8,1.2]
res = optimize!(LeastSquaresProblem(x = x, f! = cost_function,
output_length = length(t)*length(prob.u0)),
LeastSquaresOptim.Dogleg(LeastSquaresOptim.LSMR()))
```