I've dug in how direct collocation actually works when it is not used in an optimal control scheme.
It looks like our implementation is not truly based on a boundary value problem. As it has been implemented from IRK solver, the collocation method implemented still rely on an initial value problem.
And the direct collocation method is a boundary value problem. Meaning we should have a initial value and final value satisfied by the solution of the differential equation :
To implement a true collocation method, modifications could be done:
Thus, we would get n+1 equations for each segment, and a system of equations that can be solved.
Plus, this formulation could reduce the number of variables since the final value of each segment is the first value of the next segment. So, the final enhancement could be to reduce the number of symbolic variables and delete the defect when using direct collocation.
I've dug in how direct collocation actually works when it is not used in an optimal control scheme.
It looks like our implementation is not truly based on a boundary value problem. As it has been implemented from IRK solver, the collocation method implemented still rely on an initial value problem.
And the direct collocation method is a boundary value problem. Meaning we should have a initial value and final value satisfied by the solution of the differential equation :
To implement a true collocation method, modifications could be done:
the final point [1] should be added with the final boundary value https://github.com/pyomeca/bioptim/blob/3624b8cc4d34f0d3cee5736905f79ae796f24a2d/bioptim/dynamics/integrator.py#L434-L435
dynamic consistency should be ensured on collocation points only, not in [0] and [1], so dynamic consistency should be remove at [0]. https://github.com/pyomeca/bioptim/blob/3624b8cc4d34f0d3cee5736905f79ae796f24a2d/bioptim/dynamics/integrator.py#L458-L462
Thus, we would get n+1 equations for each segment, and a system of equations that can be solved.
Plus, this formulation could reduce the number of variables since the final value of each segment is the first value of the next segment. So, the final enhancement could be to reduce the number of symbolic variables and delete the defect when using direct collocation.