algorithm - GNU Simulated Annealing -
i'm working template program given here:
https://www.gnu.org/software/gsl/manual/html_node/trivial-example.html
the program give compiles , runs perfectly, nice. generalise method find minimum of function arbitrary number of parameters.
some cursory reading suggests metric function (m1) used in diagnostic , printing situations , can more or less ignored. remains define e1 , s1 appropriately. unfortunately knowledge of using pointers , void incomplete, i'm stuck trying upgrade configuration 'xp' array of parameters, rather single double.
in naivete tried moving
double x = *((double *) xp);
to
double x = (*((double *) xp))[0];
where appropriate, didn't work. i'm sure i'm missing stupid, hints nice! defining own e1 output function take these n parameters , return number.
the underlying algorithm, gsl_siman_solve()
link provided, generalized work data type. why ubiquitous xp
parameter being cast double pointer before use. should straightforward use struct or array or array of arrays instead of doubles provided callbacks coded properly.
the problem gsl_siman_solve()
seems support scalar double step size, initial guess, , 'uniform' value (from gsl_rng_uniform()
), need map scalar double values naturally multidimensional quantities. can done, messy , not flexible. in case, mapping done in s1()
.
this akin mapping digits of decimal number multidimensional space: ones digit represents x axis, tens digit represents y axis, , hundreds digit represents z axis, example. incrementing integer, 1 can walk entire 3d space (0, 0, 0) (9, 9, 9). don't have use integers , powers of 10, , components don't have have same range, there inherent limit in range of each component of packed value. in reverse: taking scalar double , unpacking multiple quantities.
lastly, code double x = (*((double *) xp))[0];
won't work because attempting dereference double array, not pointer double, ok. in other words, it's first *
problem.
Comments
Post a Comment