File: utest-hsyncnet.cpp

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 (60 lines) | stat: -rwxr-xr-x 1,393 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
/*!

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

*/


#include <gtest/gtest.h>

#include <pyclustering/cluster/hsyncnet.hpp>


using namespace pyclustering::clst;


static void template_cluster_allocation(const unsigned int number_clusters) {
    bool result_testing = false;

    for (unsigned int i = 0; i < 3; i++) {
        std::vector<std::vector<double> > sample;

        sample.push_back( { 0.1, 0.1 } );
        sample.push_back( { 1.2, 1.1 } );
        sample.push_back( { 5.0, 5.0 } );

        sample.push_back( { 10.2, 10.1 } );
        sample.push_back( { 11.3, 11.0 } );
        sample.push_back( { 15.1, 15.4 } );

        hsyncnet network(&sample, number_clusters, initial_type::EQUIPARTITION);

        hsyncnet_analyser analyser;
        network.process(0.998, solve_type::FORWARD_EULER, true, analyser);

        hsyncnet_cluster_data ensembles;
        analyser.allocate_clusters(0.1, ensembles);

        if (number_clusters != ensembles.size()) {
            continue;
        }

        result_testing = true;
    }

    ASSERT_TRUE(result_testing);
}

TEST(utest_hsyncnet, allocation_2_clusters) {
    template_cluster_allocation(2);
}

#ifndef VALGRIND_ANALYSIS_SHOCK

TEST(utest_hsyncnet, allocation_1_clusters) {
    template_cluster_allocation(1);
}

#endif