Changeset 1052


Ignore:
Timestamp:
12/12/20 00:32:55 (5 weeks ago)
Author:
Maciej Komosinski
Message:

Added a helper function; cosmetic changes in names and descriptions

Location:
cpp/frams/model/similarity
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/model/similarity/measure-distribution.cpp

    r1046 r1052  
    1212
    1313static ParamEntry simil_distribution_paramtab[] = {
    14                 { "Similarity: distribution", 1, 4, "SimilMeasureDistribution", "Evaluates morphological dissimilarity using distribution measure.", },
     14                { "Similarity: Descriptor distribution", 1, 4, "SimilMeasureDistribution", "Evaluates morphological dissimilarity using distribution measure.", },
    1515                { "simil_density", 0, 0, "Density of surface sampling", "f 1 100 10", FIELD(density), "", },
    1616                { "simil_bin_num", 0, 0, "Number of bins", "d 1 1000 128", FIELD(bin_num), "", },
  • cpp/frams/model/similarity/measure-greedy.cpp

    r1048 r1052  
    1414
    1515static ParamEntry simil_greedy_paramtab[] = {
    16                 { "Similarity: greedy", 1, 7, "SimilMeasureGreedy", "Evaluates morphological dissimilarity using greedy measure. More information:\nhttp://www.framsticks.com/bib/Komosinski-et-al-2001\nhttp://www.framsticks.com/bib/Komosinski-and-Kubiak-2011\nhttp://www.framsticks.com/bib/Komosinski-2016\nhttps://doi.org/10.1007/978-3-030-16692-2_8", },
     16                { "Similarity: Graph greedy", 1, 7, "SimilMeasureGreedy", "Evaluates morphological dissimilarity using greedy measure. More information:\nhttp://www.framsticks.com/bib/Komosinski-et-al-2001\nhttp://www.framsticks.com/bib/Komosinski-and-Kubiak-2011\nhttp://www.framsticks.com/bib/Komosinski-2016\nhttps://doi.org/10.1007/978-3-030-16692-2_8", },
    1717                { "simil_parts", 0, 0, "Weight of parts count", "f 0 100 0", FIELD(m_adFactors[0]), "Differing number of parts is also handled by the 'part degree' similarity component.", },
    1818                { "simil_partdeg", 0, 0, "Weight of parts' degree", "f 0 100 1", FIELD(m_adFactors[1]), "", },
  • cpp/frams/model/similarity/measure-hungarian.cpp

    r1048 r1052  
    1010
    1111static ParamEntry simil_hungarian_paramtab[] = {
    12                 { "Similarity: hungarian", 1, 7, "SimilMeasureHungarian", "Evaluates morphological dissimilarity using hungarian measure. More information:\nhttp://www.framsticks.com/bib/Komosinski-et-al-2001\nhttp://www.framsticks.com/bib/Komosinski-and-Kubiak-2011\nhttp://www.framsticks.com/bib/Komosinski-2016\nhttps://doi.org/10.1007/978-3-030-16692-2_8", },
     12                { "Similarity: Graph optimal", 1, 7, "SimilMeasureHungarian", "Evaluates morphological dissimilarity using hungarian measure. More information:\nhttp://www.framsticks.com/bib/Komosinski-et-al-2001\nhttp://www.framsticks.com/bib/Komosinski-and-Kubiak-2011\nhttp://www.framsticks.com/bib/Komosinski-2016\nhttps://doi.org/10.1007/978-3-030-16692-2_8", },
    1313                { "simil_parts", 0, 0, "Weight of parts count", "f 0 100 0", FIELD(m_adFactors[0]), "Differing number of parts is also handled by the 'part degree' similarity component.", },
    1414                { "simil_partdeg", 0, 0, "Weight of parts' degree", "f 0 100 1", FIELD(m_adFactors[1]), "", },
  • cpp/frams/model/similarity/simil-measure.cpp

    r1048 r1052  
    1212static ParamEntry simil_measure_paramtab[] = {
    1313        { "Similarity", 1, 2, "SimilMeasure", "Evaluates morphological dissimilarity. More information:\nhttp://www.framsticks.com/bib/Komosinski-et-al-2001\nhttp://www.framsticks.com/bib/Komosinski-and-Kubiak-2011\nhttp://www.framsticks.com/bib/Komosinski-2016\nhttps://doi.org/10.1007/978-3-030-16692-2_8", },
    14         { "measure_type", 0, 0, "Type of similarity measure", "d 0 2 0 ~Greedy (flexible criteria order and optimal matching)~Hungarian (vertex degree order and greedy matching)~Distribution (EMD on a histogram of descriptor values)", FIELD(measure_type), "", },
     14        { "type", 0, 0, "Type of similarity measure", "d 0 2 1 ~Graph greedy (vertex degree order and greedy matching)~Graph optimal (flexible criteria order and optimal matching)~Descriptor distribution (EMD on a histogram of descriptor values)", FIELD(type), "", },
    1515        { "evaluateDistance", 0, PARAM_DONTSAVE | PARAM_USERHIDDEN, "Evaluate model dissimilarity", "p f(oGeno,oGeno)", PROCEDURE(p_evaldistance), "Calculates dissimilarity between two models created from Geno objects.", },
    1616        { 0, },
     
    2424}
    2525
     26SimilMeasureBase *SimilMeasure::currentMeasure()
     27{
     28        SimilMeasureBase *measures[] = { &simil_measure_greedy,&simil_measure_hungarian,&simil_measure_distribution };
     29        if (type >= 0 && type <= (int)std::size(measures))
     30                return measures[type];
     31        logPrintf("SimilarityMeasure", "currentMeasure", LOG_ERROR, "Measure type '%d' not supported", type);
     32        return nullptr;
     33}
     34
    2635double SimilMeasure::evaluateDistance(const Geno* G0, const Geno* G1)
    2736{
    28         SimilMeasureBase *measures[] = { &simil_measure_greedy,&simil_measure_hungarian,&simil_measure_distribution };
    29         if (measure_type >= 0 && measure_type <= 2)
    30                 return measures[measure_type]->evaluateDistance(G0, G1);
    31         logPrintf("SimilarityMeasure", "evaluateDistance", LOG_ERROR, "Measure type '%d' not supported", measure_type);
     37        SimilMeasureBase *measure = currentMeasure();
     38        if (measure)
     39                return measure->evaluateDistance(G0, G1);
    3240        return -1;
    3341}
  • cpp/frams/model/similarity/simil-measure.h

    r1048 r1052  
    1313{
    1414public:
    15         int measure_type;
     15        int type;
    1616
    1717        SimilMeasureGreedy simil_measure_greedy;
     
    2424        SimilMeasure();
    2525        virtual ~SimilMeasure() {};
     26        SimilMeasureBase *currentMeasure();
    2627        double evaluateDistance(const Geno *G0, const Geno *G1);
    2728
Note: See TracChangeset for help on using the changeset viewer.