Ignore:
Timestamp:
08/30/16 17:42:29 (8 years ago)
Author:
Maciej Komosinski
Message:

Code formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/model/similarity/simil_model.h

    r605 r606  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2016  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    1616enum TDNELEMS
    1717{
    18     ORIG_IND = 0,
    19     DEGREE = 1,
    20     NEURO_CONNS = 2,
    21     NEURONS = 3,
    22     FUZZ_DEG = 4
     18        ORIG_IND = 0,
     19        DEGREE = 1,
     20        NEURO_CONNS = 2,
     21        NEURONS = 3,
     22        FUZZ_DEG = 4
    2323};
    2424
     
    3232{
    3333public:
    34     ModelSimil();
    35     virtual ~ModelSimil();
    36     double EvaluateDistance(const Geno *G0, const Geno *G1);
     34        ModelSimil();
     35        virtual ~ModelSimil();
     36        double EvaluateDistance(const Geno *G0, const Geno *G1);
    3737
    38     static int CompareDegrees(const void *pElem1, const void *pElem2);
    39     static int CompareConnsNo(const void *pElem1, const void *pElem2);
    40     static int GetNOFactors();
     38        static int CompareDegrees(const void *pElem1, const void *pElem2);
     39        static int CompareConnsNo(const void *pElem1, const void *pElem2);
     40        static int GetNOFactors();
    4141#define STATRICKCLASS ModelSimil
    42     PARAMPROCDEF(p_evaldistance);
     42        PARAMPROCDEF(p_evaldistance);
    4343#undef STATRICKCLASS
    4444
    4545protected:
    46     void _PrintSeamnessTable(std::vector<int> *pVector, int iCount);
    47     //matching function
    48     int MatchPartsGeometry();
    49     void ComputeMatching();
    50     void _PrintPartsMatching();
    51     void SaveIntermediateFiles();
     46        void _PrintSeamnessTable(std::vector<int> *pVector, int iCount);
     47        //matching function
     48        int MatchPartsGeometry();
     49        void ComputeMatching();
     50        void _PrintPartsMatching();
     51        void SaveIntermediateFiles();
    5252
    53     static int CheckPartsIdentity(Part *P1, Part *P2);
    54     int SortPartInfoTables();
    55     int CountPartNeurons();
    56     bool ComputePartsPositionsBySVD();
    57     int GetPartPositions();
    58     int CountPartDegrees();
     53        static int CheckPartsIdentity(Part *P1, Part *P2);
     54        int SortPartInfoTables();
     55        int CountPartNeurons();
     56        bool ComputePartsPositionsBySVD();
     57        int GetPartPositions();
     58        int CountPartDegrees();
    5959
    60     int SortPartInfoFuzzy();
    61     void CountFuzzyNeighb();
    62     void SortFuzzyNeighb();
    63     void GetNeighbIndexes(int mod, int partInd, std::vector<int> &indexes);
    64     void CheckFuzzyIdentity();
     60        int SortPartInfoFuzzy();
     61        void CountFuzzyNeighb();
     62        void SortFuzzyNeighb();
     63        void GetNeighbIndexes(int mod, int partInd, std::vector<int> &indexes);
     64        void CheckFuzzyIdentity();
    6565
    66     int CreatePartInfoTables();
    67     void _PrintDegrees(int i);
    68     void _PrintArray(int *array, int base, int size);
    69     void _PrintNeighbourhood(int i);
    70     void _PrintArrayDouble(double *array, int base, int size);
    71     int CountPartsDistance();
     66        int CreatePartInfoTables();
     67        void _PrintDegrees(int i);
     68        void _PrintArray(int *array, int base, int size);
     69        void _PrintNeighbourhood(int i);
     70        void _PrintArrayDouble(double *array, int base, int size);
     71        int CountPartsDistance();
    7272
    7373
    7474public:
    75     /// Table of weights for weighted distance function.
    76     /// Weights are for factors in the following order:
    77     /// [0]: m_iDV (difference in the number of vertices)
    78     /// [1]: m_iDD (difference in degrees over matching)
    79     /// [2]: m_iDN (difference in neurons over matching)
    80     /// [3]: m_dDG (difference in geometry over matching)
    81     /// @sa EvaluateDistance
    82     double m_adFactors[4];
     75        /// Table of weights for weighted distance function.
     76        /// Weights are for factors in the following order:
     77        /// [0]: m_iDV (difference in the number of vertices)
     78        /// [1]: m_iDD (difference in degrees over matching)
     79        /// [2]: m_iDN (difference in neurons over matching)
     80        /// [3]: m_dDG (difference in geometry over matching)
     81        /// @sa EvaluateDistance
     82        double m_adFactors[4];
    8383
    8484        //for Zfixed = 1, the "z" (vertical) coordinates are not taken into account during PCA alignment
    8585        int fixedZaxis;
    86        
     86
    8787        //Controls the depth of fuzzy neighbourhood
    88     int fuzzyDepth;
    89     int isFuzzy;
     88        int fuzzyDepth;
     89        int isFuzzy;
    9090
    91     /// Interface to local parameters
    92     Param localpar;
     91        /// Interface to local parameters
     92        Param localpar;
    9393
    9494protected:
    9595
    96     /// Between these genotypes distance is evaluated.
    97     const Geno *m_Gen[2];
     96        /// Between these genotypes distance is evaluated.
     97        const Geno *m_Gen[2];
    9898
    99     /// These models will be created to get the information about creatures
    100     /// from their genotypes.
    101     Model *m_Mod[2];
     99        /// These models will be created to get the information about creatures
     100        /// from their genotypes.
     101        Model *m_Mod[2];
    102102
    103     /// Index (0 or 1) of the smaler creature (in the meaning of parts).
    104     /// Index of the bigger one is (1-m_iSmaller).
    105     int m_iSmaller;
     103        /// Index (0 or 1) of the smaler creature (in the meaning of parts).
     104        /// Index of the bigger one is (1-m_iSmaller).
     105        int m_iSmaller;
    106106
    107     /// Number of parts of two creatures (index the same as for m_Mod).
    108     int m_aiPartCount[2];
     107        /// Number of parts of two creatures (index the same as for m_Mod).
     108        int m_aiPartCount[2];
    109109
    110     /// Difference between number of parts in organisms
    111     int m_iDV;
     110        /// Difference between number of parts in organisms
     111        int m_iDV;
    112112
    113     /// Sum of absolute values of differences between matched part degrees
    114     int m_iDD;
     113        /// Sum of absolute values of differences between matched part degrees
     114        int m_iDD;
    115115
    116     /// Sum of absolute values of differences between matched part
    117     /// in neurons number.
    118     int m_iDN;
    119     //2 matrices of neighbourhood of parts - one for each genotype
     116        /// Sum of absolute values of differences between matched part
     117        /// in neurons number.
     118        int m_iDN;
     119        //2 matrices of neighbourhood of parts - one for each genotype
    120120
    121     /// Sum of Euclidean distances between matched parts
    122     /// Unmatched Parts have the distance measured to (0,0,0) (the middle of
    123     /// an organism)
    124     double m_dDG;
     121        /// Sum of Euclidean distances between matched parts
     122        /// Unmatched Parts have the distance measured to (0,0,0) (the middle of
     123        /// an organism)
     124        double m_dDG;
    125125
    126     /// Object that holds the matching of Parts.
    127     // It is not clear now whether the matching function is
    128     // created for orginal indices of Parts, or for sorted Parts
    129     // Most probably it is for sorted Parts.
    130     SimilMatching *m_pMatching;
     126        /// Object that holds the matching of Parts.
     127        // It is not clear now whether the matching function is
     128        // created for orginal indices of Parts, or for sorted Parts
     129        // Most probably it is for sorted Parts.
     130        SimilMatching *m_pMatching;
    131131
    132     /// Type of 4 ints - describing one Part of the creature in
    133     /// its sorted table of degrees
    134     /// TDN[0] - original index of creature's Part (that is "i" from GetPart(i))
    135     /// TDN[1] - degree (number of adjacent joints) of one Part
    136     /// TDN[2] - number of NeuroConnections and Neurons belonging to one Part
    137     /// TDN[3] - number of Neurons of the Part
    138     /// TDN[4] - fuzzy degree
    139     typedef int TDN[5];
     132        /// Type of 4 ints - describing one Part of the creature in
     133        /// its sorted table of degrees
     134        /// TDN[0] - original index of creature's Part (that is "i" from GetPart(i))
     135        /// TDN[1] - degree (number of adjacent joints) of one Part
     136        /// TDN[2] - number of NeuroConnections and Neurons belonging to one Part
     137        /// TDN[3] - number of Neurons of the Part
     138        /// TDN[4] - fuzzy degree
     139        typedef int TDN[5];
    140140
    141     /** 2 arrays holding information about compared organisms (one for each
    142     creature) of degree and neuro info for Parts.
    143     Index corresponds to the one in m_Mod
    144     m_aDegrees[i][j] is a TDN of the j-th Part of the i-th creature in m_Mod
    145      */
    146     TDN *m_aDegrees[2];
     141        /** 2 arrays holding information about compared organisms (one for each
     142        creature) of degree and neuro info for Parts.
     143        Index corresponds to the one in m_Mod
     144        m_aDegrees[i][j] is a TDN of the j-th Part of the i-th creature in m_Mod
     145        */
     146        TDN *m_aDegrees[2];
    147147
    148     //std::pair<TDN, double> *m_aDegrees[2];
    149     /// Holds information on all on-joint neurons. Only TDN[3] and TDN[4]
    150     /// are important (original index and degree are not important).
    151     TDN m_aOnJoint[2];
     148        //std::pair<TDN, double> *m_aDegrees[2];
     149        /// Holds information on all on-joint neurons. Only TDN[3] and TDN[4]
     150        /// are important (original index and degree are not important).
     151        TDN m_aOnJoint[2];
    152152
    153     /// Holds information on all neurons that are not placed neither on
    154     /// a joint nor on a part. Only TDN[3] and TDN[4]
    155     /// are important (original index and degree are not important).
    156     TDN m_aAnywhere[2];
     153        /// Holds information on all neurons that are not placed neither on
     154        /// a joint nor on a part. Only TDN[3] and TDN[4]
     155        /// are important (original index and degree are not important).
     156        TDN m_aAnywhere[2];
    157157
    158     //array of parts neighbourhood
    159     int **m_Neighbours[2];
    160     //array of "fuzzy neigbourhood" for each of organisms. Dimensions: parts_num x fuzzyDepth
    161     float **m_fuzzyNeighb[2];
     158        //array of parts neighbourhood
     159        int **m_Neighbours[2];
     160        //array of "fuzzy neigbourhood" for each of organisms. Dimensions: parts_num x fuzzyDepth
     161        float **m_fuzzyNeighb[2];
    162162
    163     /// Two arrays of points which hold information about positions of Parts
    164     /// of both of the compared organisms.
    165     /// Matching methods which do not use geometry (MatchPartsOld
    166     /// and MatchPartsNew) simply copy these positions from models. The only
    167     /// matching method which uses geometry (MatchPartsNewGeometry) makes
    168     /// use of these arrays extensively.
    169     /// At m_aPositions[ iModel ][ iOriginalPart ] there is a Pt3D of
    170     /// a Part with index iOriginalPart of the model iModel.
    171     /// iOriginalPart means that this index is the original index of a Part,
    172     /// (before sorting).
    173     Pt3D *m_aPositions[2];
     163        /// Two arrays of points which hold information about positions of Parts
     164        /// of both of the compared organisms.
     165        /// Matching methods which do not use geometry (MatchPartsOld
     166        /// and MatchPartsNew) simply copy these positions from models. The only
     167        /// matching method which uses geometry (MatchPartsNewGeometry) makes
     168        /// use of these arrays extensively.
     169        /// At m_aPositions[ iModel ][ iOriginalPart ] there is a Pt3D of
     170        /// a Part with index iOriginalPart of the model iModel.
     171        /// iOriginalPart means that this index is the original index of a Part,
     172        /// (before sorting).
     173        Pt3D *m_aPositions[2];
    174174
    175     /// Number of weights in the function which evaluates distance.
    176     static const int iNOFactors;
     175        /// Number of weights in the function which evaluates distance.
     176        static const int iNOFactors;
    177177
    178178};
Note: See TracChangeset for help on using the changeset viewer.