I’m starting to dig deep into `ModelingToolkit.jl`

with the intention of using it to model a version of the SLAM problem. Ultimately, SLAM problems end up looking like large-scale nonlinear least squares problems. Instead of working with a single scalar objective function, large-scale least squares solvers exploit the extra structure in the problem by working with the residual function and its Jacobian directly.

`ModelingToolkit.jl`

provides `OptimizationSystem`

, but it is designed to wrap a single scalar objective function, and doesn’t provide a method for `generate_jacobian`

.

`NonlinearSystem`

seems like almost the right thing to use to build up the residual function by components (including having a `generate_jacobian`

method) but requires the system be expressed as a vector of `Equation`

s, rather than simple expressions.

My current thought is to just make use of `NonlinearSystem`

for now, prepending my residual expressions with `0 ~`

to turn them into equations.

A few questions, though:

- Immediate term: will this hack work? I think so, but I haven’t tried yet.
- Slightly longer term, what is the right way to make things less hacky for this use case? A little generalization of
`NonlinearSystem`

? A new concrete sub-type of`AbstractTimeIndependentSystem`

? - Even longer term, where might large-scale least squares solvers for problems of this sort find their way into the ecosystem? Once I’ve got my residual function modeled, I’m perfectly comfortable cobbling together the solver bits I require from elsewhere in the julia ecosystem and beyond, but it would be nice to button things up with a more complete story fully contemplated by the reach of SciML.

I opened an issue on github about this, figuring it would ultimately lead to some opportunity to bring relevant extensions to `ModelingToolkit.jl`

and/or packages in its larger ecosystem, but figured it would probably be best to cross post here, since at this point it is more about questions and discussions than specific software changes.