44template <
typename NeuronType>
65 using NeuronGenerator = std::function<std::optional<NeuronParameters>(
size_t index)>;
88 [[nodiscard]]
const UID &
get_uid()
const {
return base_.uid_; }
95 [[nodiscard]]
auto &
get_tags() {
return base_.tags_; }
102 [[nodiscard]]
const auto &
get_tags()
const {
return base_.tags_; }
142 return base_.tags_.template get_tag<std::vector<TagMap>>(
"neuron_tags")[index];
153 neurons_.reserve(count);
154 for (
size_t i = 0; i < count; ++i)
156 auto neuron = generator(i);
157 if (neuron.has_value())
160 neurons_.emplace_back(std::move(neuron.value()));
162 neurons_.template emplace_back(std::move(neuron.value()));
174 size_t index_shift = 0;
175 for (
const auto &index : neuron_indexes)
187 auto iter = neurons_.begin();
188 std::advance(iter, neuron_index);
189 neurons_.erase(iter);
211 auto begin()
const {
return neurons_.cbegin(); }
216 auto begin() {
return neurons_.begin(); }
221 auto end()
const {
return neurons_.cend(); }
226 auto end() {
return neurons_.end(); }
233 [[nodiscard]]
size_t size()
const {
return neurons_.size(); }
237 std::vector<NeuronParameters> neurons_;
248using AllPopulations = boost::mp11::mp_transform<knp::core::Population, knp::neuron_traits::AllNeurons>;
The Population class is a container of neurons of the same model.
const NeuronParameters & get_neuron_parameters(size_t index) const
Get parameters of the specific neuron in the population.
TagMap & get_neuron_tags(size_t index)
Get tags used by neuron with the specified index.
neuron_traits::neuron_parameters< NeuronType > NeuronParameters
Neuron parameters and their values for the specified neuron type.
auto end() const
Get an iterator pointing to the last element of the population.
void set_neuron_parameters(size_t index, NeuronParameters &¶meters)
Set parameters for the specific neuron in the population.
void remove_neurons(const std::vector< size_t > &neuron_indexes)
Remove neurons with given indexes from the population.
void add_neurons(NeuronGenerator generator, size_t count)
Add neurons to the population.
auto & operator[](size_t index)
Get parameter values of a neuron with the given index.
auto begin() const
Get an iterator pointing to the first element of the population.
const auto & operator[](size_t index) const
Get parameter values of a neuron with the given index.
void set_neurons_parameters(size_t index, const NeuronParameters ¶meters)
Set parameters for the specific neuron in the population.
auto end()
Get an iterator pointing to the last element of the population.
auto begin()
Get an iterator pointing to the first element of the population.
const auto & get_tags() const
Get tags used by the population.
Population< NeuronType > PopulationType
Population of neurons with the specified neuron type.
const UID & get_uid() const
Get population UID.
auto & get_tags()
Get tags used by the population.
size_t size() const
Count number of neurons in the population.
Population(const knp::core::UID &uid, NeuronGenerator generator, size_t neurons_count)
Construct a population by running a neuron generator.
Population(NeuronGenerator generator, size_t neurons_count)
Construct a population by running a neuron generator.
std::function< std::optional< NeuronParameters >(size_t index)> NeuronGenerator
Type of the neuron generator.
void remove_neuron(const size_t &neuron_index)
Remove a specific neuron from the population.
const std::vector< NeuronParameters > & get_neurons_parameters() const
Get parameters of all neurons in the population.
NeuronType PopulationNeuronType
Type of the population neurons.
Class definition for core library basic entities.
boost::mp11::mp_rename< AllPopulations, std::variant > AllPopulationsVariant
Population variant that contains any population type specified in AllPopulations.
boost::mp11::mp_transform< knp::core::Population, knp::neuron_traits::AllNeurons > AllPopulations
List of population types based on neuron types specified in knp::neuron_traits::AllNeurons.
List of all neuron type traits.
Synaptic impact message class.