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
9a480ab6
Commit
9a480ab6
authored
Feb 08, 2011
by
Frederic Kruger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bound checking function
parent
0fd78b8f
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
543 additions
and
483 deletions
+543
-483
EaseaLex.cpp
EaseaLex.cpp
+457
-456
EaseaLex.l
EaseaLex.l
+2
-1
examples/rastrigin/rastrigin.ez
examples/rastrigin/rastrigin.ez
+6
-3
libeasea/CEvolutionaryAlgorithm.cpp
libeasea/CEvolutionaryAlgorithm.cpp
+16
-7
libeasea/CPopulation.cpp
libeasea/CPopulation.cpp
+2
-0
libeasea/CStoppingCriterion.cpp
libeasea/CStoppingCriterion.cpp
+6
-2
libeasea/include/CIndividual.h
libeasea/include/CIndividual.h
+2
-0
libeasea/include/CStoppingCriterion.h
libeasea/include/CStoppingCriterion.h
+3
-2
tpl/CMAES.tpl
tpl/CMAES.tpl
+7
-2
tpl/CMAES_CUDA.tpl
tpl/CMAES_CUDA.tpl
+7
-2
tpl/CUDA.tpl
tpl/CUDA.tpl
+8
-2
tpl/CUDA_GP.tpl
tpl/CUDA_GP.tpl
+6
-1
tpl/CUDA_MEM.tpl
tpl/CUDA_MEM.tpl
+7
-2
tpl/STD.tpl
tpl/STD.tpl
+7
-1
tpl/STD_MEM.tpl
tpl/STD_MEM.tpl
+7
-2
No files found.
EaseaLex.cpp
View file @
9a480ab6
This diff is collapsed.
Click to expand it.
EaseaLex.l
View file @
9a480ab6
...
...
@@ -1636,7 +1636,8 @@ if(OPERATING_SYSTEM=WINDOWS)
<COPY_BOUND_CHECKING_FUNCTION>"\\Bound"[ \t\n]+"checking"[ \t\n]*":" {
if(TARGET==CUDA || TARGET==STD){
fprintf (fpOutputFile,"void EASEABoundChecking(EvolutionaryAlgorithm* evolutionaryAlgorithm){\n");
//fprintf (fpOutputFile,"void EASEABoundChecking(EvolutionaryAlgorithm* evolutionaryAlgorithm){\n");
fprintf (fpOutputFile,"{\n");
}
bFunction=1; bBoundCheckingFunction=1;
BEGIN COPY_USER_GENERATION;
...
...
examples/rastrigin/rastrigin.ez
View file @
9a480ab6
...
...
@@ -73,7 +73,9 @@ float gauss()
\end
\After everything else function:
//cout << "After everything else function called" << endl;
ofstream SaveFile("save.csv", ios::app);
SaveFile << bBest->fitness << ";" << endl;
SaveFile.close();
\end
\At the beginning of each generation function:
...
...
@@ -146,8 +148,8 @@ CPPFLAGS+=
\end
\Default run parameters : // Please let the parameters appear in this order
Number of generations :
9999999
// NB_GEN
Time limit:
6
0 // In seconds, 0 to deactivate
Number of generations :
100000
// NB_GEN
Time limit: 0 // In seconds, 0 to deactivate
Population size : 3840 //POP_SIZE
Offspring size : 3840 // 40%
Mutation probability : 1 // MUT_PROB
...
...
@@ -170,6 +172,7 @@ CPPFLAGS+=
Remote island model: false
IP file: ip.txt //File containing all the remote island's IP
Migration probability : 0.8
Save population: false
Start from file:false
...
...
libeasea/CEvolutionaryAlgorithm.cpp
View file @
9a480ab6
...
...
@@ -376,8 +376,16 @@ void CEvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
}
#endif
double
elapsedTime
=
res
.
tv_sec
+
0.0
;
double
micSec
=
res
.
tv_usec
+
0.0
;
params
->
timeCriterion
->
setElapsedTime
(
res
.
tv_sec
);
while
(
micSec
>
1
){
micSec
/=
10.
;
}
elapsedTime
+=
micSec
+
0.0
;
params
->
timeCriterion
->
setElapsedTime
(
elapsedTime
);
}
//REMOTE ISLAND MODEL FUNCTIONS
...
...
@@ -416,19 +424,20 @@ void CEvolutionaryAlgorithm::initializeClients(){
void
CEvolutionaryAlgorithm
::
sendIndividual
(){
//Sending an individual every n generations
if
(
globalRandomGenerator
->
random
(
0.0
,
1.0
)
<=
params
->
migrationProbability
){
//if((this->currentGeneration+this->myClientNumber)%3==0 && this->currentGeneration!=0){
//cout << "I'm going to send an Individual now" << endl;
//this->population->selectionOperator->initialize(this->population->parents, 7
, this->population->actualParentPopulationSize);
this
->
population
->
selectionOperator
->
initialize
(
this
->
population
->
parents
,
params
->
selectionPressure
,
this
->
population
->
actualParentPopulationSize
);
//unsigned index = this->population->selectionOperator->selectNext(this->population->actualParentPopulationSize);
//cout << "Going to send individual " << index << " with fitness " << this->population->parents[index]->fitness << endl;
//selecting a client randomly
int
client
=
globalRandomGenerator
->
getRandomIntMax
(
this
->
numberOfClients
);
//for(int client=0; client<this->numberOfClients; client++){
cout
<<
"Going to send and individual to client "
<<
client
<<
endl
;
cout
<<
"His IP is "
<<
this
->
Clients
[
client
]
->
getIP
()
<<
endl
;
//cout << "Sending individual " << index << " to client " << client << " now" << endl;
//cout << this->population->parents[index]->serialize() << endl;
this
->
Clients
[
client
]
->
CComUDP_client_send
((
char
*
)
bBest
->
serialize
().
c_str
());
}
}
...
...
@@ -437,16 +446,16 @@ void CEvolutionaryAlgorithm::receiveIndividuals(){
if
(
this
->
treatedIndividuals
<
(
unsigned
)
this
->
server
->
nb_data
){
//cout << "number of received individuals :" << this->server->nb_data << endl;
//cout << "number of treated individuals :" << this->treatedIndividuals << endl;
CSelectionOperator
*
antiTournament
=
getSelectionOperator
(
"Tournament"
,
!
this
->
params
->
minimizing
,
globalRandomGenerator
);
//Treating all the individuals before continuing
while
(
this
->
treatedIndividuals
<
(
unsigned
)
this
->
server
->
nb_data
){
//selecting the individual to erase
//CSelectionOperator *antiTournament = getSelectionOperator("Tournament",!this->params->minimizing, globalRandomGenerator);
//antiTournament->initialize(this->population->parents, 7, this->population->actualParentPopulationSize);
//unsigned index = antiTournament->selectNext(this->population->actualParentPopulationSize);
antiTournament
->
initialize
(
this
->
population
->
parents
,
7
,
this
->
population
->
actualParentPopulationSize
);
unsigned
index
=
antiTournament
->
selectNext
(
this
->
population
->
actualParentPopulationSize
);
//We're selecting the worst element to replace
size_t
index
=
this
->
population
->
getWorstIndividualIndex
(
this
->
population
->
parents
);
//
size_t index = this->population->getWorstIndividualIndex(this->population->parents);
//cout << "old individual fitness :" << this->population->parents[index]->fitness << endl;
//cout << "old Individual :" << this->population->parents[index]->serialize() << endl;
...
...
libeasea/CPopulation.cpp
View file @
9a480ab6
...
...
@@ -336,6 +336,8 @@ void CPopulation::produceOffspringPopulation(){
child
->
mutate
(
pMutationPerGene
);
}
child
->
boundChecking
();
offsprings
[
actualOffspringPopulationSize
++
]
=
child
;
}
delete
[](
ps
);
...
...
libeasea/CStoppingCriterion.cpp
View file @
9a480ab6
...
...
@@ -40,7 +40,7 @@ unsigned* CGenerationalCriterion::getGenerationalLimit(){
****************************************/
CTimeCriterion
::
CTimeCriterion
(
unsigned
timeLimit
){
this
->
timeLimit
=
timeLimit
;
this
->
elapsedTime
=
0
;
this
->
elapsedTime
=
0
.0
;
}
bool
CTimeCriterion
::
reached
(){
...
...
@@ -58,10 +58,14 @@ bool CTimeCriterion::reached(){
else
return
false
;
}
void
CTimeCriterion
::
setElapsedTime
(
unsigned
elapsedTime
){
void
CTimeCriterion
::
setElapsedTime
(
double
elapsedTime
){
this
->
elapsedTime
=
elapsedTime
;
}
double
CTimeCriterion
::
getElapsedTime
(){
return
this
->
elapsedTime
;
}
/* ****************************************
CtrlCStopingCriterion class
****************************************/
...
...
libeasea/include/CIndividual.h
View file @
9a480ab6
...
...
@@ -29,6 +29,8 @@ public:
virtual
std
::
string
serialize
()
=
0
;
virtual
void
deserialize
(
std
::
string
EASEA_Line
)
=
0
;
virtual
void
boundChecking
()
=
0
;
static
unsigned
getCrossoverArrity
(){
return
2
;
}
float
getFitness
(){
return
this
->
fitness
;
}
...
...
libeasea/include/CStoppingCriterion.h
View file @
9a480ab6
...
...
@@ -51,11 +51,12 @@ class CGenerationalCriterion : public CStoppingCriterion {
class
CTimeCriterion
:
public
CStoppingCriterion
{
private:
unsigned
timeLimit
;
unsigned
elapsedTime
;
double
elapsedTime
;
public:
virtual
bool
reached
();
CTimeCriterion
(
unsigned
timeLimit
);
void
setElapsedTime
(
unsigned
elapsedTime
);
void
setElapsedTime
(
double
elapsedTime
);
double
getElapsedTime
();
};
/* ****************************************
...
...
tpl/CMAES.tpl
View file @
9a480ab6
...
...
@@ -103,8 +103,6 @@ extern CEvolutionaryAlgorithm* EA;
\INSERT_INITIALISATION_FUNCTION
\INSERT_FINALIZATION_FUNCTION
\INSERT_BOUND_CHECKING
void evale_pop_chunk(CIndividual** population, int popSize){
\INSTEAD_EVAL_FUNCTION
}
...
...
@@ -184,6 +182,10 @@ float IndividualImpl::evaluate(){
}
}
void IndividualImpl::boundChecking(){
\INSERT_BOUND_CHECKING
}
string IndividualImpl::serialize(){
ostringstream AESAE_Line(ios_base::app);
\GENOME_SERIAL
...
...
@@ -414,6 +416,9 @@ public:
CIndividual* clone();
unsigned mutate(float pMutationPerGene);
void boundChecking();
string serialize();
void deserialize(string AESAE_Line);
...
...
tpl/CMAES_CUDA.tpl
View file @
9a480ab6
...
...
@@ -132,8 +132,6 @@ void cudaPreliminaryProcess(size_t populationSize, dim3* dimBlock, dim3* dimGrid
\
INSERT_INITIALISATION_FUNCTION
\
INSERT_FINALIZATION_FUNCTION
\
INSERT_BOUND_CHECKING
void
evale_pop_chunk
(
CIndividual**
population
,
int
popSize
){
\
INSTEAD_EVAL_FUNCTION
}
...
...
@@ -215,6 +213,10 @@ float IndividualImpl::evaluate(){
}
}
void IndividualImpl::boundChecking(){
\INSERT_BOUND_CHECKING
}
IndividualImpl::IndividualImpl(const IndividualImpl
&
genome){
...
...
@@ -546,6 +548,9 @@ public:
CIndividual* clone();
size_t mutate(float pMutationPerGene);
void boundChecking();
void copyToCudaBuffer(void* buffer, size_t id);
friend std::ostream
&
operator
<
<
(
std::ostream
&
O
,
const
IndividualImpl
&
B
)
;
...
...
tpl/CUDA.tpl
View file @
9a480ab6
...
...
@@ -235,8 +235,6 @@ void InitialiseGPUs(){
\
INSERT_INITIALISATION_FUNCTION
\
INSERT_FINALIZATION_FUNCTION
\
INSERT_BOUND_CHECKING
void
evale_pop_chunk
(
CIndividual**
population
,
int
popSize
){
\
INSTEAD_EVAL_FUNCTION
}
...
...
@@ -294,6 +292,11 @@ float IndividualImpl::evaluate(){
}
}
void
IndividualImpl::boundChecking
(){
\
INSERT_BOUND_CHECKING
}
string
IndividualImpl::serialize
(){
ostringstream
AESAE_Line
(
ios_base::app
);
\
GENOME_SERIAL
...
...
@@ -612,6 +615,9 @@ public:
CIndividual* clone();
unsigned mutate(float pMutationPerGene);
void boundChecking();
string serialize();
void deserialize(string AESAE_Line);
void copyToCudaBuffer(void* buffer, unsigned id);
...
...
tpl/CUDA_GP.tpl
View file @
9a480ab6
...
...
@@ -559,7 +559,9 @@ float IndividualImpl::evaluate(){
\INSERT_INITIALISATION_FUNCTION
\INSERT_FINALIZATION_FUNCTION
\INSERT_BOUND_CHECKING
void IndividualImpl::boundChecking(){
\INSERT_BOUND_CHECKING
}
string IndividualImpl::serialize(){
ostringstream AESAE_Line(ios_base::app);
...
...
@@ -934,6 +936,9 @@ public:
CIndividual* clone();
unsigned mutate(float pMutationPerGene);
void boundChecking();
string serialize();
void deserialize(string AESAE_Line);
...
...
tpl/CUDA_MEM.tpl
View file @
9a480ab6
...
...
@@ -138,8 +138,6 @@ void cudaPreliminaryProcess(unsigned populationSize, dim3* dimBlock, dim3* dimGr
\
INSERT_INITIALISATION_FUNCTION
\
INSERT_FINALIZATION_FUNCTION
\
INSERT_BOUND_CHECKING
void
evale_pop_chunk
(
CIndividual**
population
,
int
popSize
){
\
INSTEAD_EVAL_FUNCTION
}
...
...
@@ -195,6 +193,10 @@ float IndividualImpl::evaluate(){
}
}
void IndividualImpl::boundChecking(){
\INSERT_BOUND_CHECKING
}
string IndividualImpl::serialize(){
ostringstream AESAE_Line(ios_base::app);
\GENOME_SERIAL
...
...
@@ -698,6 +700,9 @@ public:
CIndividual* clone();
unsigned mutate(float pMutationPerGene);
void boundChecking();
string serialize();
void deserialize(string AESAE_Line);
void copyToCudaBuffer(void* buffer, unsigned id);
...
...
tpl/STD.tpl
View file @
9a480ab6
...
...
@@ -99,7 +99,6 @@ extern CEvolutionaryAlgorithm* EA;
\INSERT_INITIALISATION_FUNCTION
\INSERT_FINALIZATION_FUNCTION
\INSERT_BOUND_CHECKING
void evale_pop_chunk(CIndividual** population, int popSize){
\INSTEAD_EVAL_FUNCTION
...
...
@@ -150,6 +149,10 @@ float IndividualImpl::evaluate(){
}
}
void IndividualImpl::boundChecking(){
\INSERT_BOUND_CHECKING
}
string IndividualImpl::serialize(){
ostringstream AESAE_Line(ios_base::app);
\GENOME_SERIAL
...
...
@@ -404,6 +407,9 @@ public:
CIndividual* clone();
unsigned mutate(float pMutationPerGene);
void boundChecking();
string serialize();
void deserialize(string AESAE_Line);
...
...
tpl/STD_MEM.tpl
View file @
9a480ab6
...
...
@@ -99,8 +99,6 @@ extern CEvolutionaryAlgorithm* EA;
\INSERT_INITIALISATION_FUNCTION
\INSERT_FINALIZATION_FUNCTION
\INSERT_BOUND_CHECKING
void evale_pop_chunk(CIndividual** population, int popSize){
\INSTEAD_EVAL_FUNCTION
}
...
...
@@ -146,6 +144,10 @@ float IndividualImpl::evaluate(){
\INSERT_EVALUATOR
}
void IndividualImpl::boundChecking(){
\INSERT_BOUND_CHECKING
}
string IndividualImpl::serialize(){
ostringstream AESAE_Line(ios_base::app);
\GENOME_SERIAL
...
...
@@ -437,6 +439,9 @@ public:
CIndividual* clone();
unsigned mutate(float pMutationPerGene);
void boundChecking();
string serialize();
void deserialize(string AESAE_Line);
...
...
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