/** * @file tests/qss/models.hpp * @author The ARTIS Development Team * See the AUTHORS or Authors.txt file */ /* * ARTIS - the multimodeling and simulation environment * This file is a part of the ARTIS environment * * Copyright (C) 2013-2019 ULCO http://www.univ-littoral.fr * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef TESTS_QSS_MODELS_HPP #define TESTS_QSS_MODELS_HPP 1 #include #include #include namespace artis { namespace tests { namespace qss { class Constant : public artis::pdevs::qss::Derivative { public: Constant(const std::string& name, const artis::pdevs::Context& context) : artis::pdevs::qss::Derivative(name, context) { } ~Constant() override = default; double compute() const override { return 0.5; } }; struct ParabolaParameters { double alpha; }; class Parabola : public artis::pdevs::qss::Derivative { public: Parabola(const std::string& name, const artis::pdevs::Context& context) : artis::pdevs::qss::Derivative( name, context), _alpha(context.parameters().alpha) { internal("X", &Parabola::_x); } ~Parabola() override = default; double compute() const override { return _alpha * _x; } private: double _alpha; double _x; }; struct PreyPredatorParameters { double a; double b; double d; double e; }; class Predator : public artis::pdevs::qss::Derivative { public: unsigned int IN_X; Predator(const std::string& name, const artis::pdevs::Context& context) : artis::pdevs::qss::Derivative( name, context), _b(context.parameters().b), _d(context.parameters().d), _e(context.parameters().e) { internal("Y", &Predator::_y); IN_X = external("X", &Predator::_x); } ~Predator() override = default; double compute() const override { return _b * _d * _x * _y - _e * _y; } private: // parameters double _b; double _d; double _e; // state double _x; double _y; }; class Prey : public artis::pdevs::qss::Derivative { public: unsigned int IN_Y; Prey(const std::string& name, const artis::pdevs::Context& context) : artis::pdevs::qss::Derivative( name, context), _a(context.parameters().a), _b(context.parameters().b) { internal("X", &Prey::_x); IN_Y = external("Y", &Prey::_y); } ~Prey() override = default; double compute() const override { return _a * _x - _b * _y * _x; } private: // parameters double _a; double _b; // state double _x; double _y; }; } } } // namespace artis tests qss #endif