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
4b16bc6c
Commit
4b16bc6c
authored
May 07, 2009
by
maitre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bound checking
parent
727449d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
23 deletions
+45
-23
EaseaLex.l
EaseaLex.l
+41
-3
tpl/STD.tpl
tpl/STD.tpl
+4
-20
No files found.
EaseaLex.l
View file @
4b16bc6c
...
...
@@ -59,7 +59,7 @@ Centre de Math
%start COPY_EO_INITIALISER
%start COPY COPY_INITIALISER COPY_CROSSOVER COPY_MUTATOR COPY_EVALUATOR COPY_FINALIZATION_FUNCTION
%start COPY_DISPLAY COPY_USER_FUNCTION COPY_USER_GENERATION PARAMETERS_ANALYSIS GET_PARAMETERS
%start COPY_USER_FUNCTIONS COPY_GENERATION_FUNCTION GET_METHODS COPY_MAKEFILE_OPTION
%start COPY_USER_FUNCTIONS COPY_GENERATION_FUNCTION GET_METHODS COPY_MAKEFILE_OPTION
COPY_BOUND_CHECKING_FUNCTION
// lexical analyser name and class definition
%name CEASEALexer {
...
...
@@ -70,7 +70,7 @@ Centre de Math
bool bDoubleQuotes,bWithinDisplayFunction,bWithinInitialiser,bWithinMutator,bWithinXover;
bool bWaitingForSemiColon,bFinishNB_GEN,bFinishMINIMISE,bFinishMINIMIZE,bGenerationFunction;
bool bCatchNextSemiColon,bWaitingToClosePopulation, bMethodsInGenome, bFinalizationFunction;
bool bWithinCUDA_Initializer, bWithinMAKEFILEOPTION, bWithinCUDA_Evaluator;
bool bWithinCUDA_Initializer, bWithinMAKEFILEOPTION, bWithinCUDA_Evaluator
, bBoundCheckingFunction
;
CSymbol *pASymbol;
public:
...
...
@@ -85,7 +85,7 @@ Centre de Math
bSymbolInserted=bDoubleQuotes=bWithinDisplayFunction=bWithinInitialiser=bWithinMutator=bWithinXover=0;
bWaitingForSemiColon=bFinishNB_GEN=bFinishMINIMISE=bFinishMINIMIZE=bGenerationFunction=0;
bCatchNextSemiColon,bWaitingToClosePopulation=bMethodsInGenome=0;
bWithinCUDA_Initializer=bWithinMAKEFILEOPTION =bWithinCUDA_Evaluator=0;
b
BoundCheckingFunction = b
WithinCUDA_Initializer=bWithinMAKEFILEOPTION =bWithinCUDA_Evaluator=0;
}
// macros
...
...
@@ -152,6 +152,15 @@ exponent ([Ee][+-]?[0-9]+)
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_GENERATION_FUNCTION;
}
<TEMPLATE_ANALYSIS>"\\INSERT_BOUND_CHECKING" {
if (bVERBOSE) printf ("Inserting Bound Checking function.\n");
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_BOUND_CHECKING_FUNCTION;
}
<TEMPLATE_ANALYSIS>"\\ANALYSE_USER_CLASSES" {
if (bVERBOSE) printf ("Analysing user classes.\n");
yyreset();
...
...
@@ -563,6 +572,15 @@ exponent ([Ee][+-]?[0-9]+)
else fprintf(fpOutputFile,"\n EASEAGenerationFunction(ga);\n");
}
}
<TEMPLATE_ANALYSIS>"\\INSERT_BOUND_CHECKING_FCT_CALL" {
if (bBoundCheckingFunction) {
if( TARGET==CUDA || TARGET==STD ){
fprintf(fpOutputFile,"\n\tEASEABoundChecking(this);");
}
}
}
<TEMPLATE_ANALYSIS>"\\INSERT_INIT_FCT_CALL" {
if (bInitFunction) fprintf(fpOutputFile,"\n EASEAInitFunction(argc, argv);\n");
}
...
...
@@ -1069,6 +1087,26 @@ exponent ([Ee][+-]?[0-9]+)
}
<COPY_GENERATION_FUNCTION>.|\n {}
<COPY_BOUND_CHECKING_FUNCTION>"\\Bound"[ \t\n]+"checking"[ \t\n]*":" {
if(TARGET==CUDA || TARGET==STD){
fprintf (fpOutputFile,"void EASEABoundChecking(EvolutionaryAlgorithm* evolutionaryAlgorithm){\n");
}
bFunction=1; bBoundCheckingFunction=1;
BEGIN COPY_USER_GENERATION;
}
<COPY_BOUND_CHECKING_FUNCTION><<EOF>> {bGenerationFunction=0; // No Generation function was found in the .ez file
if (bVERBOSE) printf("*** No bound checking function was found. ***\n");
fprintf(fpOutputFile,"\n// No Bound checking function.\n");
rewind(fpGenomeFile);
yyin = fpTemplateFile;
BEGIN TEMPLATE_ANALYSIS;
bNotFinishedYet=1;
}
<COPY_BOUND_CHECKING_FUNCTION>.|\n {}
<ANALYSE_USER_CLASSES>"\\User"[ \t\n]+"classes"[ \t\n]*":" {
BEGIN GENOME_ANALYSIS; return CLASSES;}
<ANALYSE_USER_CLASSES>.|\n {}
...
...
tpl/STD.tpl
View file @
4b16bc6c
...
...
@@ -79,6 +79,7 @@ extern RandomGenerator* globalRandomGenerator;
\INSERT_INITIALISATION_FUNCTION
\INSERT_FINALIZATION_FUNCTION
\INSERT_GENERATION_FUNCTION
\INSERT_BOUND_CHECKING
void EASEAFinal(Population* pop){
\INSERT_FINALIZATION_FCT_CALL
...
...
@@ -252,17 +253,6 @@ 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); */
/* //ia >> *population; */
/* population->syncInVector(); */
/* //ia >> *population; */
/* } */
std::cout
<
<
"
Parent
'
s
population
initializing
"<<
std::endl
;
this-
>
population->initializeParentPopulation();
...
...
@@ -274,6 +264,7 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
while
(
this-
>
allCriteria() == false ){
population->produceOffspringPopulation();
\INSERT_BOUND_CHECKING_FCT_CALL
population->evaluateOffspringPopulation();
if(reduceParents)
...
...
@@ -293,14 +284,6 @@ void EvolutionaryAlgorithm::runEvolutionaryLoop(){
//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
;
*
/
/
*
}
*
/
}
...
...
@@ -333,8 +316,9 @@ void EvolutionaryAlgorithm::showPopulationStats(struct timeval beginTime){
//Affichage
if(currentGeneration==0)
printf("GEN\tTIME\tEVAL\tBEST\t\tAVG\t\tSTDEV\n\n");
printf("GEN\tTIME\t
\t
EVAL\tBEST\t\tAVG\t\tSTDEV\n\n");
assert( currentSTDEV == currentSTDEV );
struct timeval end, res;
gettimeofday(
&end,0);
...
...
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