Code Duplication    Length = 22-23 lines in 2 locations

pyclustering/cluster/ga.py 2 locations

@@ 123-145 (lines=23) @@
120
121
        if not self._need_mean_ff:
122
            return;
123
124
        self._mean_ff_result.append(np.mean(fitness_functions));
125
126
127
    def get_global_best(self):
128
        """!
129
        @return (dict) Returns dictionary with keys 'chromosome' and 'fitness_function' where evolution of the best chromosome
130
                 and its fitness function's value (evolution of global optimum) are stored in lists.
131
        
132
        """
133
        return self._global_best_result;
134
135
136
    def get_population_best(self):
137
        """!
138
        @brief (dict) Returns dictionary with keys 'chromosome' and 'fitness_function' where evolution of the current best chromosome
139
                 and its fitness function's value (evolution of local optimum) are stored in lists.
140
        
141
        """
142
        return self._best_population_result;
143
144
145
    def get_mean_fitness_function(self):
146
        """!
147
        @brief (list) Returns fitness function's values on each iteration.
148
        
@@ 147-168 (lines=22) @@
144
145
    def get_mean_fitness_function(self):
146
        """!
147
        @brief (list) Returns fitness function's values on each iteration.
148
        
149
        """
150
        return self._mean_ff_result;
151
152
153
154
class ga_visualizer:
155
    """!
156
    @brief Genetic algorithm visualizer is used to show clustering results that are specific for
157
            this particular algorithm: clusters, evolution of global and local optimum.
158
    @details The visualizer requires 'ga_observer' that collects evolution of clustering process in
159
              genetic algorithm. The observer is created by user and passed to genetic algorithm. There
160
              is usage example of the visualizer using the observer:
161
    @code
162
        # Read data for clustering 
163
        sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE1);
164
        
165
        # Create instance of observer that will collect all information:
166
        observer_instance = ga_observer(True, True, True);
167
        
168
        # Create genetic algorithm where observer will collect information:
169
        ga_instance = genetic_algorithm(data=sample,
170
                                      count_clusters=2,
171
                                      chromosome_count=20,