diff --git a/src/libaevol/CMakeLists.txt b/src/libaevol/CMakeLists.txt index c906493b3c2bb5477a9bfcd26ff052a0b5599f55..247c7fefbd40cfa3737b14f00d7c15e14c995990 100644 --- a/src/libaevol/CMakeLists.txt +++ b/src/libaevol/CMakeLists.txt @@ -95,14 +95,8 @@ set(libaevol_sources mutation/Translocation.h # mutation/GeneMutation.cpp # mutation/GeneMutation.h - - # The following file does not need compiling as it currently has no methods - # phenotype/AbstractFuzzy.cpp - legacy/phenotype/fuzzy/AbstractFuzzy.h legacy/phenotype/fuzzy/Fuzzy.cpp legacy/phenotype/fuzzy/Fuzzy.h - legacy/phenotype/fuzzy/FuzzyFactory.cpp - legacy/phenotype/fuzzy/FuzzyFactory.h phenotype/Gaussian.h phenotype/Phenotype.h phenotype/PhenotypicSegment.h diff --git a/src/libaevol/biochemistry/GeneticUnit.cpp b/src/libaevol/biochemistry/GeneticUnit.cpp index 497c51f0531a5a20bee10904977dffe511a1cc83..4ca8bf8b057e5efca3bff5379f9f5afa2b93affc 100644 --- a/src/libaevol/biochemistry/GeneticUnit.cpp +++ b/src/libaevol/biochemistry/GeneticUnit.cpp @@ -45,7 +45,6 @@ #include <cblas.h> #endif -#include "legacy/phenotype/fuzzy/FuzzyFactory.h" #include "legacy/ExpManager.h" #include "ExpSetup.h" #include "Codon.h" @@ -125,12 +124,12 @@ void GeneticUnit::clear_protein_list(Strand strand) { protein_list_[to_underlying(strand)].clear(); } -AbstractFuzzy* GeneticUnit::activ_contribution() const +Fuzzy* GeneticUnit::activ_contribution() const { return activ_contribution_; } -AbstractFuzzy* GeneticUnit::inhib_contribution() const +Fuzzy* GeneticUnit::inhib_contribution() const { return inhib_contribution_; } @@ -573,8 +572,8 @@ GeneticUnit::GeneticUnit(Individual* indiv) { max_gu_length_ = -1; // Create empty fuzzy sets for the phenotypic contributions - activ_contribution_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); - inhib_contribution_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); + activ_contribution_ = new Fuzzy(); + inhib_contribution_ = new Fuzzy(); // dist_to_target_per_segment_ depends on the segmentation of the environment // and will hence be newed at evaluation time @@ -1149,13 +1148,13 @@ void GeneticUnit::reset_expression() { if ( activ_contribution_ != NULL ) { delete activ_contribution_; - activ_contribution_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); + activ_contribution_ = new Fuzzy(); } if ( inhib_contribution_ != NULL ) { delete inhib_contribution_; - inhib_contribution_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); + inhib_contribution_ = new Fuzzy(); } transcribed_ = false; translated_ = false; diff --git a/src/libaevol/biochemistry/GeneticUnit.h b/src/libaevol/biochemistry/GeneticUnit.h index 7211d412829f9e2ef046c986085dec8cc9cefc31..5eb09ba6c10f7ddea74111d9f3ea2b45952bde4e 100644 --- a/src/libaevol/biochemistry/GeneticUnit.h +++ b/src/libaevol/biochemistry/GeneticUnit.h @@ -35,8 +35,7 @@ #include "legacy/biochemistry/Dna.h" #include "legacy/biochemistry/Rna.h" #include "legacy/biochemistry/Protein.h" -#include "legacy/phenotype/fuzzy/AbstractFuzzy.h" -#include "legacy/phenotype/fuzzy/FuzzyFactory.h" +#include "legacy/phenotype/fuzzy/Fuzzy.h" #include "JumpingMT.h" #include "Utils.h" #include "PhenotypicTarget.h" @@ -109,9 +108,9 @@ class GeneticUnit { Dna* dna() const; - AbstractFuzzy* activ_contribution() const; + Fuzzy* activ_contribution() const; - AbstractFuzzy* inhib_contribution() const; + Fuzzy* inhib_contribution() const; const Promoters2Strands& rna_list() const; @@ -405,8 +404,8 @@ class GeneticUnit { Individual* indiv_ = nullptr; Dna* dna_ = nullptr; - AbstractFuzzy* activ_contribution_ = nullptr; - AbstractFuzzy* inhib_contribution_ = nullptr; + Fuzzy* activ_contribution_ = nullptr; + Fuzzy* inhib_contribution_ = nullptr; // rna_list_ always has 2 elements: make it an std::array diff --git a/src/libaevol/io/parameters/ParamLoader.cpp b/src/libaevol/io/parameters/ParamLoader.cpp index ce76322e0bc3e9a8b3bd16a413d4371d6fc804a5..aab04d8e23e0fdefa9e7b48c76bc2abdcaa40f10 100644 --- a/src/libaevol/io/parameters/ParamLoader.cpp +++ b/src/libaevol/io/parameters/ParamLoader.cpp @@ -27,7 +27,6 @@ #include "ParamLoader.h" #include "ExpSetup.h" -#include "legacy/phenotype/fuzzy/FuzzyFactory.h" #include "Habitat.h" #include "legacy/population/Individual.h" #ifdef __REGUL @@ -195,9 +194,6 @@ void ParamLoader::load(const ParamValues& param_values, exp_s->set_rank_height(rank_height_); #endif - if (FuzzyFactory::fuzzyFactory == NULL) - FuzzyFactory::fuzzyFactory = new FuzzyFactory(); - // 2) --------------------------------------------- Create and init a Habitat #ifndef __REGUL Habitat habitat; diff --git a/src/libaevol/io/parameters/ParamReader.cpp b/src/libaevol/io/parameters/ParamReader.cpp index fc123df042427178ad69bfe9bf8f93d48f01daa5..37416f3049961359622909fd5397472309cefb3a 100644 --- a/src/libaevol/io/parameters/ParamReader.cpp +++ b/src/libaevol/io/parameters/ParamReader.cpp @@ -41,7 +41,6 @@ // ================================================================= // Project Files // ================================================================= -#include "legacy/phenotype/fuzzy/FuzzyFactory.h" #include "ParamReader.h" #if __cplusplus == 201103L diff --git a/src/libaevol/legacy/ExpManager.cpp b/src/libaevol/legacy/ExpManager.cpp index d303dd40ce756a908886a491388e494112951a01..50a63a3dcfd3aa2cd5ab494fad1dbd523e1aa8cd 100644 --- a/src/libaevol/legacy/ExpManager.cpp +++ b/src/libaevol/legacy/ExpManager.cpp @@ -142,12 +142,6 @@ ExpManager::~ExpManager() noexcept delete [] dna_mutator_array_; delete [] next_generation_reproducer_; - - // Several ExpManager instances can delete the fuzzy factory - if (FuzzyFactory::fuzzyFactory != nullptr) { - delete FuzzyFactory::fuzzyFactory; - FuzzyFactory::fuzzyFactory = nullptr; - } } // =========================================================================== @@ -615,10 +609,6 @@ void ExpManager::load(gzFile& exp_s_file, exp_s_->load(exp_s_file, exp_backup_file); printf(" OK\n"); - if (FuzzyFactory::fuzzyFactory == NULL) - FuzzyFactory::fuzzyFactory = new FuzzyFactory(); - - // ---------------------------------------------------------- Retrieve world printf(" Loading world..."); fflush(stdout); @@ -757,10 +747,6 @@ void ExpManager::load(const char* dir, // ------------------------------------------------------------------------- close_setup_files(exp_s_file, out_p_file); close_backup_files(exp_backup_file, world_file); - - - if (FuzzyFactory::fuzzyFactory == NULL) - FuzzyFactory::fuzzyFactory = new FuzzyFactory(); } diff --git a/src/libaevol/legacy/phenotype/fuzzy/AbstractFuzzy.cpp b/src/libaevol/legacy/phenotype/fuzzy/AbstractFuzzy.cpp deleted file mode 100644 index ae65b39e580eb53e8c0200b98406a6389fffc21a..0000000000000000000000000000000000000000 --- a/src/libaevol/legacy/phenotype/fuzzy/AbstractFuzzy.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// -// Created by arrouan on 30/07/15. -// - -#include "AbstractFuzzy.h" diff --git a/src/libaevol/legacy/phenotype/fuzzy/AbstractFuzzy.h b/src/libaevol/legacy/phenotype/fuzzy/AbstractFuzzy.h deleted file mode 100644 index 3a7bbda5cacf8484c209dd1752ee1cf96609ad0d..0000000000000000000000000000000000000000 --- a/src/libaevol/legacy/phenotype/fuzzy/AbstractFuzzy.h +++ /dev/null @@ -1,83 +0,0 @@ -// -// Created by arrouan on 30/07/15. -// - -#ifndef AEVOL_ABSTRACTFUZZY_H -#define AEVOL_ABSTRACTFUZZY_H - - -#include <list> - -#include "macros.h" -#include "Point.h" - -namespace aevol { - -class AbstractFuzzy -{ - public: - // ========================================================================== - // Constructors - // ========================================================================== -// AbstractFuzzy() {}; -// AbstractFuzzy(const AbstractFuzzy& f) {}; -// AbstractFuzzy(const gzFile backup) {}; - - // ========================================================================== - // Destructor - // ========================================================================== - virtual ~AbstractFuzzy() {}; - - // ========================================================================== - // Public Methods - // ========================================================================== - virtual void save(gzFile backup) const = 0; - virtual void load(gzFile backup) = 0; - virtual void reset() = 0; - virtual void simplify() = 0; - virtual void add_triangle(ProteinConcentration mean, ProteinConcentration width, ProteinConcentration height, bool verbose = false) = 0; - virtual void add(const AbstractFuzzy& f) = 0; - virtual void sub(const AbstractFuzzy& f, bool verbose = false) = 0; - virtual void add_point(ProteinConcentration x, ProteinConcentration y) = 0; - - /// `clipping_direction` is only used for `clip` function's keyword. - enum clipping_direction: bool {min, max}; - virtual void clip(clipping_direction direction, ProteinConcentration bound) = 0; - - // ========================================================================== - // Getters - // ========================================================================== - - virtual ProteinConcentration get_geometric_area(bool verbose = false) const = 0; - virtual ProteinConcentration get_geometric_area(ProteinConcentration start_segment, ProteinConcentration end_segment) const = 0; - - virtual bool is_identical_to(const AbstractFuzzy& fs, ProteinConcentration tolerance) const = 0; - - virtual void print() const = 0; - - virtual void clear() = 0; - - // ========================================================================== - // Setters - // ========================================================================== - - // ========================================================================== - // Operators - // ========================================================================== - - protected: - // ========================================================================== - // Protected Methods - // ========================================================================== - - - // ========================================================================== - // Attributes - // ========================================================================== - -}; - -} // namespace aevol - - -#endif //AEVOL_ABSTRACTFUZZY_H diff --git a/src/libaevol/legacy/phenotype/fuzzy/Fuzzy.cpp b/src/libaevol/legacy/phenotype/fuzzy/Fuzzy.cpp index 9251da949821cad12fd47e7e3c89b0769ed4b6cd..cd407aac102423ea3355f428ab6cc685519e5640 100644 --- a/src/libaevol/legacy/phenotype/fuzzy/Fuzzy.cpp +++ b/src/libaevol/legacy/phenotype/fuzzy/Fuzzy.cpp @@ -247,7 +247,7 @@ void Fuzzy::add_triangle(ProteinConcentration mean, ProteinConcentration width, /// Semantically speaking, we deal with fuzzy sets over the same /// range. So adding two fuzzy sets sums up to adding the probability /// functions. -void Fuzzy::add(const AbstractFuzzy& f) { +void Fuzzy::add(const Fuzzy& f) { const Fuzzy fs = (Fuzzy&)(f); // assert(invariant()); @@ -267,7 +267,7 @@ void Fuzzy::add(const AbstractFuzzy& f) { /// Substract to the current fuzzy set. /// /// TODO: Dumb version (?), to be completed. -void Fuzzy::sub(const AbstractFuzzy& f, bool verbose) { +void Fuzzy::sub(const Fuzzy& f, bool verbose) { const Fuzzy fs = (Fuzzy&)(f); // assert(invariant()); // if (verbose) print(); @@ -388,7 +388,7 @@ void Fuzzy::clip(clipping_direction direction, ProteinConcentration bound) { } -bool Fuzzy::is_identical_to(const AbstractFuzzy& f, ProteinConcentration tolerance ) const { +bool Fuzzy::is_identical_to(const Fuzzy& f, ProteinConcentration tolerance ) const { const Fuzzy fs = (Fuzzy&)(f); // Since list::size() has constant complexity since C++ 11, checking // size is an inexpensive first step. diff --git a/src/libaevol/legacy/phenotype/fuzzy/Fuzzy.h b/src/libaevol/legacy/phenotype/fuzzy/Fuzzy.h index 655e00250a5ee4a035471a665dc604c99c8ec57f..eb1792455cc7b0d4179699ce5788eb538edb3c36 100644 --- a/src/libaevol/legacy/phenotype/fuzzy/Fuzzy.h +++ b/src/libaevol/legacy/phenotype/fuzzy/Fuzzy.h @@ -31,7 +31,6 @@ #include "macros.h" #include "Point.h" -#include "AbstractFuzzy.h" namespace aevol { @@ -74,8 +73,7 @@ namespace aevol { /// \invariant{`points_.begin()->x == X_MIN`} /// \invariant{`prev(points_.end())->x == X_MAX`} /// \invariant{`is_increasing()`} -class Fuzzy : public AbstractFuzzy -{ +class Fuzzy { public: // ========================================================================== // Constructors @@ -97,10 +95,12 @@ class Fuzzy : public AbstractFuzzy void reset(); void simplify(); void add_triangle(ProteinConcentration mean, ProteinConcentration width, ProteinConcentration height, bool verbose = false); - void add(const AbstractFuzzy& f); - void sub(const AbstractFuzzy& f, bool verbose = false); + void add(const Fuzzy& f); + void sub(const Fuzzy& f, bool verbose = false); void add_point(ProteinConcentration x, ProteinConcentration y); + /// `clipping_direction` is only used for `clip` function's keyword. + enum clipping_direction: bool {min, max}; void clip(clipping_direction direction, ProteinConcentration bound); // TODO: should be made protected std::list<Point>::iterator create_interpolated_point(ProteinConcentration x, bool verbose = false); @@ -118,7 +118,7 @@ class Fuzzy : public AbstractFuzzy ProteinConcentration y(ProteinConcentration x, bool verbose = false) const; // get_x should be moved out of fuzzy class as it really applies to pair of points ProteinConcentration x(const Point& left, const Point& right, ProteinConcentration y) const; - bool is_identical_to(const AbstractFuzzy& fs, ProteinConcentration tolerance) const; + bool is_identical_to(const Fuzzy& fs, ProteinConcentration tolerance) const; void print() const; void clear(); // ========================================================================== diff --git a/src/libaevol/legacy/phenotype/fuzzy/FuzzyFactory.cpp b/src/libaevol/legacy/phenotype/fuzzy/FuzzyFactory.cpp deleted file mode 100644 index 1226a229ad66b1d1f3e1ec326db62e71a7593066..0000000000000000000000000000000000000000 --- a/src/libaevol/legacy/phenotype/fuzzy/FuzzyFactory.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// **************************************************************************** -// -// Aevol - An in silico experimental evolution platform -// -// **************************************************************************** -// -// Copyright: See the AUTHORS file provided with the package or <www.aevol.fr> -// Web: http://www.aevol.fr/ -// E-mail: See <http://www.aevol.fr/contact/> -// Original Authors : Guillaume Beslon, Carole Knibbe, David Parsons -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// -//***************************************************************************** - - - - -// ============================================================================ -// Includes -// ============================================================================ -#include "FuzzyFactory.h" -#include "Fuzzy.h" - -namespace aevol { - - -//############################################################################## -// # -// Class IndividualFactory # -// # -//############################################################################## - -// ============================================================================ -// Definition of static attributes -// ============================================================================ -FuzzyFactory* FuzzyFactory::fuzzyFactory = NULL; - -// ============================================================================ -// Constructors -// ============================================================================ - -// ============================================================================ -// Destructor -// ============================================================================ - -// ============================================================================ -// Methods -// ============================================================================ - -AbstractFuzzy* FuzzyFactory::create_fuzzy() -{ - AbstractFuzzy* fuzzy; - fuzzy = new Fuzzy(); - return fuzzy; -} - -AbstractFuzzy* FuzzyFactory::create_fuzzy(const AbstractFuzzy& copy) -{ - AbstractFuzzy* fuzzy; - fuzzy = new Fuzzy((Fuzzy&)(copy)); - return fuzzy; -} - -AbstractFuzzy* FuzzyFactory::create_fuzzy(const gzFile backup) -{ - AbstractFuzzy* fuzzy; - fuzzy = new Fuzzy(backup); - return fuzzy; -} - -// ============================================================================ -// Non inline accessors -// ============================================================================ -} // namespace aevol diff --git a/src/libaevol/legacy/phenotype/fuzzy/FuzzyFactory.h b/src/libaevol/legacy/phenotype/fuzzy/FuzzyFactory.h deleted file mode 100644 index 875a311fc04b3f8df3c0cf5a63a937ba34639887..0000000000000000000000000000000000000000 --- a/src/libaevol/legacy/phenotype/fuzzy/FuzzyFactory.h +++ /dev/null @@ -1,112 +0,0 @@ -// **************************************************************************** -// -// Aevol - An in silico experimental evolution platform -// -// **************************************************************************** -// -// Copyright: See the AUTHORS file provided with the package or <www.aevol.fr> -// Web: http://www.aevol.fr/ -// E-mail: See <http://www.aevol.fr/contact/> -// Original Authors : Guillaume Beslon, Carole Knibbe, David Parsons -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// -//***************************************************************************** - - -#ifndef AEVOL_FUZZY_FACTORY_H__ -#define AEVOL_FUZZY_FACTORY_H__ - - -// ============================================================================ -// Includes -// ============================================================================ -#include <cinttypes> -#include <cstdio> -#include <cstdlib> -#include <cassert> - -#include "AbstractFuzzy.h" - -namespace aevol { - -// ============================================================================ -// Class declarations -// ============================================================================ -class ExpSetup; - -class FuzzyFactory -{ - public : - // ========================================================================== - // Constructors - // ========================================================================== - FuzzyFactory() {}; //< Default ctor - - // ========================================================================== - // Destructor - // ========================================================================== - virtual ~FuzzyFactory(void) {}; //< Destructor - - // ========================================================================== - // Getters - // ========================================================================== - - // ========================================================================== - // Setters - // ========================================================================== - - // ========================================================================== - // Operators - // ========================================================================== - - // ========================================================================== - // Public Methods - // ========================================================================== - AbstractFuzzy* create_fuzzy(); - AbstractFuzzy* create_fuzzy(const AbstractFuzzy& copy); - AbstractFuzzy* create_fuzzy(const gzFile backup); - - static FuzzyFactory* fuzzyFactory; - protected : - // ========================================================================== - // Protected Methods - // ========================================================================== - - // ========================================================================== - // Attributes - // ========================================================================== -}; - - - -// ============================================================================ -// Getters' definitions -// ============================================================================ - -// ============================================================================ -// Setters' definitions -// ============================================================================ - -// ============================================================================ -// Operators' definitions -// ============================================================================ - -// ============================================================================ -// Inline functions' definition -// ============================================================================ - -} // namespace aevol - -#endif //AEVOL_FUZZYFACTORY_H diff --git a/src/libaevol/legacy/population/Individual.cpp b/src/libaevol/legacy/population/Individual.cpp index a2c63d087383a10438d71d1933df25ce04cf43e0..ef246b1d697cd4dff9411f29cc9a42d616e6690c 100644 --- a/src/libaevol/legacy/population/Individual.cpp +++ b/src/libaevol/legacy/population/Individual.cpp @@ -296,9 +296,9 @@ Individual::Individual(const Individual& other) { // Copy phenotype if (phenotype_computed_) { - phenotype_activ_ = FuzzyFactory::fuzzyFactory->create_fuzzy((*(other.phenotype_activ_))); - phenotype_inhib_ = FuzzyFactory::fuzzyFactory->create_fuzzy((*(other.phenotype_inhib_))); - phenotype_ = FuzzyFactory::fuzzyFactory->create_fuzzy((*(other.phenotype_))); + phenotype_activ_ = new Fuzzy((*(other.phenotype_activ_))); + phenotype_inhib_ = new Fuzzy((*(other.phenotype_inhib_))); + phenotype_ = new Fuzzy((*(other.phenotype_))); } else { phenotype_activ_ = NULL; @@ -671,12 +671,12 @@ int32_t Individual::genetic_unit_seq_length(int16_t num_unit) const { } /// TODO -AbstractFuzzy* Individual::phenotype_activ() const { +Fuzzy* Individual::phenotype_activ() const { return phenotype_activ_; } /// TODO -AbstractFuzzy* Individual::phenotype_inhib() const { +Fuzzy* Individual::phenotype_inhib() const { return phenotype_inhib_; } @@ -1279,22 +1279,22 @@ void Individual::compute_phenotype() { // * phenotype_activ_ for the proteins realising a set of functions // * phenotype_inhib_ for the proteins inhibiting a set of functions // The phenotype will then be given by the sum of these 2 fuzzy sets - phenotype_activ_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); - phenotype_inhib_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); + phenotype_activ_ = new Fuzzy(); + phenotype_inhib_ = new Fuzzy(); for (const auto& gen_unit: genetic_unit_list_) { phenotype_activ_->add(*gen_unit.activ_contribution()); phenotype_inhib_->add(*gen_unit.inhib_contribution()); } - phenotype_activ_->clip(AbstractFuzzy::max, Y_MAX); - phenotype_inhib_->clip(AbstractFuzzy::min, - Y_MAX); + phenotype_activ_->clip(Fuzzy::max, Y_MAX); + phenotype_inhib_->clip(Fuzzy::min, - Y_MAX); - phenotype_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); + phenotype_ = new Fuzzy(); phenotype_->add(*phenotype_activ_); phenotype_->add(*phenotype_inhib_); - phenotype_->clip(AbstractFuzzy::min, Y_MIN); + phenotype_->clip(Fuzzy::min, Y_MIN); phenotype_->simplify(); } @@ -1312,7 +1312,7 @@ void Individual::compute_distance_to_target(const PhenotypicTarget& target) { compute_phenotype(); // Compute the difference between the (whole) phenotype and the target - AbstractFuzzy* delta = FuzzyFactory::fuzzyFactory->create_fuzzy(*phenotype_); + Fuzzy* delta = new Fuzzy(*phenotype_); bool verbose = false; // if ((id_ == 966) && AeTime::time()==447) { // printf("Target %lf :: I %lf\n",target.fuzzy()->get_geometric_area(),delta->get_geometric_area()); diff --git a/src/libaevol/legacy/population/Individual.h b/src/libaevol/legacy/population/Individual.h index e5d4fe2f54e11c4edddd96962690a350bb1e5656..9e0477721022b66a4ef0a98101e1858ced81583e 100644 --- a/src/libaevol/legacy/population/Individual.h +++ b/src/libaevol/legacy/population/Individual.h @@ -172,8 +172,8 @@ class Individual : public Observable { Phenotype* phenotype() const; - AbstractFuzzy* phenotype_activ() const; - AbstractFuzzy* phenotype_inhib() const; + Fuzzy* phenotype_activ() const; + Fuzzy* phenotype_inhib() const; #ifndef __REGUL const PhenotypicTarget& phenotypic_target() const; @@ -545,8 +545,8 @@ class Individual : public Observable { int32_t rank_; // [1 ; POP_SIZE] // Total activation (resp. inhibition) of metabolic functions - AbstractFuzzy* phenotype_activ_ = nullptr; - AbstractFuzzy* phenotype_inhib_ = nullptr; + Fuzzy* phenotype_activ_ = nullptr; + Fuzzy* phenotype_inhib_ = nullptr; // The phenotype, roughly corresponding to the sum of activ and inhib Phenotype* phenotype_ = nullptr; diff --git a/src/libaevol/legacy/raevol/Individual_R.cpp b/src/libaevol/legacy/raevol/Individual_R.cpp index bf107a3308ae7a1f6726a06188ff6b0e803e2c8e..b7ab4646a23437db81c09bb184f7770969106782 100644 --- a/src/libaevol/legacy/raevol/Individual_R.cpp +++ b/src/libaevol/legacy/raevol/Individual_R.cpp @@ -454,9 +454,9 @@ void Individual_R::init_indiv(const Habitat_R& habitat) phenotype_activ_ = NULL; phenotype_inhib_ = NULL; } - phenotype_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); - phenotype_activ_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); - phenotype_inhib_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); + phenotype_ = new Fuzzy(); + phenotype_activ_ = new Fuzzy(); + phenotype_inhib_ = new Fuzzy(); //---------------------------------------------------------------------------- // 2) Make a list of all the rna present in the individual @@ -775,9 +775,9 @@ void Individual_R::update_phenotype( void ) delete phenotype_; // printf("%d -- Delete phenotype\n",id_); - phenotype_activ_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); - phenotype_inhib_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); - phenotype_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); + phenotype_activ_ = new Fuzzy(); + phenotype_inhib_ = new Fuzzy(); + phenotype_ = new Fuzzy(); // printf("%d -- Allocate phenotype : %u %u %u\n",id_,((Fuzzy*)phenotype_activ_)->points().size(), // ((Fuzzy*)phenotype_inhib_)->points().size(),((Fuzzy*)phenotype_)->points().size()); @@ -842,8 +842,8 @@ void Individual_R::update_phenotype( void ) } - phenotype_activ_->clip(AbstractFuzzy::max, Y_MAX); - phenotype_inhib_->clip(AbstractFuzzy::min, - Y_MAX); + phenotype_activ_->clip(Fuzzy::max, Y_MAX); + phenotype_inhib_->clip(Fuzzy::min, - Y_MAX); phenotype_activ_->simplify(); phenotype_inhib_->simplify(); @@ -852,7 +852,7 @@ void Individual_R::update_phenotype( void ) phenotype_->add(*phenotype_inhib_); // if (id_==543 && AeTime::time() == 5895) {printf("BEFORE CLIP\n"); phenotype_->print();} - phenotype_->clip(AbstractFuzzy::min, Y_MIN); + phenotype_->clip(Fuzzy::min, Y_MIN); // if (id_==543 && AeTime::time() == 5895) {printf("BEFORE SIMPLIFY\n"); phenotype_->print();} phenotype_->simplify(); // if (id_==543 && AeTime::time() == 5895) {phenotype_->print();} diff --git a/src/libaevol/phenotype/Phenotype.h b/src/libaevol/phenotype/Phenotype.h index 379e834918647b32df9c694f2133971fb980753c..1fc5e923c2080ae4fc31b34bcdaa104ef3a145bf 100644 --- a/src/libaevol/phenotype/Phenotype.h +++ b/src/libaevol/phenotype/Phenotype.h @@ -39,12 +39,13 @@ // ================================================================= // Project Files // ================================================================= -#include "legacy/phenotype/fuzzy/AbstractFuzzy.h" +#include "legacy/phenotype/fuzzy/Fuzzy.h" namespace aevol { // A phenotype is nothing more than a fuzzy set -using Phenotype = AbstractFuzzy; +// TODO<dpa> This is legacy Fuzzy +using Phenotype = Fuzzy; } // namespace aevol diff --git a/src/libaevol/phenotype/PhenotypicTarget.cpp b/src/libaevol/phenotype/PhenotypicTarget.cpp index 3d398098707ee6c9a065919be5bab117d784a6ce..4501ce989c01f0bdd36a8c26960337d872e943f8 100644 --- a/src/libaevol/phenotype/PhenotypicTarget.cpp +++ b/src/libaevol/phenotype/PhenotypicTarget.cpp @@ -31,7 +31,7 @@ // Includes // ============================================================================ #include "PhenotypicTarget.h" -#include "legacy/phenotype/fuzzy/FuzzyFactory.h" +#include "legacy/phenotype/fuzzy/Fuzzy.h" #include <cstring> @@ -53,7 +53,7 @@ namespace aevol { // Constructors // ============================================================================ PhenotypicTarget::PhenotypicTarget() { - fuzzy_ = FuzzyFactory::fuzzyFactory->create_fuzzy(); + fuzzy_ = new Fuzzy(); nb_segments_ = 1; segments_ = new PhenotypicSegment * [1]; segments_[0] = new PhenotypicSegment(X_MIN, X_MAX, METABOLISM); @@ -61,7 +61,7 @@ PhenotypicTarget::PhenotypicTarget() { } PhenotypicTarget::PhenotypicTarget(const PhenotypicTarget& rhs) { - fuzzy_ = FuzzyFactory::fuzzyFactory->create_fuzzy(*(rhs.fuzzy())); + fuzzy_ = new Fuzzy(*(rhs.fuzzy())); nb_segments_ = rhs.nb_segments_; segments_ = new PhenotypicSegment * [nb_segments_]; for (int8_t i = 0 ; i < nb_segments_ ; i++) diff --git a/src/libaevol/phenotype/PhenotypicTarget.h b/src/libaevol/phenotype/PhenotypicTarget.h index b8c14b3ce39efd78b27a96efc2c97a1e71451d77..366b9c4791d82743f047cd64e1f64e19289eea1a 100644 --- a/src/libaevol/phenotype/PhenotypicTarget.h +++ b/src/libaevol/phenotype/PhenotypicTarget.h @@ -95,7 +95,7 @@ class PhenotypicTarget return segments_; } - AbstractFuzzy* fuzzy() const { + Fuzzy* fuzzy() const { return fuzzy_; } // ========================================================================== @@ -126,7 +126,7 @@ class PhenotypicTarget /// Geometric area of each feature double* area_by_feature_; - AbstractFuzzy* fuzzy_; + Fuzzy* fuzzy_; }; diff --git a/src/libaevol/phenotype/PhenotypicTargetHandler.cpp b/src/libaevol/phenotype/PhenotypicTargetHandler.cpp index abf7e765d2cef321718d0b3c80b6bf9fd995e1cc..06d34a0f22f6a227cb39ba0f483fdf3b931e3cd2 100644 --- a/src/libaevol/phenotype/PhenotypicTargetHandler.cpp +++ b/src/libaevol/phenotype/PhenotypicTargetHandler.cpp @@ -155,8 +155,8 @@ void PhenotypicTargetHandler::BuildPhenotypicTarget() { // Add lower and upper bounds - phenotypic_target_->fuzzy()->clip(AbstractFuzzy::min, Y_MIN); - phenotypic_target_->fuzzy()->clip(AbstractFuzzy::max, Y_MAX); + phenotypic_target_->fuzzy()->clip(Fuzzy::min, Y_MIN); + phenotypic_target_->fuzzy()->clip(Fuzzy::max, Y_MAX); // if (FuzzyFactory::fuzzyFactory->get_fuzzy_flavor() == 0) { // printf("Size of points %d\n",((Fuzzy*)phenotypic_target_->fuzzy())->points().size()); @@ -344,7 +344,7 @@ void PhenotypicTargetHandler::load(gzFile backup_file) { int8_t tmp_cur_noise_saved; gzread(backup_file, &tmp_cur_noise_saved, sizeof(tmp_cur_noise_saved)); if (tmp_cur_noise_saved) - cur_noise_ = FuzzyFactory::fuzzyFactory->create_fuzzy(backup_file); + cur_noise_ = new Fuzzy(backup_file); noise_prng_ = std::make_shared<JumpingMT>(backup_file); gzread(backup_file, &noise_alpha_, sizeof(noise_alpha_)); diff --git a/src/libaevol/phenotype/PhenotypicTargetHandler.h b/src/libaevol/phenotype/PhenotypicTargetHandler.h index 090cd39076d71ec47cb5aa593435727349d1372b..d52646bb850f2147c5ba8c695564d48f2d2a5c69 100644 --- a/src/libaevol/phenotype/PhenotypicTargetHandler.h +++ b/src/libaevol/phenotype/PhenotypicTargetHandler.h @@ -44,7 +44,7 @@ #include "Gaussian.h" #include "ae_enums.h" #include "JumpingMT.h" -#include "legacy/phenotype/fuzzy/AbstractFuzzy.h" +#include "legacy/phenotype/fuzzy/Fuzzy.h" using std::list; @@ -244,7 +244,7 @@ class PhenotypicTargetHandler // -------------------------------------------------------------------- Noise /// Current noise (pure noise that is added to the phenotypic target) - AbstractFuzzy* cur_noise_ = NULL; + Fuzzy* cur_noise_ = nullptr; /// PRNG used for noise std::shared_ptr<JumpingMT> noise_prng_; PhenotypicTargetNoiseMethod noise_method_; diff --git a/src/libaevol/raevol/PhenotypicTargetHandler_R.cpp b/src/libaevol/raevol/PhenotypicTargetHandler_R.cpp index 493eeb6ab4fa769bd94289df49468a60656dea64..b69f739b49b849bb2456a5d5a06fed8042837c77 100644 --- a/src/libaevol/raevol/PhenotypicTargetHandler_R.cpp +++ b/src/libaevol/raevol/PhenotypicTargetHandler_R.cpp @@ -491,8 +491,8 @@ void PhenotypicTargetHandler_R::BuildPhenotypicTargetModel( int16_t id) { } } // Add lower and upper bounds - phenotypic_target->fuzzy()->clip(AbstractFuzzy::min, Y_MIN); - phenotypic_target->fuzzy()->clip(AbstractFuzzy::max, Y_MAX); + phenotypic_target->fuzzy()->clip(Fuzzy::min, Y_MIN); + phenotypic_target->fuzzy()->clip(Fuzzy::max, Y_MAX); // Simplify (get rid of useless points) phenotypic_target->fuzzy()->simplify(); diff --git a/src/libaevol/raevol/PhenotypicTarget_R.cpp b/src/libaevol/raevol/PhenotypicTarget_R.cpp index aa7321b825777bbfcfcd10ea07cda0348e08732b..6995581b8e10e136afee83ffbbb6355e73b736db 100644 --- a/src/libaevol/raevol/PhenotypicTarget_R.cpp +++ b/src/libaevol/raevol/PhenotypicTarget_R.cpp @@ -31,7 +31,6 @@ // Includes // ============================================================================ #include "PhenotypicTarget_R.h" -#include "legacy/phenotype/fuzzy/FuzzyFactory.h" #include <cstring> diff --git a/src/libaevol/stats/AncestorStats.cpp b/src/libaevol/stats/AncestorStats.cpp index 0f5c57a0046ad59edb947c32147392e9d27af090..281bc6d7c9d75f4a11a6f4c396739a46bad79234 100644 --- a/src/libaevol/stats/AncestorStats.cpp +++ b/src/libaevol/stats/AncestorStats.cpp @@ -394,9 +394,9 @@ void AncestorStats::write_zones_stats(int64_t t, } - AbstractFuzzy* activ = NULL; - AbstractFuzzy* inhib = NULL; - Phenotype* phen = NULL; + Fuzzy* activ = nullptr; + Fuzzy* inhib = nullptr; + Phenotype* phen = nullptr; diff --git a/src/post_treatments/aevol_post_ancestor_stats.cpp b/src/post_treatments/aevol_post_ancestor_stats.cpp index 2d78011fde8cb3a75baa4e714e54d1ea9e3e333c..2755a4e0848f8b09203c16616fa15d303a997b79 100644 --- a/src/post_treatments/aevol_post_ancestor_stats.cpp +++ b/src/post_treatments/aevol_post_ancestor_stats.cpp @@ -784,8 +784,8 @@ void write_zones_stats(int64_t t, } - AbstractFuzzy* activ = NULL; - AbstractFuzzy* inhib = NULL; + Fuzzy* activ = NULL; + Fuzzy* inhib = NULL; Phenotype* phen = NULL; diff --git a/src/post_treatments/libaevol_post/neutral_mutation_exp.cpp b/src/post_treatments/libaevol_post/neutral_mutation_exp.cpp index 9e144ab8f6cf93c87ab7bea17cb071b7ee790bb4..fc3a4cc355eb8468a8ae168816f1bcf1773b5205 100644 --- a/src/post_treatments/libaevol_post/neutral_mutation_exp.cpp +++ b/src/post_treatments/libaevol_post/neutral_mutation_exp.cpp @@ -7,7 +7,6 @@ #include "legacy/biochemistry/Dna.h" #include "DnaMutator.h" #include "ExpSetup.h" -#include "legacy/phenotype/fuzzy/FuzzyFactory.h" #include "legacy/population/Individual.h" #include "JumpingMT.h" #include "MutationEvent.h" @@ -191,7 +190,6 @@ Individual *neutral_mutation_constant_size(Individual *individual, unsigned int Individual * run_to_size(int32_t wanted_size, Individual* indiv) { auto *individual = new Individual(*indiv); - FuzzyFactory::fuzzyFactory = new FuzzyFactory(); individual->clear_everything_except_dna_and_promoters(); individual->compute_phenotype(); unsigned int current_generation = 0; @@ -210,7 +208,6 @@ Individual * run_to_size(int32_t wanted_size, Individual* indiv) { Individual* run_to_homogenize(uint32_t nb_gen, Individual* indiv) { auto *individual = new Individual(*indiv); - FuzzyFactory::fuzzyFactory = new FuzzyFactory(); individual->clear_everything_except_dna_and_promoters(); individual->compute_phenotype(); unsigned int current_generation = 0; @@ -229,7 +226,6 @@ Individual* run_to_homogenize(uint32_t nb_gen, Individual* indiv) { Individual * run_generations(unsigned int nb_generations, Individual* indiv) { auto *individual = new Individual(*indiv); - FuzzyFactory::fuzzyFactory = new FuzzyFactory(); individual->clear_everything_except_dna_and_promoters(); individual->compute_phenotype();