public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* Area constraint in 2-d roots?
@ 2002-07-18 12:54 Peter S. Christopher
  2002-07-21  6:50 ` Brian Gough
  0 siblings, 1 reply; 2+ messages in thread
From: Peter S. Christopher @ 2002-07-18 12:54 UTC (permalink / raw)
  To: gsl-discuss

Hi there,
	I'm inquiring about the gsl_multiroot_fsolver_iterate function.
Specifically I'm interested in constraining the allowable solutions that
the algorithm searches to a small area.

I'm using the gsl_multiroot_fsolver_hybrids algorithm. I am passing a
function that looks something like this

int zeroBmu(const gsl_vector *x, void *params, gsl_vector * f){
	...
	...
  m0 = gsl_vector_get(x,0);
  mA = gsl_vector_get(x,1);
	...
	...	
  return GSL_SUCCESS;
}


My problem is that I need to bracket m0 and mA; specifically these
parameters must be > 0.0 and < 1.0. The solution I'm using is something
like 

int zeroBmu(const gsl_vector *x, void *params, gsl_vector * f){
        ...
        ...
  /*be sure that x0,x1 are both > 0.0*/
  gsl_vector_set((gsl_vector *)x, 0, fabs(gsl_vector_get(x,0)));
  gsl_vector_set((gsl_vector *)x, 1, fabs(gsl_vector_get(x,1)));

  m0 = gsl_vector_get(x,0);
  mA = gsl_vector_get(x,1);
  if( m0 >= 1.0)
    {
	/*do something that forces m0 to be smaller then 1.0. */
        gsl_vector_set((gsl_vector *)x,0,m0);
    }
  if(mA >= 1.0)
    {
	/*ext.*/
    }
        ...
        ...
	...
  return GSL_SUCCESS;
} 

MY 2 QUESTIONS:
	1) Will this provide the appropriate constraint.
	2) Is there a more "elegant" way to do this. Maybe one that is
built into the solvers. Maybe something that doesn't force me to break the
"const gsl_vector *" of x with a cast.


Thanks for any help,

Pete Christopher

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Area constraint in 2-d roots?
  2002-07-18 12:54 Area constraint in 2-d roots? Peter S. Christopher
@ 2002-07-21  6:50 ` Brian Gough
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Gough @ 2002-07-21  6:50 UTC (permalink / raw)
  To: Peter S. Christopher; +Cc: gsl-discuss

Peter S. Christopher writes:
 > Hi there,
 > 	I'm inquiring about the gsl_multiroot_fsolver_iterate function.
 > Specifically I'm interested in constraining the allowable solutions that
 > the algorithm searches to a small area.

GSL doesn't have any routines for constrained minimization.

You can use a penalty function to safely discourage the minimizer from
going outside the desired region.  Modification of const arguments is
definitely not recommended.

regards
Brian Gough

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-21 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-18 12:54 Area constraint in 2-d roots? Peter S. Christopher
2002-07-21  6:50 ` Brian Gough

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).