Ignore:
Timestamp:
10/07/18 13:23:11 (6 years ago)
Author:
oriona
Message:

MDS procedure replaced with weighted MDS procedure.

File:
1 edited

Legend:

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

    r782 r817  
    3535
    3636static ParamEntry MSparam_tab[] = {
    37                 { "Creature: Similarity", 1, 6, "ModelSimilarity", "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", },
     37                { "Creature: Similarity", 1, 7, "ModelSimilarity", "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", },
    3838                { "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.", },
    3939                { "simil_partdeg", 0, 0, "Weight of parts' degree", "f 0 100 1", FIELD(m_adFactors[1]), "", },
     
    4141                { "simil_partgeom", 0, 0, "Weight of parts' geometric distances", "f 0 100 0", FIELD(m_adFactors[3]), "", },
    4242                { "simil_fixedZaxis", 0, 0, "Fix 'z' (vertical) axis?", "d 0 1 0", FIELD(fixedZaxis), "", },
     43                { "simil_weightedMDS", 0, 0, "Should weighted MDS be used?", "d 0 1 0", FIELD(wMDS), "", },
    4344                { "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.", },
    4445                { 0, },
     
    7576        isFuzzy = 0;
    7677        fuzzyDepth = 10;
     78       
     79        //Determines whether weighted MDS should be used.
     80        wMDS = 0;
    7781}
    7882
     
    19811985                int nSize = m_Mod[iMod]->getPartCount();
    19821986
    1983                 double *pDistances = (double *)malloc(nSize * nSize * sizeof(double));
     1987                double *pDistances =  new double[nSize * nSize];
    19841988
    19851989                for (int i = 0; i < nSize; i++)
     
    19931997                Pt3D P1Pos, P2Pos; // positions of parts
    19941998                double dDistance; // the distance between Parts
     1999               
     2000                double *weights = new double[nSize];
     2001                for (int i = 0; i < nSize; i++)
     2002                {
     2003                        if (wMDS==1)
     2004                                weights[i] = 0;
     2005                        else
     2006                                weights[i] = 1;
     2007                }
     2008                               
     2009                if (wMDS==1)
     2010                        for (int i = 0; i < pModel->getJointCount(); i++)
     2011                        {
     2012                                weights[pModel->getJoint(i)->p1_refno]++;
     2013                                weights[pModel->getJoint(i)->p2_refno]++;
     2014                        }
     2015               
    19952016                for (iP1 = 0; iP1 < pModel->getPartCount(); iP1++)
    19962017                {
     
    20202041                } // for (iP1)
    20212042
    2022                 MatrixTools::SVD(vEigenvalues, nSize, pDistances, m_aPositions[iMod]);
     2043                MatrixTools::weightedMDS(vEigenvalues, nSize, pDistances, m_aPositions[iMod], weights);
    20232044                if (fixedZaxis == 1) //restore the original vertical coordinate of each Part
    20242045                {
     
    20292050                }
    20302051
    2031                 free(pDistances);
     2052                delete[] pDistances;
     2053                delete[] weights;
    20322054        }
    20332055
Note: See TracChangeset for help on using the changeset viewer.