Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Arnaud Kress
easea
Commits
80302dde
Commit
80302dde
authored
Mar 09, 2010
by
kruger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nouvelle Version avec Version CUDA Memetic
parent
d3b11d7c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
17 deletions
+45
-17
Easea.h
Easea.h
+1
-0
EaseaLex.l
EaseaLex.l
+32
-5
EaseaParse.y
EaseaParse.y
+6
-8
examples/memetic_std/memetic_weierstrass.ez
examples/memetic_std/memetic_weierstrass.ez
+4
-2
libeasea/include/CPopulation.h
libeasea/include/CPopulation.h
+2
-2
No files found.
Easea.h
View file @
80302dde
...
...
@@ -29,6 +29,7 @@ Centre de Math
#define CUDA_FLAVOR_MO 1
#define CUDA_FLAVOR_CMAES 2
#define CUDA_FLAVOR_GP 3
#define CUDA_FLAVOR_MEMETIC 4
#define UNIX 1
...
...
EaseaLex.l
View file @
80302dde
...
...
@@ -73,7 +73,7 @@ Centre de Math
%start GENOME_ANALYSIS TEMPLATE_ANALYSIS MACRO_IDENTIFIER MACRO_DEFINITION
%start COPY_USER_DECLARATIONS COPY_INITIALISATION_FUNCTION ANALYSE_USER_CLASSES
%start COPY_EO_INITIALISER
%start COPY COPY_INITIALISER COPY_CROSSOVER COPY_MUTATOR COPY_EVALUATOR COPY_FINALIZATION_FUNCTION
COPY_OPTIMISER
%start COPY COPY_INITIALISER COPY_CROSSOVER COPY_MUTATOR COPY_EVALUATOR
COPY_OPTIMISER
COPY_FINALIZATION_FUNCTION
%start COPY_DISPLAY COPY_USER_FUNCTION COPY_USER_GENERATION PARAMETERS_ANALYSIS GET_PARAMETERS
%start COPY_USER_FUNCTIONS COPY_GENERATION_FUNCTION_BEFORE_REPLACEMENT GET_METHODS COPY_MAKEFILE_OPTION COPY_BOUND_CHECKING_FUNCTION COPY_BEG_GENERATION_FUNCTION COPY_END_GENERATION_FUNCTION COPY_INSTEAD_EVAL
...
...
@@ -398,6 +398,23 @@ exponent ([Ee][+-]?[0-9]+)
}
}
<TEMPLATE_ANALYSIS>"\\COPY_CUDA_CTOR" {
CListItem<CSymbol*> *pSym;
if (bVERBOSE) printf ("Creating default copy constructor.\n");
fprintf (fpOutputFile,"// Memberwise copy\n");
pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem()){
if (pSym->Object->ObjectQualifier==1) continue; // 1=Static
if (pSym->Object->ObjectType==oObject)
fprintf(fpOutputFile," dest->%s=src->%s;\n",pSym->Object->sName,pSym->Object->sName);
if (pSym->Object->ObjectType==oArray){
fprintf(fpOutputFile," {for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/pSym->Object->pType->nSize);
fprintf(fpOutputFile," dest->%s[EASEA_Ndx]=src->%s[EASEA_Ndx];}\n",pSym->Object->sName,pSym->Object->sName);
}
}
}
<TEMPLATE_ANALYSIS>"\\GENOME_DTOR" {
CListItem<CSymbol*> *pSym;
if (bVERBOSE) printf ("Creating default destructor.\n");
...
...
@@ -552,9 +569,9 @@ exponent ([Ee][+-]?[0-9]+)
<TEMPLATE_ANALYSIS>"\\INSERT_OPTIMISER" {
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
lineCounter=1;
BEGIN COPY_OPTIMISER;
}
<TEMPLATE_ANALYSIS>"\\INSERT_CUDA_EVALUATOR" {
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
...
...
@@ -562,6 +579,13 @@ exponent ([Ee][+-]?[0-9]+)
lineCounter=1;
BEGIN COPY_EVALUATOR;
}
<TEMPLATE_ANALYSIS>"\\INSERT_CUDA_OPTIMISOR" {
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
bWithinCUDA_Evaluator = 1;
lineCounter=1;
BEGIN COPY_OPTIMISER;
}
<TEMPLATE_ANALYSIS>"\\ANALYSE_PARAMETERS" {
yyreset();
...
...
@@ -1368,7 +1392,8 @@ if(OPERATING_SYSTEM=WINDOWS)
fprintf(fpOutputFile,"#line %d \"%s.ez\"\n",lineCounter, sRAW_PROJECT_NAME);
return USER_OPTIMISER;
}
<COPY_OPTIMISER>.|\n {lineCounter++;}
<COPY_OPTIMISER>. {}
<COPY_OPTIMISER>\n {lineCounter++;}
//****************************************
// Basic copy to .cpp file with major changes
...
...
@@ -1530,7 +1555,7 @@ if(OPERATING_SYSTEM=WINDOWS)
// takes care of C++-like comments
<COPY_USER_FUNCTION>\/\/[^\n]* {fprintf(fpOutputFile,yytext);} // blah blah on a line containing sth else
<COPY_USER_FUNCTION>^[ \t]*\/\/[^\n]*\n {fprintf(fpOutputFile,yytext);} // blah blah on its own on a single line
<COPY_USER_FUNCTION>\/\*[^\*]*\*\/ {fprintf(fpOutputFile,yytext);} /* blah blah on a line containing sth else */
<COPY_USER_FUNCTION>\/\*[^\*]*\*\/
\n
{fprintf(fpOutputFile,yytext);
printf("%s\n",yytext);
} /* blah blah on a line containing sth else */
<COPY_USER_FUNCTION>^[ \t]*\/\*[^\*]*\*\/[ \t]*\n {fprintf(fpOutputFile,yytext);} /* blah blah with nothing before the comment */
<COPY_USER_FUNCTION>"GenomeClass" {
...
...
@@ -1555,7 +1580,7 @@ if(OPERATING_SYSTEM=WINDOWS)
<COPY_USER_FUNCTION>"initOpts." {
if( (bWithinEvaluator && !bWithinCUDA_Evaluator) && ( TARGET==STD || TARGET==CUDA )){
if(
(
(bWithinEvaluator
|| bWithinOptimiser)
&& !bWithinCUDA_Evaluator) && ( TARGET==STD || TARGET==CUDA )){
fprintf(fpOutputFile,"");
}
else
...
...
@@ -1844,6 +1869,8 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
strcat(sTemp,"CUDA.tpl");
else if(TARGET_FLAVOR == CUDA_FLAVOR_CMAES )
strcat(sTemp,"CMAES_CUDA.tpl");
else if(TARGET_FLAVOR == CUDA_FLAVOR_MEMETIC )
strcat(sTemp,"CUDA_MEM.tpl");
else
strcat(sTemp,"CUDA_MO.tpl");
...
...
EaseaParse.y
View file @
80302dde
...
...
@@ -448,15 +448,11 @@ StandardFunctionAnalysis
| USER_EVALUATOR {
if (bVERBOSE) printf("Inserting user genome evaluator (taken from .ez file).\n");
}
END_OF_FUNCTION {
if (TARGET!=CUDA && TARGET!=STD) fprintf(fpOutputFile,"}\n");
}
END_OF_FUNCTION {}
| USER_OPTIMISER {
if (bVERBOSE) printf("Inserting user genome optimiser (taken from .ez file).\n");
}
END_OF_FUNCTION {
if (TARGET!=CUDA && TARGET!=STD) fprintf(fpOutputFile,"}\n");
}
END_OF_FUNCTION {}
| MAKEFILE_OPTION END_OF_FUNCTION {
//DEBUG_PRT("User makefile options have been reduced");
}
...
...
@@ -682,7 +678,6 @@ int main(int argc, char *argv[]){
TARGET=STD;
TARGET_FLAVOR = CUDA_FLAVOR_GP;
}
else if (!mystricmp(sTemp,"std")) {
TARGET=STD;
TARGET_FLAVOR = STD_FLAVOR_SO;
...
...
@@ -703,7 +698,10 @@ int main(int argc, char *argv[]){
TARGET=STD;
TARGET_FLAVOR = STD_FLAVOR_MEMETIC;
}
else if (!mystricmp(sTemp,"memetic_cuda")) {
TARGET=CUDA;
TARGET_FLAVOR = CUDA_FLAVOR_MEMETIC;
}
else if (!mystricmp(sTemp,"v")) bVERBOSE=true;
else if (!mystricmp(sTemp,"tl")){
...
...
examples/memetic_std/memetic_weierstrass.ez
View file @
80302dde
...
...
@@ -146,10 +146,12 @@ return NbMut;
\end
\GenomeClass::optimiser : // Optimises the Genome
for(int i=0; i<SIZE; i++){
/*
for(int i=0; i<SIZE; i++){
if(random(0.,1.)<0.2)
Genome.x[i]+=0.1;
}
}*/
float pas = .01;
Genome.x[currentIteration%SIZE]+=pas;
\end
\User Makefile options:
...
...
libeasea/include/CPopulation.h
View file @
80302dde
...
...
@@ -67,13 +67,13 @@ public:
void
evaluatePopulation
(
CIndividual
**
population
,
size_t
populationSize
);
virtual
void
optimisePopulation
(
CIndividual
**
population
,
size_t
populationSize
);
virtual
void
evaluateParentPopulation
();
void
optimiseParentPopulation
();
virtual
void
optimiseParentPopulation
();
void
strongElitism
(
size_t
elitismSize
,
CIndividual
**
population
,
size_t
populationSize
,
CIndividual
**
outPopulation
,
size_t
outPopulationSize
);
void
weakElitism
(
size_t
elitismSize
,
CIndividual
**
parentsPopulation
,
CIndividual
**
offspringPopulation
,
size_t
*
parentPopSize
,
size_t
*
offPopSize
,
CIndividual
**
outPopulation
,
size_t
outPopulationSize
);
virtual
void
evaluateOffspringPopulation
();
void
optimiseOffspringPopulation
();
virtual
void
optimiseOffspringPopulation
();
CIndividual
**
reducePopulations
(
CIndividual
**
population
,
size_t
populationSize
,
CIndividual
**
reducedPopulation
,
size_t
obSize
);
CIndividual
**
reduceParentPopulation
(
size_t
obSize
);
...
...
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