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]

simulated annealing


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


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