def allocate_sync_ensembles(self, tolerance = <NUM_LIT>, indexes = None, iteration = None):
if (self._ccore_sync_dynamic_pointer is not None):<EOL><INDENT>ensembles = wrapper.sync_dynamic_allocate_sync_ensembles(self._ccore_sync_dynamic_pointer, tolerance, iteration);<EOL>if (indexes is not None):<EOL><INDENT>for ensemble in ensembles:<EOL><INDENT>for index in range(len(ensemble)):<EOL><INDENT>ensemble[index] = indexes[ ensemble[index] ];<EOL><DEDENT><DEDENT><DEDENT>return ensembles;<EOL><DEDENT>if ( (self._dynamic is None) or (len(self._dynamic) == <NUM_LIT:0>) ):<EOL><INDENT>return [];<EOL><DEDENT>number_oscillators = len(self._dynamic[<NUM_LIT:0>]);<EOL>last_state = None;<EOL>if (iteration is None):<EOL><INDENT>last_state = self._dynamic[len(self._dynamic) - <NUM_LIT:1>];<EOL><DEDENT>else:<EOL><INDENT>last_state = self._dynamic[iteration];<EOL><DEDENT>clusters = [];<EOL>if (number_oscillators > <NUM_LIT:0>):<EOL><INDENT>clusters.append([<NUM_LIT:0>]);<EOL><DEDENT>for i in range(<NUM_LIT:1>, number_oscillators, <NUM_LIT:1>):<EOL><INDENT>cluster_allocated = False;<EOL>for cluster in clusters:<EOL><INDENT>for neuron_index in cluster:<EOL><INDENT>last_state_shifted = abs(last_state[i] - <NUM_LIT:2> * pi);<EOL>if ( ( (last_state[i] < (last_state[neuron_index] + tolerance)) and (last_state[i] > (last_state[neuron_index] - tolerance)) ) or<EOL>( (last_state_shifted < (last_state[neuron_index] + tolerance)) and (last_state_shifted > (last_state[neuron_index] - tolerance)) ) ):<EOL><INDENT>cluster_allocated = True;<EOL>real_index = i;<EOL>if (indexes is not None):<EOL><INDENT>real_index = indexes[i];<EOL><DEDENT>cluster.append(real_index);<EOL>break;<EOL><DEDENT><DEDENT>if (cluster_allocated == True):<EOL><INDENT>break;<EOL><DEDENT><DEDENT>if (cluster_allocated == False):<EOL><INDENT>clusters.append([i]);<EOL><DEDENT><DEDENT>return clusters<EOL>
!
        @brief Allocate clusters in line with ensembles of synchronous oscillators where each synchronous ensemble corresponds to only one cluster.

        @param[in] tolerance (double): Maximum error for allocation of synchronous ensemble oscillators.
        @param[in] indexes (list): List of real object indexes and it should be equal to amount of oscillators (in case of 'None' - indexes are in range [0; amount_oscillators]).
        @param[in] iteration (uint): Iteration of simulation that should be used for allocation.

        @return (list) Grours (lists) of indexes of synchronous oscillators.
                For example [ [index_osc1, index_osc3], [index_osc2], [index_osc4, index_osc5] ].