help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] Questions about BFGS2 algorithm implemented for the GSL


From: Sanjay Bhatnagar
Subject: [Help-gsl] Questions about BFGS2 algorithm implemented for the GSL
Date: Fri, 23 May 2008 11:44:55 -0600

Hi,

I am trying to use the BFGS algorithm implemented as the "bfgs2" in
GSL.  The test is to fit a single 2D symmetric gaussian.  While I am
fitting for the amplitude and the width of the gaussian, the initial
guess for the amplitude is accurate.  The initial guess for the width
is not accurate but not too far either.

A call to gsl_multimin_fdfminimizer_iterate returns with GSL_NOPROG
(well before convergence).  I traced the return GSL_NOPROG to the
following test in linear_minimize.c (around line number 214):

     if ((a-alpha)*fpa <= GSL_DBL_EPSILON) {
       /* roundoff prevents progress */
       fprintf(stderr,"linear min. no prog: %e %e %e
%e\n",a,alpha,fpa,GSL_DBL_EPSILON);
       return GSL_ENOPROG;
     };

The message printed was:

    linear min. no prog: 1.498441e-01 1.498441e-01 3.012037e-02 2.220446e-16

Does anyone know what could be wrong?  I have tested the f and fdf function
evaluations and they appear to be correct.

Following is the code snippet that I am using to solve for the
parameters of the gaussian:
----------------------------------------------------------------------------------------------
template<class T>
  int SSCompressor2<T>::findComponent(int NIter, gsl_multimin_fdfminimizer *s,
                                     gsl_vector *x,
                                     gsl_multimin_function_fdf *func,
                                     AspCompList<T> &MI,   vector<int> &PIndex,
                                     int P0,int Pi, int DoInit,int RestartAt)
  {
    int iter = 0,mm=0,status;
    gsl_vector *x0, *p0;
    T A,S;

    Float Min0=0, Min=0;
    do
      {
        {
          gsl_vector *x0;
          T InitStep;
        
          x0 = gsl_multimin_fdfminimizer_x(s);
          InitStep = gsl_blas_dnrm2 (x0);
          gsl_multimin_fdfminimizer_set(s, func, x0, InitStep, Tolerance);
        
          gsl_multimin_fdfminimizer_restart(s);
        }
        
        x0 = gsl_multimin_fdfminimizer_x(s);
        p0 = gsl_multimin_fdfminimizer_gradient(s);
        
        mm=0;
        Min = gsl_multimin_fdfminimizer_minimum(s);
        //
        // Make the move!
        //
        {status = gsl_multimin_fdfminimizer_iterate(s);}
        //      cerr << "###Info: " << gsl_strerror(status) << endl;
        p0 = gsl_multimin_fdfminimizer_gradient(s);

        if (status == GSL_ENOPROG) gsl_multimin_fdfminimizer_restart(s);
        Min0 = Min;
        Min = gsl_multimin_fdfminimizer_minimum(s);
        
        if (status)
          {
            cerr << "###Info: " << gsl_strerror(status) << endl;
            break;
          }
        
        status = gsl_multimin_test_gradient(s->gradient, 1E-6);
        T normG=gsl_blas_dnrm2(s->dx);
        if (normG<= 1e-6) break;
        if ((Min0-Min < 0) && (abs((Min0-Min)/Min) > 1e-2)) break;
      }
    while((status == GSL_CONTINUE) && (iter < NIter) && abs(Min-Min0)
> Tolerance);

    x0 = gsl_multimin_fdfminimizer_x(s);
    fromGSLParameters(MI,x0);

    return status;
  }

----------------------------------------------------------------------------------------------

Thanks.

Sanjay

-- 
संजय

reply via email to

[Prev in Thread] Current Thread [Next in Thread]