Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
easea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Arnaud Kress
easea
Commits
f50f76db
Commit
f50f76db
authored
Apr 01, 2009
by
maitre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
elitism bug tracking
parent
4945abf3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
27 deletions
+39
-27
tpl/STD.tpl
tpl/STD.tpl
+39
-27
No files found.
tpl/STD.tpl
View file @
f50f76db
...
...
@@ -7,6 +7,7 @@ using namespace std;
#include
<iostream>
#include "EASEATools.hpp"
#include "EASEAIndividual.hpp"
#include
<time.h>
RandomGenerator* globalRandomGenerator;
...
...
@@ -17,12 +18,15 @@ int main(int argc, char** argv){
parseArguments("EASEA.prm",argc,argv);
size_t parentPopulationSize = setVariable("popSize",\POP_SIZE);
size_t offspringPopulationSize = setVariable("
popSize
",\OFF_SIZE);
size_t offspringPopulationSize = setVariable("
nbOffspring
",\OFF_SIZE);
float pCrossover = \XOVER_PROB;
float pMutation = \MUT_PROB;
float pMutationPerGene = 0.05;
globalRandomGenerator = new RandomGenerator(0);
time_t seed = setVariable("seed",time(0));
globalRandomGenerator = new RandomGenerator(seed);
std::cout
<
<
"
Seed
is
:
"
<<
seed
<<
std::endl
;
SelectionOperator*
selectionOperator =
new
\
SELECTOR
;
SelectionOperator*
replacementOperator =
new
\
RED_FINAL
;
...
...
@@ -36,7 +40,7 @@ int main(int argc, char** argv){
EvolutionaryAlgorithm
ea
(
parentPopulationSize
,
offspringPopulationSize
,
selectionPressure
,
replacementPressure
,
selectionOperator
,
replacementOperator
,
pCrossover
,
pMutation
,
pMutationPerGene
,
outputfile
,
inputfile
);
StoppingCriterion* sc = new GenerationalCriterion(
&ea,
\NB_GEN
);
StoppingCriterion*
sc =
new
GenerationalCriterion
(&
ea
,
setVariable
("
nbGen
",\
NB_GEN
)
);
ea.addStoppingCriterion
(
sc
);
Population*
pop =
ea.getPopulation();
...
...
@@ -275,7 +279,29 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
currentAverageFitness=0.0;
currentSTDEV=0.0;
//Calcul de la moyenne et de l'ecart type
showPopulationStats();
\INSERT_GEN_FCT_CALL
}
population->sortParentPopulation();
//std::cout
<
<
*population
<<
std::endl
;
std::cout
<<
"
Generation
:
"
<<
currentGeneration
<<
std::endl
;
if
(
outputfile
){
DEBUG_PRT
("
Dumping
final
population
to
file
:
%
s
",
outputfile-
>
c_str());
std::ofstream ofs(outputfile->c_str());
boost::archive::text_oarchive oa(ofs);
population->syncOutVector();
oa
<
<
*population
;
}
}
void
EvolutionaryAlgorithm::showPopulationStats
(){
//
Calcul
de
la
moyenne
et
de
l
'
ecart
type
for
(
int
i=
0;
i
<
population-
>
parentPopulationSize; i++){
currentAverageFitness+=population->parents[i]->getFitness();
if(currentGeneration== 1
&&
i==0)
...
...
@@ -294,30 +320,13 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
//Affichage
if(currentGeneration==1){
printf("GEN\tTIME\tEVAL\tBEST\t\tAVG\t\tSTDEV\n\n");
printf("%d\t%d\t%d\t%f\t%f\t%f\n",currentGeneration,0,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV);
}
else
printf("%d\t%d\t%d\t%f\t%f\t%f\n",currentGeneration,0,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV);
\INSERT_GEN_FCT_CALL
}
population->sortParentPopulation();
std::cout
<
<
*population
<<
std::endl
;
std::cout
<<
"
Generation
:
"
<<
currentGeneration
<<
std::endl
;
if
(
outputfile
){
DEBUG_PRT
("
Dumping
final
population
to
file
:
%
s
",
outputfile-
>
c_str());
std::ofstream ofs(outputfile->c_str());
boost::archive::text_oarchive oa(ofs);
population->syncOutVector();
oa
<
<
*population
;
}
printf("GEN\tTIME\tEVAL\tBEST\t\tAVG\t\tSTDEV\n\n");
printf("%d\t%d\t%d\t%f\t%f\t%f\n",currentGeneration,0,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV);
}
else
printf("%d\t%d\t%d\t%f\t%f\t%f\n",currentGeneration,0,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV);
}
bool EvolutionaryAlgorithm::allCriteria(){
for( size_t i=0 ; i
<stoppingCriteria.size
();
i
++
){
...
...
@@ -418,6 +427,8 @@ public:
Population* population;
size_t reduceParents;
size_t reduceOffsprings;
void showPopulationStats();
std::vector
<StoppingCriterion
*
>
stoppingCriteria;
std::string* outputfile;
...
...
@@ -1137,6 +1148,7 @@ void parseArguments(const char* parametersFileName, int ac, char** av,
("nbOffspring",po::value
<int>
(),"set the offspring population size")
("elite",po::value
<int>
(),"Nb of elite parents (absolute)")
("eliteType",po::value
<int>
(),"Strong (1) or weak (1)")
("nbGen",po::value
<int>
(),"Set the number of generation")
("surviveParents",po::value
<int>
()," Nb of surviving parents (absolute)")
("surviveOffsprings",po::value
<int>
()," Nb of surviving offsprings (absolute)")
("outputfile",po::value
<string>
(),"Set an output file for the final population (default : none)")
...
...
@@ -1489,7 +1501,7 @@ clean:
# Parameter file generated by AESAE-EO v0.7b
#
#***************************************
--seed=0 # -S : Random number seed. It is possible to give a specific seed.
#
--seed=0 # -S : Random number seed. It is possible to give a specific seed.
###### Evolution Engine ######
--popSize=\POP_SIZE # -P : Population Size
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment