Hi,
I planning to use IPOPT in an optimization project.
I would like to know if there is a way to share the solution of a system of equations (like Ax=b) between different functions called by IPOPT, say the constraint and its jacobian functions. Because otherwise Ax=b needs to be solved twice, once per function call, g and dgdx.
It seems difficult even at C API level because we don’t know the order Ipopt calls eval_g and eval_jac_g (I am not sure if Ipopt guarantees the order to call user-provided functions). Otherwise we can solve Ax=b in eval_g and use the result directly in eval_jac_g.
Maybe a silly solution is to create an extra array to memorize recent values of x and corresponding solution of expensive Ax=b (for example, latest 5 values of x), then check the distance between current x and previously encountered x. If the distance is small enough, the memorized equation solution can be used directly.
Thanks, you are right. We do not know the order of function calls and hence who comes first…
The solution you propose makes sense, thanks. But I think it requires to have global variables(or arrays) and to check whether their value has changed since the last function call before solving again the system within a certain function. Right?