[galib] RE: galib Digest, Vol 18, Issue 7
Dickinson, Bill
dickinsw at CMG.MFLDCLIN.EDU
Wed Dec 29 21:51:40 EST 2004
Anthony, argv and argc originated with the birth of the C programming language (K&R), not C++. A trivial point, I agree, but, proper credit is due to Brian Kernigan and Dennis Ritchie, the original authors of the C language. The idea of argv and argc was extended to C++ when it was created out of C.
Regards,
Bill Dickinson
-----Original Message-----
From: galib-request at mit.edu [mailto:galib-request at mit.edu]
Sent: Wednesday, December 29, 2004 8:45 AM
To: galib at mit.edu
Subject: galib Digest, Vol 18, Issue 7
Send galib mailing list submissions to
galib at mit.edu
To subscribe or unsubscribe via the World Wide Web, visit
http://mailman.mit.edu/mailman/listinfo/galib
or, via email, send a message with subject or body 'help' to
galib-request at mit.edu
You can reach the person managing the list at
galib-owner at mit.edu
When replying, please edit your Subject line so it is more specific than "Re: Contents of galib digest..."
Today's Topics:
1. RE: benifit of argc and argv to main() ? (Liekens, A.M.L.)
2. would anyone like to test 2.4.6 pre-release? (matthew wall)
3. Re: would anyone like to test 2.4.6 pre-release?
(Tomasz Samotyjak)
4. galib-2.4.6pre1 (Tomasz Samotyjak, PWSZ)
5. integrating GA with a program that does other functions
(Essam Almasri)
----------------------------------------------------------------------
Date: Tue, 28 Dec 2004 18:00:23 +0100
From: "Liekens, A.M.L." <A.M.L.Liekens at tue.nl>
To: "Essam Almasri" <masryesam at yahoo.com>, <galib at mit.edu>
Subject: RE: [galib] benifit of argc and argv to main() ?
Message-ID: <0871B485E5512548B2F0D050C76827BD03E00DBF at wtbex2.campus.tue.nl>
Content-Type: text/plain;
charset="Windows-1252"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Precedence: list
Message: 1
I'm sorry to be bold in my reply, but do you have any experience with C++?
int argc is the number of arguments given on the command line to the executable, and char** argv is the array containing the commands themselves. In the examples of galib, you can give a seed for the random number generator as a parameter when executing the example, i.e. by running
./ex1 seed 5
thus affecting the behavior of the GA by seeding it (the strcmp() recognizes the parameter "seed" and the atoi() converges the "5" to an int).
You won't really see anything different, indeed, if you don't pass a seed parameter to the executable, and remove the parts of the code that interpretes these parameters, duh.
There is consequently, some usefulness in those parts of the code.
Anthony,-
-----Original Message-----
From: galib-bounces at mit.edu on behalf of Essam Almasri
Sent: Tue 12/28/04 15:45
To: galib at mit.edu
Cc:
Subject: [galib] benifit of argc and argv to main() ?
Dear Sir/ Madam
Does it make difference to define:
int main(argc, **argv) or int main().
what is the use of this part which I see in all examples:
for(int ii=1; ii<argc; ii++) {
if(strcmp(argv[ii++],"seed") == 0) {
seed = atoi(argv[ii]);
}
}
I have tried to run the examples without that parts and it works. Am I wrong.
Regards
---------------------------------
Do you Yahoo!?
Dress up your holiday email, Hollywood style. Learn more.
------------------------------
Date: Tue, 28 Dec 2004 22:35:42 -0500
From: matthew wall <mwall at oculustech.com>
To: galib at mit.edu
Subject: [galib] would anyone like to test 2.4.6 pre-release?
Message-ID: <B7554640-594A-11D9-B535-000D93388360 at oculustech.com>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
MIME-Version: 1.0 (Apple Message framework v619)
Content-Transfer-Encoding: 7bit
Precedence: list
Message: 2
hello everyone,
galib 2.4.6 is almost ready for release. i have tested it on the
following:
cygwin gcc 3.3.3
win2k vcpp 12.00.8804
win2k vcpp 12.00.8168
irix 6.5 CC 7.3.1
macosx 10.3.7 gcc 2.95.2
macosx 10.3.7 gcc 3.3
linux redhat 6.2 gcc 2.91
linux fedora core 2 gcc 3.3.3
linux yellow dog 3 gcc 3.2.2
solaris 6 sparc gcc 2.95.2
solaris 7 intel gcc 2.95.2
aix 4.3.3 vacpp 6
hpux 11 aCC A.03.31
on all of these it compiles out-of-the-box with no warnings (ok, almost
no warnings. hpux has a few on one file and vcpp has one.)
my aix 5.1 installation is not yet up and running, and i am still
trying to get a borland installation in place. also, my visual
studio.net installation is buggered, so i cannot test on that one. i
do not have access to a sun compiler. i do not have access to an intel
compiler.
so if you can test on any platform not listed above, please grab the
pre-release from http://lancet.mit.edu/ga/dist/galib246-pre1.tgz and do
a 'make test' and let me know how it goes.
barring any major nasties, 2.4.6 should be release right around the
first week of january 2005.
as for what has changed, this is from the release notes for 2.4.6:
2.4.6 January 2005
------------------------------------------------------------------------
-------
updated macros in gaconfig.h to have fewer clashes with other libraries.
much improved out-of-the-box behavior with various recent compilers,
including
gcc3 and vcpp7. added options for building on macosx with gcc2 and
gcc3.
all galib random number generators have been change to garan* in order
to avoid
naming conflicts with other libraries. there is still only one rng at
a time
and no run-time modification of the rng is possible (that is coming
with 3.0).
better inclusion of GARealGenome and GAStringGenome files for
specializations.
the new method accommodates gcc3 premature instantiation quirks and
makes the
code that uses the genomes slightly less cryptic. see ex21.C to see
how this
is done.
there is now a file called std_stream.h in the ga directory. this file
takes
care of the differences between various iostream naming requirements.
some
platforms require std for the namespace, some do not. some require use
of
<iostream.h>, others require simply <iostream>. when you create your
own code
that uses GAlib, you do not need to use the macros from std_stream.h,
but they
are used in the examples so that the example code will build in any environment, regardless of its use of streams.
the macros for controlling use of streams are now easier to understand
and use.
fixed bug in GASelector::update that could cause memory corruption
(thanks to
Giovanni Sartoni for finding this one). added assertions to expose any
other
end-of-array problems in the selector algorithms.
use local copy of score when calculating population statistics just in
case the
genome scores change on each invocation of the score method.
------------------------------
Date: Wed, 29 Dec 2004 12:05:26 +0100
From: Tomasz Samotyjak <t.samotyjak at pwsz.elblag.pl>
To: galib at mit.edu
Subject: Re: [galib] would anyone like to test 2.4.6 pre-release?
Message-ID: <200412291205.26055.t.samotyjak at pwsz.elblag.pl>
In-Reply-To: <B7554640-594A-11D9-B535-000D93388360 at oculustech.com>
References: <B7554640-594A-11D9-B535-000D93388360 at oculustech.com>
Content-Type: text/plain;
charset="iso-8859-2"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Precedence: list
Reply-To: t.samotyjak at pwsz.elblag.pl
Message: 3
Hallo,
There is log from make test for PLD linux gcc 3.3.5
[tomek at localhost galib246pre1]$ make test
cd ga; make
make[1]: Wej¶cie do katalogu `/home/users/tomek/temp/galib246pre1/ga'
g++ -g -Wall -I.. -c garandom.C
g++ -g -Wall -I.. -c gaerror.C
g++ -g -Wall -I.. -c GAParameter.C
g++ -g -Wall -I.. -c GAStatistics.C
g++ -g -Wall -I.. -c GABaseGA.C
../ga/gaversion.h:17: warning: `const char*rcsid' defined but not used
g++ -g -Wall -I.. -c GASStateGA.C
g++ -g -Wall -I.. -c GASimpleGA.C
g++ -g -Wall -I.. -c GAIncGA.C
g++ -g -Wall -I.. -c GADemeGA.C
g++ -g -Wall -I.. -c GADCrowdingGA.C
g++ -g -Wall -I.. -c GASelector.C
g++ -g -Wall -I.. -c GAScaling.C
g++ -g -Wall -I.. -c GAPopulation.C
g++ -g -Wall -I.. -c GAGenome.C
g++ -g -Wall -I.. -c GABinStr.C
g++ -g -Wall -I.. -c gabincvt.C
g++ -g -Wall -I.. -c GAAllele.C
g++ -g -Wall -I.. -c GA1DBinStrGenome.C
g++ -g -Wall -I.. -c GA2DBinStrGenome.C
g++ -g -Wall -I.. -c GA3DBinStrGenome.C
g++ -g -Wall -I.. -c GABin2DecGenome.C
g++ -g -Wall -I.. -c GA1DArrayGenome.C
g++ -g -Wall -I.. -c GA2DArrayGenome.C
g++ -g -Wall -I.. -c GA3DArrayGenome.C
g++ -g -Wall -I.. -c GATreeBASE.C
g++ -g -Wall -I.. -c GATree.C
g++ -g -Wall -I.. -c GATreeGenome.C
g++ -g -Wall -I.. -c GAListBASE.C
g++ -g -Wall -I.. -c GAList.C
g++ -g -Wall -I.. -c GAListGenome.C
ar rv libga.a garandom.o gaerror.o GAParameter.o GAStatistics.o GABaseGA.o
GASStateGA.o GASimpleGA.o GAIncGA.o GADemeGA.o GADCrowdingGA.o GASelector.o
GAScaling.o GAPopulation.o GAGenome.o GABinStr.o gabincvt.o GAAllele.o
GA1DBinStrGenome.o GA2DBinStrGenome.o GA3DBinStrGenome.o GABin2DecGenome.o
GA1DArrayGenome.o GA2DArrayGenome.o GA3DArrayGenome.o GATreeBASE.o GATree.o
GATreeGenome.o GAListBASE.o GAList.o GAListGenome.o
ar: creating libga.a
a - garandom.o
a - gaerror.o
a - GAParameter.o
a - GAStatistics.o
a - GABaseGA.o
a - GASStateGA.o
a - GASimpleGA.o
a - GAIncGA.o
a - GADemeGA.o
a - GADCrowdingGA.o
a - GASelector.o
a - GAScaling.o
a - GAPopulation.o
a - GAGenome.o
a - GABinStr.o
a - gabincvt.o
a - GAAllele.o
a - GA1DBinStrGenome.o
a - GA2DBinStrGenome.o
a - GA3DBinStrGenome.o
a - GABin2DecGenome.o
a - GA1DArrayGenome.o
a - GA2DArrayGenome.o
a - GA3DArrayGenome.o
a - GATreeBASE.o
a - GATree.o
a - GATreeGenome.o
a - GAListBASE.o
a - GAList.o
a - GAListGenome.o
echo no ranlib libga.a
no ranlib libga.a
echo "g++ -g -Wall" > BUILD
libga.a is now up-to-date
make[1]: Opuszczenie katalogu `/home/users/tomek/temp/galib246pre1/ga'
cd examples; make
make[1]: Wej¶cie do katalogu `/home/users/tomek/temp/galib246pre1/examples'
g++ -g -Wall -I.. -c randtest.C
g++ randtest.o -o randtest -L../ga -lga -lm
g++ -g -Wall -I.. -c ex1.C
g++ ex1.o -o ex1 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex2.C
g++ ex2.o -o ex2 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex3.C
g++ ex3.o -o ex3 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex4.C
g++ ex4.o -o ex4 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex5.C
g++ ex5.o -o ex5 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex6.C
g++ ex6.o -o ex6 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex7.C
g++ ex7.o -o ex7 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex8.C
g++ ex8.o -o ex8 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex9.C
g++ ex9.o -o ex9 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex10.C
g++ ex10.o -o ex10 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex11.C
g++ ex11.o -o ex11 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex12.C
g++ ex12.o -o ex12 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex13.C
g++ ex13.o -o ex13 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex14.C
g++ ex14.o -o ex14 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex15.C
g++ ex15.o -o ex15 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex16.C
g++ ex16.o -o ex16 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex17.C
g++ ex17.o -o ex17 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex18.C
g++ ex18.o -o ex18 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex19.C
g++ ex19.o -o ex19 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex20.C
g++ ex20.o -o ex20 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex21.C
g++ ex21.o -o ex21 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex22.C
g++ ex22.o -o ex22 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex23.C
g++ ex23.o -o ex23 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex24.C
g++ ex24.o -o ex24 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex25.C
g++ ex25.o -o ex25 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex26.C
g++ ex26.o -o ex26 -L../ga -lga -lm
g++ -g -Wall -I.. -c ex27.C
g++ ex27.o -o ex27 -L../ga -lga -lm
make[1]: Opuszczenie katalogu `/home/users/tomek/temp/galib246pre1/examples'
cd examples; make test
make[1]: Wej¶cie do katalogu `/home/users/tomek/temp/galib246pre1/examples'
rm -rf test_results.txt test_stats.txt
running tests. this could take up to 1/2 hour, depending on the speed of your computer. monitor test_results.txt and test_stats.txt to see what is happening.
for x in randtest ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10 ex11 ex12
ex13 ex14 ex15 ex16 ex17 ex18 ex19 ex20 ex21 ex22 ex23 ex24 ex25 ex26 ex27;
do \
echo "$x... "; \
echo "$x" >> test_stats.txt; \
echo "start: " `date` >> test_stats.txt; \
./$x seed 555 >> test_results.txt; \
echo "finish: " `date` >> test_stats.txt; \
echo "" >> test_stats.txt; \
done
randtest...
This program checks the random number generators in GAlib. These are not rigorous statistical tests, but they should give you a quick indication of whether or not the library is working properly. Command-line options include:
[+-]chi - do the chi square test (default)
[+-]hist - do the histogram tests. Histograms should be
nearlyflat, i.e. each number has an equal chance
of beingchosen.
[+-]bnds - do the bounds tests. All numbers generated
should be within the limits specified in the
test.
[+-]means - do the means tests. A few thousand invocations
of each random number function are made, and the
averages of these calls are displayed with the
number that should have been found.
seed n - specify the seed number to use for the RNG. You
should get the same results every time if you
specify the same seed every time. A seed of 0
tells the lib to pick its own seed based upon the
current time.
chi-square test...
integer test (1000)...
integer test (10000)...
integer test (10000)...
integer test (100000)...
ex1...
ex2...
ex3...
ex4...
ex5...
ex6...
ex7...
ex8...
ex9...
ex10...
ex11...
ex12...
ex13...
ex14...
ex15...
ex16...
ex17...
ex18...
ex19...
ex20...
ex21...
ex22...
GAParameterList::parse:
unrecognized name seed
GAParameter.C : 614
GAParameterList::parse:
unrecognized name 555
GAParameter.C : 614
ex23...
GAParameterList::parse:
unrecognized name seed
GAParameter.C : 614
GAParameterList::parse:
unrecognized name 555
GAParameter.C : 614
ex24...
GAParameterList::parse:
unrecognized name seed
GAParameter.C : 614
GAParameterList::parse:
unrecognized name 555
GAParameter.C : 614
ex25...
ex26...
ex27...
------------------------------
Date: Wed, 29 Dec 2004 12:26:08 +0100
From: "Tomasz Samotyjak, PWSZ" <t.samotyjak at pwsz.elblag.pl>
To: <galib at mit.edu>
Subject: [galib] galib-2.4.6pre1
Message-ID: <000b01c4ed99$31b2ff10$d400c80a at siomek>
Content-Type: text/plain;
format=flowed;
charset="iso-8859-2";
reply-type=original
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Precedence: list
Message: 4
Hallo,
There is log for Dev-Cpp gcc 3.4.2
Wykonywanie make...
make.exe -f "C:\Temp\galib246pre1\Makefile.win" all
g++.exe -c ga/GA1DArrayGenome.C -o
ga/GA1DArrayGenome.o -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"
-I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"
-I"C:/Dev-Cpp/include" -I"C:/Temp/galib246pre1" -w
g++.exe -c ga/GA1DBinStrGenome.C -o
ga/GA1DBinStrGenome.o -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"
-I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"
-I"C:/Dev-Cpp/include" -I"C:/Temp/galib246pre1" -w
g++.exe -c ga/GA2DArrayGenome.C -o
ga/GA2DArrayGenome.o -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"
-I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"
-I"C:/Dev-Cpp/include" -I"C:/Temp/galib246pre1" -w
ga/GA2DArrayGenome.C: In member function `virtual int
GA2DArrayGenome<T>::resize(int, int)':
ga/GA2DArrayGenome.C:116: error: there are no arguments to `move' that
depend on a template parameter, so a declaration of `move' must be available
ga/GA2DArrayGenome.C:116: error: (if you use `-fpermissive', G++ will accept
your code, but allowing the use of an undeclared name is deprecated)
make.exe: *** [ga/GA2DArrayGenome.o] Error 1
Best regards
Tomasz Samotyjak
http://samotyjak.pwsz.elblag.pl
------------------------------
Date: Wed, 29 Dec 2004 03:30:10 -0800 (PST)
From: Essam Almasri <masryesam at yahoo.com>
To: galib at mit.edu
Subject: [galib] integrating GA with a program that does other functions
Message-ID: <20041229113010.46458.qmail at web53605.mail.yahoo.com>
Content-Type: multipart/alternative; boundary="0-237505648-1104319810=:45090"
MIME-Version: 1.0
Precedence: list
Message: 5
--0-237505648-1104319810=:45090
Content-Type: text/plain; charset=us-ascii
Hallo
I have little experience with C++. I have the problem of integrating the GA in a part of a program that does GA and other things. Taking ex9 as acase study I have derived a function called getvalue and within this function. This I call this function in my program.as seen at the end this massage. In this sollution I have ignored the argc and argv and this part. The sollution seems to be OK.
for(int ii=1; ii
if(strcmp(argv[ii++],"seed") == 0) {
seed = atoi(argv[ii]);
}
}
What should I do for not ignoring them.
Thank you in advance
float objective(GAGenome &);
int getvalue();
int main()
{
getvalue();
// here are the other parts of the program
//
//
//
return 0;
}
int getvalue()
{
cout << "Example 9\n\n";
cout << "This program finds the maximum value in the function\n";
cout << " y = - x1^2 - x2^2\n";
cout << "with the constraints\n";
cout << " -5 <= x1 <= 5\n";
cout << " -5 <= x2 <= 5\n";
cout << "\n\n"; cout.flush();
// See if we've been given a seed to use (for testing purposes). When you // specify a random seed, the evolution will be exactly the same each time // you use that seed number.
unsigned int seed = 0;
// Declare variables for the GA parameters and set them to some default values.
int popsize = 30;
int ngen = 100;
float pmut = 0.01;
float pcross = 0.6;
// Create a phenotype for two variables. The number of bits you can use to // represent any number is limited by the type of computer you are using. In // this case, we use 16 bits to represent a floating point number whose value // can range from -5 to 5, inclusive. The bounds on x1 and x2 can be applied // here and/or in the objective function.
GABin2DecPhenotype map;
map.add(16, -5, 5);
map.add(16, -5, 5);
// Create the template genome using the phenotype map we just made.
GABin2DecGenome genome(map, objective);
// Now create the GA using the genome and run it. We'll use sigma truncation // scaling so that we can handle negative objective scores.
GASimpleGA ga(genome);
GASigmaTruncationScaling scaling;
ga.populationSize(popsize);
ga.nGenerations(ngen);
ga.pMutation(pmut);
ga.pCrossover(pcross);
ga.scaling(scaling);
ga.scoreFilename("bog.dat");
ga.scoreFrequency(10);
ga.flushFrequency(50);
ga.evolve(seed);
// Dump the results of the GA to the screen.
genome = ga.statistics().bestIndividual();
cout << "the ga found an optimum at the point (";
cout << genome.phenotype(0) << ", " << genome.phenotype(1) << ")\n\n";
cout << "best of generation data are in '" << ga.scoreFilename() << "'\n";
return 0;
}
// This objective function tries to maximize the value of the function //
// y = -(x1*x1 + x2*x2)
//
float
objective(GAGenome & c)
{
GABin2DecGenome & genome = (GABin2DecGenome &)c;
float y;
y = -genome.phenotype(0) * genome.phenotype(0);
y -= genome.phenotype(1) * genome.phenotype(1);
return y;
}
---------------------------------
Do you Yahoo!?
The all-new My Yahoo! - What will yours do? --0-237505648-1104319810=:45090
Content-Type: text/html; charset=us-ascii
<DIV>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">Hallo </SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> I have little experience with C++. I have the problem of integrating the GA in a part of a program that does GA and other things. Taking ex9 as acase study I have derived a function called getvalue and within this function. This I call this function in my program.as seen at the end this massage. In this sollution I have ignored the argc and argv and this part. The sollution seems to be OK.<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">for(int ii=1; ii<BR><ARGC; ii++) {>if(strcmp(argv[ii++],"seed") == 0) {<BR>seed = atoi(argv[ii]);<BR>}<BR>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">What should I do for not ignoring them.<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">Thank you in advance<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">float objective(GAGenome &);<BR>int getvalue();<BR>int main()<BR>{<BR> getvalue();</SPAN></P><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"></SPAN></DIV> <DIV><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// here are the other parts of the program <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%">//</P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%">//</P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%">//<BR> return 0;<BR>}<BR>int getvalue()<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">{<BR> cout << "Example 9\n\n";<BR> cout << "This program finds the maximum value in the function\n";<BR> cout << " y = - x1^2 - x2^2\n";<BR> cout << "with the constraints\n";<BR> cout << " -5 <= x1 <= 5\n";<BR> cout << " -5 <= x2 <= 5\n";<BR> cout << "\n\n"; cout.flush();<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// See if we've been given a seed to use (for testing purposes). When you<BR>// specify a random seed, the evolution will be exactly the same each time<BR>// you use that seed number.<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> unsigned int seed = 0;<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// Declare variables for the GA parameters and set them to some default values.<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> int popsize = 30;<BR> int ngen = 100;<BR> float pmut = 0.01;<BR> float pcross = 0.6;<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// Create a phenotype for two variables. The number of bits you can use to<BR>// represent any number is limited by the type of computer you are using. In<BR>// this case, we use 16 bits to represent a floating point number whose value<BR>// can range from -5 to 5, inclusive. The bounds on x1 and x2 can be applied<BR>// here and/or in the objective function.<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> GABin2DecPhenotype map;<BR> map.add(16, -5, 5);<BR> map.add(16, -5, 5);<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// Create the template genome using the phenotype map we just made.<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> GABin2DecGenome genome(map, objective);<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// Now create the GA using the genome and run it. We'll use sigma truncation<BR>// scaling so that we can handle negative objective scores.<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> </SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial">GASimpleGA ga(genome);<BR> GASigmaTruncationScaling scaling;<BR> ga.populationSize(popsize);<BR> ga.nGenerations(ngen);<BR> ga.pMutation(pmut);<BR> ga.pCrossover(pcross);<BR> ga.scaling(scaling);<BR> ga.scoreFilename("bog.dat");<BR> ga.scoreFrequency(10);<BR> ga.flushFrequency(50);<BR> ga.evolve(seed);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// Dump the results of the GA to the screen.<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> genome = ga.statistics().bestIndividual();<BR> cout << "the ga found an optimum at the point (";<BR> cout << genome.phenotype(0) << ", " << genome.phenotype(1) << ")\n\n";<BR> cout << "best of generation data are in '" << ga.scoreFilename() << "'\n";<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> return 0;<BR>}<BR> <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// This objective function tries to maximize the value of the function<BR>//<BR>// y = -(x1*x1 + x2*x2)<BR>//<BR>float<BR>objective(GAGenome & c)<BR>{<BR> GABin2DecGenome & genome = (GABin2DecGenome &)c;<o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 12pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"> float y;<BR> y = -genome.phenotype(0) * genome.phenotype(0);<BR> y -= genome.phenotype(1) * genome.phenotype(1);<BR> return y;<BR>}<o:p></o:p></SPAN></P></DIV><p>
<hr size=1>Do you Yahoo!?<br>
The <a href="http://my.yahoo.com">all-new My Yahoo!</a> - What will yours do?
--0-237505648-1104319810=:45090--
------------------------------
_______________________________________________
galib mailing list
galib at mit.edu
http://mailman.mit.edu/mailman/listinfo/galib
End of galib Digest, Vol 18, Issue 7
************************************
More information about the galib
mailing list