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
ca98311c
Commit
ca98311c
authored
Dec 06, 2010
by
Lidia Yamamoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed condition to show statistics, keep track of worst individual and print it in statistics too
parent
ac644472
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
12 deletions
+19
-12
libeasea/CEvolutionaryAlgorithm.cpp
libeasea/CEvolutionaryAlgorithm.cpp
+18
-12
libeasea/include/CPopulation.h
libeasea/include/CPopulation.h
+1
-0
No files found.
libeasea/CEvolutionaryAlgorithm.cpp
View file @
ca98311c
...
...
@@ -232,8 +232,8 @@ void CEvolutionaryAlgorithm::runEvolutionaryLoop(){
population
->
reduceTotalPopulation
(
elitistPopulation
);
population
->
sortParentPopulation
();
if
(
this
->
params
->
printStats
||
this
->
params
->
generateCSVFile
)
showPopulationStats
(
begin
);
//
if( this->params->printStats || this->params->generateCSVFile )
showPopulationStats
(
begin
);
// (always calculate stats)
bBest
=
population
->
Best
;
EASEAEndGenerationFunction
(
this
);
...
...
@@ -286,7 +286,7 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
currentSTDEV
=
0.0
;
//Calcul de la moyenne et de l'ecart type
population
->
Best
=
population
->
parents
[
0
];
population
->
Best
=
population
->
Worst
=
population
->
parents
[
0
];
for
(
unsigned
i
=
0
;
i
<
population
->
parentPopulationSize
;
i
++
){
currentAverageFitness
+=
population
->
parents
[
i
]
->
getFitness
();
...
...
@@ -295,6 +295,12 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
if
(
(
params
->
minimizing
&&
population
->
parents
[
i
]
->
getFitness
()
<
population
->
Best
->
getFitness
())
||
(
!
params
->
minimizing
&&
population
->
parents
[
i
]
->
getFitness
()
>
population
->
Best
->
getFitness
()))
population
->
Best
=
population
->
parents
[
i
];
// keep track of worst individual too, for statistical purposes
if
(
(
params
->
minimizing
&&
population
->
parents
[
i
]
->
getFitness
()
>
population
->
Worst
->
getFitness
())
||
(
!
params
->
minimizing
&&
population
->
parents
[
i
]
->
getFitness
()
<
population
->
Worst
->
getFitness
()))
population
->
Worst
=
population
->
parents
[
i
];
}
currentAverageFitness
/=
population
->
parentPopulationSize
;
...
...
@@ -318,11 +324,11 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
//Affichage
if
(
params
->
printStats
){
if
(
currentGeneration
==
0
)
printf
(
"GEN
\t
TIME
\t\t
EVAL
\t
BEST
\t\t\t\t
AVG
\t\t\t\t
STDEV
\n\n
"
);
printf
(
"GEN
\t
TIME
\t\t
EVAL
\t
BEST
\t\t\t\t
AVG
\t\t\t\t
STDEV
\
t\t\t
WORST
\
n\n
"
);
#ifdef WIN32
printf
(
"%lu
\t
%2.6f
\t
%lu
\t
%.15e
\t\t
%.15e
\t\t
%.15e
\n
"
,
currentGeneration
,
duration
,
population
->
currentEvaluationNb
,
population
->
Best
->
getFitness
(),
currentAverageFitness
,
currentSTDEV
);
printf
(
"%lu
\t
%2.6f
\t
%lu
\t
%.15e
\t\t
%.15e
\t\t
%.15e
\t
%.15e
\n
"
,
currentGeneration
,
duration
,
population
->
currentEvaluationNb
,
population
->
Best
->
getFitness
(),
currentAverageFitness
,
currentSTDEV
,
population
->
Worst
->
getFitness
()
);
#else
printf
(
"%d
\t
%ld.%06ld
\t
%d
\t
%.15e
\t\t
%.15e
\t\t
%.15e
\
n
"
,(
int
)
currentGeneration
,
res
.
tv_sec
,
res
.
tv_usec
,(
int
)
population
->
currentEvaluationNb
,
population
->
Best
->
getFitness
(),
currentAverageFitness
,
currentSTDEV
);
printf
(
"%d
\t
%ld.%06ld
\t
%d
\t
%.15e
\t\t
%.15e
\t\t
%.15e
\
t
%.15e
\n
"
,(
int
)
currentGeneration
,
res
.
tv_sec
,
res
.
tv_usec
,(
int
)
population
->
currentEvaluationNb
,
population
->
Best
->
getFitness
(),
currentAverageFitness
,
currentSTDEV
,
population
->
Worst
->
getFitness
()
);
#endif
//printf("%lu\t%ld.%06ld\t%lu\t%f\t%f\t%f\n",currentGeneration,res.tv_sec,res.tv_usec,population->currentEvaluationNb,population->Best->getFitness(),currentAverageFitness,currentSTDEV);
}
...
...
@@ -334,11 +340,11 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
f
=
fopen
(
fichier
.
c_str
(),
"a"
);
//ajouter .csv
if
(
f
!=
NULL
){
if
(
currentGeneration
==
0
)
fprintf
(
f
,
"#GEN
\t
TIME
\t\t
EVAL
\t
BEST
\t\t
AVG
\t\t
STDEV
\n\n
"
);
fprintf
(
f
,
"#GEN
\t
TIME
\t\t
EVAL
\t
BEST
\t\t
AVG
\t\t
STDEV
\
t\t
WORST
\
n\n
"
);
#ifdef WIN32
fprintf
(
f
,
"%lu
\t
%2.6f
\t
%lu
\t
%.15e
\t
%.15e
\t
%.15e
\
n
"
,
currentGeneration
,
duration
,
population
->
currentEvaluationNb
,
population
->
Best
->
getFitness
(),
currentAverageFitness
,
currentSTDEV
);
fprintf
(
f
,
"%lu
\t
%2.6f
\t
%lu
\t
%.15e
\t
%.15e
\t
%.15e
\
t
%.15e
\n
"
,
currentGeneration
,
duration
,
population
->
currentEvaluationNb
,
population
->
Best
->
getFitness
(),
currentAverageFitness
,
currentSTDEV
,
population
->
Worst
->
getFitness
()
);
#else
fprintf
(
f
,
"%d
\t
%ld.%06ld
\t
%d
\t
%.15e
\t
%.15e
\t
%.15e
\
n
"
,(
int
)
currentGeneration
,
res
.
tv_sec
,
res
.
tv_usec
,(
int
)
population
->
currentEvaluationNb
,
population
->
Best
->
getFitness
(),
currentAverageFitness
,
currentSTDEV
);
fprintf
(
f
,
"%d
\t
%ld.%06ld
\t
%d
\t
%.15e
\t
%.15e
\t
%.15e
\
t
%.15e
\n
"
,(
int
)
currentGeneration
,
res
.
tv_sec
,
res
.
tv_usec
,(
int
)
population
->
currentEvaluationNb
,
population
->
Best
->
getFitness
(),
currentAverageFitness
,
currentSTDEV
,
population
->
Worst
->
getFitness
()
);
#endif
fclose
(
f
);
}
...
...
@@ -350,11 +356,11 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
f
=
fopen
(
fichier
.
c_str
(),
"a"
);
//ajouter .csv
if
(
f
!=
NULL
){
if
(
currentGeneration
==
0
)
fprintf
(
f
,
"GEN,TIME,EVAL,BEST,AVG,STDEV
\n
"
);
fprintf
(
f
,
"GEN,TIME,EVAL,BEST,AVG,STDEV
,WORST
\n
"
);
#ifdef WIN32
fprintf
(
f
,
"%lu,%2.6f,%lu,%.15e,%.15e,%.15e
\n
"
,
currentGeneration
,
duration
,
population
->
currentEvaluationNb
,
population
->
Best
->
getFitness
(),
currentAverageFitness
,
currentSTDEV
);
fprintf
(
f
,
"%lu,%2.6f,%lu,%.15e,%.15e,%.15e
,%.15e
\n
"
,
currentGeneration
,
duration
,
population
->
currentEvaluationNb
,
population
->
Best
->
getFitness
(),
currentAverageFitness
,
currentSTDEV
,
population
->
Worst
->
getFitness
()
);
#else
fprintf
(
f
,
"%d,%ld.%ld,%d,%f,%f,%f
\n
"
,(
int
)
currentGeneration
,
res
.
tv_sec
,
res
.
tv_usec
,(
int
)
population
->
currentEvaluationNb
,
population
->
Best
->
getFitness
(),
currentAverageFitness
,
currentSTDEV
);
fprintf
(
f
,
"%d,%ld.%ld,%d,%f,%f,%f
,%f
\n
"
,(
int
)
currentGeneration
,
res
.
tv_sec
,
res
.
tv_usec
,(
int
)
population
->
currentEvaluationNb
,
population
->
Best
->
getFitness
(),
currentAverageFitness
,
currentSTDEV
,
population
->
Worst
->
getFitness
()
);
#endif
fclose
(
f
);
}
...
...
libeasea/include/CPopulation.h
View file @
ca98311c
...
...
@@ -33,6 +33,7 @@ public:
float
pMutationPerGene
;
CIndividual
*
Best
;
CIndividual
*
Worst
;
float
currentAverageFitness
;
float
currentSTDEV
;
...
...
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