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

Added a helper function; cosmetic changes in names and descriptions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.