/** * @file generators.h * @brief Common generators used for tests. * @kaspersky_support Artiom N. * @date 23.06.2023 * @license Apache 2.0 * @copyright © 2024-2025 AO Kaspersky Lab * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include #include #include /** * @brief Test namespace. */ namespace knp::testing { using DeltaProjection = knp::core::Projection; using ResourceDeltaProjection = knp::core::Projection; using BLIFATPopulation = knp::core::Population; using ResourceBlifatPopulation = knp::core::Population; using ResourceDeltaProjection = knp::core::Projection; using ResourceSynapse = knp::synapse_traits::SynapticResourceSTDPDeltaSynapse; using ResourceSynapseData = ResourceDeltaProjection::Synapse; using ResourceSynapseParams = knp::synapse_traits::synapse_parameters; // Create an input projection. static inline std::optional input_projection_gen(size_t /*index*/) // NOLINT { return DeltaProjection::Synapse{{1.0, 1, knp::synapse_traits::OutputType::EXCITATORY}, 0, 0}; } // Create a loop projection. static inline std::optional synapse_generator(size_t /*index*/) // NOLINT { return DeltaProjection::Synapse{{1.1, 6, knp::synapse_traits::OutputType::EXCITATORY}, 0, 0}; } // Create an input resource projection static inline std::optional input_res_projection_gen(size_t /*index*/) // NOLINT { knp::synapse_traits::synapse_parameters syn; syn.rule_.w_max_ = 2.0; syn.rule_.w_min_ = 1.0; syn.rule_.synaptic_resource_ = 1.0; syn.rule_.dopamine_plasticity_period_ = 5; syn.weight_ = 1.5; syn.delay_ = 1; syn.output_type_ = synapse_traits::OutputType::EXCITATORY; return ResourceDeltaProjection::Synapse{syn, 0, 0}; } // Create a loop resource projection static inline std::optional loop_res_projection_gen(size_t /*index*/) // NOLINT { knp::synapse_traits::synapse_parameters syn; syn.rule_.w_max_ = 2.0; syn.rule_.w_min_ = 1.0; syn.rule_.synaptic_resource_ = 1.0; syn.rule_.dopamine_plasticity_period_ = 5; syn.weight_ = 1.5; syn.delay_ = 6; syn.output_type_ = synapse_traits::OutputType::EXCITATORY; return ResourceDeltaProjection::Synapse{syn, 0, 0}; } // Create population. static inline knp::neuron_traits::neuron_parameters neuron_generator( size_t) // NOLINT { return knp::neuron_traits::neuron_parameters{}; } // Create resource population static inline auto neuron_res_generator(size_t) // NOLINT { return knp::neuron_traits::neuron_parameters{}; } } // namespace knp::testing