Closed ShihaoWang closed 6 years ago
I can't really debug your problem with only a snippet of your definitions for iGfun/jGvar.
Are you specifying all derivatives (i.e., are you setting option 'Derivative option' to 0 or 1)?
Your Verify output is for the 3rd variable, when iGvar == 2 (in C, since SNOPT is Fortran and 1-indexed). Make sure you are computing the values of G in your user-defined function in the same order as you define the coordinates in iGfun/jGvar.
If you haven't already, I would recommend looking at the documentation (http://ccom.ucsd.edu/~optimizers/static/pdfs/snopt7-6.pdf), in particular sections 3.2 and 3.3. Just remember the doc is for the Fortran library so the indices start at 1.
Sorry for the previous confusion. Actually I just identifiy the cause of my problem. I forget to delete the computerJac() command while using my own gradient. After I remove this finite-difference gradient computation, the optimization solver works perfectly!
Hi there,
I am a new user of SNOPT and currently I get stuck in using the user-defined derivative to conduct a nonlinear optimization. After the definition of neG, iGfun and jGvar, I give the analytical expression of the jacobian matrix. However, the solver won't agree with the provided jacobian. After I set the "verify" option to 3, I find that actually the main reason for this problem is the discrepancy between the finite-difference gradient and the user-defined gradient.
Even though I may have an idea of what is causing this problem, I am not sure how to address this issue. For example, I define the neG, iGfun and jGvar as follows, // The Jacobian matrix neG = 0; iGfun[neG] = 0; jGvar[neG] = 2; neG++; iGfun[neG] = 1; jGvar[neG] = 1; neG++; iGfun[neG] = 1; jGvar[neG] = 2; neG++; iGfun[neG] = 1; jGvar[neG] = 6; neG++; iGfun[neG] = 1; jGvar[neG] = 7; neG++; iGfun[neG] = 1; jGvar[neG] = 8; neG++; iGfun[neG] = 2; jGvar[neG] = 1; neG++; iGfun[neG] = 2; jGvar[neG] = 2; neG++; iGfun[neG] = 2; jGvar[neG] = 6; neG++; It is clearly that these gradient position is not at the same column but from the finite-difference result,
the verification is conducted on the same column. I am not sure how to address this problem. Can you help me with this issue?
Thanks, Shihao