This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
simulated annealing
- From: Francisco J Molina <FJMolina at lbl dot gov>
- To: "gsl-discuss at sources dot redhat dot com" <gsl-discuss at sources dot redhat dot com>
- Date: Fri, 14 Jun 2002 18:51:00 -0700
- Subject: simulated annealing
- Organization: Lawrence Berkeley National Laboratory
I am trying to use the Simulated Annealing function under C++ and I am
trying to avoid the use of the functions of C that allocate/deallocate
dynamic memory ( malloc,...).
My configuration could be described with a pair of vectors ( one int
and the other one float ) and an integer number.
The problem is that the size of these vectors is not known at compiling
time but at
running time, so that, I can not declare my configuration as an
structure.
I thought of passing
lengthRealVector * sizeof( float ) + lengthIntVector * sizeof( int ) +
sizeof( int )
as
element_size
to
gsl_siman_solv
and then using the following declarations within the functions energy
and
take-step:
static int* pInteger;
static double* realVector;
static int* intVector;
pInteger = ( int* ) pOinter;
realVector = ( double* )( pInteger + 1 );
intVector = ( int* )( realVector + lengthRealVector );
where pOinter is the void pointer to the configuration ( argument ).
With this fixed-size approach, the problem was to create the initial
configuration.
Do you know if there is any way to solve this problem( trying to make
gsl_siman_solv work in the fixed-size mode, when the size of the
configuration is part of the input and the configuration is described
by several elements of different data types )
Second question:
In the non-fixed-approach, can I use new and delete in the functions
to clone, create and delete configurations?
Thank you for reading this long email