Replies: 3 comments 3 replies
-
It could be due to ill-conditioning. The following works
Both of these worked and hope that helps. |
Beta Was this translation helpful? Give feedback.
-
To quantify my response earlier, @edhmr I modified your code. The code plots condition number of the NLP jacobian (eq. 2 of ref). Consider cases where guess for velocity is all zeros and all ones. This is what condition number at each iteration looks like and I have set max iteration to 100.
|
Beta Was this translation helpful? Give feedback.
-
Hello, Despite everything that is said above being correct suggestions for better solutions, that’s not really the issue in this example. The main issue is that you did not define time to be positive. Here a more concise version
And to answer on the Opti abstraction; yes you could define your variables inside of the loop, but it not really necessary in this example. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I am playing around with CasADi, but I have stumbled upon an issue I do not understand. It seems that variable declaration order and constraint order affect the convergence of the optimization problem.
For example, I transformed the Rocket Launch GEKKO example (see: https://apmonitor.com/wiki/index.php/Apps/RocketLaunch) into CasADi. I reformulated the dynamics a bit to have a linear set of equations (Ax=b, with x being the state-derivatives). This all works fine using this code:
Then I was updating my code and decided to swap the declaration of the state variables (s_k, v_k, m_k) and decision variables (u_k and tf), like this:
When I used this (i.e., the declaration of state variables before the decision variables), the solver fails to converge. Also, shuffling around with the order of constraints (i.e., first the dynamic constraint then boundary&box constraints) influence the convergence.
In sum, my observation is that both the variable declaration order and the constraint order affect the convergence. I would like to understand why this happens.
Thanks in advance. 🚀
Beta Was this translation helpful? Give feedback.
All reactions