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
b301ea50
Commit
b301ea50
authored
Apr 01, 2009
by
maitre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minimaxi
define std_tpl out/input file disabled
parent
f50f76db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
45 deletions
+61
-45
EaseaLex.l
EaseaLex.l
+8
-2
exemples/cuda_listsort/listsort.ez
exemples/cuda_listsort/listsort.ez
+1
-1
tpl/STD.tpl
tpl/STD.tpl
+52
-42
No files found.
EaseaLex.l
View file @
b301ea50
...
...
@@ -543,10 +543,16 @@ exponent ([Ee][+-]?[0-9]+)
<TEMPLATE_ANALYSIS>"\\STEADYSTATE" {if ((fREPL_PERC==0)||(!strcmp(sREPLACEMENT,"Incremental"))||(!strcmp(sREPLACEMENT,"Simple")))
fprintf(fpOutputFile,"// undefined ");}
<TEMPLATE_ANALYSIS>"\\COMMENT" {if (mystricmp(sREPLACEMENT,"SSGA")) fprintf(fpOutputFile,"//");}
<TEMPLATE_ANALYSIS>"\\MINIMAXI" {switch (TARGET) { case GALIB : fprintf(fpOutputFile,"%d",nMINIMISE? -1:1); break;
<TEMPLATE_ANALYSIS>"\\MINIMAXI" {
switch (TARGET) {
case GALIB : fprintf(fpOutputFile,"%d",nMINIMISE? -1:1); break;
case EO : fprintf(fpOutputFile,"%s",nMINIMISE? "eoMinimizingFitness" : "eoMaximizingFitness"); break;
case DREAM : fprintf(fpOutputFile,"%s",nMINIMISE? "false" : "true"); break;
} }
case STD:
case CUDA: fprintf(fpOutputFile,"%s",(nMINIMISE? "false" : "true")); break;
}
}
<TEMPLATE_ANALYSIS>"\\ELITIST_REPLACE_NAME" {if (TARGET==EO) {if (bELITISM) fprintf(fpOutputFile,"standardR");
else fprintf(fpOutputFile,"r");}}
<TEMPLATE_ANALYSIS>"\\ELITISM" {
...
...
exemples/cuda_listsort/listsort.ez
View file @
b301ea50
...
...
@@ -44,7 +44,7 @@ void cross(GenomeClass *pChild, GenomeClass *pParent, int locus){
\Finalization function:
std::cout << "fonction de finalization svp" << std::endl;
std::cout << population ;
//
std::cout << population ;
\end
\GenomeClass::initialiser:
...
...
tpl/STD.tpl
View file @
b301ea50
...
...
@@ -52,6 +52,8 @@ int main(int argc, char** argv){
delete
pop
;
delete
sc
;
return
0;
}
...
...
@@ -62,6 +64,8 @@ int main(int argc, char** argv){
#include
<
string.h
>
#include
<fstream>
#define STD_TPL
extern RandomGenerator* globalRandomGenerator;
\INSERT_USER_DECLARATIONS
...
...
@@ -245,17 +249,17 @@ void EvolutionaryAlgorithm::addStoppingCriterion(StoppingCriterion* sc){
void EvolutionaryAlgorithm::runEvolutionaryLoop(){
std::vector
<Individual
*
>
tmpVect;
if( inputfile ){
DEBUG_PRT("Loading initial population from file : %s",inputfile->c_str());
std::ifstream ifs("essai.out");
DEBUG_PRT("parent population size in ea %d",population->parentPopulationSize);
//population->parents = new Individual*[population->parentPopulationSize];
boost::archive::text_iarchive ia(ifs);
/* if( inputfile ){ */
/* DEBUG_PRT("Loading initial population from file : %s",inputfile->c_str()); */
/* std::ifstream ifs("essai.out"); */
/* DEBUG_PRT("parent population size in ea %d",population->parentPopulationSize); */
/* //population->parents = new Individual*[population->parentPopulationSize]; */
/* boost::archive::text_iarchive ia(ifs); */
ia >> *population;
population->syncInVector();
//ia >> *population;
}
/* //ia >> *population; */
/* population->syncInVector(); */
/* //ia >> *population; */
/* } */
std::cout
<
<
"
Parent
'
s
population
initializing
"<<
std::endl
;
this-
>
population->initializeParentPopulation();
...
...
@@ -275,7 +279,7 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
population->reduceTotalPopulation();
currentGeneration += 1;
currentAverageFitness=0.0;
currentSTDEV=0.0;
...
...
@@ -283,48 +287,54 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
showPopulationStats();
\INSERT_GEN_FCT_CALL
currentGeneration += 1;
}
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
;
/
*
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)
population->Best=population->parents[i];
else{
if(population->parents[i]->getFitness()
<population->
Best->getFitness())
population->Best=population->parents[i];
}
}
currentAverageFitness/=population->parentPopulationSize;
for(int i=0; i
<population->
parentPopulationSize; i++){
currentSTDEV+=(population->parents[i]->getFitness()-currentAverageFitness)*(population->parents[i]->getFitness()-currentAverageFitness);
}
currentSTDEV/=population->parentPopulationSize;
currentSTDEV=sqrt(currentSTDEV);
//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);
//
Calcul
de
la
moyenne
et
de
l
'
ecart
type
if
(
currentGeneration =
=
0
)
population-
>
Best=population->parents[0];
for(int i=0; i
<population->
parentPopulationSize; i++){
currentAverageFitness+=population->parents[i]->getFitness();
#if \MINIMAXI
if(population->parents[i]->getFitness()>population->Best->getFitness())
#else
if(population->parents[i]->getFitness()
<population->
Best->getFitness())
#endif
population->Best=population->parents[i];
}
currentAverageFitness/=population->parentPopulationSize;
for(int i=0; i
<population->
parentPopulationSize; i++){
currentSTDEV+=(population->parents[i]->getFitness()-currentAverageFitness)*(population->parents[i]->getFitness()-currentAverageFitness);
}
currentSTDEV/=population->parentPopulationSize;
currentSTDEV=sqrt(currentSTDEV);
//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);
}
bool EvolutionaryAlgorithm::allCriteria(){
...
...
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