[Top][All Lists]

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

Re: [Help-gsl] constrained fdf multimin

From: Tim Fenn
Subject: Re: [Help-gsl] constrained fdf multimin
Date: Mon, 22 Jan 2007 03:08:34 -0800
User-agent: Mutt/1.5.12-2006-07-14

On Sat, Jan 20, 2007 at 02:25:22PM -0800, Tim Fenn wrote:
> On Sat, Jan 20, 2007 at 11:17:02AM +0000, Brian Gough wrote:
> > At Wed, 17 Jan 2007 12:14:15 -0800,
> > Tim Fenn wrote:
> > > I know the idea of constrained multimin refinement has come up on
> > > several occasions, and I recently made some changes to the multimin
> > > code to allow for very simple bound constraints (primarily for some of
> > > my own problems, but I thought the code could be useful).  I've
> > > attached the patches, but I'm curious to hear if the
> > > style/format/method I've incorporated seems reasonable. 
> > 
> > This certainly does the job.  It might be possible to get close to
> > that within the existing API, by having the user-defined function
> > return +Inf for points outside the constraints.  The minimiser could
> > be modified to use that as a signal to backtrack.  This would allow
> > arbitrary constraints, but loses the advantage of knowing exactly
> > where the edge of the allowed region is.
> > 
> It won't take long to incorporate a user-callback - I'll see what I
> can do over the next day or two.  I hadn't given much thought to the
> backtracking idea, but that wouldn't be terribly difficult as a next
> step.

I've attached the latest iteration.  The current API is maintained, so
any existing code will continue to work.  To implement a callback, one
can simply do something to the effect of:

<begin code>
  gsl_multimin_function_fdf my_func;

  my_func.f = &my_f;
  my_func.df = &my_df;
  my_func.fdf = &my_fdf; = &my_cf;
  my_func.n = 2;
  my_func.params = &par;
<end code>

the key being the "" bit.  this is the callback function the
user wishes to bring about at each step iteration (I've currently only
added the GSL_MULTIMIN_FN_EVAL_CF to the various fdf routines, I'd
appreciate some help on the simplex routine - i'd rather not put the
calls in places where they shouldn't be).  In any event, the only
addition to the API are the minimizer setups:

gsl_multimin_cf_fminimizer_set (gsl_multimin_fminimizer * s,
                                gsl_multimin_function * f,
                                const gsl_vector * x,
                                const gsl_vector * step_size);

gsl_multimin_cf_fdfminimizer_set (gsl_multimin_fdfminimizer * s,
                                  gsl_multimin_function_fdf *fdf,
                                  const gsl_vector * x,
                                  double step_size, double tol);

which are identical to their non-"_cf_" containing counterparts, with
the exception that the "void (*cf)" function should exist, or else Bad
Things will happen.

Here's the rest of the above example, for clarity:

<begin code>
  gsl_multimin_cf_fdfminimizer_set (s, &my_func, x, 0.01, 1e-4);


my_cf (const gsl_vector *xi, void *params)
  size_t i;
  gsl_vector *lb = ((struct cf_data *) params)->lb;
  gsl_vector *ub = ((struct cf_data *) params)->ub;

  double *l = lb->data;
  double *u = ub->data;
  double *x = xi->data;

  for (i=0; i<xi->size; i++)
      *x = GSL_MAX(*l, GSL_MIN(*x, *u));
<end code>

which would constrain the parameters to the lower and upper bounds
contained in lb and ub, respectively.  Of course, this leaves the
callback to the users imagination: constraints of any kind can be
applied.  This of course requires some handiwork, but at least the
power is available to the user.

I'll think some more about backtracking, but any ideas/comments are
more than welcome.

Hope it helps.



        Tim Fenn
        Stanford University, School of Medicine
        James H. Clark Center
        318 Campus Drive, Room E300
        Stanford, CA  94305-5432
        Phone:  (650) 736-1714
        FAX:  (650) 736-1961


Attachment: multimin_bound.patch.gz
Description: Binary data

reply via email to

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