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})
......
......@@ -29,27 +29,27 @@ else
# You can now install easea into your system or use it from
# its current directory.
#
# System Installation (you need admnistration rights):
# 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.
# Finally, environment variables will be updated (EZ_PATH and PATH),
# Finaly, 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:
# .bash_profile file (EZ_PATH and). To do so type:
else
# .bashrc file (EZ_PATH). To do so type:
# .bashrc file (EZ_PATH and). To do so type:
endif
# "source install.sh local"
# ". install.sh local".
#
# Thanks for using EASEA.
#
......@@ -80,13 +80,13 @@ bin:
@test -d bin || mkdir bin || echo "Cannot make dir bin"
build/EaseaParse.o: EaseaParse.cpp EaseaLex.cpp
build/EaseaParse.o: compiler/EaseaParse.cpp compiler/EaseaLex.cpp
$(CXX) $(CPPFLAGS) $< -o $@ -c -w
build/EaseaLex.o: EaseaLex.cpp
build/EaseaLex.o: compiler/EaseaLex.cpp
$(CXX) $(CPPFLAGS) $< -o $@ -c -w
build/%.o:%.cpp
build/%.o:compiler/%.cpp
$(CXX) $(CPPFLAGS) -c -o $@ $<
#compile library for alex and ayacc unix version
......
......@@ -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,9 +8,16 @@
#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:
public:
/* Variables for Uniform() */
long int startseed;
long int aktseed;
......@@ -20,16 +27,22 @@ public:
/* Variables for Gauss() */
short flgstored;
double hold;
public:
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:
public:
int dim;
double sigma; /* step size */
double *rgxmean; /* mean x vector, "parent" */
......@@ -70,7 +83,7 @@ public:
Caleatoire alea; /* random number generator */
int seed;
public:
public:
CCmaes(int lambda, int mu, int problemdim);
~CCmaes();
void cmaes_update(double **popparent, double *fitness);
......
......@@ -8,9 +8,17 @@
#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:
public:
/* Variables for Uniform() */
long int startseed;
long int aktseed;
......@@ -20,16 +28,23 @@ public:
/* Variables for Gauss() */
short flgstored;
float hold;
public:
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:
public:
int dim;
float sigma; /* step size */
float *rgxmean; /* mean x vector, "parent" */
......@@ -70,7 +85,7 @@ public:
CaleatoireCuda alea; /* random number generator */
int seed;
public:
public:
CCmaesCuda(int lambda, int mu, int problemdim);
~CCmaesCuda();
void cmaes_update(float **popparent, float *fitness);
......
/**
* @file CGPNode.h
* @version 1.0
*
**/
#ifndef __C_GPNODE__
#define __C_GPNODE__
......@@ -7,9 +13,15 @@ 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
......@@ -17,61 +29,79 @@ public:
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
{
for(int EASEA_Ndx=0; EASEA_Ndx<2; 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++)
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++)
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
// Class members
int var_id;
double erc_value;
// char opCode;
......
......@@ -13,13 +13,20 @@ class CRandomGenerator;
#include <stdlib.h>
#include "Parameters.h"
/**
* \class CGrapher
* \brief Launch the grapher within EASEA
* \details Launch the java grapher in a exec'd fork.
* TODO:(re)Implement the constructor for Windows.
**/
class CGrapher {
public:
public:
FILE *fWrit;
FILE *fRead;
int pid;
int valid;
public:
public:
CGrapher(Parameters* param, char* title);
~CGrapher();
};
......
......@@ -12,12 +12,12 @@ class CRandomGenerator;
#include <iostream>
class CIndividual {
public:
public:
bool valid;
bool isImmigrant;
float fitness;
static CRandomGenerator* rg;
public:
public:
CIndividual();
//CIndividual(const CIndividual& indiv);
virtual ~CIndividual();
......
......@@ -27,7 +27,7 @@ class CStats;
class CPopulation {
public:
public:
float pCrossover;
float pMutation;
......@@ -62,7 +62,8 @@ public:
public:
CPopulation();
CPopulation(unsigned parentPopulationSize, unsigned offspringPopulationSize,
float pCrossover, float pMutation, float pMutationPerGene, CRandomGenerator* rg, Parameters* params, CStats* cstats);
float pCrossover, float pMutation, float pMutationPerGene,
CRandomGenerator* rg, Parameters* params, CStats* cstats);
virtual ~CPopulation();
//virtual void initializeParentPopulation() = 0;
......@@ -73,12 +74,18 @@ public:
virtual void evaluateParentPopulation();
virtual void optimiseParentPopulation();
void strongElitism(unsigned elitismSize, CIndividual** population, unsigned populationSize, CIndividual** outPopulation, unsigned outPopulationSize);
void weakElitism(unsigned elitismSize, CIndividual** parentsPopulation, CIndividual** offspringPopulation, unsigned* parentPopSize, unsigned* offPopSize, CIndividual** outPopulation, unsigned outPopulationSize);
void strongElitism(unsigned elitismSize, CIndividual** population, unsigned populationSize,
CIndividual** outPopulation, unsigned outPopulationSize);
void weakElitism(unsigned elitismSize, CIndividual** parentsPopulation,
CIndividual** offspringPopulation, unsigned* parentPopSize, unsigned* offPopSize,
CIndividual** outPopulation, unsigned outPopulationSize);
virtual void evaluateOffspringPopulation();
virtual void optimiseOffspringPopulation();
CIndividual** reducePopulations(CIndividual** population, unsigned populationSize,CIndividual** reducedPopulation, unsigned obSize,int pressure);
CIndividual** reducePopulations(CIndividual** population, unsigned populationSize,
CIndividual** reducedPopulation, unsigned obSize,int pressure);
CIndividual** reduceParentPopulation(unsigned obSize);
CIndividual** reduceOffspringPopulation(unsigned obSize);
void reduceTotalPopulation(CIndividual** elitPop);
......@@ -118,6 +125,7 @@ public:
static void reducePopulation(CIndividual** population, unsigned populationSize,
CIndividual** reducedPopulation, unsigned obSize,
CSelectionOperator* replacementOperator,int pressure);
void syncOutVector();
void syncInVector();
......
......@@ -14,7 +14,7 @@ class CRandomGenerator {
private:
unsigned seed;
MTRand* mt_rnd;
public:
public:
CRandomGenerator(unsigned int seed);
~CRandomGenerator();
int randInt();
......
......@@ -13,12 +13,12 @@
#include <string>
class CSelectionOperator {
public:
public:
virtual void initialize(CIndividual** population, float selectionPressure, size_t populationSize);
virtual size_t selectNext(size_t populationSize);
virtual float getExtremum() = 0 ;
virtual ~CSelectionOperator(){;}
protected:
protected:
CIndividual** population;
float currentSelectionPressure;
};
......@@ -28,14 +28,14 @@ extern CSelectionOperator* getSelectionOperator(std::string selectop, int minimi
/* ****************************************
Tournament classes (min and max)
****************************************/
****************************************/
class MaxTournament : public CSelectionOperator{
public:
public:
MaxTournament(CRandomGenerator* rg){ this->rg = rg; }
virtual void initialize(CIndividual** population, float selectionPressure, size_t populationSize);
virtual size_t selectNext(size_t populationSize);
float getExtremum();
private:
private:
CRandomGenerator* rg;
};
......@@ -43,12 +43,12 @@ private:
class MinTournament : public CSelectionOperator{
public:
public:
MinTournament(CRandomGenerator* rg){ this->rg = rg; }
virtual void initialize(CIndividual** population, float selectionPressure, size_t populationSize);
virtual size_t selectNext(size_t populationSize);
float getExtremum();
private:
private:
CRandomGenerator* rg;
};
......@@ -102,12 +102,12 @@ class MinRandom : public CSelectionOperator{
*****************************************/
class MaxRoulette : public CSelectionOperator{
public:
public:
MaxRoulette(CRandomGenerator* rg){ this->rg = rg; }
virtual void initialize(CIndividual** population, float selectionPressure, size_t populationSize);
virtual size_t selectNext(size_t populationSize);
float getExtremum();
private:
private:
size_t populationSize;
CRandomGenerator* rg;
};
......
......@@ -3,7 +3,7 @@
class CStats{
public:
public:
int totalNumberOfImmigrants;
int currentNumberOfImmigrants;
......@@ -13,7 +13,7 @@ public:
double currentAverageFitness;
double currentStdDev;
public:
public:
CStats();
~CStats();
void resetCurrentStats();
......
......@@ -23,10 +23,10 @@ class CEvolutionaryAlgorithm;
/* ****************************************
StoppingCriterion class
****************************************/
****************************************/
class CStoppingCriterion {
public:
public:
virtual bool reached() = 0;
virtual ~CStoppingCriterion(){;}
};
......@@ -34,7 +34,7 @@ public:
/* ****************************************
GenerationalCriterion class
****************************************/
****************************************/
class CGenerationalCriterion : public CStoppingCriterion {
private:
unsigned* currentGenerationPtr;
......@@ -48,7 +48,7 @@ class CGenerationalCriterion : public CStoppingCriterion {
/* ****************************************
TimeCriterion class
****************************************/
****************************************/
class CTimeCriterion : public CStoppingCriterion {
private:
unsigned timeLimit;
......@@ -62,7 +62,7 @@ class CTimeCriterion : public CStoppingCriterion {
/* ****************************************
ControlCStopingCriterion class
****************************************/
****************************************/
extern void signal_handler(int sig);
class CControlCStopingCriterion : public CStoppingCriterion {
......
......@@ -14,7 +14,7 @@ class CControlCStopingCriterion;
class CSelectionOperator;
class Parameters {
public:
public:
CSelectionOperator* selectionOperator;
CSelectionOperator* replacementOperator;
CSelectionOperator* parentReductionOperator;
......@@ -81,7 +81,7 @@ public:
int fstGpu;
int lstGpu;
public:
public:
#ifdef WIN32
Parameters();
~Parameters();
......
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