Ignore:
Timestamp:
07/14/20 16:04:46 (4 years ago)
Author:
Maciej Komosinski
Message:

Improved the fS encoding

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/fS/fS_general.h

    r1000 r1006  
    2727const char NEURON_END = ']';
    2828const char NEURON_SEPARATOR = ';';
    29 const SString NEURON_INTERNAL_SEPARATOR("_");
     29const SString NEURON_INTERNAL_SEPARATOR("'");
    3030#define NEURON_I_W_SEPARATOR ':'
    3131//@}
     
    6969const char CUBOID = 'C';
    7070const char CYLINDER = 'R';
    71 const std::unordered_map<Part::Shape, char> SHAPETYPE_TO_GENE = {
     71const std::unordered_map<Part::Shape, char> SHAPE_TO_GENE = {
    7272                {Part::Shape::SHAPE_ELLIPSOID, ELLIPSOID},
    7373                {Part::Shape::SHAPE_CUBOID,    CUBOID},
     
    7676
    7777// This map is inverse to SHAPE_TO_SYMBOL. Those two should be compatible
    78 const std::unordered_map<char, Part::Shape> GENE_TO_SHAPETYPE = {
     78const std::unordered_map<char, Part::Shape> GENE_TO_SHAPE = {
    7979                {ELLIPSOID, Part::Shape::SHAPE_ELLIPSOID},
    8080                {CUBOID,    Part::Shape::SHAPE_CUBOID},
    8181                {CYLINDER,  Part::Shape::SHAPE_CYLINDER},
    8282};
    83 const int SHAPE_COUNT = 3;    // This should be the count of SHAPETYPE_TO_GENE and GENE_TO_SHAPETYPE
     83const int SHAPE_COUNT = 3;    // This should be the count of SHAPE_TO_GENE and GENE_TO_SHAPE
    8484
    8585const char DEFAULT_JOINT = 'a';
     
    100100};
    101101
    102 extern const std::map<string, double> defaultValues;
    103 
    104102/** @name Number of tries of performing a mutation before GENOPER_FAIL is returned */
    105103#define mutationTries  20
     
    198196        MultiRange toMultiRange()
    199197        {
    200                 MultiRange range;
    201                 range.add(start, start + len - 1);
    202                 return range;
     198                int end = start + len - 1;
     199                return MultiRange(IRange(start, end));
    203200        }
    204201};
     
    244241{
    245242public:
     243        int start, end;
    246244        std::map<int, double> inputs;
    247245
     
    274272        Part *part;     /// A part object built from node. Used in building the Model
    275273        int partCodeLen; /// The length of substring that directly describes the corresponding part
     274        std::map<string, double> defaultValues;
    276275        GenotypeParams genotypeParams;
    277 
    278276
    279277        vector<Node *> children;    /// Vector of all direct children
    280278        std::map<char, int> modifiers;     /// Vector of all modifiers
    281279        vector<fS_Neuron *> neurons;    /// Vector of all the neurons
     280
     281        void prepareParams();
    282282
    283283        double getDistance();
     
    398398
    399399        /**
    400          * Change the value of the size parameter by given multiplier
    401          * Do not change the value if any of the size restrictions is not satisfied
    402          * @param paramKey
    403          * @param multiplier
    404          * @param ensureCircleSection
    405          * @return True if the parameter value was change, false otherwise
    406          */
    407         bool mutateSizeParam(string paramKey,  bool ensureCircleSection);
    408 
    409         /**
    410400         * Counts all the nodes in subtree
    411401         * @return node count
     
    521511         * @param a reference to a model that will contain a built model
    522512         */
    523         void buildModel(Model &model);
     513        Model buildModel(bool using_checkpoints);
    524514
    525515        /**
Note: See TracChangeset for help on using the changeset viewer.