libfgen  0.1.15
Library for optimization using a genetic algorithm or particle swarm optimization
fgen.h
00001 /*
00002     fgen.h -- main API header file.
00003 
00004     fgen -- Library for optimization using a genetic algorithm or particle swarm optimization.
00005     Copyright 2012, Harm Hanemaaijer
00006 
00007     This file is part of fgen.
00008 
00009     fgen is free software: you can redistribute it and/or modify it
00010     under the terms of the GNU Lesser General Public License as published
00011     by the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     fgen is distributed in the hope that it will be useful, but WITHOUT
00015     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00017     License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public
00020     License along with fgen.  If not, see <http://www.gnu.org/licenses/>.
00021 
00022 */
00023 
00024 
00025 /*
00026  * User API for the libfgen library.
00027  */
00028 
00029 #ifndef __FGEN_H__
00030 #define __FGEN_H__
00031 
00032 #undef __BEGIN_DECLS
00033 #undef __END_DECLS
00034 #ifdef __cplusplus
00035 #define __BEGIN_DECLS extern "C" {
00036 #define __END_DECLS }
00037 #else
00038 #define __BEGIN_DECLS /* empty */
00039 #define __END_DECLS /* empty */
00040 #endif
00041 
00042 // Generic helper definitions for shared library support
00043 #if defined _WIN32 || defined __CYGWIN__
00044   #define FGEN_HELPER_DLL_IMPORT __declspec(dllimport)
00045   #define FGEN_HELPER_DLL_EXPORT __declspec(dllexport)
00046   #define FGEN_HELPER_DLL_LOCAL
00047 #else
00048   #if __GNUC__ >= 4
00049     #define FGEN_HELPER_DLL_IMPORT __attribute__ ((visibility ("default")))
00050     #define FGEN_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
00051     #define FGEN_HELPER_DLL_LOCAL  __attribute__ ((visibility ("hidden")))
00052   #else
00053     #define FGEN_HELPER_DLL_IMPORT
00054     #define FGEN_HELPER_DLL_EXPORT
00055     #define FGEN_HELPER_DLL_LOCAL
00056   #endif
00057 #endif
00058 
00059 // Now we use the generic helper definitions above to define FGEN_API and FGEN_LOCAL.
00060 // FGEN_API is used for the public API symbols. It either DLL imports or DLL exports (or does nothing
00061 // for static build). FGEN_LOCAL is used for non-api symbols.
00062 
00063 #ifdef FGEN_DLL // defined if FGEN is compiled as a DLL
00064   #ifdef FGEN_DLL_EXPORTS // defined if we are building the GA DLL (instead of using it)
00065     #define FGEN_API FGEN_HELPER_DLL_EXPORT
00066   #else
00067     #define FGEN_API FGEN_HELPER_DLL_IMPORT
00068   #endif // FGEN_DLL_EXPORTS
00069   #define FGEN_LOCAL FGEN_HELPER_DLL_LOCAL
00070 #else // FGEN_DLL is not defined: this means FGEN is a static lib.
00071   #define FGEN_API
00072   #define FGEN_LOCAL
00073 #endif // FGEN_DLL
00074 
00075 __BEGIN_DECLS
00076 
00077 /*
00078  * fgen functionality.
00079  */
00080 
00085 typedef struct FGEN_API {
00086         unsigned char *bitstring;
00087         double fitness;
00088         int refcount;
00089         /* Flags: */
00090         unsigned char fitness_is_valid;
00091         unsigned char obsolete;
00092         unsigned char is_elite;
00093         unsigned char unused;
00094 } FgenIndividual;
00095 
00096 typedef struct FgenPopulation_t FgenPopulation;
00097 
00098 typedef struct FGEN_API {
00099         unsigned char *bitstring;
00100         double fitness;
00101         int date_mru;
00102 } FgenCacheEntry;
00103 
00104 typedef struct FGEN_API {
00105         int size;
00106         int nu_accesses;
00107         int nu_hits;
00108         double hit_rate;
00109         FgenCacheEntry **entry;
00110         int refcount;
00111 } FgenCache;
00112 
00113 #define FGEN_RNG_STATE_SIZE 4096
00114 
00115 typedef struct FGEN_API {
00116         unsigned int Q[FGEN_RNG_STATE_SIZE];
00117         unsigned int c;
00118         int index;
00119         unsigned int storage;
00120         int storage_size;
00121         int last_random_n_power_of_2;
00122         int last_random_n_power_of_2_bit_count;
00123 } FgenRNG;
00124 
00126 typedef void (*FgenGenerationCallbackFunc)(FgenPopulation *pop, int generation);
00129 typedef double (*FgenCalculateFitnessFunc)(const FgenPopulation *pop, const unsigned char *bitstring);
00131 typedef void (*FgenSeedFunc)(FgenPopulation *pop, unsigned char *bitstring);
00134 typedef void (*FgenMutationFunc)(FgenPopulation *pop, const unsigned char *parent,
00135 unsigned char *child);
00138 typedef void (*FgenCrossoverFunc)(FgenPopulation *pop, const unsigned char *parent1,
00139 const unsigned char *parent2, unsigned char *child1, unsigned char *child2);
00140 
00141 struct FgenPopulation_t {
00142 /* Core parameters. */
00143         int size;                       
00144         int individual_size_in_bits;    
00145         int data_element_size;          
00146         int generation;                 
00147         FgenIndividual **ind;           
00148         int island;                     
00149 /* Evolution parameters. */
00150         int selection_type;             
00151         int tournament_size;            
00152         int nu_elites;                  
00153         int selection_fitness_type;     
00154         float crossover_probability_float;      
00155         int crossover_probability;
00156         float mutation_probability_float;       
00157         int mutation_probability;
00158         float macro_mutation_probability_float; 
00159         int macro_mutation_probability;
00160         float migration_probability_float;      
00161         int migration_probability;
00162         int migration_interval;                 
00163         int permutation_size;                   
00164         int generation_callback_interval;       
00165 /* Miscellaneous. */
00166         int stop_signalled;                     
00167         int cache_is_shared;                    
00168         int max_threads;                        
00169         FgenCache *cache;                       
00170         FgenRNG *rng;                           
00171         void *user_data;                        
00172 /* Callback functions. */
00173         FgenGenerationCallbackFunc fgen_generation_callback_func;       
00174         FgenCalculateFitnessFunc fgen_calculate_fitness_func;           
00175         FgenSeedFunc fgen_seed_func;            
00176         FgenMutationFunc fgen_mutation_func;    
00177         FgenCrossoverFunc fgen_crossover_func;  
00178         float *fast_mutation_cumulative_chance; 
00179         int fast_mutation_nu_bits_to_mutate;    
00180         int initialization_type;                
00181         float fast_mutation_probability;        
00182 };
00183 
00184 /* Fitness selection types. */
00185 #define FGEN_FITNESS_PROPORTIONAL               1
00186 #define FGEN_SUBTRACT_MIN_FITNESS               2
00187 #define FGEN_SUBTRACT_MIN_FITNESS_DIV_2 3
00188 
00189 /* Selection types. */
00190 #define FGEN_STOCHASTIC_TYPE_MASK       3
00191 #define FGEN_ELITIST_ELEMENT            4
00192 #define FGEN_EXTINCTION_ELEMENT         8
00193 #define FGEN_STOCHASTIC                 0
00194 #define FGEN_SUS                        1
00195 #define FGEN_TOURNAMENT                 2
00196 #define FGEN_RANK                       3
00197 #define FGEN_KILL_TOURNAMENT_ELEMENT    16
00198 #define FGEN_ELITIST_STOCHASTIC                 (FGEN_STOCHASTIC | FGEN_ELITIST_ELEMENT)
00199 #define FGEN_ELITIST_SUS                        (FGEN_SUS | FGEN_ELITIST_ELEMENT)
00200 #define FGEN_ELITIST_SUS_WITH_EXTINCTION        (FGEN_SUS | FGEN_ELITIST_ELEMENT | FGEN_EXTINCTION_ELEMENT)             
00201 #define FGEN_ELITIST_TOURNAMENT                 (FGEN_TOURNAMENT | FGEN_ELITIST_ELEMENT)
00202 #define FGEN_ELITIST_TOURNAMENT_WITH_EXTINCTION (FGEN_TOURNAMENT | FGEN_ELITIST_ELEMENT | FGEN_EXTINCTION_ELEMENT)
00203 #define FGEN_ELITIST_RANK                       (FGEN_RANK | FGEN_ELITIST_ELEMENT)
00204 #define FGEN_KILL_TOURNAMENT                    (FGEN_TOURNAMENT | FGEN_KILL_TOURNAMENT_ELEMENT)
00205 
00206 /* Initialization types. */
00207 
00208 #define FGEN_INITIALIZATION_SEED        0
00209 #define FGEN_INITIALIZATION_CONTINUE    1
00210 
00211 /* Main interface. */
00212 
00213 FGEN_API FgenPopulation *fgen_create(
00214         int population_size,
00215         int individual_size_in_bits,
00216         int data_element_size,
00217         FgenGenerationCallbackFunc fgen_generation_callback_func,
00218         FgenCalculateFitnessFunc fgen_calculate_fitness_func,
00219         FgenSeedFunc fgen_seed_func,
00220         FgenMutationFunc fgen_mutation_func,
00221         FgenCrossoverFunc fgen_crossover_func
00222         );
00223 FGEN_API void fgen_initialize(
00224         FgenPopulation *pop,
00225         int population_size,
00226         int individual_size_in_bits,
00227         int data_element_size,
00228         FgenGenerationCallbackFunc fgen_generation_callback_func,
00229         FgenCalculateFitnessFunc fgen_calculate_fitness_func,
00230         FgenSeedFunc fgen_seed_func,
00231         FgenMutationFunc fgen_mutation_func,
00232         FgenCrossoverFunc fgen_crossover_func
00233         );
00234 FGEN_API void fgen_set_parameters(
00235         FgenPopulation *pop,
00236         int selection_type,
00237         int selection_fitness_type,
00238         float crossover_probability_float,
00239         float mutation_per_bit_probability_float,
00240         float macro_mutation_probability_float
00241         );
00242 FGEN_API void fgen_run(FgenPopulation *pop, int max_generation);
00243 FGEN_API void fgen_run_threaded(FgenPopulation *pop, int max_generation);
00244 FGEN_API void fgen_destroy(FgenPopulation *pop);
00245 FGEN_API void fgen_run_archipelago(int nu_pops, FgenPopulation **pops, int max_generation);
00246 FGEN_API void fgen_run_archipelago_threaded(int nu_pops, FgenPopulation **pops, int max_generation);
00247 FGEN_API void fgen_run_steady_state(FgenPopulation *pop, int max_generation);
00248 FGEN_API void fgen_run_steady_state_archipelago(int nu_pops, FgenPopulation **pops, int max_generation);
00249 FGEN_API void fgen_run_steady_state_archipelago_threaded(int nu_pops, FgenPopulation **pops, int max_generation);
00250 
00251 /* Parameter interface.  */
00252 
00253 FGEN_API void fgen_set_mutation_probability(FgenPopulation *pop, float);
00254 FGEN_API void fgen_set_macro_mutation_probability(FgenPopulation *pop, float);
00255 FGEN_API void fgen_set_crossover_probability(FgenPopulation *pop, float);
00256 FGEN_API void fgen_set_selection_fitness_type(FgenPopulation *pop, int);
00257 FGEN_API void fgen_set_selection_type(FgenPopulation *pop, int);
00258 FGEN_API void fgen_set_tournament_size(FgenPopulation *pop, int);
00259 FGEN_API void fgen_set_data_element_size(FgenPopulation *pop, int);
00260 FGEN_API void fgen_set_number_of_elites(FgenPopulation *pop, int);
00261 FGEN_API void fgen_set_permutation_size(FgenPopulation *pop, int);
00262 FGEN_API void fgen_set_user_data(FgenPopulation *pop, void *user_data);
00263 FGEN_API void fgen_enable_cache(FgenPopulation *pop, int cache_size);
00264 FGEN_API void fgen_enable_cache_on_archipelago(int nu_pops, FgenPopulation **pops, int cache_size);
00265 FGEN_API void fgen_invalidate_cache(FgenPopulation *pop);
00266 FGEN_API void fgen_set_migration_probability(FgenPopulation *pop, float);
00267 FGEN_API void fgen_set_migration_interval(FgenPopulation *pop, int);
00268 FGEN_API void fgen_set_generation_callback_interval(FgenPopulation *pop, int);
00269 FGEN_API void fgen_set_initialization_type(FgenPopulation *pop, int);
00270 
00271 /* Default operator functions. */
00272 
00273 FGEN_API void fgen_seed_random(FgenPopulation *pop, unsigned char *bitstring);
00274 FGEN_API void fgen_mutation_per_bit(FgenPopulation *pop, const unsigned char *parent, unsigned char *child);
00275 FGEN_API void fgen_mutation_per_bit_plus_macro_mutation(FgenPopulation *pop, const unsigned char *parent,
00276 unsigned char *child);
00277 FGEN_API void fgen_mutation_per_bit_fast(FgenPopulation *pop, const unsigned char *parent, unsigned char *child);
00278 FGEN_API void fgen_mutation_per_bit_plus_macro_mutation_fast(FgenPopulation *pop, const unsigned char *parent,
00279 unsigned char *child);
00280 FGEN_API void fgen_crossover_one_point_per_bit(FgenPopulation *pop, const unsigned char *parent1,
00281 const unsigned char *parent2, unsigned char *child1, unsigned char *child2);
00282 FGEN_API void fgen_crossover_one_point_per_element(FgenPopulation *pop, const unsigned char *parent1,
00283 const unsigned char *parent2, unsigned char *child1, unsigned char *child2);
00284 FGEN_API void fgen_crossover_two_point_per_bit(FgenPopulation *pop, const unsigned char *parent1,
00285 const unsigned char *parent2, unsigned char *child1, unsigned char *child2);
00286 FGEN_API void fgen_crossover_two_point_per_element(FgenPopulation *pop, const unsigned char *parent1,
00287 const unsigned char *parent2,unsigned char *child1, unsigned char *child2);
00288 FGEN_API void fgen_crossover_uniform_per_bit(FgenPopulation *pop, const unsigned char *parent1,
00289 const unsigned char *parent2, unsigned char *child1, unsigned char *child2);
00290 FGEN_API void fgen_crossover_uniform_per_element(FgenPopulation *pop, const unsigned char *parent1,
00291 const unsigned char *parent2, unsigned char *child1, unsigned char *child2);
00292 FGEN_API void fgen_seed_permutation_random(FgenPopulation *pop, unsigned char *bitstring);
00293 FGEN_API void fgen_mutation_permutation_swap(FgenPopulation *pop, const unsigned char *parent,
00294 unsigned char *child);
00295 FGEN_API void fgen_mutation_permutation_insert(FgenPopulation *pop, const unsigned char *parent,
00296 unsigned char *child);
00297 FGEN_API void fgen_mutation_permutation_invert(FgenPopulation *pop, const unsigned char *parent,
00298 unsigned char *child);
00299 FGEN_API void fgen_crossover_permutation_order_based(FgenPopulation *pop, const unsigned char *parent1,
00300 const unsigned char *parent2, unsigned char *child1, unsigned char *child2);
00301 FGEN_API void fgen_crossover_permutation_position_based(FgenPopulation *pop, const unsigned char *parent1,
00302 const unsigned char *parent2, unsigned char *child1, unsigned char *child2);
00303 FGEN_API void fgen_crossover_noop(FgenPopulation *pop, const unsigned char *parent1,
00304 const unsigned char *parent2, unsigned char *child1, unsigned char *child2);
00305 
00306 /* Helper functions to be called from the GenerationCallbackFunc. */
00307 
00308 FGEN_API FgenIndividual *fgen_best_individual_of_population(FgenPopulation *pop);
00309 FGEN_API FgenIndividual *fgen_worst_individual_of_population(FgenPopulation *pop);
00310 FGEN_API FgenIndividual *fgen_best_individual_of_archipelago(int nu_pops, FgenPopulation **pops);
00311 FGEN_API void fgen_update_population_fitness(FgenPopulation *pop);
00312 FGEN_API void fgen_invalidate_population_fitness(FgenPopulation *pop);
00313 FGEN_API void fgen_signal_stop(FgenPopulation *pop);
00314 FGEN_API int fgen_individual_size_in_bytes(const FgenPopulation *pop);
00315 FGEN_API int fgen_get_island(const FgenPopulation *pop);
00316 FGEN_API int fgen_is_cached(const FgenPopulation *pop);
00317 FGEN_API double fgen_get_cache_hit_rate(const FgenPopulation *pop);
00318 FGEN_API FgenRNG *fgen_get_rng(const FgenPopulation *pop);
00319 FGEN_API int fgen_get_generation(const FgenPopulation *pop);
00320 
00321 /* Bitstring decoding helper functions. */
00322 
00323 FGEN_API double fgen_bitstring_uint16_to_double(const unsigned char *bitstring, double domain_min,
00324 double domain_max);
00325 FGEN_API double fgen_bitstring_uint32_to_double(const unsigned char *bitstring, double domain_min,
00326 double domain_max);
00327 FGEN_API double fgen_bitstring_uint64_to_double(const unsigned char *bitstring, double domain_min,
00328 double domain_max);
00329 FGEN_API void fgen_decode_from_gray(const FgenPopulation *pop, const unsigned char *src_bitstring, unsigned char *dest_bitstring);
00330 FGEN_API void fgen_encode_to_gray(const FgenPopulation *pop, const unsigned char *src_bitstring, unsigned char *dest_bitstring);
00331 
00332 /* Bitstring helper functions. */
00333 
00334 FGEN_API void fgen_mutate_bit(unsigned char *bitstring, int n);
00335 FGEN_API void fgen_set_random_bitstring(FgenRNG *rng, unsigned char *bitstring, int offset, int nu_bits);
00336 FGEN_API int fgen_get_bit(const unsigned char *bitstring, int n);
00337 FGEN_API void fgen_copy_partial_bitstring(const unsigned char *src_bitstring, unsigned char *dest_bitstring, int offset,
00338 int nu_bits);
00339 
00340 /* Random number functions. */
00341 
00342 FGEN_API FgenRNG *fgen_random_create_rng();
00343 FGEN_API void fgen_random_destroy_rng(FgenRNG *rng);
00344 FGEN_API void fgen_random_seed_rng(FgenRNG *rng, unsigned int seed);
00345 FGEN_API void fgen_random_seed_with_timer(FgenRNG *rng);
00346 FGEN_API int fgen_random_2(FgenRNG *rng);
00347 FGEN_API int fgen_random_8(FgenRNG *rng);
00348 FGEN_API int fgen_random_16(FgenRNG *rng);
00349 FGEN_API unsigned int fgen_random_32(FgenRNG *rng);
00350 FGEN_API int fgen_random_n(FgenRNG *rng, int n);
00351 FGEN_API float fgen_random_f(FgenRNG *rng, float range);
00352 FGEN_API double fgen_random_d(FgenRNG *rng, double range);
00353 FGEN_API double fgen_random_from_range_d(FgenRNG *rng, double min_bound, double max_bound);
00354 
00357 /* 
00358  * fpso functionality.
00359  */
00360 
00365 typedef struct FGEN_API {
00366         double *position;
00367         double *velocity;
00368         double *best_known_position;
00369         double best_known_error; 
00370 } FpsoIndividual;
00371 
00372 typedef struct FpsoPopulation_t FpsoPopulation;
00373 typedef void (*FpsoGenerationCallbackFunc)(FpsoPopulation *pop, int generation);
00374 typedef double (*FpsoCalculateErrorFunc)(const FpsoPopulation *pop, const double *parameters);
00375 
00376 struct FpsoPopulation_t {
00377         int size;
00378         int nu_params;
00379         FpsoIndividual *ind;
00380         double omega;
00381         double phi1;
00382         double phi2;
00383         int topology;
00384         int bounding_strategy;
00385         double *lower_bound;
00386         double *upper_bound;
00387         double *best_known_position;
00388         double best_known_error;
00389         int stop_signalled;
00390         FgenRNG *rng;
00391         void *user_data;
00392         FpsoGenerationCallbackFunc fpso_generation_callback_func;
00393         FpsoCalculateErrorFunc fpso_calculate_error_func;
00394 };
00395 
00396 #define FPSO_DEFAULT_OMEGA 0.7298
00397 #define FPSO_DEFAULT_PHI1 1.49618
00398 #define FPSO_DEFAULT_PHI2 1.49618
00399 
00400 #define FPSO_TOPOLOGY_GBEST 0
00401 #define FPSO_TOPOLOGY_LBEST 1
00402 
00403 #define FPSO_BOUND_VELOCITY_ELEMENT 1 
00404 #define FPSO_BOUND_POSITION_ELEMENT 2 
00405 #define FPSO_BOUND_NOTHING 0
00406 #define FPSO_BOUND_VELOCITY 1
00407 #define FPSO_BOUND_POSITION 2
00408 #define FPSO_BOUND_POSITION_AND_VELOCITY 3
00409 
00410 FGEN_API FpsoPopulation *fpso_create(
00411         int population_size,
00412         int nu_parameters,
00413         FpsoGenerationCallbackFunc fpso_generation_callback_func,
00414         FpsoCalculateErrorFunc fpso_calculate_error_func
00415         );
00416 FGEN_API void fpso_set_parameters(
00417         FpsoPopulation *pop,
00418         int topology,
00419         int bounding_strategy,
00420         double omega,
00421         double phi1,
00422         double phi2
00423         );
00424 FGEN_API void fpso_run(FpsoPopulation *pop, int max_generation);
00425 FGEN_API void fpso_destroy(FpsoPopulation *pop);
00426 FGEN_API void fpso_signal_stop(FpsoPopulation *pop);
00427 
00428 /* Parameter interface. */
00429 
00430 FGEN_API void fpso_set_parameter_bounds(FpsoPopulation *pso, int parameter_index, double min_bound, double max_bound);
00431 FGEN_API void fpso_set_topology(FpsoPopulation *pso, int type);
00432 FGEN_API void fpso_set_bounding_strategy(FpsoPopulation *pso, int type);
00433 FGEN_API void fpso_set_user_data(FpsoPopulation *pop, void *user_data);
00434 
00435 /* Miscelaneous. */
00436 
00437 FGEN_API void fpso_bound_position(const FpsoPopulation *pop, const double *source, double *dest);
00438 FGEN_API double *fpso_get_best_known_position(const FpsoPopulation *pop);
00439 FGEN_API double fpso_get_best_known_error(const FpsoPopulation *pop);
00440 FGEN_API FgenRNG *fpso_get_rng(const FpsoPopulation *pop);
00441 
00444 /*
00445  * Ffit functionality.
00446  */
00447 
00452 typedef struct Ffit_t Ffit;
00453 
00456 typedef double (*FfitCalculateErrorFunc)(const Ffit *fit, const double *param);
00460 typedef void (*FfitGenerationCallbackFunc)(Ffit * fit, int generation, const double *best_param, double best_error);
00461 
00464 struct Ffit_t {
00465         int nu_params;          
00466         int nu_bits_per_param;  
00467         double *range_min;      
00468         double *range_max;      
00469         int *mapping;           
00470         int population_size;    
00471         int optimization_type;  
00472         int stop_signalled;     
00473         int model_change_signalled;     
00474         int nu_islands;                 
00475         double *best_island_params;     
00476         double best_island_error;       
00477         int threading_level;    
00478         int generation_callback_interval;       
00479         void *population;       
00480         FfitGenerationCallbackFunc ffit_generation_callback_func; 
00481         FfitCalculateErrorFunc ffit_calculate_error_func;         
00482 };
00483 
00484 #define FFIT_MAPPING_LINEAR             0
00485 #define FFIT_MAPPING_SQUARE             1
00486 #define FFIT_MAPPING_CUBE               2
00487 #define FFIT_MAPPING_LOG                3
00488 #define FFIT_MAPPING_BINOMIAL_1_TO_5    4
00489 #define FFIT_MAPPING_BINOMIAL_1_TO_7    5
00490 
00491 #define FFIT_OPTIMIZATION_FGEN_ELEMENT          1
00492 #define FFIT_OPTIMIZATION_ARCHIPELAGO_ELEMENT   2
00493 #define FFIT_OPTIMIZATION_HILL_CLIMB_ELEMENT    4
00494 #define FFIT_OPTIMIZATION_FPSO_ELEMENT          8
00495 #define FFIT_OPTIMIZATION_FGEN_REAL_VALUED_ELEMENT 16
00496 #define FFIT_OPTIMIZATION_FGEN                  FFIT_OPTIMIZATION_FGEN_ELEMENT
00497 #define FFIT_OPTIMIZATION_FGEN_ARCHIPELAGO      (FFIT_OPTIMIZATION_FGEN_ELEMENT | FFIT_OPTIMIZATION_ARCHIPELAGO_ELEMENT)
00498 #define FFIT_OPTIMIZATION_FGEN_WITH_HILL_CLIMB  (FFIT_OPTIMIZATION_FGEN_ELEMENT | FFIT_OPTIMIZATION_HILL_CLIMB_ELEMENT)
00499 #define FFIT_OPTIMIZATION_FGEN_ARCHIPELAGO_WITH_HILL_CLIMB      (FFIT_OPTIMIZATION_FGEN_ELEMENT | \
00500     FFIT_OPTIMIZATION_ARCHIPELAGO_ELEMENT | FFIT_OPTIMIZATION_HILL_CLIMB_ELEMENT)
00501 #define FFIT_OPTIMIZATION_FPSO                  FFIT_OPTIMIZATION_FPSO_ELEMENT
00502 #define FFIT_OPTIMIZATION_FGEN_REAL_VALUED      (FFIT_OPTIMIZATION_FGEN_ELEMENT | \
00503     FFIT_OPTIMIZATION_FGEN_REAL_VALUED_ELEMENT)
00504 #define FFIT_OPTIMIZATION_FGEN_REAL_VALUED_ARCHIPELAGO (FFIT_OPTIMIZATION_FGEN_ELEMENT | \
00505 FFIT_OPTIMIZATION_FGEN_REAL_VALUED_ELEMENT | FFIT_OPTIMIZATION_ARCHIPELAGO_ELEMENT)
00506 
00507 #define FFIT_THREADING_DISABLED 0
00508 #define FFIT_THREADING_ENABLED  1
00509 
00510 FGEN_API Ffit *ffit_create(
00511         int nu_params,
00512         FfitGenerationCallbackFunc ffit_generation_callback_func,
00513         FfitCalculateErrorFunc ffit_calculate_error_func
00514         );
00515 FGEN_API void ffit_set_parameter_range_and_mapping(Ffit *fit, int index, double range_min, double range_max, int mapping);
00516 
00517 FGEN_API void ffit_run_fgen_with_defaults(Ffit *fit);
00518 FGEN_API void ffit_run_fgen(Ffit *fit, int population_size, int nu_bits_per_param,
00519 int selection_type, FgenCrossoverFunc crossover, float crossover_probability_float,
00520 float mutation_per_bit_probability_float, float macro_mutation_probability_float);
00521 FGEN_API void ffit_run_fgen_archipelago(Ffit *fit, int nu_islands, int population_size,
00522 int nu_bits_per_param, int selection_type, FgenCrossoverFunc crossover,
00523 float crossover_probability_float, float mutation_probability_float,
00524 float macro_mutation_probability_float, float migration_probability_float,
00525 int migration_interval);
00526 FGEN_API void ffit_run_fgen_real_valued(Ffit *fit, int population_size, int selection_type,
00527 float crossover_probability_float, float mutation_per_bit_probability_float, float macro_mutation_probability_float);
00528 FGEN_API void ffit_run_fgen_real_valued_archipelago(Ffit *fit, int nu_islands, int population_size, int selection_type,
00529 float crossover_probability_float, float mutation_probability_float, float macro_mutation_probability_float,
00530 float migration_probability_float, int migration_interval);
00531 /* FGEN_API void ffit_run_fgen_with_hill_climb(Ffit *fit, int population_size, int nu_bits_per_param, int selection_type,
00532 FgenCrossoverFunc crossover, float crossover_probability_float, float mutation_per_bit_probability_float, float
00533 macro_mutation_probability_float); */
00534 FGEN_API void ffit_run_fpso(Ffit *fit, int population_size, int topology, int bounding_strategy,
00535 double omega, double phi1, double phi2);
00536 
00537 FGEN_API void ffit_signal_stop(Ffit *fit);
00538 FGEN_API void ffit_signal_model_change(Ffit *fit);
00539 FGEN_API void ffit_destroy(Ffit *fit);
00540 FGEN_API int ffit_get_population_size(const Ffit *fit);
00541 FGEN_API void ffit_get_individual_params(const Ffit *fit, int index, double *params);
00542 FGEN_API void *ffit_get_population(const Ffit *fit);
00543 FGEN_API void ffit_set_threading(Ffit *fit, int threading_level);
00544 FGEN_API void ffit_set_generation_callback_interval(Ffit *fit, int interval);
00545 
00548 __END_DECLS
00549 
00550 #endif
00551 
 All Data Structures Functions Variables