Commit 541b0b9d authored by Joseph Pallamidessi's avatar Joseph Pallamidessi

Clean a bit the directories and the compiler have its own

parent 2c92732c
......@@ -28,12 +28,12 @@ FILE(GLOB boost_src boost/*.cpp)
ADD_LIBRARY( program_options STATIC ${boost_src} )
SET_TARGET_PROPERTIES(program_options PROPERTIES OUTPUT_NAME "program_options" PREFIX "" COMPILE_FLAGS "-O2")
#Easea compiler
SET(easea_src
EaseaLex.cpp
EaseaParse.cpp
EaseaSym.cpp
EaseaYTools.cpp)
compiler/EaseaLex.cpp
compiler/EaseaParse.cpp
compiler/EaseaSym.cpp
compiler/EaseaYTools.cpp)
ADD_EXECUTABLE(easea ${easea_src})
......
UNAME := $(shell uname)
ifeq ($(shell uname -o 2>/dev/null),Msys)
OS := MINGW
endif
EXEC = bin/easea
CPPFLAGS += -DUNIX_OS -Ialexyacc/include/ -g -Wno-deprecated -DDEBUG -DLINE_NUM_EZ_FILE
LDFLAGS =
OBJ= build/EaseaSym.o build/EaseaParse.o build/EaseaLex.o alexyacc/libalex.a build/EaseaYTools.o boost/program_options.a libeasea/libeasea.a
#ifeq ($(UNAME),Darwin)
$(EXEC):build bin $(OBJ)
$(CXX) $(CPPFLAGS) $(LDFLAGS) $(OBJ) -o $@
ifneq ("$(OS)","")
#
# Congratulations ! It looks like you compiled EASEA successfully.
#
# You can use easea from this directory by typing :
# For example :
# easea.exe examples\weierstrass_std\weierstrass.ez
# Go to the target directory and type make -f weierstrass.mak
#
# Thanks for using EASEA.
#
else
#
# Congratulations ! It looks like you compiled EASEA successfully.
#
# You can now install easea into your system or use it from
# its current directory.
#
# System Installation (you need admnistration rights):
# EASEA will be installed into /usr/local/easea/ directory,
# including, the binary, its libraries and the templates.
# Finally, environment variables will be updated (EZ_PATH and PATH),
ifeq ($(UNAME),Darwin)
# into your .bash_profile file.
else
# into your .bashrc file.
endif
# To install EASEA into your system, type:
# "source install.sh "
#
# Local Usage:
# All EASEA elements will stay in the current directory,
# but some environment variables need to be updated into your
ifeq ($(UNAME),Darwin)
# .bash_profile file (EZ_PATH). To do so type:
else
# .bashrc file (EZ_PATH). To do so type:
endif
# "source install.sh local"
#
# Thanks for using EASEA.
#
endif
# $(EXEC):EaseaSym.o EaseaParse.o EaseaLex.o alexyacc/libalex.so
# $(CXX) $(CPPFLAGS) $(LDFLAGS) $^ -o $@
# $(EXEC)_bin:EaseaSym.o EaseaParse.o EaseaLex.o
# $(CXX) $(CPPFLAGS) $(LDFLAGS) $^ -o $@ -lalex
install:
mkdir -p /usr/local/easea/ /usr/local/easea/bin /usr/local/easea/tpl /usr/local/easea/libeasea/include /usr/local/easea/boost /usr/local/easea/easeagrapher/
cp bin/easea /usr/local/easea/bin/
cp tpl/* /usr/local/easea/tpl/
cp libeasea/include/* /usr/local/easea/libeasea/include/
cp libeasea/libeasea.a /usr/local/easea/libeasea/
cp boost/program_options.a /usr/local/easea/boost
cp -r boost/boost/ /usr/local/easea/boost/boost/
cp easeagrapher/EaseaGrapher.jar /usr/local/easea/easeagrapher/
build:
@test -d build || mkdir build || echo "Cannot make dir build"
bin:
@test -d bin || mkdir bin || echo "Cannot make dir bin"
build/EaseaParse.o: EaseaParse.cpp EaseaLex.cpp
$(CXX) $(CPPFLAGS) $< -o $@ -c -w
build/EaseaLex.o: EaseaLex.cpp
$(CXX) $(CPPFLAGS) $< -o $@ -c -w
build/%.o:%.cpp
$(CXX) $(CPPFLAGS) -c -o $@ $<
#compile library for alex and ayacc unix version
alexyacc/libalex.so:alexyacc/*.cpp
cd alexyacc && make libalex.so
alexyacc/libalex.a:alexyacc/*.cpp
cd alexyacc && make libalex.a
#ifeq ($(UNAME),Darwin)
boost/program_options.a:boost/*.cpp
cd boost && make program_options.a
#endif #OS
#compile libeasea
libeasea/libeasea.a:libeasea/*.cpp
cd libeasea && make libeasea.a
clean:
rm -f build/*.o $(EXEC) $(EXEC)_bin
cd alexyacc && make clean
cd libeasea && make clean
cd boost && make clean
#ifeq ($(UNAME),Darwin)
cd boost && make clean
#endif
#install:$(EXEC)
# sudo cp $< /usr/bin/dev-easea
#ifeq ($(UNAME),Linux)
#realclean: clean
# rm -f EaseaParse.cpp EaseaParse.h EaseaLex.cpp EaseaLex.h
# AT commented these lines, because they imply the presence of wine + programs in a specific location
#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
#endif
UNAME := $(shell uname)
ifeq ($(shell uname -o 2>/dev/null),Msys)
OS := MINGW
endif
EXEC = bin/easea
CPPFLAGS += -DUNIX_OS -Ialexyacc/include/ -g -Wno-deprecated -DDEBUG -DLINE_NUM_EZ_FILE
LDFLAGS =
OBJ= build/EaseaSym.o build/EaseaParse.o build/EaseaLex.o alexyacc/libalex.a build/EaseaYTools.o boost/program_options.a libeasea/libeasea.a
#ifeq ($(UNAME),Darwin)
$(EXEC):build bin $(OBJ)
$(CXX) $(CPPFLAGS) $(LDFLAGS) $(OBJ) -o $@
ifneq ("$(OS)","")
#
# Congratulations ! It looks like you compiled EASEA successfully.
#
# You can use easea from this directory by typing :
# For example :
# easea.exe examples\weierstrass_std\weierstrass.ez
# Go to the target directory and type make -f weierstrass.mak
#
# Thanks for using EASEA.
#
else
#
# Congratulations ! It looks like you compiled EASEA successfully.
#
# You can now install easea into your system or use it from
# its current directory.
#
# Installation:
# To install EASEA into your system, type:
# ". install.sh ".
# EASEA will be installed into /usr/local/easea/ directory,
# including, the binary, its libraries and the templates.
# Finaly, environment variables will be updated (EZ_PATH and PATH),
ifeq ($(UNAME),Darwin)
# into your .bash_profile file.
else
# into your .bashrc file.
endif
#
# Local Usage:
# All EASEA elements will stay in the current directory,
# but some environment variables need to be updated into your
ifeq ($(UNAME),Darwin)
# .bash_profile file (EZ_PATH and). To do so type:
else
# .bashrc file (EZ_PATH and). To do so type:
endif
# ". install.sh local".
#
# Thanks for using EASEA.
#
endif
# $(EXEC):EaseaSym.o EaseaParse.o EaseaLex.o alexyacc/libalex.so
# $(CXX) $(CPPFLAGS) $(LDFLAGS) $^ -o $@
# $(EXEC)_bin:EaseaSym.o EaseaParse.o EaseaLex.o
# $(CXX) $(CPPFLAGS) $(LDFLAGS) $^ -o $@ -lalex
install:
mkdir -p /usr/local/easea/ /usr/local/easea/bin /usr/local/easea/tpl /usr/local/easea/libeasea/include /usr/local/easea/boost /usr/local/easea/easeagrapher/
cp bin/easea /usr/local/easea/bin/
cp tpl/* /usr/local/easea/tpl/
cp libeasea/include/* /usr/local/easea/libeasea/include/
cp libeasea/libeasea.a /usr/local/easea/libeasea/
cp boost/program_options.a /usr/local/easea/boost
cp -r boost/boost/ /usr/local/easea/boost/boost/
cp easeagrapher/EaseaGrapher.jar /usr/local/easea/easeagrapher/
build:
@test -d build || mkdir build || echo "Cannot make dir build"
bin:
@test -d bin || mkdir bin || echo "Cannot make dir bin"
build/EaseaParse.o: compiler/EaseaParse.cpp compiler/EaseaLex.cpp
$(CXX) $(CPPFLAGS) $< -o $@ -c -w
build/EaseaLex.o: compiler/EaseaLex.cpp
$(CXX) $(CPPFLAGS) $< -o $@ -c -w
build/%.o:compiler/%.cpp
$(CXX) $(CPPFLAGS) -c -o $@ $<
#compile library for alex and ayacc unix version
alexyacc/libalex.so:alexyacc/*.cpp
cd alexyacc && make libalex.so
alexyacc/libalex.a:alexyacc/*.cpp
cd alexyacc && make libalex.a
#ifeq ($(UNAME),Darwin)
boost/program_options.a:boost/*.cpp
cd boost && make program_options.a
#endif #OS
#compile libeasea
libeasea/libeasea.a:libeasea/*.cpp
cd libeasea && make libeasea.a
clean:
rm -f build/*.o $(EXEC) $(EXEC)_bin
cd alexyacc && make clean
cd libeasea && make clean
cd boost && make clean
#ifeq ($(UNAME),Darwin)
cd boost && make clean
#endif
#install:$(EXEC)
# sudo cp $< /usr/bin/dev-easea
#ifeq ($(UNAME),Linux)
#realclean: clean
# rm -f EaseaParse.cpp EaseaParse.h EaseaLex.cpp EaseaLex.h
# AT commented these lines, because they imply the presence of wine + programs in a specific location
#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
#endif
......@@ -81,8 +81,10 @@ bin:
build/EaseaParse.o: EaseaParse.cpp EaseaLex.cpp
cd compiler
$(CXX) $(CPPFLAGS) $< -o $@ -c -w
build/EaseaLex.o: EaseaLex.cpp
cd compiler
$(CXX) $(CPPFLAGS) $< -o $@ -c -w
......
......@@ -2423,7 +2423,7 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
if (bVERBOSE) {
printf("\n ");
printf("\n E A S E A (v1.1)");
printf("\n E A S E A (v1.0.3)");
printf("\n ___________________ ");
printf("\n ");
printf("\n Stochastic Optimisation and Nature Inspired Computing");
......
......@@ -8,76 +8,89 @@
#ifndef CCMAES_H_
#define CCMAES_H_
#include "define.h"
/**
* \class Caleatoire
* \brief Random generator for CMA-ES
* \details Randomness using Gaussian or Uniform distribution
*
**/
class Caleatoire
{
public:
/* Variables for Uniform() */
long int startseed;
long int aktseed;
long int aktalea;
long int rgalea[32];
/* Variables for Gauss() */
short flgstored;
double hold;
public:
long alea_Start(long unsigned inseed);
long alea_init(long unsigned inseed);
double alea_Gauss();
double alea_Uniform();
public:
/* Variables for Uniform() */
long int startseed;
long int aktseed;
long int aktalea;
long int rgalea[32];
/* Variables for Gauss() */
short flgstored;
double hold;
public:
long alea_Start(long unsigned inseed);
long alea_init(long unsigned inseed);
double alea_Gauss();
double alea_Uniform();
};
/**
* \class CCmaes
* \brief Covariance Matrix Adaptation Evolution Strategy
* \details Is set before entering the main evolutionary loop
*
**/
class CCmaes{
//random_t rand; /* random number generator */
public:
int dim;
double sigma; /* step size */
double *rgxmean; /* mean x vector, "parent" */
double chiN;
double **C; /* lower triangular matrix: i>=j for C[i][j] */
double **B; /* matrix with normalize eigenvectors in columns */
double *rgD; /* axis lengths */
double *rgpc;
double *rgps;
double *rgxold;
double *rgout;
double *rgBDz; /* for B*D*z */
double *rgdTmp; /* temporary (random) vector used in different places */
short flgEigensysIsUptodate;
short flgCheckEigen; /* control via signals.par */
double genOfEigensysUpdate;
//random_t rand; /* random number generator */
public:
int dim;
double sigma; /* step size */
double *rgxmean; /* mean x vector, "parent" */
double chiN;
double **C; /* lower triangular matrix: i>=j for C[i][j] */
double **B; /* matrix with normalize eigenvectors in columns */
double *rgD; /* axis lengths */
double *rgpc;
double *rgps;
double *rgxold;
double *rgout;
double *rgBDz; /* for B*D*z */
double *rgdTmp; /* temporary (random) vector used in different places */
short flgEigensysIsUptodate;
short flgCheckEigen; /* control via signals.par */
double genOfEigensysUpdate;
short flgIniphase;
int lambda; /* -> mu, <- N */
int mu; /* -> weights, (lambda) */
double mucov, mueff; /* <- weights */
double *weights; /* <- mu, -> mueff, mucov, ccov */
double damps; /* <- cs, maxeval, lambda */
double cs; /* -> damps, <- N */
double ccumcov; /* <- N */
double ccov; /* <- mucov, <- N */
int gen;
short flgIniphase;
int lambda; /* -> mu, <- N */
int mu; /* -> weights, (lambda) */
double mucov, mueff; /* <- weights */
double *weights; /* <- mu, -> mueff, mucov, ccov */
double damps; /* <- cs, maxeval, lambda */
double cs; /* -> damps, <- N */
double ccumcov; /* <- N */
double ccov; /* <- mucov, <- N */
int gen;
double * xstart;
double * typicalX;
int typicalXcase;
double * rgInitialStds;
double * rgDiffMinChange;
double * xstart;
double * typicalX;
int typicalXcase;
double * rgInitialStds;
double * rgDiffMinChange;
struct { int flgalways; double modulo; double maxtime; } updateCmode;
double facupdateCmode;
struct { int flgalways; double modulo; double maxtime; } updateCmode;
double facupdateCmode;
Caleatoire alea; /* random number generator */
int seed;
public:
CCmaes(int lambda, int mu, int problemdim);
~CCmaes();
void cmaes_update(double **popparent, double *fitness);
void Cmaes_init_param(int lambda, int mu);
void TestMinStdDevs();
void cmaes_UpdateEigensystem(int flgforce);
void Adapt_C2(int hsig, double **parents);
Caleatoire alea; /* random number generator */
int seed;
public:
CCmaes(int lambda, int mu, int problemdim);
~CCmaes();
void cmaes_update(double **popparent, double *fitness);
void Cmaes_init_param(int lambda, int mu);
void TestMinStdDevs();
void cmaes_UpdateEigensystem(int flgforce);
void Adapt_C2(int hsig, double **parents);
};
int Check_Eigen(int taille, double **C, double *diag, double **Q);
......
......@@ -8,76 +8,91 @@
#ifndef CCMAES_H_
#define CCMAES_H_
#include "define.h"
/**
* \class CaleatoireCuda
* \brief Random generator for CMA-ES CUDA
* \details Randomness using Gaussian or Uniform distribution.CUDA version of
* class Caleatoire.
*
**/
class CaleatoireCuda
{
public:
/* Variables for Uniform() */
long int startseed;
long int aktseed;
long int aktalea;
long int rgalea[32];
/* Variables for Gauss() */
short flgstored;
float hold;
public:
long alea_Start(long unsigned inseed);
long alea_init(long unsigned inseed);
float alea_Gauss();
float alea_Uniform();
public:
/* Variables for Uniform() */
long int startseed;
long int aktseed;
long int aktalea;
long int rgalea[32];
/* Variables for Gauss() */
short flgstored;
float hold;
public:
long alea_Start(long unsigned inseed);
long alea_init(long unsigned inseed);
float alea_Gauss();
float alea_Uniform();
};
/**
* \class CCmaesCuda
* \brief Covariance Matrix Adaptation Evolution Strategy for CUDA
* \details Is set before entering the main evolutionary loop. CUDA version of
* class CCmaes
*
**/
class CCmaesCuda{
//random_t rand; /* random number generator */
public:
int dim;
float sigma; /* step size */
float *rgxmean; /* mean x vector, "parent" */
float chiN;
float **C; /* lower triangular matrix: i>=j for C[i][j] */
float **B; /* matrix with normalize eigenvectors in columns */
float *rgD; /* axis lengths */
float *rgpc;
float *rgps;
float *rgxold;
float *rgout;
float *rgBDz; /* for B*D*z */
float *rgdTmp; /* temporary (random) vector used in different places */
short flgEigensysIsUptodate;
short flgCheckEigen; /* control via signals.par */
float genOfEigensysUpdate;
//random_t rand; /* random number generator */
public:
int dim;
float sigma; /* step size */
float *rgxmean; /* mean x vector, "parent" */
float chiN;
float **C; /* lower triangular matrix: i>=j for C[i][j] */
float **B; /* matrix with normalize eigenvectors in columns */
float *rgD; /* axis lengths */
float *rgpc;
float *rgps;
float *rgxold;
float *rgout;
float *rgBDz; /* for B*D*z */
float *rgdTmp; /* temporary (random) vector used in different places */
short flgEigensysIsUptodate;
short flgCheckEigen; /* control via signals.par */
float genOfEigensysUpdate;
short flgIniphase;
int lambda; /* -> mu, <- N */
int mu; /* -> weights, (lambda) */
float mucov, mueff; /* <- weights */
float *weights; /* <- mu, -> mueff, mucov, ccov */
float damps; /* <- cs, maxeval, lambda */
float cs; /* -> damps, <- N */
float ccumcov; /* <- N */
float ccov; /* <- mucov, <- N */
int gen;
short flgIniphase;
int lambda; /* -> mu, <- N */
int mu; /* -> weights, (lambda) */
float mucov, mueff; /* <- weights */
float *weights; /* <- mu, -> mueff, mucov, ccov */
float damps; /* <- cs, maxeval, lambda */
float cs; /* -> damps, <- N */
float ccumcov; /* <- N */
float ccov; /* <- mucov, <- N */
int gen;
float * xstart;
float * typicalX;
int typicalXcase;
float * rgInitialStds;
float * rgDiffMinChange;
float * xstart;
float * typicalX;
int typicalXcase;
float * rgInitialStds;
float * rgDiffMinChange;
struct { int flgalways; float modulo; float maxtime; } updateCmode;
float facupdateCmode;
struct { int flgalways; float modulo; float maxtime; } updateCmode;
float facupdateCmode;
CaleatoireCuda alea; /* random number generator */
int seed;
public:
CCmaesCuda(int lambda, int mu, int problemdim);
~CCmaesCuda();
void cmaes_update(float **popparent, float *fitness);
void Cmaes_init_param(int lambda, int mu);
void TestMinStdDevs();
void cmaes_UpdateEigensystem(int flgforce);
void Adapt_C2(int hsig, float **parents);
CaleatoireCuda alea; /* random number generator */
int seed;
public:
CCmaesCuda(int lambda, int mu, int problemdim);
~CCmaesCuda();
void cmaes_update(float **popparent, float *fitness);
void Cmaes_init_param(int lambda, int mu);
void TestMinStdDevs();
void cmaes_UpdateEigensystem(int flgforce);
void Adapt_C2(int hsig, float **parents);
};
int Check_Eigen(int taille, float **C, float *diag, float **Q);
......
/**
* @file CGPNode.h
* @version 1.0
*
**/
#ifndef __C_GPNODE__
#define __C_GPNODE__
......@@ -7,76 +13,100 @@ using namespace std;
#define MAX_ARITY 2 // maximum arrity for GP node
/**
* \class GPNode
* \brief Genetic Programming
* \details Used to modelised nodes of abstract syntax tree
*
**/
class GPNode {
public:
public:
GPNode(){ // Constructor
for(int EASEA_Ndx=0; EASEA_Ndx<2; EASEA_Ndx++)
children[EASEA_Ndx]=NULL;
}
GPNode(){ // Constructor
for(int EASEA_Ndx=0; EASEA_Ndx<2; EASEA_Ndx++)
children[EASEA_Ndx]=NULL;
}
GPNode(int var_id, double erc_value, char opCode, GPNode** childrenToAdd) : var_id(var_id), erc_value(erc_value), opCode(opCode)// other constructor
GPNode(int var_id, double erc_value, char opCode, GPNode** childrenToAdd) : var_id(var_id), erc_value(erc_value), opCode(opCode)// other constructor
{
for(int EASEA_Ndx=0; EASEA_Ndx<2; EASEA_Ndx++)
this->children[EASEA_Ndx]=childrenToAdd[EASEA_Ndx];
this->children[EASEA_Ndx]=childrenToAdd[EASEA_Ndx];
}
GPNode(const GPNode &EASEA_Var) { // Copy constructor
var_id=EASEA_Var.var_id;
erc_value=EASEA_Var.erc_value;
//arity=EASEA_Var.arity;
opCode=EASEA_Var.opCode;
for(int EASEA_Ndx=0; EASEA_Ndx<2; EASEA_Ndx++)
GPNode(const GPNode &EASEA_Var) { // Copy constructor
var_id=EASEA_Var.var_id;
erc_value=EASEA_Var.erc_value;
//arity=EASEA_Var.arity;
opCode=EASEA_Var.opCode;
for(int EASEA_Ndx=0; EASEA_Ndx<2; EASEA_Ndx++)
if( EASEA_Var.children[EASEA_Ndx] ) children[EASEA_Ndx] = new GPNode(*(EASEA_Var.children[EASEA_Ndx]));
else children[EASEA_Ndx] = NULL;
}
virtual ~GPNode() { // Destructor
for(int EASEA_Ndx=0; EASEA_Ndx<2; EASEA_Ndx++)
}
virtual ~GPNode() { // Destructor
for(int EASEA_Ndx=0; EASEA_Ndx<2; EASEA_Ndx++)
if( children[EASEA_Ndx] ) delete children[EASEA_Ndx];
}
GPNode& operator=(const GPNode &EASEA_Var) { // Operator=
if (&EASEA_Var == this) return *this;
var_id = EASEA_Var.var_id;
erc_value = EASEA_Var.erc_value;
//arity = EASEA_Var.arity;
opCode = EASEA_Var.opCode;
for(int EASEA_Ndx=0; EASEA_Ndx<2; EASEA_Ndx++)
if(EASEA_Var.children[EASEA_Ndx]) children[EASEA_Ndx] = new GPNode(*(EASEA_Var.children[EASEA_Ndx]));
return *this;
}
bool operator==(GPNode &EASEA_Var) const { // Operator==
if (var_id!=EASEA_Var.var_id) return false;
if (erc_value!=EASEA_Var.erc_value) return false;
//if (arity!=EASEA_Var.arity) return false;
if (opCode!=EASEA_Var.opCode) return false;
{for(int EASEA_Ndx=0; EASEA_Ndx<2; EASEA_Ndx++)
if (children[EASEA_Ndx]!=EASEA_Var.children[EASEA_Ndx]) return false;}
return true;
}
bool operator!=(GPNode &EASEA_Var) const {return !(*this==EASEA_Var);} // operator!=
friend ostream& operator<< (ostream& os, const GPNode& EASEA_Var) { // Output stream insertion operator
os << "var_id:" << EASEA_Var.var_id << "\n";
os << "erc_value:" << EASEA_Var.erc_value << "\n";
//os << "arity:" << EASEA_Var.arity << "\n";
os << "opCode:" << EASEA_Var.opCode << "\n";
{os << "Array children : ";
for(int EASEA_Ndx=0; EASEA_Ndx<2; EASEA_Ndx++)
if( EASEA_Var.children[EASEA_Ndx] ) os << "[" << EASEA_Ndx << "]:" << *(EASEA_Var.children[EASEA_Ndx]) << "\t";}
os << "\n";
return os;
}
// Class members
int var_id;
double erc_value;
// char opCode;
int opCode;
GPNode* children[2];
}
GPNode& operator=(const GPNode &EASEA_Var) { // Operator=
if (&EASEA_Var == this) return *this;