📄 gaconfig.h
字号:
// $Header: /usr/people/mbwall/src/galib/ga/RCS/gaconfig.h,v 1.4 1998/11/11 20:31:56 mbwall Exp $/* ---------------------------------------------------------------------------- config.h mbwall 27jun95 Copyright (c) 1995-1996 Massachusetts Institute of Technology all rights reserved DESCRIPTION: Configuration header file for the GA library. Use this file to set theparameters that are specific to machine/compiler/operating system. This filealso contains macros that control which parts of the library will be compiledand which operators will be the defaults.---------------------------------------------------------------------------- */#ifndef _ga_config_h_#define _ga_config_h_/* ----------------------------------------------------------------------------PREPROCESSOR DIRECTIVES Here are the preprocessor directives that the library understands. If you are using a makefile, then put these in the line with the DEFINES macro. Forexample, to define the NO_TEMPLATES and BORLAND_INST options then do DEFINES = -DNO_TEMPLATES -DBORLAND_INSTIn MacOS or DOS, use your development environment's preprocessor directives option to set the values. Beware that if you use the makefile or your development environment to do the defines then someone may compile a programlater on that does not use the same defines you used to compile the library.For best results (ie smallest chance of error), modify this header file ratherthan using the makefile or development environment. Some of these are already set up for the OSes with which I am familiar. Seebelow for the pre-defined sets. NO_STREAMS If you want to compile the library without streams, set this flag. The library will compile with no stream input or output in any class and no dependencies on the streams library. NO_CPP_CASTS If your compiler does not support RTTI, or if you turn off the RTTI abilities of your compiler, then define this macro. The result is that if improper casts are made, things will die horribly rather than dropping out in an RTTI-induced exception. NO_PID For machines that do not have the getpid() function or the unistd.h header file. NO_TEMPLATES For compilers that do not do templates. The only type of genome available when you use this is binary string and any derived classes. list, tree, and array all use templates. You can still use the template code, but you will have to hack it yourself to make it work. BORLAND_INST For compilers that use the Borland instantiation model. These compilers expect all of the template code to be in the header file. The Cfront model, on the other hand, expects source files with names similar to the header files, but all of the template code does not need to be in the header files. When you define this flag, the source file that corresponds to the header file is explicitly included at the end of the header file for all headers that contain templates. NO_AUTO_INST For compilers that do not do automatic instantiation (such as g++ version 2.6.8) you will have to force instantiations. When this flag is defined, GAlib forces an instantiation of all of the template classes that it uses (such as real genome and string genome). USE_RAN1 USE_RAN2 USE_RAN3 USE_RAND USE_RANDOM USE_RAND48 These specify which random number function to use. Only one of these may be specified. You may have to tweak random.h a bit as well (these functions are not defined the same way on each platform). For best results, use ran2 or ran3 (performance is slightly slower than most system RNGs, but you'll get better results). If you want to use another random number generator you must hack random.h directly (see the comments in that file). BITBASE The built-in type to use for bit conversions. This should be set to the type of the largest integer that your system supports. If you have long long int then use it. If you don't plan to use more than 16 or 32 bits to represent your binary-to-decimal mappings then you can use something smaller (long int for example). If you do not set this, GAlib will automatically use the size of a long int. The bitbase determines the maximum number of bits you can use to represent a decimal number in the binary-to-decimal genomes. BITS_IN_WORD How many bits are in a word? For many systems, a word is a char and is 8 bits long.---------------------------------------------------------------------------- */// Here are the defines needed for some of the compilers/OSes on which I have// been able to test the GA library. You may have to remove and/or modify// these to get things to work on your system.// If only every compiler were as easy to use and as well maintained as the// ones from metrowerks...#if defined(__MWERKS__)#if !__option(RTTI)#define NO_CPP_CASTS#endif#if defined(macintosh)#define BORLAND_INST#define NO_AUTO_INST#define NO_PID#elif defined(__INTEL__)#define BORLAND_INST#define NO_AUTO_INST#define NO_PID#endif#endif// Symantec C++ for mac. This compiler does not handle templates very well, // so if you want to use any of the template components of GAlib then you will// probably have to do some hacking to get things to work.#if defined(__SC__)#define NO_PID#endif// You may or may not need the BORLAND_INST flag defined when you use a borland// compiler. I did not need it when I compiled using version 4.0, but I did// need it when I compiled with an earlier version (I think it was 3.x but I// do not remember for certain).// Note that the default random number generator when using a borland (or// any PC compiler, for that matter) is the basic system's RNG.// I did this because of the hassles of 16- vs 32-bit DOS/Windows rubbish. If// you want a better RNG, you can use the others in GAlib, but you'll have to// do a bit of checking to make sure it works with your DOS/Windows config.// All of the RNGs work fine under all of the 32-bit OSes I've tried, but they// don't do so well in a 16-bit OS.// Use the randtest example to check GAlib's RNG after you compile everything.#if defined(__BORLANDC__)#define NO_PID#define NO_AUTO_INST#define USE_RAND // comment this if you're using a 32-bit OS//#define BORLAND_INST#endif// MicroSoft's Visual C++ programming environment.#if defined(_MSC_VER)#define NO_PID#define NO_AUTO_INST//#pragma warning (disable : 4244)//#pragma warning (disable : 4305)#endif// for g++ 2.6.3 - 2.8.x// if you use 2.8.x then you might want to comment out the NO_CPP_CASTS macro// since 2.8 will do rtti without requiring the -frtti flag.#if defined(__GNUG__)#define BORLAND_INST#define NO_AUTO_INST#define NO_CPP_CASTS#endif// SGI DCC on irix 5.3 and irix 6.x#if defined(__sgi)#define NO_CPP_CASTS#endif// If no RNG has been selected, use the ran2 generator by default#if !defined(USE_RAND) && !defined(USE_RANDOM) && \ !defined(USE_RAND48) && !defined(USE_RAN2) && !defined(USE_RAN3)#define USE_RAN2#endif// This defines how many bits are in a single word on your system. Most // systems have a word length of 8 bits.#ifndef BITS_IN_WORD#define BITS_IN_WORD 8#endif// Use this to set the maximum number of bits that can be used in binary-to-// decimal conversions. You should make this type the largest integer type // that your system supports.#ifndef BITBASE#define BITBASE long int#endif// If the system/compiler understands C++ casts, then we use them. Otherwise// we default to the C-style casts. The macros make explicit the fact that we// are doing casts.#if defined(NO_CPP_CASTS)#define DYN_CAST(type,x) ((type)(x))#define CON_CAST(type,x) ((type)(x))#define STA_CAST(type,x) ((type)(x))#define REI_CAST(type,x) ((type)(x))#else#define DYN_CAST(type,x) (dynamic_cast<type>(x))#define CON_CAST(type,x) (const_cast<type>(x))#define STA_CAST(type,x) (static_cast<type>(x))#define REI_CAST(type,x) (reinterpret_cast<type>(x))#endif/* ----------------------------------------------------------------------------SPACE SAVERS and DEFAULT OPERATORS These directives determine which operators will be used by default for eachof the objects in GAlib. If space is limited, you may want to compile the library with only the partsthat you need (compiling in DOS comes to mind). Your compiler should do thisautomatically for you (ie only use the parts that you use). If not, then comment out the chunks in the files you're not going to use (for example, comment out the ordered initializer in the list object). To disable a certain type of genome, simply don't compile its source file.The following directives are defined so that you can trim out the parts of thegenetic algorithm objects that are not in separate files.---------------------------------------------------------------------------- */// scaling schemes#define USE_LINEAR_SCALING 1#define USE_SIGMA_TRUNC_SCALING 1#define USE_POWER_LAW_SCALING 1#define USE_SHARING 1// selection schemes#define USE_RANK_SELECTOR 1#define USE_ROULETTE_SELECTOR 1#define USE_TOURNAMENT_SELECTOR 1#define USE_DS_SELECTOR 1#define USE_SRS_SELECTOR 1#define USE_UNIFORM_SELECTOR 1// These are the compiled-in defaults for various genomes and GA objects#define DEFAULT_SCALING GALinearScaling#define DEFAULT_SELECTOR GARouletteWheelSelector#define DEFAULT_TERMINATOR TerminateUponGeneration#define DEFAULT_1DBINSTR_INITIALIZER UniformInitializer#define DEFAULT_1DBINSTR_MUTATOR FlipMutator#define DEFAULT_1DBINSTR_COMPARATOR BitComparator#define DEFAULT_1DBINSTR_CROSSOVER OnePointCrossover#define DEFAULT_2DBINSTR_INITIALIZER UniformInitializer#define DEFAULT_2DBINSTR_MUTATOR FlipMutator#define DEFAULT_2DBINSTR_COMPARATOR BitComparator#define DEFAULT_2DBINSTR_CROSSOVER OnePointCrossover#define DEFAULT_3DBINSTR_INITIALIZER UniformInitializer#define DEFAULT_3DBINSTR_MUTATOR FlipMutator#define DEFAULT_3DBINSTR_COMPARATOR BitComparator#define DEFAULT_3DBINSTR_CROSSOVER OnePointCrossover#define DEFAULT_BIN2DEC_ENCODER GABinaryEncode#define DEFAULT_BIN2DEC_DECODER GABinaryDecode#define DEFAULT_BIN2DEC_COMPARATOR BitComparator#define DEFAULT_1DARRAY_INITIALIZER NoInitializer#define DEFAULT_1DARRAY_MUTATOR SwapMutator#define DEFAULT_1DARRAY_COMPARATOR ElementComparator#define DEFAULT_1DARRAY_CROSSOVER OnePointCrossover#define DEFAULT_2DARRAY_INITIALIZER NoInitializer#define DEFAULT_2DARRAY_MUTATOR SwapMutator#define DEFAULT_2DARRAY_COMPARATOR ElementComparator#define DEFAULT_2DARRAY_CROSSOVER OnePointCrossover#define DEFAULT_3DARRAY_INITIALIZER NoInitializer#define DEFAULT_3DARRAY_MUTATOR SwapMutator#define DEFAULT_3DARRAY_COMPARATOR ElementComparator#define DEFAULT_3DARRAY_CROSSOVER OnePointCrossover#define DEFAULT_1DARRAY_ALLELE_INITIALIZER UniformInitializer#define DEFAULT_1DARRAY_ALLELE_MUTATOR FlipMutator#define DEFAULT_1DARRAY_ALLELE_COMPARATOR ElementComparator#define DEFAULT_1DARRAY_ALLELE_CROSSOVER OnePointCrossover#define DEFAULT_2DARRAY_ALLELE_INITIALIZER UniformInitializer#define DEFAULT_2DARRAY_ALLELE_MUTATOR FlipMutator#define DEFAULT_2DARRAY_ALLELE_COMPARATOR ElementComparator#define DEFAULT_2DARRAY_ALLELE_CROSSOVER OnePointCrossover#define DEFAULT_3DARRAY_ALLELE_INITIALIZER UniformInitializer#define DEFAULT_3DARRAY_ALLELE_MUTATOR FlipMutator#define DEFAULT_3DARRAY_ALLELE_COMPARATOR ElementComparator#define DEFAULT_3DARRAY_ALLELE_CROSSOVER OnePointCrossover#define DEFAULT_STRING_INITIALIZER UniformInitializer#define DEFAULT_STRING_MUTATOR FlipMutator#define DEFAULT_STRING_COMPARATOR ElementComparator#define DEFAULT_STRING_CROSSOVER UniformCrossover#define DEFAULT_REAL_INITIALIZER UniformInitializer#define DEFAULT_REAL_MUTATOR GARealGaussianMutator#define DEFAULT_REAL_COMPARATOR ElementComparator#define DEFAULT_REAL_CROSSOVER UniformCrossover#define DEFAULT_TREE_INITIALIZER NoInitializer#define DEFAULT_TREE_MUTATOR SwapSubtreeMutator#define DEFAULT_TREE_COMPARATOR TopologyComparator#define DEFAULT_TREE_CROSSOVER OnePointCrossover#define DEFAULT_LIST_INITIALIZER NoInitializer#define DEFAULT_LIST_MUTATOR SwapMutator#define DEFAULT_LIST_COMPARATOR NodeComparator#define DEFAULT_LIST_CROSSOVER OnePointCrossover#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -