Commit eb546cbc authored by moh_lo's avatar moh_lo
Browse files

Almost ready version

with working weierstrass algorithm
parent eb43e1e1
......@@ -25,7 +25,7 @@ class CSymbolTable;
%start COPY_EO_INITIALISER
%start COPY COPY_INITIALISER COPY_CROSSOVER COPY_MUTATOR COPY_EVALUATOR
%start COPY_DISPLAY COPY_USER_FUNCTION COPY_USER_GENERATION PARAMETERS_ANALYSIS GET_PARAMETERS
%start COPY_USER_FUNCTIONS COPY_GENERATION_FUNCTION
%start COPY_USER_FUNCTIONS COPY_GENERATION_FUNCTION COPY_USER_FUNCTIONS_PROTO
// lexical analyser name and class definition
%name CEASEALexer {
......@@ -78,7 +78,8 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
char sFileName[1000];
strcpy(sFileName, sRAW_PROJECT_NAME);
switch (TARGET) {
case DREAM : strcat(sFileName,".java"); break;
case DREAM : strcat(sFileName,".java"); break;
case GPU : strcat(sFileName,".cu"); break;
default : strcat(sFileName,".cpp");
}
fpOutputFile=fopen(sFileName,"w");
......@@ -118,6 +119,12 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN ANALYSE_USER_CLASSES;
}
<TEMPLATE_ANALYSIS>"\\ANALYSE_ENV" {
if (bVERBOSE) printf ("Analysing evironement variables.\n");
}
<TEMPLATE_ANALYSIS>"\\INSERT_USER_CLASSES" {
if (bVERBOSE) printf ("Inserting User classes.\n");
if (TARGET!=DREAM) fprintf (fpOutputFile,"// User classes\n");
......@@ -127,6 +134,31 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
if ((pSym->Object->pType->ObjectType==oUserClass)&&(!pSym->Object->pType->bAlreadyPrinted))
pSym->Object->pType->printClasses(fpOutputFile);
}
<TEMPLATE_ANALYSIS>"\\INSERT_USER_CLASSES_HDR" {
if (bVERBOSE) printf ("Inserting User header classes.\n");
if (TARGET!=DREAM) fprintf (fpOutputFile,"// User classes header\n");
CListItem<CSymbol*> *pSym;
pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem())
if ((pSym->Object->pType->ObjectType==oUserClass)&&(!pSym->Object->pType->bAlreadyPrinted))
pSym->Object->pType->printClassesHdr(fpOutputFile);
}
<TEMPLATE_ANALYSIS>"\\INSERT_USER_CLASSES_CODE" {
if (bVERBOSE) printf ("Inserting User code classes.\n");
if (TARGET!=DREAM) fprintf (fpOutputFile,"// User classes Code\n");
CListItem<CSymbol*> *pSym;
pGENOME->pSymbolList->reset();
reInitAlreadyPtedBit(pGENOME->pSymbolList);
pGENOME->bAlreadyPrinted = false;
pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem())
if ((pSym->Object->pType->ObjectType==oUserClass)&&(!pSym->Object->pType->bAlreadyPrinted)){
pSym->Object->pType->printClassesCode(fpOutputFile);
}
}
<TEMPLATE_ANALYSIS>"\\GENOME_CTOR" {
CListItem<CSymbol*> *pSym;
if (bVERBOSE) printf ("Inserting default genome constructor.\n");
......@@ -245,6 +277,10 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
else fprintf(fpOutputFile," if (%s) delete %s;\n %s=NULL;\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->sName);
}
}
<TEMPLATE_ANALYSIS>"\\ENV_SHM" {
fprintf(stdout,"here takes place the environement variables analysis\n");
}
<TEMPLATE_ANALYSIS>"\\EQUAL" {
CListItem<CSymbol*> *pSym;
if (bVERBOSE) printf ("Creating default diversity test.\n");
......@@ -374,6 +410,15 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_USER_FUNCTIONS;
}
<TEMPLATE_ANALYSIS>"\\INSERT_USER_FUNCTIONS_PROTO" {
if (bVERBOSE) printf ("Inserting user functions prototype.\n");
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_USER_FUNCTIONS_PROTO;
}
<TEMPLATE_ANALYSIS>"\\INSERT_EO_INITIALISER" {
yyreset();
bWithinEO_Function=1;
......@@ -405,6 +450,10 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
}
<TEMPLATE_ANALYSIS>"\\INSERT_EVALUATOR" {
yyreset();
if( TARGET == GPU ){
bWithinGPU_Function = true;
//bWithinGPUEval = true;
}
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_EVALUATOR;
}
......@@ -421,7 +470,12 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
}
<TEMPLATE_ANALYSIS>"\\SELECTOR" {fprintf(fpOutputFile,"%s",sSELECTOR);}
//<TEMPLATE_ANALYSIS>"\\GEN_SELECTOR" {fprintf(fpOutputFile,"%s(%s,%d)",sGEN_SELECTOR);}
<TEMPLATE_ANALYSIS>"\\SELECT_PRM" {fprintf(fpOutputFile,"%s",sSELECT_PRM);}
<TEMPLATE_ANALYSIS>"\\SELECT_PRM" {
if(bVERBOSE){
fprintf(stdout,"SELECT_PRM : %s",sSELECT_PRM);
}
fprintf(fpOutputFile,"%s",sSELECT_PRM);
}
<TEMPLATE_ANALYSIS>"\\POP_SIZE" {fprintf(fpOutputFile,"%d",nPOP_SIZE);}
<TEMPLATE_ANALYSIS>"\\OFF_SIZE" {fprintf(fpOutputFile,"%d",nOFF_SIZE);}
<TEMPLATE_ANALYSIS>"\\ELITE_SIZE" {fprintf(fpOutputFile,"%d",nELITE);}
......@@ -446,10 +500,14 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
<TEMPLATE_ANALYSIS>"\\STEADYSTATE" {if ((fREPL_PERC==0)||(!strcmp(sREPLACEMENT,"Incremental"))||(!strcmp(sREPLACEMENT,"Simple")))
fprintf(fpOutputFile,"// undefined ");}
<TEMPLATE_ANALYSIS>"\\COMMENT" {if (mystricmp(sREPLACEMENT,"SSGA")) fprintf(fpOutputFile,"//");}
<TEMPLATE_ANALYSIS>"\\MINIMAXI" {switch (TARGET) { case GALIB : fprintf(fpOutputFile,"%d",nMINIMISE? -1:1); break;
case EO : fprintf(fpOutputFile,"%s",nMINIMISE? "eoMinimizingFitness" : "eoMaximizingFitness"); break;
case DREAM : fprintf(fpOutputFile,"%s",nMINIMISE? "false" : "true"); break;
} }
<TEMPLATE_ANALYSIS>"\\MINIMAXI" {
switch (TARGET) {
case GALIB : fprintf(fpOutputFile,"%d",nMINIMISE? -1:1); break;
case EO : fprintf(fpOutputFile,"%s",nMINIMISE? "eoMinimizingFitness" : "eoMaximizingFitness"); break;
case DREAM : fprintf(fpOutputFile,"%s",nMINIMISE? "false" : "true"); break;
case GPU : fprintf(fpOutputFile,"%s",nMINIMISE? "false" : "true"); break;
}
}
<TEMPLATE_ANALYSIS>"\\ELITIST_REPLACE_NAME" {if (TARGET==EO) {if (bELITISM) fprintf(fpOutputFile,"standardR");
else fprintf(fpOutputFile,"r");}}
<TEMPLATE_ANALYSIS>"\\ELITISM" {switch (TARGET) { case GALIB : if (!mystricmp(sREPLACEMENT,"simple"))
......@@ -516,6 +574,15 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
if (bVERBOSE) printf("Creating %s...\n",sFileName);
}
<TEMPLATE_ANALYSIS>"\\START_USER_FUN_C_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
strcat(sFileName,"UserFunc.cpp");
fpOutputFile=fopen(sFileName,"w");
if (bVERBOSE) printf("Creating %s...\n",sFileName);
}
<TEMPLATE_ANALYSIS>"\\START_EO_GENOME_H_TPL" {
char sFileName[1000];
......@@ -713,6 +780,7 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
fprintf (fpOutputFile,"// User functions\n\n");
BEGIN COPY;
}
<COPY_USER_FUNCTIONS><<EOF>> {
if (bVERBOSE) printf("*** No user functions were found. ***\n");
fprintf(fpOutputFile,"\n// No user functions.\n");
......@@ -720,9 +788,28 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
yyin = fpTemplateFile;
BEGIN TEMPLATE_ANALYSIS;
bNotFinishedYet=1;
}
}
<COPY_USER_FUNCTIONS>.|\n {}
<COPY_USER_FUNCTIONS_PROTO>"\\User"[ \t\n]+"functions"[ \t\n]+"proto"[ \t\n]*":" {
fprintf (fpOutputFile,"// User functions proto\n\n");
BEGIN COPY;
}
<COPY_USER_FUNCTIONS_PROTO><<EOF>> {
if (bVERBOSE) printf("*** No user functions were found. ***\n");
fprintf(fpOutputFile,"\n// No user functions.\n");
rewind(fpGenomeFile);
yyin = fpTemplateFile;
BEGIN TEMPLATE_ANALYSIS;
bNotFinishedYet=1;
}
<COPY_USER_FUNCTIONS_PROTO>.|\n {}
<COPY_INITIALISATION_FUNCTION>"\\Initialisation"[ \t\n]+"function"[ \t\n]*":" {
if (TARGET==DREAM)
fprintf (fpOutputFile,"// Evaluator Constructor\n\n public %sEvaluator(){",sPROJECT_NAME);
......@@ -763,6 +850,11 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
BEGIN GENOME_ANALYSIS; return CLASSES;}
<ANALYSE_USER_CLASSES>.|\n {}
<ANALYSE_ENV>"\\User"[ \t\n]+"evaluator"[ \t\n]+"env"[ \t\n]*:{
BEGIN GENOME_ANALYSIS; return CLASSES;}
<ANALYSE_ENV>.|\n {}
//****************************************
// Basic copy to cpp file with minor changes
//****************************************
......@@ -936,6 +1028,7 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
<COPY_CROSSOVER>.|\n {}
<COPY_MUTATOR>"\\GenomeClass::mutator"[ \t\n]*":" {
bWithinMutator=1;
if(TARGET == GPU) bWithinGPU_Function = true;
BEGIN COPY_USER_FUNCTION;
return USER_MUTATOR;
}
......@@ -1117,14 +1210,15 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
<COPY_USER_FUNCTION>^[ \t]*\/\*[^\*]*\*\/[ \t]*\n {fprintf(fpOutputFile,yytext);} /* blah blah with nothing before the comment */
<COPY_USER_FUNCTION>"GenomeClass" {if (TARGET==EO) fprintf(fpOutputFile, "GenotypeT");
else fprintf(fpOutputFile,"Genome.");
}
else fprintf(fpOutputFile,"Genome.");
}
<COPY_USER_FUNCTION>"Genome" {
if (bWithinDisplayFunction && TARGET!=GPU) fprintf(fpOutputFile,"(*this)");
else if ((TARGET==EO)&&(bWithinInitialiser)) fprintf(fpOutputFile, "(*genome)");
else if ((TARGET==EO)&&(bWithinMutator)) fprintf(fpOutputFile, "_genotype");
else if (TARGET==GPU && bWithinGPUEval) fprintf(fpOutputFile,"(*genome)");
else fprintf(fpOutputFile,"genome");
else if (TARGET==GPU && bWithinEvaluator) fprintf(fpOutputFile,"(*genome)");
else fprintf(fpOutputFile,"genome");
} // local genome name
<COPY_USER_FUNCTION>"\"" {(bDoubleQuotes ? bDoubleQuotes=0:bDoubleQuotes=1); fprintf(fpOutputFile,"\"");}
<COPY_USER_FUNCTION>"\\\"" {fprintf(fpOutputFile,"\\\"");}
......
......@@ -485,307 +485,330 @@ RunParameters
;
Parameter
: NB_GEN NUMBER2
{nNB_GEN=(int)$2;}
| NB_ISLANDS NUMBER2
{nNB_ISLANDS=(int)$2;}
| PROP_SEQ IDENTIFIER2{
if (!mystricmp($2->sName,"proportionally")) bPROP_SEQ=true;
else if (!mystricmp($2->sName,"sequentially")) bPROP_SEQ=false;
: NB_GEN NUMBER2
{nNB_GEN=(int)$2;}
| NB_ISLANDS NUMBER2
{nNB_ISLANDS=(int)$2;}
| PROP_SEQ IDENTIFIER2{
if (!mystricmp($2->sName,"proportionally")) bPROP_SEQ=true;
else if (!mystricmp($2->sName,"sequentially")) bPROP_SEQ=false;
else {
fprintf(stderr,"\n%s - Error line %d: Looking for \"Proportionally\" or \"Sequentially\".\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
} }
| MUT_PROB NUMBER2
{
fMUT_PROB=(float)$2;
printf("mut prob %f\n",(float)$2);
}
| XOVER_PROB NUMBER2
{
fXOVER_PROB=(float)$2;
printf("xover prob %f\n",(float)$2);
}
| POP_SIZE NUMBER2
{nPOP_SIZE=(int)$2;}
| SELECTOR IDENTIFIER2{
strcpy(sSELECTOR, $2->sName);
switch (TARGET) {
case DREAM : if (!mystricmp(sSELECTOR,"EPTrn")){
fprintf(stderr,"\n%s - Error line %d: The EP-Tournament selector is not implemented in DREAM.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else if (!mystricmp(sSELECTOR,"Tournament")) sprintf(sSELECTOR,"TournamentSelector(MAX, 1, 2)");
else if (!mystricmp(sSELECTOR,"StochTrn")) {
fprintf(stderr,"\n%s - Warning line %d: The Stochatic Tournament selector needs a parameter in [0.5,1].\nDefault value 1 inserted",
sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
sprintf(sSELECTOR,"TournamentSelector(MAX, 1, 2)");
}
else if (!mystricmp(sSELECTOR,"RouletteWheel")) sprintf(sSELECTOR,"RouletteWheelSelector(MAX)");
else if (!mystricmp(sSELECTOR,"Random")) sprintf(sSELECTOR,"RandomSelector()");
else if (!mystricmp(sSELECTOR,"Sequential")) sprintf(sSELECTOR,"BestNSelector(MAX,%d)",nPOP_SIZE);
else if (!mystricmp(sSELECTOR,"Ranking")) sprintf(sSELECTOR,"RankingSelector(MAX)");
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sSELECTOR);
exit(1);
}
break;
case GALIB : if (!mystricmp(sSELECTOR,"Ranking")){
fprintf(stderr,"\n%s - Error line %d: The Ranking selector is not implemented in GALib.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else if (!mystricmp(sSELECTOR,"Tournament")) sprintf(sSELECTOR,"Tournament");
else if (!mystricmp(sSELECTOR,"StochTrn")) sprintf(sSELECTOR,"TournamentSelector(true, 1, 2)");
else if (!mystricmp(sSELECTOR,"RouletteWheel")) sprintf(sSELECTOR,"RouletteWheel");
else if (!mystricmp(sSELECTOR,"Random")) sprintf(sSELECTOR,"Uniform");
else if (!mystricmp(sSELECTOR,"Sequential")) sprintf(sSELECTOR,"Rank");
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sSELECTOR);
exit(1);
}
break;
case GPU :
case EO :
if (!mystricmp(sSELECTOR,"RouletteWheel")){
if (nMINIMISE==1) {
fprintf(stderr,"\n%s - Error line %d: The RouletteWheel selection scheme cannot be\n selected when \"minimising the fitness\" is the evaluator goal.\n",
sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else sprintf(sSELECTOR,"Roulette");
}
else if (!mystricmp(sSELECTOR,"Tournament")) sprintf(sSELECTOR,"DetTour");
else if (!mystricmp(sSELECTOR,"StochTrn")) sprintf(sSELECTOR,"StochTour");
else if (!mystricmp(sSELECTOR,"Random")) sprintf(sSELECTOR,"Random");
else if (!mystricmp(sSELECTOR,"Ranking")) sprintf(sSELECTOR,"Ranking");
else if (!mystricmp(sSELECTOR,"Sequential")) sprintf(sSELECTOR,"Sequential");
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist in EO.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sSELECTOR);
exit(1);
}
}
}
| SELECTOR IDENTIFIER2 NUMBER2 {
sprintf(sSELECTOR, $2->sName);
switch (TARGET) {
case DREAM : if (!mystricmp(sSELECTOR,"EPTrn")){
fprintf(stderr,"\n%s - Error line %d: The EP-Tournament selector is not implemented in DREAM.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else if (!mystricmp(sSELECTOR,"Tournament")) {
if ($3>=2) sprintf(sSELECTOR,"TournamentSelector(MAX, 1, %d)",(int)$3);
else if (($3>.5)&&($3<=1.0)) sprintf(sSELECTOR,"TournamentSelector(MAX, %f, 2)",(float)$3);
else {fprintf(stderr,"\n%s - Error line %d: The parameter of the Tournament selector must be either >=2 or within ]0.5, 1].\n",sEZ_FILE_NAME,EASEALexer.yylineno); exit(1);}
}
else if (!mystricmp(sSELECTOR,"StochTrn")) {
if (($3>.5)&&($3<=1.0)) sprintf(sSELECTOR,"TournamentSelector(MAX, %f, 2)",(float)$3);
else {fprintf(stderr,"\n%s - Error line %d: The parameter of the Tournament selector must be either >=2 or within ]0.5, 1].\n",sEZ_FILE_NAME,EASEALexer.yylineno); exit(1);}
}
else if (!mystricmp(sSELECTOR,"RouletteWheel")) sprintf(sSELECTOR,"RouletteWheelSelector(MAX)");
else if (!mystricmp(sSELECTOR,"Random")) sprintf(sSELECTOR,"RandomSelector()");
else if (!mystricmp(sSELECTOR,"Sequential")) sprintf(sSELECTOR,"BestNSelector(MAX,%d)",nPOP_SIZE);
else if (!mystricmp(sSELECTOR,"Ranking")) sprintf(sSELECTOR,"RankingSelector(MAX)");
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sSELECTOR);
exit(1);
}
break;
case GALIB : fprintf(stderr,"\n%s - Warning line %d: No GALib selector takes parameters yet. The parameter will be ignored.\n",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
if (!mystricmp(sSELECTOR,"Ranking")) sprintf(sSELECTOR,"Rank");
else if (!mystricmp(sSELECTOR,"Tournament")) sprintf(sSELECTOR,"Tournament");
else if (!mystricmp(sSELECTOR,"StochTrn")) sprintf(sSELECTOR,"TournamentSelector(true, 1, 2)");
else if (!mystricmp(sSELECTOR,"RouletteWheel")) sprintf(sSELECTOR,"RouletteWheel");
else if (!mystricmp(sSELECTOR,"Random")) sprintf(sSELECTOR,"Uniform");
else if (!mystricmp(sSELECTOR,"Sequential")){
fprintf(stderr,"\n%s - Error line %d: The Sequential selector does not exist under GALib.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sSELECTOR);
exit(1);
}
break;
case GPU :
case EO : if (!mystricmp(sSELECTOR,"Tournament")||!mystricmp(sSELECTOR,"StochTrn")) {
if ($3>=2) {sprintf(sSELECTOR,"DetTour");sprintf(sSELECT_PRM,"(%d)",(int) $3);}
else if (($3>.5)&&($3<=1.0)) {sprintf(sSELECTOR,"StochTour");sprintf(sSELECT_PRM,"(%f)",(float) $3);}
else {fprintf(stderr,"\n%s - Error line %d: The parameter of the Tournament selector must be either >=2 or within ]0.5, 1].\n",sEZ_FILE_NAME,EASEALexer.yylineno); exit(1);}
}
else if (!mystricmp(sSELECTOR,"RouletteWheel")) {
sprintf(sSELECTOR,"Roulette");
if ($3<1) {fprintf(stderr,"\n%s - Warning line %d: The parameter of RouletteWheel must be greater than one.\nThe parameter will therefore be ignored.",
sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;}
else sprintf(sSELECT_PRM,"(%f)",(float) $3);
}
else if (!mystricmp(sSELECTOR,"Random")) {
sprintf(sSELECTOR,"Random");
fprintf(stderr,"\n%s - Warning line %d: The Uniform selector does not (yet) take any parameter in EO.\nThe parameter will therefore be ignored.",
sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
}
else if (!mystricmp(sSELECTOR,"Ranking")) {
sprintf(sSELECTOR,"Ranking");
if (($3<=1)||($3>2)) {
fprintf(stderr,"\n%s - Warning line %d: The parameter of Ranking must be in (1,2].\nThe parameter will default to 2.",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
sprintf(sSELECT_PRM,"(2)");
}
else sprintf(sSELECT_PRM,"(%f)",(float) $3);
}
else if (!mystricmp(sSELECTOR,"Sequential")) {
sprintf(sSELECTOR,"Sequential");
if ($3==0) sprintf(sSELECT_PRM,"(unordered)");
else if ($3==1) sprintf(sSELECT_PRM,"(ordered)");
else {
fprintf(stderr,"\n%s - Error line %d: Looking for \"Proportionally\" or \"Sequentially\".\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
} }
| MUT_PROB NUMBER2
{fMUT_PROB=(float)$2;}
| XOVER_PROB NUMBER2
{fXOVER_PROB=(float)$2;}
| POP_SIZE NUMBER2
{nPOP_SIZE=(int)$2;}
| SELECTOR IDENTIFIER2{
strcpy(sSELECTOR, $2->sName);
switch (TARGET) {
case DREAM : if (!mystricmp(sSELECTOR,"EPTrn")){
fprintf(stderr,"\n%s - Error line %d: The EP-Tournament selector is not implemented in DREAM.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else if (!mystricmp(sSELECTOR,"Tournament")) sprintf(sSELECTOR,"TournamentSelector(MAX, 1, 2)");
else if (!mystricmp(sSELECTOR,"StochTrn")) {
fprintf(stderr,"\n%s - Warning line %d: The Stochatic Tournament selector needs a parameter in [0.5,1].\nDefault value 1 inserted",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
sprintf(sSELECTOR,"TournamentSelector(MAX, 1, 2)");
}
else if (!mystricmp(sSELECTOR,"RouletteWheel")) sprintf(sSELECTOR,"RouletteWheelSelector(MAX)");
else if (!mystricmp(sSELECTOR,"Random")) sprintf(sSELECTOR,"RandomSelector()");
else if (!mystricmp(sSELECTOR,"Sequential")) sprintf(sSELECTOR,"BestNSelector(MAX,%d)",nPOP_SIZE);
else if (!mystricmp(sSELECTOR,"Ranking")) sprintf(sSELECTOR,"RankingSelector(MAX)");
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sSELECTOR);
exit(1);
}
break;
case GALIB : if (!mystricmp(sSELECTOR,"Ranking")){
fprintf(stderr,"\n%s - Error line %d: The Ranking selector is not implemented in GALib.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else if (!mystricmp(sSELECTOR,"Tournament")) sprintf(sSELECTOR,"Tournament");
else if (!mystricmp(sSELECTOR,"StochTrn")) sprintf(sSELECTOR,"TournamentSelector(true, 1, 2)");
else if (!mystricmp(sSELECTOR,"RouletteWheel")) sprintf(sSELECTOR,"RouletteWheel");
else if (!mystricmp(sSELECTOR,"Random")) sprintf(sSELECTOR,"Uniform");
else if (!mystricmp(sSELECTOR,"Sequential")) sprintf(sSELECTOR,"Rank");
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sSELECTOR);
exit(1);
}
break;
case EO : if (!mystricmp(sSELECTOR,"RouletteWheel")){
if (nMINIMISE==1) {
fprintf(stderr,"\n%s - Error line %d: The RouletteWheel selection scheme cannot be\n selected when \"minimising the fitness\" is the evaluator goal.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else sprintf(sSELECTOR,"Roulette");
}
else if (!mystricmp(sSELECTOR,"Tournament")) sprintf(sSELECTOR,"DetTour");
else if (!mystricmp(sSELECTOR,"StochTrn")) sprintf(sSELECTOR,"StochTour");
else if (!mystricmp(sSELECTOR,"Random")) sprintf(sSELECTOR,"Random");
else if (!mystricmp(sSELECTOR,"Ranking")) sprintf(sSELECTOR,"Ranking");
else if (!mystricmp(sSELECTOR,"Sequential")) sprintf(sSELECTOR,"Sequential");
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist in EO.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sSELECTOR);
exit(1);
}
fprintf(stderr,"\n%s - Warning line %d: The parameter of Sequential must be either 0 (unordered) or 1 (ordered).\nThe parameter will default to 1.",
sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
sprintf(sSELECT_PRM,"(ordered)");
}
}
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sSELECTOR);
exit(1);
}
}}
| RED_PAR IDENTIFIER2{
sprintf(sRED_PAR, $2->sName);
switch (TARGET) {
case DREAM :
if (!mystricmp(sRED_PAR,"EPTrn")){
fprintf(stderr,"\n%s - Error line %d: The EP-Tournament selector is not implemented in DREAM.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else if (!mystricmp(sRED_PAR,"Tournament")) sprintf(sRED_PAR,"TournamentSelector(MAX, 1, 2)");
else if (!mystricmp(sRED_PAR,"StochTrn")) {
fprintf(stderr,"\n%s - Warning line %d: The Stochatic Tournament selector needs a parameter in [0.5,1].\nDefault value 1 inserted",
sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
sprintf(sRED_PAR,"TournamentSelector(MAX, 1, 2)");
}
else if (!mystricmp(sRED_PAR,"RouletteWheel")) sprintf(sRED_PAR,"RouletteWheelSelector(MAX)");
else if (!mystricmp(sRED_PAR,"Random")) sprintf(sRED_PAR,"RandomSelector()");
else if (!mystricmp(sRED_PAR,"Sequential")) sprintf(sRED_PAR,"BestNSelector(MAX,%d)",nPOP_SIZE);
else if (!mystricmp(sRED_PAR,"Ranking")) sprintf(sRED_PAR,"RankingSelector(MAX)");
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sRED_PAR);
exit(1);
}
break;
case EO : if (!mystricmp(sRED_PAR,"RouletteWheel")){
if (nMINIMISE==1) {
fprintf(stderr,"\n%s - Error line %d: The RouletteWheel selection scheme cannot be\n selected when \"minimising the fitness\" is the evaluator goal.\n",
sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
| SELECTOR IDENTIFIER2 NUMBER2 {
sprintf(sSELECTOR, $2->sName);
switch (TARGET) {
case DREAM : if (!mystricmp(sSELECTOR,"EPTrn")){
fprintf(stderr,"\n%s - Error line %d: The EP-Tournament selector is not implemented in DREAM.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else if (!mystricmp(sSELECTOR,"Tournament")) {
if ($3>=2) sprintf(sSELECTOR,"TournamentSelector(MAX, 1, %d)",(int)$3);
else if (($3>.5)&&($3<=1.0)) sprintf(sSELECTOR,"TournamentSelector(MAX, %f, 2)",(float)$3);
else {fprintf(stderr,"\n%s - Error line %d: The parameter of the Tournament selector must be either >=2 or within ]0.5, 1].\n",sEZ_FILE_NAME,EASEALexer.yylineno); exit(1);}
}
else if (!mystricmp(sSELECTOR,"StochTrn")) {
if (($3>.5)&&($3<=1.0)) sprintf(sSELECTOR,"TournamentSelector(MAX, %f, 2)",(float)$3);
else {fprintf(stderr,"\n%s - Error line %d: The parameter of the Tournament selector must be either >=2 or within ]0.5, 1].\n",sEZ_FILE_NAME,EASEALexer.yylineno); exit(1);}
}
else if (!mystricmp(sSELECTOR,"RouletteWheel")) sprintf(sSELECTOR,"RouletteWheelSelector(MAX)");
else if (!mystricmp(sSELECTOR,"Random")) sprintf(sSELECTOR,"RandomSelector()");
else if (!mystricmp(sSELECTOR,"Sequential")) sprintf(sSELECTOR,"BestNSelector(MAX,%d)",nPOP_SIZE);
else if (!mystricmp(sSELECTOR,"Ranking")) sprintf(sSELECTOR,"RankingSelector(MAX)");
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sSELECTOR);
exit(1);
}
break;
case GALIB : fprintf(stderr,"\n%s - Warning line %d: No GALib selector takes parameters yet. The parameter will be ignored.\n",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
if (!mystricmp(sSELECTOR,"Ranking")) sprintf(sSELECTOR,"Rank");
else if (!mystricmp(sSELECTOR,"Tournament")) sprintf(sSELECTOR,"Tournament");
else if (!mystricmp(sSELECTOR,"StochTrn")) sprintf(sSELECTOR,"TournamentSelector(true, 1, 2)");
else if (!mystricmp(sSELECTOR,"RouletteWheel")) sprintf(sSELECTOR,"RouletteWheel");
else if (!mystricmp(sSELECTOR,"Random")) sprintf(sSELECTOR,"Uniform");
else if (!mystricmp(sSELECTOR,"Sequential")){
fprintf(stderr,"\n%s - Error line %d: The Sequential selector does not exist under GALib.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sSELECTOR);
exit(1);
}
break;
case EO : if (!mystricmp(sSELECTOR,"Tournament")||!mystricmp(sSELECTOR,"StochTrn")) {
if ($3>=2) {sprintf(sSELECTOR,"DetTour");sprintf(sSELECT_PRM,"(%d)",(int) $3);}
else if (($3>.5)&&($3<=1.0)) {sprintf(sSELECTOR,"StochTour");sprintf(sSELECT_PRM,"(%f)",(float) $3);}
else {fprintf(stderr,"\n%s - Error line %d: The parameter of the Tournament selector must be either >=2 or within ]0.5, 1].\n",sEZ_FILE_NAME,EASEALexer.yylineno); exit(1);}
}
else if (!mystricmp(sSELECTOR,"RouletteWheel")) {
sprintf(sSELECTOR,"Roulette");
if ($3<1) {fprintf(stderr,"\n%s - Warning line %d: The parameter of RouletteWheel must be greater than one.\nThe parameter will therefore be ignored.",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;}
else sprintf(sSELECT_PRM,"(%f)",(float) $3);
}
else if (!mystricmp(sSELECTOR,"Random")) {
sprintf(sSELECTOR,"Random");
fprintf(stderr,"\n%s - Warning line %d: The Uniform selector does not (yet) take any parameter in EO.\nThe parameter will therefore be ignored.",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
}
else if (!mystricmp(sSELECTOR,"Ranking")) {
sprintf(sSELECTOR,"Ranking");
if (($3<=1)||($3>2)) {
fprintf(stderr,"\n%s - Warning line %d: The parameter of Ranking must be in (1,2].\nThe parameter will default to 2.",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
sprintf(sSELECT_PRM,"(2)");
}
else sprintf(sSELECT_PRM,"(%f)",(float) $3);
}
else if (!mystricmp(sSELECTOR,"Sequential")) {
sprintf(sSELECTOR,"Sequential");
if ($3==0) sprintf(sSELECT_PRM,"(unordered)");
else if ($3==1) sprintf(sSELECT_PRM,"(ordered)");
else {
fprintf(stderr,"\n%s - Warning line %d: The parameter of Sequential must be either 0 (unordered) or 1 (ordered).\nThe parameter will default to 1.",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
sprintf(sSELECT_PRM,"(ordered)");
}
}
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sSELECTOR);
exit(1);
}
}}
| RED_PAR IDENTIFIER2{
sprintf(sRED_PAR, $2->sName);
switch (TARGET) {
case DREAM :
if (!mystricmp(sRED_PAR,"EPTrn")){
fprintf(stderr,"\n%s - Error line %d: The EP-Tournament selector is not implemented in DREAM.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else if (!mystricmp(sRED_PAR,"Tournament")) sprintf(sRED_PAR,"TournamentSelector(MAX, 1, 2)");
else if (!mystricmp(sRED_PAR,"StochTrn")) {
fprintf(stderr,"\n%s - Warning line %d: The Stochatic Tournament selector needs a parameter in [0.5,1].\nDefault value 1 inserted",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
sprintf(sRED_PAR,"TournamentSelector(MAX, 1, 2)");
}
else if (!mystricmp(sRED_PAR,"RouletteWheel")) sprintf(sRED_PAR,"RouletteWheelSelector(MAX)");
else if (!mystricmp(sRED_PAR,"Random")) sprintf(sRED_PAR,"RandomSelector()");
else if (!mystricmp(sRED_PAR,"Sequential")) sprintf(sRED_PAR,"BestNSelector(MAX,%d)",nPOP_SIZE);
else if (!mystricmp(sRED_PAR,"Ranking")) sprintf(sRED_PAR,"RankingSelector(MAX)");
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sRED_PAR);
exit(1);
}
break;
case EO : if (!mystricmp(sRED_PAR,"RouletteWheel")){
if (nMINIMISE==1) {
fprintf(stderr,"\n%s - Error line %d: The RouletteWheel selection scheme cannot be\n selected when \"minimising the fitness\" is the evaluator goal.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else sprintf(sRED_PAR,"Roulette");
}
else if (!mystricmp(sRED_PAR,"Tournament")) sprintf(sRED_PAR,"DetTour");
else if (!mystricmp(sRED_PAR,"StochTrn")) sprintf(sRED_PAR,"StochTour");
else if (!mystricmp(sRED_PAR,"Random")) sprintf(sRED_PAR,"Random");
else if (!mystricmp(sRED_PAR,"Ranking")) sprintf(sRED_PAR,"Ranking");
else if (!mystricmp(sRED_PAR,"Sequential")) sprintf(sRED_PAR,"Sequential");
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist in EO.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sRED_PAR);
exit(1);
}
}
}
| RED_PAR IDENTIFIER2 NUMBER2 {
sprintf(sRED_PAR, $2->sName);
switch (TARGET) {
case DREAM : if (!mystricmp(sRED_PAR,"EPTrn")){
fprintf(stderr,"\n%s - Error line %d: The EP-Tournament selector is not implemented in DREAM.\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(1);
}
else if (!mystricmp(sRED_PAR,"Tournament")) {
if ($3>=2) sprintf(sRED_PAR,"TournamentSelector(MAX, 1, %d)",(int)$3);
else if (($3>.5)&&($3<=1.0)) sprintf(sRED_PAR,"TournamentSelector(MAX, %f, 2)",(float)$3);
else {fprintf(stderr,"\n%s - Error line %d: The parameter of the Tournament selector must be either >=2 or within ]0.5, 1].\n",sEZ_FILE_NAME,EASEALexer.yylineno); exit(1);}
}
else if (!mystricmp(sRED_PAR,"StochTrn")) {
if (($3>.5)&&($3<=1.0)) sprintf(sRED_PAR,"TournamentSelector(MAX, %f, 2)",(float)$3);
else {fprintf(stderr,"\n%s - Error line %d: The parameter of the Tournament selector must be either >=2 or within ]0.5, 1].\n",sEZ_FILE_NAME,EASEALexer.yylineno); exit(1);}
}
else if (!mystricmp(sRED_PAR,"RouletteWheel")) sprintf(sRED_PAR,"RouletteWheelSelector(MAX)");
else if (!mystricmp(sRED_PAR,"Random")) sprintf(sRED_PAR,"RandomSelector()");
else if (!mystricmp(sRED_PAR,"Sequential")) sprintf(sRED_PAR,"BestNSelector(MAX,%d)",nPOP_SIZE);
else if (!mystricmp(sRED_PAR,"Ranking")) sprintf(sRED_PAR,"RankingSelector(MAX)");
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sRED_PAR);
exit(1);
}
break;
case EO : if (!mystricmp(sRED_PAR,"Tournament")||!mystricmp(sRED_PAR,"StochTrn")) {
if ($3>=2) {sprintf(sRED_PAR,"DetTour");sprintf(sRED_PAR_PRM,"(%d)",(int) $3);}
else if (($3>.5)&&($3<=1.0)) {sprintf(sRED_PAR,"StochTour");sprintf(sRED_PAR_PRM,"(%f)",(float) $3);}
else {fprintf(stderr,"\n%s - Error line %d: The parameter of the Tournament selector must be either >=2 or within ]0.5, 1].\n",sEZ_FILE_NAME,EASEALexer.yylineno); exit(1);}
}
else if (!mystricmp(sRED_PAR,"RouletteWheel")) {
sprintf(sRED_PAR,"Roulette");
if ($3<1) {fprintf(stderr,"\n%s - Warning line %d: The parameter of RouletteWheel must be greater than one.\nThe parameter will therefore be ignored.",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;}
else sprintf(sRED_PAR_PRM,"(%f)",(float) $3);
}
else if (!mystricmp(sRED_PAR,"Random")) {
sprintf(sRED_PAR,"Random");
fprintf(stderr,"\n%s - Warning line %d: The Uniform selector does not (yet) take any parameter in EO.\nThe parameter will therefore be ignored.",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
}
else if (!mystricmp(sRED_PAR,"Ranking")) {
sprintf(sRED_PAR,"Ranking");
if (($3<=1)||($3>2)) {
fprintf(stderr,"\n%s - Warning line %d: The parameter of Ranking must be in (1,2].\nThe parameter will default to 2.",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
sprintf(sRED_PAR_PRM,"(2)");
}
else sprintf(sRED_PAR_PRM,"(%f)",(float) $3);
}
else if (!mystricmp(sRED_PAR,"Sequential")) {
sprintf(sRED_PAR,"Sequential");
if ($3==0) sprintf(sRED_PAR_PRM,"(unordered)");
else if ($3==1) sprintf(sRED_PAR_PRM,"(ordered)");
else {
fprintf(stderr,"\n%s - Warning line %d: The parameter of Sequential must be either 0 (unordered) or 1 (ordered).\nThe parameter will default to 1.",sEZ_FILE_NAME,EASEALexer.yylineno);nWARNINGS++;
sprintf(sRED_PAR_PRM,"(ordered)");