Ignore:
Timestamp:
07/13/20 13:53:25 (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

    r969 r1000  
    1616/** @name Values of constants used in encoding */
    1717//@{
     18#define MODE_SEPARATOR ':'
    1819#define BRANCH_START '('
    1920#define BRANCH_END ')'
     
    3536        RIGHT = 1
    3637};
    37 
    38 /** @name Every modifier changes the underlying value by this multiplier */
    39 const double MODIFIER_MULTIPLIER = 1.1;
    40 /**
    41  * Used in finding the proper distance between the parts
    42  * distance between spheres / sphere radius
    43  * That default value can be changed in certain cases
    44  * */
    45 const float SPHERE_RELATIVE_DISTANCE = 0.25;
    46 /**
    47  * Used in finding the proper distance between the parts
    48  * The maximal allowed value for
    49  * maximal radius of the node / sphere radius
    50  */
    51 const int MAX_DIAMETER_QUOTIENT = 30;
    52 /**
    53  * The tolerance of the value of distance between parts
    54  */
    55 const double SPHERE_DISTANCE_TOLERANCE = 0.99;
    5638
    5739
     
    10991const vector<string> PARAMS {INGESTION, FRICTION, ROT_X, ROT_Y, ROT_Z, RX, RY, RZ, SIZE, SIZE_X, SIZE_Y, SIZE_Z,
    11092                                                         STIFFNESS};
     93const vector<string> SIZE_PARAMS {SIZE, SIZE_X, SIZE_Y, SIZE_Z};
    11194
    11295/** @name Default values of node parameters*/
    113 static const Part defPart = Model::getDefPart();
    114 static const Joint defJoint = Model::getDefJoint();
    11596const std::map<Part::Shape, double> volumeMultipliers = {
    11697                {Part::Shape::SHAPE_CUBOID, 8.0},
     
    11899                {Part::Shape::SHAPE_ELLIPSOID, (4.0 / 3.0) * M_PI},
    119100};
    120 const std::map<string, double> defaultValues = {
    121                 {INGESTION,      defPart.ingest},
    122                 {FRICTION,       defPart.friction},
    123                 {STIFFNESS,              defJoint.stif},
    124                 {ROT_X,          0.0},
    125                 {ROT_Y,          0.0},
    126                 {ROT_Z,          0.0},
    127                 {RX,             0.0},
    128                 {RY,             0.0},
    129                 {RZ,             0.0},
    130                 {SIZE,           1.0},
    131                 {SIZE_X,         1.0},
    132                 {SIZE_Y,         1.0},
    133                 {SIZE_Z,         1.0}
    134 };
    135 
    136 const std::map<string, double> minValues = {
    137                 {INGESTION,      0},
    138                 {FRICTION,       0},
    139                 {STIFFNESS,      0.0},
    140                 {ROT_X,          -M_PI},
    141                 {ROT_Y,          -M_PI},
    142                 {ROT_Z,          -M_PI},
    143                 {RX,             -M_PI},
    144                 {RY,             -M_PI},
    145                 {RZ,             -M_PI},
    146                 {SIZE,           0.01},
    147                 {SIZE_X,         0.01},
    148                 {SIZE_Y,         0.01},
    149                 {SIZE_Z,         0.01}
    150 };
    151 
    152 const std::map<string, double> maxValues = {
    153                 {INGESTION,      1.0},
    154                 {FRICTION,       1.0},
    155                 {STIFFNESS,      0.0},
    156                 {ROT_X,          M_PI},
    157                 {ROT_Y,          M_PI},
    158                 {ROT_Z,          M_PI},
    159                 {RX,             M_PI},
    160                 {RY,             M_PI},
    161                 {RZ,             M_PI},
    162                 {SIZE,           100.0},
    163                 {SIZE_X,         100.0},
    164                 {SIZE_Y,         100.0},
    165                 {SIZE_Z,         100.0}
    166 };
     101
     102extern const std::map<string, double> defaultValues;
    167103
    168104/** @name Number of tries of performing a mutation before GENOPER_FAIL is returned */
     
    318254};
    319255
     256struct GenotypeParams{
     257        double modifierMultiplier;      // Every modifier changes the underlying value by this multiplier
     258};
     259
    320260/**
    321261 * Represents a node in the graph that represents a genotype.
     
    334274        Part *part;     /// A part object built from node. Used in building the Model
    335275        int partCodeLen; /// The length of substring that directly describes the corresponding part
    336 
    337         std::map<string, double> params; /// The map of all the node params
     276        GenotypeParams genotypeParams;
     277
     278
    338279        vector<Node *> children;    /// Vector of all direct children
    339280        std::map<char, int> modifiers;     /// Vector of all modifiers
     
    432373        Part::Shape partType;  /// The type of the part
    433374        State *state = nullptr; /// The phenotypic state that inherits from ancestors
    434 
    435         Node(Substring &genotype, Node *parent);
     375        std::map<string, double> params; /// The map of all the node params
     376
     377        Node(Substring &genotype, Node *parent, GenotypeParams genotypeParams);
    436378
    437379        ~Node();
     
    463405         * @return True if the parameter value was change, false otherwise
    464406         */
    465         bool changeSizeParam(string paramKey,  bool ensureCircleSection);
     407        bool mutateSizeParam(string paramKey,  bool ensureCircleSection);
    466408
    467409        /**
Note: See TracChangeset for help on using the changeset viewer.