ralna / CUTEst

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

Function values and derivatives inconsistent? #14

Closed dpo closed 4 years ago

dpo commented 4 years ago

Jean-Pierre Dussault reported the following behaviour using the Julia interface to CUTEst, but I can reproduce it directly in Fortran. The idea is to compare the values and derivatives of t -> f(x - tg) where x is the initial guess and g the gradient of the objective at the initial guess.

If I stick the following into, e.g., gen90_main.f90:

  OPEN(69, FILE='TVALS.dat', FORM='FORMATTED', STATUS='NEW')
  OPEN(70, FILE='FVALS.dat', FORM='FORMATTED', STATUS='NEW')
  OPEN(71, FILE='GVALS.dat', FORM='FORMATTED', STATUS='NEW')

  tmin = 0.120
  tmax = 0.124
  dt = (tmax - tmin) / 10000

  ALLOCATE(G(n), Gt(n), Xt(n))
  CALL CUTEST_ugr(status, n, X, G)

  DO i = 0, 10000
    t = tmin + i * dt
    WRITE(69, '(D22.15)') t
    Xt = X - t * G
    CALL CUTEST_ufn(status, n, Xt, Ft)
    WRITE(70, '(D22.15)') Ft
    CALL CUTEST_ugr(status, n, Xt, Gt)
    slope = -DDOT(n, Gt, 1, G, 1)
    WRITE(71, '(D22.15)') slope
  END DO

  DEALLOCATE(Xt, Gt, G)
  CLOSE(71)
  CLOSE(70)
  CLOSE(69)

and run runcutest -p gen90 -lblas -D VAREIGVL, and plot the values in FVALS.dat and GVALS.dat, I obtain

fvals gvals

Thus the slope is zero around t = 0.123. However, f appears to attain its minimum before 0.121, where the slope is not small.

Would this be related to an error in the SIF file, the decoder, the gradient computation, or between the screen and the chair?

nimgould commented 4 years ago

Ho ho ho. The behaviour you report seems to be due to a bug in the VAREIGVL.SIF file. The group function 1/p g^p incorrectly rounds the exponent p to an integer (presumably as a fix because some compiler objected to g**p, but not enough care was taken) - the derivative is correctly flagged as wrong using LANCELOT with full derivative checking.

I will issue a corrected version of the file to the gitbucket repository tomorrow (no access from home). In the mean time, if you wish, add

GV LQ2 GVAR GP LQ2 POWER

to the GROUP TYPE section, change

XT G(N+1) LQ2

and add

T LQ2 F GVAR POWER / POWER G GVAR (POWER - 1.0D0) H (POWER - 1.0D0) * GVAR**(POWER - 2.0D0)

in the GROUPS file.

Let me know if that sorts things out.

Was this jiust an issue for VAREIGVL, you didn't say?

Nick

dpo commented 4 years ago

No other inconsistent problem at the moment. Thanks!

nimgould commented 4 years ago

Updated VAREIGVL.SIF now in https://bitbucket.org/optrove/sif