File: syncnet.hpp

package info (click to toggle)
python-pyclustering 0.10.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 11,128 kB
  • sloc: cpp: 38,888; python: 24,311; sh: 384; makefile: 105
file content (168 lines) | stat: -rwxr-xr-x 5,027 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*!

@authors Andrei Novikov (pyclustering@yandex.ru)
@date 2014-2020
@copyright BSD-3-Clause

*/

#pragma once


#include <vector>

#include <pyclustering/nnet/sync.hpp>


using namespace pyclustering::nnet;


namespace pyclustering {

namespace clst {


using syncnet_cluster       = std::vector<std::size_t>;
using syncnet_cluster_data  = ensemble_data<syncnet_cluster>;


/*!

@class   syncnet_analyser syncnet.hpp pyclustering/cluster/syncnet.hpp

@brief   Analyser for syncnet - oscillatory neural network based on Kuramoto model for cluster analysis.

@see syncnet

*/
class syncnet_analyser: public sync_dynamic {
public:
    /*!
    
    @brief  Default constructor of the output dynamic of Sync network.
    
    */
    syncnet_analyser() = default;

    /*!

    @brief  Default destructor of the output dynamic of Sync network.

    */
    virtual ~syncnet_analyser() = default;

public:
    /*!

    @brief      Performs analysis of the output dynamic in order to obtain clusters.
    @details    Allocated clusters are placed to output argument `data`.

    @param[in]  eps: tolerance that defines the maximum difference between phases of oscillators that belong to one cluster.
    @param[out] data: allocated clusters during the analysis of the output dynamic.

    */
    void allocate_clusters(const double eps, syncnet_cluster_data & data);
};


/*!

@class   syncnet syncnet.hpp pyclustering/cluster/syncnet.hpp

@brief   Oscillatory neural network based on Kuramoto model for cluster analysis.

@see syncnet_analyser

 */
class syncnet: public sync_network {
protected:
    std::vector<std::vector<double> >    * oscillator_locations;    /**< Spatial location of each oscillator. */
    std::vector<std::vector<double> >    * distance_conn_weights;   /**< Weight of each connection in the network. */

public:
    /*!
    
    @brief   Contructor of the adapted oscillatory network SYNC for cluster analysis.
    
    @param[in] input_data: input data for clustering.
    @param[in] connectivity_radius: connectivity radius between points.
    @param[in] enable_conn_weight: if True - enable mode when strength between oscillators 
                depends on distance between two oscillators. Otherwise all connection between 
                oscillators have the same strength.
    @param[in] initial_phases: type of initialization of initial phases of oscillators.
    
    */
    syncnet(std::vector<std::vector<double> > * input_data, const double connectivity_radius, const bool enable_conn_weight, const initial_type initial_phases);

    /*!
    
    @brief   Copy-contructor of the sync-net algorithm is forbidden.
    
    @param[in] p_other: other syncnet instance.
    
    */
    syncnet(const syncnet & p_other) = delete;

    /*
    
    @brief   Default destructor.
    
    */
    virtual ~syncnet();

    /*!
    
    @brief Performs cluster analysis by the network simulation.
    
    @param[in]  order: order of synchronization that is used as indication for stopping processing, the `order` value should be in range `(0, 1)`.
    @param[in]  solver: specified type of solving diff. equation.
    @param[in]  collect_dynamic: specified requirement to collect whole dynamic of the network.
    @param[out] analyser: analyser of sync results of clustering.
    
    */
    virtual void process(const double order, const solve_type solver, const bool collect_dynamic, syncnet_analyser & analyser);

    /*!
    
    @brief   Overrided method for calculation of oscillator phase.
    
    @param[in] t: current value of phase.
    @param[in] teta: time (can be ignored). 
    @param[in] argv: index of oscillator whose phase represented by argument teta.
    
    @return  Return new value of phase of oscillator with index 'argv'.
    
    */
    virtual double phase_kuramoto(const double t, const double teta, const std::vector<void *> & argv) const override;

    virtual void phase_kuramoto_equation(const double t, const differ_state<double> & inputs, const differ_extra<void *> & argv, differ_state<double> & outputs) const override;

public:
    /*!
    
    @brief   Assignment operator for the sync-net algorithm is forbidden.
    
    @param[in] p_other: other syncnet instance.
    
    */
    syncnet & operator=(const syncnet & p_other) = delete;

protected:
    /*!
    
    @brief   Create connections between oscillators in line with input radius of connectivity.
    
    
    @param[in] connectivity_radius: connectivity radius between oscillators.
    @param[in] enable_conn_weight: if True - enable mode when strength between oscillators 
                depends on distance between two oscillators. Otherwise all connection between 
                oscillators have the same strength.
     
    */
    void create_connections(const double connectivity_radius, const bool enable_conn_weight);
};


}

}