ralna / CUTEst

The Constrained and Unconstrained Testing Environment with safe threads (CUTEst) for optimization software
Other
83 stars 18 forks source link

chjprod gives incorrect result when goth = .false. #40

Closed jfowkes closed 6 months ago

jfowkes commented 6 months ago

When calling chjprod on ALLINITC with the default starting point x and Lagrange multipliers y:

double y0 = 3.5;
double p[] = {0.3, 0.3, 0.3, 0.3};
CUTEST_chjprod(&status, &CUTEst_nvar, &CUTEst_ncon, true, x, &y0, y, p, r);
CUTEST_cdh(&status, &CUTEst_nvar, &CUTEst_ncon, x+1.5, y-0.2, CUTEst_nvar, r);
CUTEST_chjprod(&status, &CUTEst_nvar, &CUTEst_ncon, true, NULL, &y0, NULL, p, r);
CUTEST_chjprod(&status, &CUTEst_nvar, &CUTEst_ncon, true, x+1.5, &y0, y-0.2, p, r);

gives

chjprod: [  4.2   2.1   8.4 -10.5]
chjprod: [ 94.314672   100.74225564 128.62426465  78.6433218 ]
chjprod: [330.40135202 352.89789475 450.18492627 275.25162631]

which is clearly incorrect.

nimgould commented 6 months ago

There must be something wrong with the setup, above, as if p is the zero vector, Hp = 0. This is what the fortran tests of the above say

jfowkes commented 6 months ago

Yes sorry p should be [0.3 0.3 0.3 0.3]

nimgould commented 6 months ago

The issue is that the call to cdh evaluates the Hessian of the Lagrangian, not the John function, and thus when calling chjprod again, we have the wrong Hessian. I will update the docs, and (perhaps) at some stage add a cdhj function