Commit 6d388b3a authored by moh_lo's avatar moh_lo

Initial Import

parents
/****************************************************************************
Easea.h
General header for the EASEA language (EAsy Specification for Evolutionary Algorithms)
Pierre COLLET (Pierre.Collet@polytechnique.fr)
Ecole Polytechnique
Centre de Mathmatiques Appliques
91128 Palaiseau cedex
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#define true 1
#define false 0
#define GALIB 1
#define EO 2
#define DREAM 3
#define UNIX 1
#define WINDOWS 2
#define UNKNOWN_OS 3
#define YYTEXT_SIZE 10000
class CSymbol;
extern CSymbol *pCURRENT_CLASS, *pCURRENT_TYPE, *pGENOME;
extern FILE *fpOutputFile, *fpTemplateFile, *fpGenomeFile, *fpExplodedGenomeFile;
extern char sRAW_PROJECT_NAME[], sPROJECT_NAME[], sEO_DIR[], sEZ_PATH[], sEZ_FILE_NAME[];
extern char sLOWER_CASE_PROJECT_NAME[];
extern char sREPLACEMENT[], sSELECTOR[], sSELECT_PRM[], sRED_PAR[], sRED_PAR_PRM[], sRED_FINAL[], sRED_FINAL_PRM[], sRED_OFF[], sRED_OFF_PRM[], sDISCARD[], sDISCARD_PRM[];
extern int nMINIMISE,nELITE;
extern bool bELITISM, bVERBOSE;
extern bool bPROP_SEQ;
extern int nPOP_SIZE, nNB_GEN, nNB_ISLANDS, nOFF_SIZE, nSURV_PAR_SIZE, nSURV_OFF_SIZE;
extern float fMUT_PROB, fXOVER_PROB, fREPL_PERC, fMIG_FREQ;
extern int nMIG_CLONE, nNB_MIG, nIMMIG_REPL;
extern char sMIG_SEL[], sMIGRATOR[], sIMMIG_SEL[],sMIG_TARGET_SELECTOR[];
extern int nWARNINGS, nERRORS;
extern int TARGET, OPERATING_SYSTEM;
// Prototypes
extern int mystricmp(char *, char *);
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef _EASEALEX_H
#define _EASEALEX_H
#include <clex.h>
#line 17 "C:\\repo\\src\\EaseaLex.l"
// forward references
class CEASEAParser;
class CSymbolTable;
#line 13 "C:\\repo\\src\\EaseaLex.h"
#define GENOME_ANALYSIS 2
#define TEMPLATE_ANALYSIS 4
#define MACRO_IDENTIFIER 6
#define MACRO_DEFINITION 8
#define COPY_USER_DECLARATIONS 10
#define COPY_INITIALISATION_FUNCTION 12
#define ANALYSE_USER_CLASSES 14
#define COPY_EO_INITIALISER 16
#define COPY 18
#define COPY_INITIALISER 20
#define COPY_CROSSOVER 22
#define COPY_MUTATOR 24
#define COPY_EVALUATOR 26
#define COPY_DISPLAY 28
#define COPY_USER_FUNCTION 30
#define COPY_USER_GENERATION 32
#define PARAMETERS_ANALYSIS 34
#define GET_PARAMETERS 36
#define COPY_USER_FUNCTIONS 38
#define COPY_GENERATION_FUNCTION 40
#define GET_METHODS 42
/////////////////////////////////////////////////////////////////////////////
// CEASEALexer
#ifndef YYDECLSPEC
#define YYDECLSPEC
#endif
class YYFAR YYDECLSPEC CEASEALexer : public yyflexer {
public:
CEASEALexer();
protected:
void yytables();
virtual int yyaction(int action);
public:
#line 31 "C:\\repo\\src\\EaseaLex.l"
protected:
CSymbolTable *pSymbolTable; // the symbol table
bool bSymbolInserted,bWithinEvaluator; // used to change evalutor type from double to float
bool bInitFunction,bDisplayFunction,bFunction, bNotFinishedYet, bWithinEO_Function;
bool bDoubleQuotes,bWithinDisplayFunction,bWithinInitialiser,bWithinMutator,bWithinXover;
bool bWaitingForSemiColon,bFinishNB_GEN,bFinishMINIMISE,bFinishMINIMIZE,bGenerationFunction;
bool bCatchNextSemiColon,bWaitingToClosePopulation, bMethodsInGenome;
CSymbol *pASymbol;
public:
int create(CEASEAParser* pParser, CSymbolTable* pSymbolTable);
int yywrap();
double myStrtod() const;
#line 67 "C:\\repo\\src\\EaseaLex.h"
};
#ifndef YYLEXNAME
#define YYLEXNAME CEASEALexer
#endif
#ifndef INITIAL
#define INITIAL 0
#endif
#endif
%{
/****************************************************************************
EaseaLex.l
Lexical analyser for the EASEA language (EAsy Specification for Evolutionary Algorithms)
Pierre COLLET (Pierre.Collet@polytechnique.fr)
Ecole Polytechnique
Centre de Mathmatiques Appliques
91128 Palaiseau cedex
****************************************************************************/
#include "Easea.h"
#include "EaseaParse.h"
%}
// include file
%include {
// forward references
class CEASEAParser;
class CSymbolTable;
}
%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
%start COPY_DISPLAY COPY_USER_FUNCTION COPY_USER_GENERATION PARAMETERS_ANALYSIS GET_PARAMETERS
%start COPY_USER_FUNCTIONS COPY_GENERATION_FUNCTION GET_METHODS
// lexical analyser name and class definition
%name CEASEALexer {
protected:
CSymbolTable *pSymbolTable; // the symbol table
bool bSymbolInserted,bWithinEvaluator; // used to change evalutor type from double to float
bool bInitFunction,bDisplayFunction,bFunction, bNotFinishedYet, bWithinEO_Function;
bool bDoubleQuotes,bWithinDisplayFunction,bWithinInitialiser,bWithinMutator,bWithinXover;
bool bWaitingForSemiColon,bFinishNB_GEN,bFinishMINIMISE,bFinishMINIMIZE,bGenerationFunction;
bool bCatchNextSemiColon,bWaitingToClosePopulation, bMethodsInGenome;
CSymbol *pASymbol;
public:
int create(CEASEAParser* pParser, CSymbolTable* pSymbolTable);
int yywrap();
double myStrtod() const;
}
// constructor
{
bFunction=bWithinEvaluator=bDisplayFunction=bInitFunction=bNotFinishedYet=0;
bSymbolInserted=bDoubleQuotes=bWithinDisplayFunction=bWithinInitialiser=bWithinMutator=bWithinXover=0;
bWaitingForSemiColon=bFinishNB_GEN=bFinishMINIMISE=bFinishMINIMIZE=bGenerationFunction=0;
bCatchNextSemiColon,bWaitingToClosePopulation=bMethodsInGenome=0;
}
// macros
exponent ([Ee][+-]?[0-9]+)
%%
%{
// extract yylval for use later on in actions
YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
%}
// Gobbles up ^Ms, to be compatible with unix
\r {}
// switch immediately to TEMPLATE_ANALYSIS state
<INITIAL>. {
BEGIN TEMPLATE_ANALYSIS; yyless(yyleng-1);
}
//****************************************
// GA_GENERATION lexer (feeds on template file and occasionally on .ez file)
//****************************************
<TEMPLATE_ANALYSIS>"\\TEMPLATE_START" {
char sFileName[1000];
strcpy(sFileName, sRAW_PROJECT_NAME);
switch (TARGET) {
case DREAM : strcat(sFileName,".java"); break;
default : strcat(sFileName,".cpp");
}
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"AESAE" {fprintf(fpOutputFile,"EASEA");}
<TEMPLATE_ANALYSIS>"EASEA" {fprintf(fpOutputFile,"%s",sPROJECT_NAME);}
<TEMPLATE_ANALYSIS>"\\EZ_PATH" {fprintf(fpOutputFile,"%s",sEZ_PATH);}
<TEMPLATE_ANALYSIS>"\\EO_DIR" {fprintf(fpOutputFile,"%s",sEO_DIR);}
<TEMPLATE_ANALYSIS>"LC_EASEA" {fprintf(fpOutputFile,"%s",sLOWER_CASE_PROJECT_NAME);}
<TEMPLATE_ANALYSIS>"\\OPERATING_SYSTEM" {switch (OPERATING_SYSTEM) {
case UNIX : fprintf(fpOutputFile,"UNIX_OS"); break;
case WINDOWS : fprintf(fpOutputFile,"WINDOWS_OS"); break;
case UNKNOWN_OS : fprintf(fpOutputFile,"UNKNOWN_OS"); break;
}
}
<TEMPLATE_ANALYSIS>"\\INSERT_USER_DECLARATIONS" {
if (bVERBOSE) printf ("Inserting user declarations.\n");
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_USER_DECLARATIONS;
}
<TEMPLATE_ANALYSIS>"\\INSERT_INITIALISATION_FUNCTION" {
if (bVERBOSE) printf ("Inserting initialisation function.\n");
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_INITIALISATION_FUNCTION;
}
<TEMPLATE_ANALYSIS>"\\INSERT_GENERATION_FUNCTION" {
if (bVERBOSE) printf ("Inserting generation function.\n");
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_GENERATION_FUNCTION;
}
<TEMPLATE_ANALYSIS>"\\ANALYSE_USER_CLASSES" {
if (bVERBOSE) printf ("Analysing user classes.\n");
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN ANALYSE_USER_CLASSES;
}
<TEMPLATE_ANALYSIS>"\\INSERT_USER_CLASSES" {
if (bVERBOSE) printf ("Inserting User classes.\n");
if (TARGET!=DREAM) fprintf (fpOutputFile,"// User classes\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->printClasses(fpOutputFile);
}
<TEMPLATE_ANALYSIS>"\\GENOME_CTOR" {
CListItem<CSymbol*> *pSym;
if (bVERBOSE) printf ("Inserting default genome constructor.\n");
pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem()){
if (pSym->Object->ObjectQualifier==1) continue; // 1=Static
if ((pSym->Object->ObjectType==oArray)&&(TARGET==DREAM))
fprintf(fpOutputFile," %s = new %s[%d];\n",pSym->Object->sName,pSym->Object->pType->sName,pSym->Object->nSize/pSym->Object->pType->nSize);
if (pSym->Object->ObjectType==oPointer){
if (TARGET==DREAM) fprintf(fpOutputFile," %s=null;\n",pSym->Object->sName);
else fprintf(fpOutputFile," %s=NULL;\n",pSym->Object->sName);
}
}
}
<TEMPLATE_ANALYSIS>"\\INSERT_GENOME" {
if (pGENOME->sString) {
if (bVERBOSE) printf ("Inserting Methods into Genome Class.\n");
fprintf(fpOutputFile,"// User-defined methods:\n\n");
fprintf(fpOutputFile,"%s\n",pGENOME->sString);
}
if (bVERBOSE) printf ("Inserting genome.\n");
pGENOME->print(fpOutputFile);
}
<TEMPLATE_ANALYSIS>"\\ASSIGNMENT_OP" {
CListItem<CSymbol*> *pSym;
if (bVERBOSE) printf ("Creating default assignment constructor.\n");
fprintf (fpOutputFile,"// Memberwise assignment\n");
pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem()){
if (pSym->Object->ObjectQualifier==1) continue; // 1=Static
if (pSym->Object->ObjectType==oObject)
fprintf(fpOutputFile," %s=genome.%s;\n",pSym->Object->sName,pSym->Object->sName);
if (pSym->Object->ObjectType==oPointer)
fprintf(fpOutputFile," %s=new %s(*(genome.%s));\n",pSym->Object->sName,pSym->Object->pType->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," %s[EASEA_Ndx]=genome.%s[EASEA_Ndx];}\n",pSym->Object->sName,pSym->Object->sName);
}
}
}
<TEMPLATE_ANALYSIS>"\\CLONE" {
CListItem<CSymbol*> *pSym;
if (bVERBOSE) printf ("Creating default clone method.\n");
fprintf (fpOutputFile,"// Memberwise Cloning\n");
pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem()){
if (pSym->Object->ObjectQualifier==1) continue; // 1=Static
if (TARGET==DREAM){
if (pSym->Object->ObjectType==oObject)
fprintf(fpOutputFile," %s=EZ_genome.%s;\n",pSym->Object->sName,pSym->Object->sName);
if (pSym->Object->ObjectType==oPointer)
fprintf(fpOutputFile," %s=((EZ_genome.%s!=null) ? new %s(EZ_genome.%s) : null);\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->pType->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);
if (pSym->Object->pType->ObjectType==oUserClass) fprintf(fpOutputFile," this.%s[EASEA_Ndx]=new %s(EZ_genome.%s[EASEA_Ndx]);}\n",pSym->Object->sName, pSym->Object->pType->sName, pSym->Object->sName);
else fprintf(fpOutputFile," this.%s[EASEA_Ndx]=EZ_genome.%s[EASEA_Ndx];}\n",pSym->Object->sName,pSym->Object->sName);
}
}
else {
if (pSym->Object->ObjectType==oObject)
fprintf(fpOutputFile," %s=genome.%s;\n",pSym->Object->sName,pSym->Object->sName);
if (pSym->Object->ObjectType==oPointer)
fprintf(fpOutputFile," %s=(genome.%s ? new %s(*(genome.%s)) : NULL);\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->pType->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," %s[EASEA_Ndx]=genome.%s[EASEA_Ndx];}\n",pSym->Object->sName,pSym->Object->sName);
}
}
}
}
<TEMPLATE_ANALYSIS>"\\COPY_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 (TARGET==DREAM){
if (pSym->Object->ObjectType==oObject)
fprintf(fpOutputFile," EZ_genome.%s=%s;\n",pSym->Object->sName,pSym->Object->sName);
if (pSym->Object->ObjectType==oPointer)
fprintf(fpOutputFile," EZ_genome.%s=(%s!=null ? new %s(%s) : null);\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->pType->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);
if (pSym->Object->pType->ObjectType==oUserClass) fprintf(fpOutputFile," EZ_genome.%s[EASEA_Ndx]=new %s(this.%s[EASEA_Ndx]);}\n",pSym->Object->sName, pSym->Object->pType->sName, pSym->Object->sName);
else fprintf(fpOutputFile," EZ_genome.%s[EASEA_Ndx]=this.%s[EASEA_Ndx];}\n",pSym->Object->sName, pSym->Object->sName);
}
}
else {
if (pSym->Object->ObjectType==oObject)
fprintf(fpOutputFile," %s=genome.%s;\n",pSym->Object->sName,pSym->Object->sName);
if (pSym->Object->ObjectType==oPointer)
fprintf(fpOutputFile," %s=(genome.%s ? new %s(*(genome.%s)) : NULL);\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->pType->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," %s[EASEA_Ndx]=genome.%s[EASEA_Ndx];}\n",pSym->Object->sName,pSym->Object->sName);
}
}
}
}
<TEMPLATE_ANALYSIS>"\\GENOME_DTOR" {
CListItem<CSymbol*> *pSym;
if (bVERBOSE) printf ("Creating default destructor.\n");
fprintf (fpOutputFile,"// Destructing pointers\n");
pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem())
if (pSym->Object->ObjectType==oPointer){
if (TARGET==DREAM) fprintf(fpOutputFile," if (%s) delete %s;\n %s=null;\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->sName);
else fprintf(fpOutputFile," if (%s) delete %s;\n %s=NULL;\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->sName);
}
}
<TEMPLATE_ANALYSIS>"\\EQUAL" {
CListItem<CSymbol*> *pSym;
if (bVERBOSE) printf ("Creating default diversity test.\n");
fprintf (fpOutputFile,"// Default diversity test (required by GALib)\n");
pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem()) {
if (pSym->Object->ObjectType==oObject)
fprintf(fpOutputFile," if (%s!=genome.%s) return 0;\n",pSym->Object->sName,pSym->Object->sName);
if (pSym->Object->ObjectType==oPointer)
fprintf(fpOutputFile," if (*%s!=*(genome.%s)) return 0;\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," if (%s[EASEA_Ndx]!=genome.%s[EASEA_Ndx]) return 0;}\n",pSym->Object->sName,pSym->Object->sName);
}
}
}
<TEMPLATE_ANALYSIS>"\\COMPARE" {
CListItem<CSymbol*> *pSym;
if (bVERBOSE) printf ("Creating default genome comparator.\n");
fprintf (fpOutputFile,"// Default genome comparator (required by GALib)\n");
pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem()) {
if (pSym->Object->ObjectType==oObject)
fprintf(fpOutputFile," if (sis.%s!=bro.%s) diff++;\n",pSym->Object->sName,pSym->Object->sName);
if (pSym->Object->ObjectType==oPointer)
fprintf(fpOutputFile," if (*(sis.%s)!=*(bro.%s)) diff++;\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," if (sis.%s[EASEA_Ndx]!=bro.%s[EASEA_Ndx]) diff++;}\n",pSym->Object->sName,pSym->Object->sName);
}
}
}
<TEMPLATE_ANALYSIS>"\\READ" {
CListItem<CSymbol*> *pSym;
if (bVERBOSE) printf ("Creating default read command.\n");
fprintf (fpOutputFile,"// Default read command\n");
pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem()){
if (pSym->Object->ObjectQualifier==1) continue; // 1=Static
if (TARGET==GALIB) {
if ((pSym->Object->ObjectType==oObject)&&(strcmp(pSym->Object->pType->sName, "bool")))
fprintf(fpOutputFile," is >> %s;\n",pSym->Object->sName);
if ((pSym->Object->ObjectType==oArray)&&(strcmp(pSym->Object->pType->sName, "bool"))){
fprintf(fpOutputFile," {for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/pSym->Object->pType->nSize);
fprintf(fpOutputFile," is >> %s[EASEA_Ndx];}\n",pSym->Object->sName);
}
if (pSym->Object->ObjectType==oPointer)
fprintf(fpOutputFile," is >> *%s;\n",pSym->Object->sName);
}
if (TARGET==EO) {
if (pSym->Object->ObjectType==oObject)
fprintf(fpOutputFile," is >> %s;\n",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," is >> %s[EASEA_Ndx];}\n",pSym->Object->sName);
}
if (pSym->Object->ObjectType==oPointer)
fprintf(fpOutputFile," is >> *(%s);\n",pSym->Object->sName);
}
}
}
<TEMPLATE_ANALYSIS>"\\INSERT_DISPLAY" {
if (bVERBOSE) printf ("Inserting genome display function.\n");
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_DISPLAY;
}
<TEMPLATE_ANALYSIS>"\\WRITE" {
CListItem<CSymbol*> *pSym;
if (!bDisplayFunction){
if (bVERBOSE) printf ("*** Creating default display function. ***\n");
fprintf (fpOutputFile,"// Default display function\n");
pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem()){
if (pSym->Object->ObjectQualifier==1) continue; // 1=Static
if (TARGET==DREAM) {
if (pSym->Object->ObjectType==oObject){
if (bDisplayFunction) printf("//");
fprintf(fpOutputFile," EASEA_S = EASEA_S + \"%s:\" + %s + \"\\n\";\n",pSym->Object->sName,pSym->Object->sName);
}
if (pSym->Object->ObjectType==oArray){
if (bDisplayFunction) printf("//");
fprintf(fpOutputFile," {EASEA_S = \"Array %s : \";\n",pSym->Object->sName);
if (bDisplayFunction) printf("//");
fprintf(fpOutputFile," for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/pSym->Object->pType->nSize);
if (bDisplayFunction) printf("//");
fprintf(fpOutputFile," EASEA_S = EASEA_S + \"\\t\"+ %s[EASEA_Ndx];}\n",pSym->Object->sName);
if (bDisplayFunction) printf("//");
}
if (pSym->Object->ObjectType==oPointer){
if (bDisplayFunction) printf("//");
fprintf(fpOutputFile," if (%s!=null) EASEA_S = EASEA_S + \"%s:\" + %s + \"\\n\";\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->sName);
}
}
else {
if (pSym->Object->ObjectType==oObject){
if (bDisplayFunction) printf("//");
if (TARGET==GALIB) fprintf(fpOutputFile," os << \"%s:\" << %s << \"\\n\";\n",pSym->Object->sName,pSym->Object->sName);
if (TARGET==EO) fprintf(fpOutputFile," os << \"%s:\" << %s << \"\\n\";\n",pSym->Object->sName,pSym->Object->sName);
}
if (pSym->Object->ObjectType==oArray){
if (bDisplayFunction) printf("//");
if (TARGET == GALIB) fprintf(fpOutputFile," {os << \"Array %s : \";\n",pSym->Object->sName);
if (TARGET == DREAM) fprintf(fpOutputFile," {EASEA_S = \"Array %s : \";\n",pSym->Object->sName);
if (TARGET == EO) fprintf(fpOutputFile," {",pSym->Object->sName);
if (bDisplayFunction) printf("//");
fprintf(fpOutputFile," for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/pSym->Object->pType->nSize);
if (bDisplayFunction) printf("//");
if (TARGET==GALIB) fprintf(fpOutputFile," os << \"[\" << EASEA_Ndx << \"]:\" << %s[EASEA_Ndx] << \"\\t\";}\n",pSym->Object->sName);
if (TARGET==EO) fprintf(fpOutputFile," os << %s[EASEA_Ndx];}\n",pSym->Object->sName);
if (TARGET==DREAM) fprintf(fpOutputFile," EASEA_S = EASEA_S + \"\\t\"+ %s[EASEA_Ndx];}\n",pSym->Object->sName);
if (bDisplayFunction) printf("//");
if (TARGET!=DREAM) fprintf(fpOutputFile," os << \"\\n\";\n",pSym->Object->sName);
}
if (pSym->Object->ObjectType==oPointer){
if (bDisplayFunction) printf("//");
if (TARGET==GALIB) fprintf(fpOutputFile," os << \"%s:\" << *%s << \"\\n\";\n",pSym->Object->sName,pSym->Object->sName);
if (TARGET==EO) fprintf(fpOutputFile," os << \"%s:\" << *%s << \"\\n\";\n",pSym->Object->sName,pSym->Object->sName);
}
}
}
}
}
<TEMPLATE_ANALYSIS>"\\INSERT_USER_FUNCTIONS" {
if (bVERBOSE) printf ("Inserting user functions.\n");
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_USER_FUNCTIONS;
}
<TEMPLATE_ANALYSIS>"\\INSERT_EO_INITIALISER" {
yyreset();
bWithinEO_Function=1;
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_EO_INITIALISER; // not implemented as a function !
}
<TEMPLATE_ANALYSIS>"\\INSERT_INITIALISER" {
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_INITIALISER;
}
<TEMPLATE_ANALYSIS>"\\INSERT_CROSSOVER" {
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_CROSSOVER;
}
<TEMPLATE_ANALYSIS>"\\INSERT_MUTATOR" {
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_MUTATOR;
}
<TEMPLATE_ANALYSIS>"\\INSERT_EVALUATOR" {
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN COPY_EVALUATOR;
}
<TEMPLATE_ANALYSIS>"\\ANALYSE_PARAMETERS" {
yyreset();
yyin = fpGenomeFile; // switch to .ez file and analyser
BEGIN PARAMETERS_ANALYSIS;
}
<TEMPLATE_ANALYSIS>"\\INSERT_GEN_FCT_CALL" {
if (bGenerationFunction) fprintf(fpOutputFile,"\n EASEAGenerationFunction(ga);\n");
}
<TEMPLATE_ANALYSIS>"\\INSERT_INIT_FCT_CALL" {
if (bInitFunction) fprintf(fpOutputFile,"\n EASEAInitFunction(argc, argv);\n");
}
<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>"\\POP_SIZE" {fprintf(fpOutputFile,"%d",nPOP_SIZE);}
<TEMPLATE_ANALYSIS>"\\OFF_SIZE" {fprintf(fpOutputFile,"%d",nOFF_SIZE);}
<TEMPLATE_ANALYSIS>"\\ELITE_SIZE" {fprintf(fpOutputFile,"%d",nELITE);}
<TEMPLATE_ANALYSIS>"\\RED_PAR" {fprintf(fpOutputFile,"%s",sRED_PAR);}
<TEMPLATE_ANALYSIS>"\\RED_PAR_PRM" {fprintf(fpOutputFile,"%s",sRED_PAR_PRM);}
<TEMPLATE_ANALYSIS>"\\RED_OFF" {fprintf(fpOutputFile,"%s",sRED_OFF);}
<TEMPLATE_ANALYSIS>"\\RED_OFF_PRM" {fprintf(fpOutputFile,"%s",sRED_OFF_PRM);}
<TEMPLATE_ANALYSIS>"\\RED_FINAL" {fprintf(fpOutputFile,"%s",sRED_FINAL);}
<TEMPLATE_ANALYSIS>"\\RED_FINAL_PRM" {fprintf(fpOutputFile,"%s",sRED_FINAL_PRM);}
<TEMPLATE_ANALYSIS>"\\SURV_PAR_SIZE" {fprintf(fpOutputFile,"%d",nSURV_PAR_SIZE);}
<TEMPLATE_ANALYSIS>"\\SURV_OFF_SIZE" {fprintf(fpOutputFile,"%d",nSURV_OFF_SIZE);}
<TEMPLATE_ANALYSIS>"\\NB_GEN" {fprintf(fpOutputFile,"%d",nNB_GEN);}
<TEMPLATE_ANALYSIS>"\\NB_ISLANDS" {fprintf(fpOutputFile,"%d",nNB_ISLANDS);}
<TEMPLATE_ANALYSIS>"\\PROP_OR_SEQ" {fprintf(fpOutputFile,"%s",bPROP_SEQ?"Prop":"Seq");}
<TEMPLATE_ANALYSIS>"\\MUT_PROB" {if (TARGET==GALIB)fprintf(fpOutputFile,"(float)%f",fMUT_PROB);
else fprintf(fpOutputFile,"%f",fMUT_PROB);}
<TEMPLATE_ANALYSIS>"\\XOVER_PROB" {if (TARGET==GALIB)fprintf(fpOutputFile,"(float)%f",fXOVER_PROB);
else fprintf(fpOutputFile,"%f",fXOVER_PROB);}
<TEMPLATE_ANALYSIS>"\\REPLACEMENT" {fprintf(fpOutputFile,"%s",sREPLACEMENT);}
<TEMPLATE_ANALYSIS>"\\REPL_PERC" {fprintf(fpOutputFile,"(float)%f/100",fREPL_PERC);}
<TEMPLATE_ANALYSIS>"\\DISCARD_PRM" {fprintf(fpOutputFile,"%s",sDISCARD_PRM);}
<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>"\\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"))
if (bELITISM) fprintf(fpOutputFile," ga.elitist(gaTrue);\n");
else fprintf(fpOutputFile," ga.elitist(gaFalse);\n");
break;
case EO : fprintf(fpOutputFile,"%d",bELITISM);
} }
<TEMPLATE_ANALYSIS>"\\IMMIG_SEL" {fprintf(fpOutputFile,"%s",sIMMIG_SEL);}
<TEMPLATE_ANALYSIS>"\\IMMIG_REPL" {fprintf(fpOutputFile,"%d",nIMMIG_REPL);}
<TEMPLATE_ANALYSIS>"\\MIGRATOR" {fprintf(fpOutputFile,"%s",sMIGRATOR);}
<TEMPLATE_ANALYSIS>"\\MIG_SEL" {fprintf(fpOutputFile,"%s",sMIG_SEL);}
<TEMPLATE_ANALYSIS>"\\MIG_CLONE" {fprintf(fpOutputFile,"%d",nMIG_CLONE);}
<TEMPLATE_ANALYSIS>"\\NB_MIG" {fprintf(fpOutputFile,"%d",nNB_MIG);}
<TEMPLATE_ANALYSIS>"\\MIG_FREQ" {fprintf(fpOutputFile,"%f",fMIG_FREQ);}
<TEMPLATE_ANALYSIS>"\\MIG_TARGET_SELECTOR" {fprintf(fpOutputFile,"%s",sMIG_TARGET_SELECTOR);}
<TEMPLATE_ANALYSIS>"\\START_EO_GENOME_H_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
strcat(sFileName,"Genome.h");
fpOutputFile=fopen(sFileName,"w");
if (bVERBOSE) printf("Creating %s...\n",sFileName);
}
<TEMPLATE_ANALYSIS>"\\START_EO_EVAL_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
strcat(sFileName,"EvalFunc.h");
if (bVERBOSE) printf("Creating %s...\n",sFileName);
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"\\START_EO_INITER_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
strcat(sFileName,"Init.h");
if (bVERBOSE) printf("Creating %s...\n",sFileName);
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"\\START_EO_MUT_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
strcat(sFileName,"Mutation.h");
if (bVERBOSE) printf("Creating %s...\n",sFileName);
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"\\START_EO_QUAD_XOVER_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
strcat(sFileName,"QuadCrossover.h");
if (bVERBOSE) printf("Creating %s...\n",sFileName);
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"\\START_EO_CONTINUE_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
strcat(sFileName,"_make_continue.h");
if (bVERBOSE) printf("Creating %s...\n",sFileName);
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"\\START_EO_MAKE_GENOTYPE_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
strcat(sFileName,"_make_genotype.h");
if (bVERBOSE) printf("Creating %s...\n",sFileName);
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"\\START_EO_MAKE_OPERATORS_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
strcat(sFileName,"_make_operators.h");
if (bVERBOSE) printf("Creating %s...\n",sFileName);
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"\\START_EO_PARAM_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
strcat(sFileName,".prm");
if (bVERBOSE) printf("Creating %s...\n",sFileName);
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"\\START_EO_MAKEFILE_TPL" {