Commit 4b16bc6c authored by maitre's avatar maitre

Bound checking

parent 727449d9
......@@ -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;
bBoundCheckingFunction = bWithinCUDA_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 {}
......
......@@ -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\tEVAL\tBEST\t\tAVG\t\tSTDEV\n\n");
assert( currentSTDEV == currentSTDEV );
struct timeval end, res;
gettimeofday(&end,0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment