From 9c491e5df0b2d633711d71bdee60d3dea0204220 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 22 Dec 2008 11:44:17 +0100 Subject: [PATCH] Fix newline in Windows. --- GOclasses/algorithms/ASA.cpp | 6 +++--- GOclasses/algorithms/DE.cpp | 6 +++--- GOclasses/algorithms/DE.h | 4 ++-- GOclasses/algorithms/MPSO.cpp | 6 +++--- GOclasses/algorithms/MPSO.h | 2 +- GOclasses/algorithms/PSO.cpp | 6 +++--- GOclasses/algorithms/PSO.h | 6 +++--- GOclasses/algorithms/SGA.cpp | 8 ++++---- GOclasses/algorithms/SGA.h | 10 +++++----- GOclasses/basic/individual.cpp | 22 +++++++++++----------- GOclasses/basic/individual.h | 14 +++++++------- GOclasses/basic/population.cpp | 14 +++++++------- GOclasses/basic/population.h | 16 ++++++++-------- 13 files changed, 60 insertions(+), 60 deletions(-) diff --git a/GOclasses/algorithms/ASA.cpp b/GOclasses/algorithms/ASA.cpp index cdfd009..b81cce5 100644 --- a/GOclasses/algorithms/ASA.cpp +++ b/GOclasses/algorithms/ASA.cpp @@ -13,9 +13,9 @@ #include "rng.h" Population ASAalgorithm::evolve(Individual x0, GOProblem& problem) { - - const std::vector& LB = problem.getLB(); - const std::vector& UB = problem.getUB(); + + const std::vector& LB = problem.getLB(); + const std::vector& UB = problem.getUB(); std::vector xNEW = x0.getDecisionVector(); std::vector xOLD = xNEW; diff --git a/GOclasses/algorithms/DE.cpp b/GOclasses/algorithms/DE.cpp index c8a580f..741a761 100644 --- a/GOclasses/algorithms/DE.cpp +++ b/GOclasses/algorithms/DE.cpp @@ -27,9 +27,9 @@ void DEalgorithm::initDE(int generationsInit, int SolDimInit, double FInit, doub Population DEalgorithm::evolve(Population deme, GOProblem& problem){ - const std::vector& LB = problem.getLB(); - const std::vector& UB = problem.getUB(); - + const std::vector& LB = problem.getLB(); + const std::vector& UB = problem.getUB(); + int NP = deme.size(); int D = SolDim; diff --git a/GOclasses/algorithms/DE.h b/GOclasses/algorithms/DE.h index 3473551..1991ce2 100644 --- a/GOclasses/algorithms/DE.h +++ b/GOclasses/algorithms/DE.h @@ -26,7 +26,7 @@ public: int SolDimInit, double FInit, double CRInit, - int strategyInit, + int strategyInit, uint32_t randomSeed); private: @@ -34,7 +34,7 @@ private: int SolDim; double F; double CR; - int strategy; + int strategy; rng_double_type drng; }; diff --git a/GOclasses/algorithms/MPSO.cpp b/GOclasses/algorithms/MPSO.cpp index a3b4f51..7487c9e 100644 --- a/GOclasses/algorithms/MPSO.cpp +++ b/GOclasses/algorithms/MPSO.cpp @@ -26,9 +26,9 @@ void MPSOalgorithm::initMPSO(int generationsInit, int SolDimInit, double omegaIn Population MPSOalgorithm::evolve(Population deme, GOProblem& problem){ - const std::vector& LB = problem.getLB(); - const std::vector& UB = problem.getUB(); - + const std::vector& LB = problem.getLB(); + const std::vector& UB = problem.getUB(); + int NP = deme.size()/nswarms; //potentially dangerous when the deme size is not divisible by the numberof swamrs int D = LB.size(); diff --git a/GOclasses/algorithms/MPSO.h b/GOclasses/algorithms/MPSO.h index 4792e4a..1b3ee04 100644 --- a/GOclasses/algorithms/MPSO.h +++ b/GOclasses/algorithms/MPSO.h @@ -16,7 +16,7 @@ #include "GOproblem.h" #include "population.h" #include "rng.h" - + class MPSOalgorithm{ public: diff --git a/GOclasses/algorithms/PSO.cpp b/GOclasses/algorithms/PSO.cpp index 2f35b6b..4598124 100644 --- a/GOclasses/algorithms/PSO.cpp +++ b/GOclasses/algorithms/PSO.cpp @@ -25,9 +25,9 @@ void PSOalgorithm::initPSO(int generationsInit, int SolDimInit, double omegaInit Population PSOalgorithm::evolve(Population deme, GOProblem& problem){ - const std::vector& LB = problem.getLB(); - const std::vector& UB = problem.getUB(); - + const std::vector& LB = problem.getLB(); + const std::vector& UB = problem.getUB(); + int n = deme.size(); int m = LB.size(); diff --git a/GOclasses/algorithms/PSO.h b/GOclasses/algorithms/PSO.h index aef7f3f..41e260a 100644 --- a/GOclasses/algorithms/PSO.h +++ b/GOclasses/algorithms/PSO.h @@ -26,7 +26,7 @@ void initPSO(int generationsInit, double omegaInit, double eta1Init, double eta2Init, - double vcoeffInit, + double vcoeffInit, uint32_t randomSeed); private: @@ -35,8 +35,8 @@ private: double omega; double eta1; double eta2; - double vcoeff; + double vcoeff; rng_double_type drng; }; -#endif +#endif diff --git a/GOclasses/algorithms/SGA.cpp b/GOclasses/algorithms/SGA.cpp index ee7349f..66e58b6 100644 --- a/GOclasses/algorithms/SGA.cpp +++ b/GOclasses/algorithms/SGA.cpp @@ -19,15 +19,15 @@ void SGAalgorithm::initSGA(int generationsInit, int SolDimInit, double CRInit, d CR = CRInit; M = MInit; insert_best = insert_bestInit; - rng.seed(randomSeed); + rng.seed(randomSeed); drng.seed(randomSeed); } Population SGAalgorithm::evolve(Population deme, GOProblem& problem){ - const std::vector& LB = problem.getLB(); - const std::vector& UB = problem.getUB(); - + const std::vector& LB = problem.getLB(); + const std::vector& UB = problem.getUB(); + int NP = deme.size(); int D = LB.size(); diff --git a/GOclasses/algorithms/SGA.h b/GOclasses/algorithms/SGA.h index 678e455..d09147b 100644 --- a/GOclasses/algorithms/SGA.h +++ b/GOclasses/algorithms/SGA.h @@ -11,11 +11,11 @@ #define SGA_H #include -#include +#include #include "GOproblem.h" #include "population.h" -#include "rng.h" +#include "rng.h" class SGAalgorithm{ public: @@ -26,7 +26,7 @@ void initSGA(int generationsInit, int SolDimInit, double CRInit, double MInit, - int insert_bestInit, + int insert_bestInit, uint32_t randomSeed ); @@ -35,9 +35,9 @@ private: int SolDim; double CR; //crossover double M; //mutation - int insert_best; + int insert_best; rng_double_type drng; rng_uint32_type rng; }; -#endif +#endif diff --git a/GOclasses/basic/individual.cpp b/GOclasses/basic/individual.cpp index 10b0768..4817792 100644 --- a/GOclasses/basic/individual.cpp +++ b/GOclasses/basic/individual.cpp @@ -7,11 +7,11 @@ * */ -#include "individual.h" +#include "individual.h" #include "rng.h" - void Individual::createRandomIndividual(std::vector LB, std::vector UB, rng_double_type &drng){ - + void Individual::createRandomIndividual(std::vector LB, std::vector UB, rng_double_type &drng){ + //We first delete the vector content if any x.clear(); v.clear(); @@ -39,7 +39,7 @@ } double Individual::evaluateFitness(GOProblem& problem){ - this->fitness = problem.objfun(x); + this->fitness = problem.objfun(x); return this->fitness; }; @@ -76,11 +76,11 @@ v = newindividual.getVelocity(); fitness = newindividual.getFitness(); }; - - std::ostream& operator<<(std::ostream& s, Individual& x){ - for (unsigned int i=0;i #include "GOproblem.h" -#include "constants.h" +#include "constants.h" #include "rng.h" class Individual{ -public: +public: //methods void createRandomIndividual(std::vector LB, std::vector UB, rng_double_type &); double evaluateFitness(GOProblem&); @@ -29,13 +29,13 @@ public: void setDecisionVector(std::vector xnew); std::vector getVelocity() const; void setVelocity(std::vector xnew); - void resetVelocity(std::vector LB, std::vector UB, rng_double_type &); - + void resetVelocity(std::vector LB, std::vector UB, rng_double_type &); + //operators double& operator[](int index); - void operator=(const Individual& newindividual); - - //logging function + void operator=(const Individual& newindividual); + + //logging function friend std::ostream& operator<<(std::ostream& s, Individual& x); private: std::vector x; //this is the "chromosome" or "decision vector" diff --git a/GOclasses/basic/population.cpp b/GOclasses/basic/population.cpp index 060c7c2..0cd3895 100644 --- a/GOclasses/basic/population.cpp +++ b/GOclasses/basic/population.cpp @@ -177,12 +177,12 @@ void Population::operator=(const Individual &x){ pop.clear(); pop.push_back(x); - }; - - std::ostream& operator<<(std::ostream& s, Population& pop){ - for (unsigned int i=0;i &, const std::vector &, int N, rng_double_type &); @@ -34,19 +34,19 @@ public: Population extractRandomDeme(int, std::vector &, rng_double_type &); void insertDeme(const Population &, const std::vector &); void insertBestInDeme(const Population &, const std::vector &); - void insertDemeForced(const Population &, const std::vector &); - + void insertDemeForced(const Population &, const std::vector &); + //Operators Individual &operator[](int); const Individual &operator[](int) const; void operator=(const Population &newpop); - void operator=(const Individual &x); - - //logging function + void operator=(const Individual &x); + + //logging function friend std::ostream& operator<<(std::ostream& s, Population& pop); private: std::vector pop; -};//class Population - +};//class Population + std::ostream& operator<<(std::ostream& s, Population& pop); #endif -- 2.11.4.GIT