This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Multi-dimensional root finding


Andrew W Steiner writes:
 > 	I was attempting to implement such a prescription using the gsl
 > code, but I have run into a problem. Since the solver retains only the
 > best guess at present and not the last attempted step, it is difficult for
 > me to recover from a GSL_EBADFUNC error. When I do know the last attempted
 > step, I often try to cut it in half to see if the smaller step will remain
 > in the domain. (This particular prescription is probably naive, but
 > sufficient for the kinds of functions that I work with.)

I recommend making a user-defined algorithm to do this.  User defined
algorithms can be called in the same way as the existing ones in the
library.

For example, you can grab the file gnewton.c, put it in your
application and rename all its functions to 'mygnewton_'. Then you
will have a mygnewton_ solver.  If you modify this to back-track
instead of returning GSL_EBADFUNC it should do what you want.

Note that you can write a polyalgorithm which uses a second solver
(e.g. mygnewton) like this,

do {
  status = gsl_multiroot_fdfsolver_iterate (s1);
  if (status == GSL_EBADFUNC) {
     /* Try alternate solver s2 on failed step */
     gsl_multiroot_fdfsolver_set (s2, fdf, s1->x);
     status = gsl_multiroot_fdfsolver_iterate (s2);
     gsl_multiroot_fdfsolver_set (s1, fdf, s2->x);
  }
  ....
}

regards
Brian Gough


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]