Description
The following invariant must hold:
isapprox(f_original(f_reconstruct(u_compressed))), `f_expand_resid(f_compressed(u_compressed)))`
where f_compressed
is the optimized DAE/ODE function we have right now, f_reconstruct
is as in DAECompiler v1 and takes a state vector and expands it into a variable vector, f_expand_resid
maps from state numbers to original equation numbers and makes all other entries zero, and f_original
is the original function without any optimization (but with variable numbers the same as after structural analysis, so there's a little bit of work to do to hook that up right).
Validating this invariant would be a powerful check on our code generation. We need to write code generators for:
- f_reconstruct
- f_expand_resid
- f_original
However, all of these should be relatively straightforward. f_reconstruct
codegen can largely be copied from v1. f_expand_resid
, is just a bunch of setindex and f_original
is largely unmodified IR, with the exception of encoding the variable numbers.
Bonus points for a version of this that can do this on a partition-by-partition basis to narrow down which function is being miscompiled, but that can be follow on PR.