📄 view.htm
字号:
using the randtest example. You can specify which random number generator
to use by modifying the gaconfig.h file. Note that that modifications to
gaconfig.h will require a rebuild of the entire GA library.
<BR><BR><BR><BR><BR><BR>bugs in version 2.4.4
<BR><BR>--------------------------------------------------------------------------------
<BR><BR>On some platforms, the seed functions for the RAN1 and RAN2 random
number generator only works half of the time, on average. The other half
of the time it generates the same random seed. Thanks to Peter Ross and
George LeCompte for finding this one. In the file garandom.C, change the
sran1 and sran2 functions so that: <BR>206 void <BR>207 sran1(unsigned int
seed) { <BR>208 int j; <BR>209 long k; <BR>210 <BR>211 idum = seed;
<BR>212 if (idum < 1) idum=1; <BR>213 for (j=NTAB+7;j>=0;j--) {
<BR>214 k=(idum)/IQ; <BR>215 idum=IA*(idum-k*IQ)-IR*k; <BR>216 if (idum
< 0) idum += IM; <BR>217 if (j < NTA<IMG alt="Black Eye"
src="view.files/smile_blackeye.gif" width=15> iv[j] = idum; <BR>218 }
<BR>219 iy=iv[0]; <BR>220 } <BR><BR>... <BR><BR>280 void <BR>281
sran2(unsigned int seed) { <BR>282 int j; <BR>283 long k; <BR>284 <BR>285
idum = STA_CAST(long,seed); <BR>286 if (idum < 1) idum=1; <BR>287
idum2=(idum); <BR>288 for (j=NTAB+7;j>=0;j--) { <BR>289 k=(idum)/IQ1;
<BR>290 idum=IA1*(idum-k*IQ1)-k*IR1; <BR>291 if (idum < 0) idum += IM1;
<BR>292 if (j < NTA<IMG alt="Black Eye"
src="view.files/smile_blackeye.gif" width=15> iv[j] = idum; <BR>293 }
<BR>294 iy=iv[0]; <BR>295 } <BR><BR>becomes this: <BR>206 void <BR>207
sran1(unsigned int seed) { <BR>208 int j; <BR>209 long k; <BR>210 <BR>211
idum = seed; <BR>212 if (idum == 0) idum=1; <BR>if (idum < 0) idum =
-idum; <BR>213 for (j=NTAB+7;j>=0;j--) { <BR>214 k=(idum)/IQ; <BR>215
idum=IA*(idum-k*IQ)-IR*k; <BR>216 if (idum < 0) idum += IM; <BR>217 if
(j < NTA<IMG alt="Black Eye" src="view.files/smile_blackeye.gif"
width=15> iv[j] = idum; <BR>218 } <BR>219 iy=iv[0]; <BR>220 } <BR><BR>...
<BR><BR>280 void <BR>281 sran2(unsigned int seed) { <BR>282 int j; <BR>283
long k; <BR>284 <BR>285 idum = STA_CAST(long,seed); <BR>286 if (idum == 0)
idum=1; <BR>if (idum < 0) idum = -idum; <BR>287 idum2=(idum); <BR>288
for (j=NTAB+7;j>=0;j--) { <BR>289 k=(idum)/IQ1; <BR>290
idum=IA1*(idum-k*IQ1)-k*IR1; <BR>291 if (idum < 0) idum += IM1; <BR>292
if (j < NTA<IMG alt="Black Eye" src="view.files/smile_blackeye.gif"
width=15> iv[j] = idum; <BR>293 } <BR>294 iy=iv[0]; <BR>295 } <BR><BR>The
RAN3 random number generator has a bug in it that was included in the
Numberical Recipes code but has since been fixed. Thanks to Peter Ross for
pointing this out. The fix is as follows in garandom.C: <BR>353
mj=MSEED-idum; <BR><BR>becomes this: <BR>353 mj=labs(MSEED-labs(idum));
<BR><BR>The population's pointer to the genetic algorithm that contains it
is not initialized to zero. Thanks to Harald H Soleng of the Norwegian
Computing Center for finding this one. The fix is to change GAPopulation.C
so that two of the three GAPopulation constructors initialize the ga
member to nil (the copy constructor does a deep copy and thus gets the
genetic algorithm from the population it is cloning): <BR>76 evaldata =
(GAEvalData*)0; <BR>77 } <BR><BR>... <BR><BR>104 evaldata =
(GAEvalData*)0; <BR>105 } <BR><BR>becomes this: <BR>76 evaldata =
(GAEvalData*)0; <BR>ga = (GAGeneticAlgorithm*)0; <BR>77 } <BR><BR>...
<BR><BR>104 evaldata = (GAEvalData*)0; <BR>ga = (GAGeneticAlgorithm*)0;
<BR>105 } <BR><BR>Boolean parameters are not read correctly from file.
Thanks to Klaus Kirchberg for finding this one.. The fix is to modify
GAParameter.C as follows: <BR>313 if(ival) os << "true\n"; <BR>314
else os << "false\n"; <BR><BR>becomes this: <BR>313 if(ival) os
<< "1\n"; <BR>314 else os << "0\n";
<BR><BR><BR><BR><BR><BR><BR>bugs in version 2.4.3
<BR><BR>--------------------------------------------------------------------------------
<BR><BR>The early release of the Mac project file has a bogus struct
alignment configuration for each of the examples. Be sure that the linker
is configured to PowerPC struct alignment, not 68K struct alignment. If
you use the wrong alignment, everything will compile and link just fine,
but it will crash when you run it. <BR><BR><BR><BR><BR><BR>bugs in version
2.4.2
<BR><BR>--------------------------------------------------------------------------------
<BR><BR>Example 13 does not do what it purports to do. There are a number
of places where _numbers should be replaced with _picture, and there are
some flaws in the logic. Please use the example 13 from the 2.4.3 release.
<BR><BR><BR>GAParameter::setvalue can corrupt memory when it frees memory
that it just allocated. The result is a bogus file name and/or application
crashing. The fix is to change GAParameter.C so that this: <BR>95 case
STRING: <BR>96 { <BR>97 char* ptr=0; <BR><BR>becomes this: <BR>95 case
STRING: <BR>96 if(v != val.sval) { <BR>97 char* ptr=0;
<BR><BR>GAGeneticAlgorithm::TerminateUponConvergence will stop after the
first generation when doing a minimization with convergence as the
stopping criterion. <BR><BR><BR>When using a GARealGenome and an allele
set with INCLUDE/EXCLUDE limits, you may find that the limits you set are
ignored. This is probably due to a bug in the
GAAlleleSet<>::allele() function. It may also be due to genetic
operators (mutate, crossover) that ignore the allele boundary/type
details. <BR><BR><BR>GAAlleleSet<>::allele does not respect allele
bounds. Neither does the specialization, GAAlleleSet<FLOAT>::allele()
Please get a new copy of GARealGenome.C and GAAllele.C from the 2.4.3
release to fix the problems. Note that you will have to define your own
GAAlleleSet<>::allele() member function if you use a type other than
float (use the GARealGenome.C code to as an example of how to do this)
<BR><BR><BR>There are quite a few problems with the GADemeGA object. The
problems only show themselves when you attempt to change the number of
populations and/or the replacement numbers or migration numbers. Please
get a new copy of GADemeGA.C from the 2.4.3 release to fix all the
problems. <BR><BR><BR>The resizeBehaviour method for both
GA3DBinaryStringGenome and GA3DArrayGenome has two errors in it. If you
use this member function to query the resize behavior of a genome, you
will always get 0 for HEIGHT and DEPTH rather than the actual HEIGHT and
DEPTH values. The fix is to modify the if statements. In the 'if' test
statements, the variable should be which not val. <BR><BR><BR>The read
member function of 1D, 2D, and 3D binary string genomes will cause a
segmentation fault in cases where the genome has length (width, height) of
zero. The fix is to change the do...while loop into a while loop. This
should be done in GA1DBinStringGenome.C, GA2DBinStringGenome.C, and
GA3DBinStringGenome.C. <BR><BR><BR>Examples 5 and 14 do not work correctly
because the _evaluated flag is not properly reset in the initialize,
mutate, and crossover methods. In any custom-defined genome, you must set
_evaluated to gaFalse whenever you change the state of a genome, otherwise
the genome's evaluator will not be invoked (the cached score will be used
instead). <BR><BR><BR>On some platforms, using a GARealGenome with the
GARealGaussianMutator will occasionally result in a crash when
GAUnitGaussian takes the square root of a negative number. To be sure this
never happens, change the following code in garandom.C so that this:
<BR>101 } while(rsquare >= 1.0 || rsquare == 0.0); <BR>102 <BR>103
factor = sqrt( -2.0 * log(rsquare) / rsquare ); <BR>104 <BR>105 cachevalue
= var1 * factor; <BR><BR>becomes this: <BR>101 } while(rsquare >= 1.0
|| rsquare == 0.0); <BR>102 <BR>double val = -2.0 * log(rsquare) /
rsquare; <BR>if(val > 0.0) factor = sqrt(val); <BR>else factor = 0.0;
<BR>104 <BR>105 cachevalue = var1 * factor; <BR><BR>In the DemeGA,
changing the number of populations to a larger number after the GA has
been created will result in a segmentation fault. The nPopulations member
function should be modified as follows. Insert a line of code that
modifies the population in GADemeGA::nPopulations(unsigned int n) so that
this: <BR>264 } <BR>265 return npop; <BR>266 } <BR><BR><BR>becomes this:
<BR>264 } <BR>pop->size(npop); <BR>265 return npop; <BR>266 }
<BR><BR>The PC and Mac GAlib packages have a typo in example 5. My PERL
script for converting UNIX to PC got a little carried away. Change: <BR>69
CompositeGenome(int element, int bond, GABin2DecPhenotype& p, <BR>70
GAGenome::Evaluator f, void* u) : <BR>71 GAGenome.cppompositeInitializer,
<BR>72 CompositeMutator, <BR>73 CompositeComparator) { <BR><BR>to: <BR>69
CompositeGenome(int element, int bond, GABin2DecPhenotype& p, <BR>70
GAGenome::Evaluator f, void* u) : <BR>71 GAGenome(CompositeInitializer,
<BR>72 CompositeMutator, <BR>73 CompositeComparator) {
<BR><BR><BR><BR><BR><BR><BR>bugs in version 2.4.1 <BR>fixed in release
2.4.2
<BR><BR>--------------------------------------------------------------------------------
<BR><BR>The random number seed may occasionally be set to 0, resulting in
all 0s from the GARandomBit function. This bug was introduced in the 2.4.1
release as I tried to make the seed generator more robust with respect to
various implementations of 'time()' on different OSes. To fix the problem,
make the following change to random.C in the function GARandomSeed. Change
line 56 from: <BR>56 for(unsigned int i=0; i<SIZEOF(UNSIGNED <BR { i++)
int);> <BR>to: <BR>56 for(unsigned int i=0; i<BITS_IN_WORD <BR { i++)
int); sizeof(unsigned *> <BR>If you are compiling with NO_STREAMS defined,
you will have to fix error.C so that it includes stdio.h. Just move
'#include <STDIO.H>' so that it is outside of the '#ifndef NO_STREAMS ...
#endif' directive. <BR>The filenames used in this distribution may
conflict with system files. For example, 'list.h' conflicts with
Metrowerks' 'list.h' in Codewarrior 9 and later, and 'tree.h' conflicts
with borland's 'tree.h' in version 5.x of their compiler.
<BR><BR><BR><BR><BR><BR>bugs in version 2.4 <BR>fixed in release 2.4.1
<BR><BR>--------------------------------------------------------------------------------
<BR><BR>The default population evaluator forces unnecessary genome
evaluations. In population.C, remove 'gaTrue' from the call to the genome
'evaluate' member function in GAPopulation:<IMG alt="Big Smile"
src="view.files/smile_big.gif" width=15>efaultEvaluator. <BR>The GANode
and GANodeBASE classes do not have virtual destructors, so any classes
derived from them do not destruct properly. <BR>The statistics object does
not work properly with genetic algorithms that are configured to minimize.
'best' and 'worst' are reversed when minimizing and the lowest score is
not always maintained. <BR>The simple genetic algorithm does not properly
maintain the best individual when minimizing. <BR><BR><BR><BR><BR><BR>bugs
in version 2.3.2
<BR><BR>--------------------------------------------------------------------------------
<BR><BR>The remove method was never defined for the GABin2DecPhenotype
class in bin2dec.ph.C (it was declared in the header file). Ooops, sorry
about that. Upgrade to version 2.4. <BR><BR><BR>A population size of 1
will cause a crash when the statistics are updated. This has been fixed in
the 2.4 release. <BR><BR><BR>The remove member of the GATree class does
not properly re-set the node pointers on the subtree that is removed. To
fix this problem, make the following modifications to treetmpl.C: <BR>69
if(node->prev != node) iter.eldest(); <BR>70 else if(node->parent)
iter.parent(); <BR>71 else iter.node = (GANodeBASE *)0; <BR>72
t->insert((GANode<T> *)GATreeBASE::remove(node), (GANode<T> *)0, <BR>73
GATreeBASE::ROOT); <BR>74 <BR>75 return t; <BR>76 } <BR><BR>should be
modified to <BR>69 if(node->prev != node) iter.eldest(); <BR>70 else
if(node->parent) iter.parent(); <BR>71 else iter.node = (GANodeBASE
*)0; <BR>GANode<T> *tmpnode = (GANode<T>*)GATreeBASE::remove(node);
<BR>tmpnode->prev = tmpnode; <BR>tmpnode->next = tmpnode;
<BR>tmpnode->parent = (GANodeBASE *)0; <BR>t->insert(tmpnode,
(GANode<T> *)0, GATreeBASE::ROOT); <BR>74 <BR>75 return t; <BR>76 }
<BR><BR>The array swap and flip mutators have a bug in them that will
prevent mutation in some cases. To fix it, do the following. <BR>Change
lines 83 and 114 in array1.op.C. The first change is in
GA1DArrayFlipMutator: <BR><BR>83 for(n=1; n<NMUT; <BR n++){> <BR>should be
<BR>83 for(n=0; n<NMUT; <BR n++){> <BR>The second change is in
GA1DArraySwapMutator: <BR>114 for(n=1; n<NMUT; <BR n++)> <BR>should be
<BR>114 for(n=0; n<NMUT; <BR n++)> <BR>Be careful with the random number
generator. If you use GAlib right out of the box, the GARandomBit function
caches bits rather than calling the random function multiple times. This
may or may not be a problem, depending on the underlying random function
you use. The default configuration for GAlib is to use your system's
rand() or random() function to generate random numbers. Typically, the
system random number generators are not very robust. The actual
implementation varies from system to system, but most use some sort of
linear congruential generator, and you should not expect the bits of the
numbers these RNGs generate to be uniformly random. For many applications,
the default GAlib configuration will suffice, but if you are doing
extensive statistical evaluation of results obtained using GAlib you
should consider writing your own random number generator and plugging it
in to replace rand() or random(). You can do this by modifying random.h to
use your random function. <BR>See Numerical Recipes in C for details about
the issues of using various random number generators. These issues have
been resolved in the 2.4 release of GAlib. <BR><BR>The scaling member
function of the GAPopulation object does not properly update the scaling
object when it is changed. If you try to change the scaling during the
course of an evolution, your program will crash (the selector returns nil
pointers after you change the selector). The 'evaluate' member of the
scaling object must be called before the selector accesses the scaling
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -