Commit 4110cd42 authored by maitre's avatar maitre

Handle Makefile options from the ez file

parent 6a088d6d
......@@ -22,6 +22,7 @@ Centre de Math
#define EO 2
#define DREAM 3
#define CUDA 4
#define STD 5
#define UNIX 1
#define WINDOWS 2
#define UNKNOWN_OS 3
......
This diff is collapsed.
......@@ -92,6 +92,7 @@ class CSymbol;
%token USER_XOVER
%token USER_MUTATOR
%token USER_EVALUATOR
%token MAKEFILE_OPTION
%token END_OF_FUNCTION
//%token DELETE
%token <szString> END_METHODS
......@@ -467,7 +468,7 @@ StandardFunctionAnalysis
} }
END_OF_FUNCTION {
if (TARGET==DREAM) fprintf(fpOutputFile," }\n");
if( TARGET!=CUDA ) fprintf(fpOutputFile,"}");
if( TARGET!=CUDA && TARGET!=STD) fprintf(fpOutputFile,"}");
}
| USER_EVALUATOR {
if (bVERBOSE) printf("Inserting user genome evaluator (taken from .ez file).\n");
......@@ -485,8 +486,12 @@ StandardFunctionAnalysis
fprintf(fpOutputFile," EZ_NB_EVALUATIONS++;\n",sPROJECT_NAME);
} }
END_OF_FUNCTION {
if (TARGET!=EO && TARGET!=CUDA ) fprintf(fpOutputFile,"}\n");
if (TARGET!=EO && TARGET!=CUDA && TARGET!=STD) fprintf(fpOutputFile,"}\n");
}
| MAKEFILE_OPTION END_OF_FUNCTION {
DEBUG_PRT("User makefile options have been reduced");
}
| MAKEFILE_OPTION {}
;
RunParameters
......@@ -547,18 +552,28 @@ Parameter
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");
case CUDA:
case STD:
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");
if( TARGET==CUDA || TARGET==STD )
sprintf(sSELECT_PRM,"(0)");
}
else if (!mystricmp(sSELECTOR,"Ranking")) sprintf(sSELECTOR,"Ranking");
else if (!mystricmp(sSELECTOR,"Sequential")){
sprintf(sSELECTOR,"Sequential");
if( TARGET==CUDA || TARGET==STD) sprintf(sSELECT_PRM,"(0)");
}
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);
......@@ -606,6 +621,7 @@ Parameter
}
break;
case CUDA:
case STD:
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);}
......@@ -630,7 +646,12 @@ Parameter
}
else if (!mystricmp(sSELECTOR,"Sequential")) {
sprintf(sSELECTOR,"Sequential");
if ($3==0) sprintf(sSELECT_PRM,"(unordered)");
if ($3==0)
if( TARGET==CUDA || TARGET==STD )
sprintf(sSELECT_PRM,"(0)");
else
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++;
......@@ -708,6 +729,7 @@ Parameter
}
break;
case CUDA :
case STD:
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);}
......@@ -732,8 +754,13 @@ Parameter
}
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)");
if ($3==0)
if( TARGET==CUDA || TARGET==STD )
sprintf(sSELECT_PRM,"(0)");
else
sprintf(sSELECT_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)");
......@@ -831,7 +858,11 @@ Parameter
}
else if (!mystricmp(sRED_OFF,"Sequential")) {
sprintf(sRED_OFF,"Sequential");
if ($3==0) sprintf(sRED_OFF_PRM,"(unordered)");
if ($3==0) if( TARGET==CUDA || TARGET==STD )
sprintf(sSELECT_PRM,"(0)");
else
sprintf(sRED_OFF_PRM,"(unordered)");
else if ($3==1) sprintf(sRED_OFF_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++;
......@@ -864,6 +895,8 @@ Parameter
exit(1);
}
break;
case CUDA:
case STD:
case EO : if (!mystricmp(sRED_FINAL,"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);
......@@ -873,9 +906,16 @@ Parameter
}
else if (!mystricmp(sRED_FINAL,"Tournament")) sprintf(sRED_FINAL,"DetTour");
else if (!mystricmp(sRED_FINAL,"StochTrn")) sprintf(sRED_FINAL,"StochTour");
else if (!mystricmp(sRED_FINAL,"Random")) sprintf(sRED_FINAL,"Random");
else if (!mystricmp(sRED_FINAL,"Random")){
sprintf(sRED_FINAL,"Random");
if( TARGET==CUDA || TARGET==STD )
sprintf(sRED_FINAL_PRM,"(0)");
}
else if (!mystricmp(sRED_FINAL,"Ranking")) sprintf(sRED_FINAL,"Ranking");
else if (!mystricmp(sRED_FINAL,"Sequential")) sprintf(sRED_FINAL,"Sequential");
else if (!mystricmp(sRED_FINAL,"Sequential")) {
sprintf(sRED_FINAL,"Sequential");
sprintf(sRED_FINAL_PRM,"(2)");
}
else {
fprintf(stderr,"\n%s - Error line %d: The %s selection scheme does not exist in EO.\n",sEZ_FILE_NAME,EASEALexer.yylineno, sRED_FINAL);
exit(1);
......@@ -907,6 +947,7 @@ Parameter
}
break;
case CUDA :
case STD:
case EO :
if (!mystricmp(sRED_FINAL,"Tournament")||!mystricmp(sRED_FINAL,"StochTrn")) {
if ($3>=2) {
......@@ -935,7 +976,11 @@ Parameter
}
else if (!mystricmp(sRED_FINAL,"Sequential")) {
sprintf(sRED_FINAL,"Sequential");
if ($3==0) sprintf(sRED_FINAL_PRM,"(unordered)");
if ($3==0)
if( TARGET==CUDA || TARGET==STD )
sprintf(sRED_FINAL_PRM,"(0)");
else
sprintf(sRED_FINAL_PRM,"(unordered)");
else if ($3==1) sprintf(sRED_FINAL_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++;
......@@ -1276,6 +1321,7 @@ int main(int argc, char *argv[]){
else if (!mystricmp(sTemp,"galib")) TARGET=GALIB;
else if (!mystricmp(sTemp,"dream")) TARGET=DREAM;
else if (!mystricmp(sTemp,"cuda")) TARGET=CUDA;
else if (!mystricmp(sTemp,"std")) TARGET=STD;
else if (!mystricmp(sTemp,"v")) bVERBOSE=true;
else if (!mystricmp(sTemp,"path")) {
if (argv[++nParamNb][0]=='"') {
......
......@@ -154,7 +154,7 @@ void CSymbol::print(FILE *fp){
fprintf(fp," if ((%s)&&(%s!=EASEA_Var.%s)) return gaFalse;\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->sName, pSym->Object->pType->sName,pSym->Object->sName,pSym->Object->sName);
}
}
if (TARGET==EO || TARGET==CUDA){
if (TARGET==EO || TARGET==CUDA || TARGET==STD){
if (pSym->Object->ObjectType==oObject)
fprintf(fp," if (%s!=EASEA_Var.%s) return false;\n",pSym->Object->sName,pSym->Object->sName);
if (pSym->Object->ObjectType==oArray){
......@@ -168,7 +168,7 @@ void CSymbol::print(FILE *fp){
}
}
if (TARGET==GALIB) fprintf(fp," return gaTrue;\n }\n\n"); // operator==
if (TARGET==EO || TARGET==CUDA) fprintf(fp," return true;\n }\n\n"); // operator==
if (TARGET==EO || TARGET==CUDA || TARGET==STD) fprintf(fp," return true;\n }\n\n"); // operator==
fprintf(fp," bool operator!=(%s &EASEA_Var) const {return !(*this==EASEA_Var);} // operator!=\n\n",sName); // operator!=
......@@ -329,7 +329,7 @@ void CSymbol::printClasses(FILE *fp){
void CSymbol::printUC(FILE* fp){
DEBUG_PRT("print user classes definitions");
if (strcmp(sName,"Genome")&&(TARGET==CUDA)){ // If we are printing a user class other than the genome
if (strcmp(sName,"Genome") && (TARGET==CUDA || TARGET==STD)){ // If we are printing a user class other than the genome
fprintf(fp,"\nclass %s;\n",sName); // class header
}
DEBUG_PRT("%s",sName);
......
EXEC = main.out
CPPFLAGS = -DUNIX_OS -Ialexyacc/include/ -DDEBUG -g
CPPFLAGS += -DUNIX_OS -Ialexyacc/include/ -g
CPPC = g++
LDFLAGS =
......@@ -20,39 +20,14 @@ alexyacc/libalex.so:alexyacc/*.cpp
clean:
rm -f *.o $(EXEC)
rm -f EaseaParse.cpp EaseaParse.h EaseaLex.cpp EaseaLex.h
cd alexyacc && make clean
realclean: clean
rm -f EaseaParse.cpp EaseaParse.h EaseaLex.cpp EaseaLex.h
EaseaParse.cpp: EaseaParse.y
wine ~/.wine/drive_c/Program\ Files/Parser\ Generator/BIN/ayacc.exe $< -Tcpp -d
EaseaLex.cpp: EaseaLex.l
wine ~/.wine/drive_c/Program\ Files/Parser\ Generator/BIN/ALex.exe $< -Tcpp -i
# #handle file between windows and local directory
# winclean:
# rm -f $(TMP_DIR)/EaseaLex.cpp $(TMP_DIR)/EaseaLex.h $(TMP_DIR)/EaseaParse.cpp $(TMP_DIR)/EaseaParse.h $(TMP_DIR)/EaseaParse.v
# winrealclean: winclean
# rm -f $(TMP_DIR)/EaseaParse.y $(TMP_DIR)/EaseaLex.l
# #send alex and ayacc files to windows
# winsend: winsend_l winsend_y
# winsend_l:
# sudo cp EaseaLex.l $(TMP_DIR)/
# winsend_y:
# sudo cp EaseaParse.y $(TMP_DIR)/
# #receveive alex and ayacc files from windows
# winreceive: winreceive_l winreceive_y
# winreceive_l:
# cp $(TMP_DIR)/EaseaLex.cpp $(TMP_DIR)/EaseaLex.h ./
# chmod -x EaseaLex.cpp EaseaLex.h
# winreceive_y:
# cp $(TMP_DIR)/EaseaParse.cpp $(TMP_DIR)/EaseaParse.h ./
# chmod -x EaseaParse.cpp EaseaParse.h
\ No newline at end of file
wine ~/.wine/drive_c/Program\ Files/Parser\ Generator/BIN/ALex.exe $< -Tcpp -i
\ No newline at end of file
......@@ -50,7 +50,6 @@ inline float random(float b1=0, float b2=1){
\ANALYSE_PARAMETERS
\INSERT_USER_DECLARATIONS
\INSERT_INITIALISATION_FUNCTION
// include here whatever specific files for your representation
......@@ -74,6 +73,7 @@ typedef \MINIMAXI MyFitT ; // type of fitness
typedef EASEAGenome<MyFitT> Indi; // ***MUST*** derive from EO
\INSERT_USER_FUNCTIONS
\INSERT_INITIALISATION_FUNCTION
/** definition of evaluation:
* class EASEAEvalFunc MUST derive from eoEvalFunc<EASEAGenome>
......
This diff is collapsed.
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