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]
Other format: [Raw text]

A specific problem - efficiency question


Dear all,

I have a question on efficiency and I hope someone can suggest a sound
approach.

I have a 40-dimensional function F (40 independent parameters) for which I
need to determine the values of these parameters by solving the inverse
problem - I have the measurements and by adjusting parameters I want to
minimize chi2. For this I am using the downhill simplex method.

Say we have a global struct that holds all 40 parameters + some 10
switches that control the calculation logic:

	typedef struct all_pars
	  {
	  double par1;
	  double par2;
	  ...
	  double par40;
	  int switch1;
	  int switch2;
	  ...
	  int switch10;
	  } all_pars;

Next to this global struct there is a global lookup table with parameter
name, its value, adjustability switch and step size:

	typedef struct adjustable_tag
	  {
	  char *name;
	  double value;
	  int switch;
	  double step_size;
	  } adjustable_tag;

	adjustable_tag *adjustables;

Finally, there is a function to calculate the value of F:

	double F (all_pars pars);

This is where GSL comes to play. I want to minimize the chi2 (F -
observations) by adjusting only *some* parameters that are marked to be
adjusted in adjustables table. GSL minimizer takes the gsl_vector of
parameters to be adjusted and the (void *) cast to other constant
parameters. My idea is to pass the address of 'pars' variable to (void *)
variable and to build gsl_vector with to-be-adjusted parameters. However,
within the cost function, F has to be evaluated as quickly as possible and
I cannot lookup the table each time on what parameters to take from pars
and what from the passed gsl_vector. I guess it would be useful to have a
tied pointer to the gsl_vector values and always call F only with 'pars'.
But this means building an alternate (local) all_pars struct each time the
cost function is evaluated, so this isn't efficient.

I hope I wasn't completely cryptic in my question and that someone may
propose a better solution!

Thank you very much in advance! Sincerely,

Andrej


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