source: cpp/frams/model/similarity/measure-hungarian.h @ 1273

Last change on this file since 1273 was 1044, checked in by oriona, 4 years ago

Similarity measures code refactored. Distribution-based similarity measure added.

File size: 2.0 KB
RevLine 
[1044]1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5#ifndef HUNGARIAN_MEASURE_H
6#define HUNGARIAN_MEASURE_H
7
8#include "measure-mds-based.h"
9#include "frams/genetics/geno.h"
10#include "frams/model/model.h"
11#include "hungarian/hungarian.h"
12
13class SimilMeasureHungarian : public SimilMeasureMDSBased
14{
15public:
16        SimilMeasureHungarian();
17        ~SimilMeasureHungarian(){};
18       
19        double distanceForTransformation();
20        double distanceWithoutAlignment();
21       
22        static int getNOFactors();
23        int setParams(std::vector<double> params);
24
25        /// Table of weights for weighted distance function.
26        /// Weights are for factors in the following order:
27        /// [0]: m_iDV (difference in the number of vertices)
28        /// [1]: m_iDD (difference in degrees over matching)
29        /// [2]: m_iDN (difference in neurons over matching)
30        /// [3]: m_dDG (difference in geometry over matching)
31        /// @sa EvaluateDistance
32        double m_adFactors[4];
33       
34        /// Interface to local parameters
35        Param localpar;
36
37protected:
38        void prepareData();
39        void beforeTransformation();
40        void copyMatching();
41        void cleanData();
42       
43        void countDegrees();
44        void countNeurons();
45        void fillPartsDistances(double*& dist, int bigger, int smaller, bool geo);
46        double addNeuronsPartsDiff(double dist);
47       
48        //Smaller and greater structures sizes
49        int nSmaller;
50        int nBigger;
51       
52        //Vertex degrees for both structures
53        int *degrees[2];
54       
55        //Count of neurons attached to each parts for both structures
56        int *neurons[2];
57       
58        //Number of on-joint and unattached neurons for both structures
59        int on_joint[2];
60        int anywhere[2];
61       
62        //Temporary and final assignment
63        int *assignment;
64        std::vector<int> min_assignment;
65       
66        //Final and temporary parts distances
67        double* parts_distances;
68        double* temp_parts_distances;
69       
70        HungarianAlgorithm hungarian;
71       
72        /// Number of weights in the function which evaluates distance.
73        static const int iNOFactors;
74};
75
76
77#endif /* HUNGARIAN_MEASURE_H */
78
Note: See TracBrowser for help on using the repository browser.