I am solving optimal control problems where I need to calculate the D or differentiation matrix, it is full of derivartives of Lagrange Polynomials . This matrix is also a function of the final time (tf
, which is a design variable within the optimization). My first attempt (F2) to calculate this matrix was to modify this function (F1) for JuMP by creating many @NLexpression()
s. The output for F1
and F2
match perfectly until the final time is small tf < 0.1
I am not sure why this is. Could it be a simplification that @NLexpression()
is making?
Anyways, after all of this I decided that there must be a better way to accomplish my goal. What (I think) I need to do is generate an analytical expression of the D matrix
in terms of tf
before optimization. Then, during optimization, I can use the elements of the D matrix (which will be functions of tf
) in an @NLconstraint()
current code.
Any suggestions or thoughts ? It seems that automatic differentiation may not work for my case since I don’t know tf
before optimization. I was thinking about using Calculus.jl, but I am not sure if that will be waisting more of my time (if there is a better package or better way to do this). Also, I was thinking about registering the functions of tf
in the D matrix
using JuMP, but I am very concerned with speed and since the registering functionality uses ForwardDiff I am not sure if it will be fast enough.
Thank you very much!