|
@@ -8,7 +8,7 @@
|
|
* ARTIS - the multimodeling and simulation environment
|
|
* ARTIS - the multimodeling and simulation environment
|
|
* This file is a part of the ARTIS environment
|
|
* This file is a part of the ARTIS environment
|
|
*
|
|
*
|
|
- * Copyright (C) 2013-2019 ULCO http://www.univ-littoral.fr
|
|
|
|
|
|
+ * Copyright (C) 2013-2022 ULCO http://www.univ-littoral.fr
|
|
*
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* 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
|
|
* it under the terms of the GNU General Public License as published by
|
|
@@ -27,7 +27,7 @@
|
|
#include <tests/qss/graph_manager.hpp>
|
|
#include <tests/qss/graph_manager.hpp>
|
|
|
|
|
|
#include <artis-star/common/RootCoordinator.hpp>
|
|
#include <artis-star/common/RootCoordinator.hpp>
|
|
-#include <artis-star/common/observer/Iterator.hpp>
|
|
|
|
|
|
+#include <artis-star/common/observer/TimedIterator.hpp>
|
|
#include <artis-star/common/observer/Output.hpp>
|
|
#include <artis-star/common/observer/Output.hpp>
|
|
|
|
|
|
#include <fstream>
|
|
#include <fstream>
|
|
@@ -36,17 +36,14 @@
|
|
|
|
|
|
using namespace artis::tests::qss;
|
|
using namespace artis::tests::qss;
|
|
|
|
|
|
-void test_parabola()
|
|
|
|
-{
|
|
|
|
|
|
+void test_parabola() {
|
|
artis::qss::QSSParameters<ParabolaParameters> parameters = {{0.5},
|
|
artis::qss::QSSParameters<ParabolaParameters> parameters = {{0.5},
|
|
{true, true, 0.001, 3},
|
|
{true, true, 0.001, 3},
|
|
{0.2}};
|
|
{0.2}};
|
|
|
|
|
|
- class View : public artis::observer::View<artis::common::DoubleTime>
|
|
|
|
- {
|
|
|
|
|
|
+ class View : public artis::common::observer::View<artis::common::DoubleTime> {
|
|
public:
|
|
public:
|
|
- View()
|
|
|
|
- {
|
|
|
|
|
|
+ View() {
|
|
selector("Value",
|
|
selector("Value",
|
|
{OnlyOneParabolaGraphManager::A, ParabolaGraphManager::submodel::S_Integrator,
|
|
{OnlyOneParabolaGraphManager::A, ParabolaGraphManager::submodel::S_Integrator,
|
|
artis::qss::Integrator<artis::common::DoubleTime>::var::VALUE});
|
|
artis::qss::Integrator<artis::common::DoubleTime>::var::VALUE});
|
|
@@ -55,31 +52,29 @@ void test_parabola()
|
|
|
|
|
|
artis::common::context::Context<artis::common::DoubleTime> context(0, 5);
|
|
artis::common::context::Context<artis::common::DoubleTime> context(0, 5);
|
|
artis::common::RootCoordinator<
|
|
artis::common::RootCoordinator<
|
|
- artis::common::DoubleTime, artis::pdevs::Coordinator<
|
|
|
|
- artis::common::DoubleTime,
|
|
|
|
- OnlyOneParabolaGraphManager,
|
|
|
|
- artis::qss::QSSParameters<ParabolaParameters>>
|
|
|
|
|
|
+ artis::common::DoubleTime, artis::pdevs::Coordinator<
|
|
|
|
+ artis::common::DoubleTime,
|
|
|
|
+ OnlyOneParabolaGraphManager,
|
|
|
|
+ artis::qss::QSSParameters<ParabolaParameters>>
|
|
> rc(context, "root", parameters, artis::common::NoParameters());
|
|
> rc(context, "root", parameters, artis::common::NoParameters());
|
|
|
|
|
|
- rc.attachView("Value", new View());
|
|
|
|
|
|
+// rc.attachView("Value", new View());
|
|
|
|
|
|
rc.run(context);
|
|
rc.run(context);
|
|
|
|
|
|
- const View::Values &values = rc.observer().view("Value").get("Value");
|
|
|
|
-
|
|
|
|
- for (const auto &value: values) {
|
|
|
|
- double v;
|
|
|
|
-
|
|
|
|
- value.second(v);
|
|
|
|
- std::cout << value.first << ": " << v << std::endl;
|
|
|
|
- }
|
|
|
|
|
|
+// const View::Values &values = rc.observer().view("Value").get("Value");
|
|
|
|
+//
|
|
|
|
+// for (const auto &value: values) {
|
|
|
|
+// double v;
|
|
|
|
+//
|
|
|
|
+// value.second(v);
|
|
|
|
+// std::cout << value.first << ": " << v << std::endl;
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
-class PredatorPreyView : public artis::observer::View<artis::common::DoubleTime>
|
|
|
|
-{
|
|
|
|
|
|
+class PredatorPreyView : public artis::common::observer::View<artis::common::DoubleTime> {
|
|
public:
|
|
public:
|
|
- PredatorPreyView()
|
|
|
|
- {
|
|
|
|
|
|
+ PredatorPreyView() {
|
|
selector("PredatorView",
|
|
selector("PredatorView",
|
|
{PreyPredatorGraphManager::PREDATOR, PredatorGraphManager::submodel::S_Integrator,
|
|
{PreyPredatorGraphManager::PREDATOR, PredatorGraphManager::submodel::S_Integrator,
|
|
artis::qss::Integrator<artis::common::DoubleTime>::var::VALUE});
|
|
artis::qss::Integrator<artis::common::DoubleTime>::var::VALUE});
|
|
@@ -90,24 +85,23 @@ public:
|
|
};
|
|
};
|
|
|
|
|
|
void run_predator_prey(artis::common::context::Context<artis::common::DoubleTime> &context,
|
|
void run_predator_prey(artis::common::context::Context<artis::common::DoubleTime> &context,
|
|
- const PreyPredatorGraphManagerParameters ¶meters)
|
|
|
|
-{
|
|
|
|
|
|
+ const PreyPredatorGraphManagerParameters ¶meters) {
|
|
artis::common::RootCoordinator<
|
|
artis::common::RootCoordinator<
|
|
- artis::common::DoubleTime, artis::pdevs::Coordinator<
|
|
|
|
- artis::common::DoubleTime,
|
|
|
|
- PreyPredatorGraphManager,
|
|
|
|
- PreyPredatorGraphManagerParameters>
|
|
|
|
|
|
+ artis::common::DoubleTime, artis::pdevs::Coordinator<
|
|
|
|
+ artis::common::DoubleTime,
|
|
|
|
+ PreyPredatorGraphManager,
|
|
|
|
+ PreyPredatorGraphManagerParameters>
|
|
> rc(context, "root", parameters, artis::common::NoParameters());
|
|
> rc(context, "root", parameters, artis::common::NoParameters());
|
|
|
|
|
|
- rc.attachView("Value1", new PredatorPreyView());
|
|
|
|
|
|
+// rc.attachView("Value1", new PredatorPreyView());
|
|
|
|
|
|
rc.run(context);
|
|
rc.run(context);
|
|
|
|
|
|
- artis::observer::Output<artis::common::DoubleTime,
|
|
|
|
- artis::observer::TimedIterator<artis::common::DoubleTime>>
|
|
|
|
- output(rc.observer());
|
|
|
|
-
|
|
|
|
- output(context.begin(), context.end(), {context.begin(), 0.1});
|
|
|
|
|
|
+// artis::common::observer::Output<artis::common::DoubleTime,
|
|
|
|
+// artis::common::observer::TimedIterator<artis::common::DoubleTime>>
|
|
|
|
+// output(rc.observer());
|
|
|
|
+//
|
|
|
|
+// output(context.begin(), context.end(), {context.begin(), 0.1});
|
|
|
|
|
|
// rc.save(context);
|
|
// rc.save(context);
|
|
//
|
|
//
|
|
@@ -142,14 +136,13 @@ void run_predator_prey(artis::common::context::Context<artis::common::DoubleTime
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
|
|
|
|
-void test_predator_prey()
|
|
|
|
-{
|
|
|
|
|
|
+void test_predator_prey() {
|
|
PreyPredatorGraphManagerParameters parameters = {{{45.},
|
|
PreyPredatorGraphManagerParameters parameters = {{{45.},
|
|
- {true, true, 0.1, 3},
|
|
|
|
- {0.5, 0.01, 0.01, 0.2}},
|
|
|
|
|
|
+ {true, true, 0.1, 3},
|
|
|
|
+ {0.5, 0.01, 0.01, 0.2}},
|
|
{{5000.},
|
|
{{5000.},
|
|
- {true, true, 1, 3},
|
|
|
|
- {0.5, 0.01, 0.01, 0.2}}};
|
|
|
|
|
|
+ {true, true, 1, 3},
|
|
|
|
+ {0.5, 0.01, 0.01, 0.2}}};
|
|
|
|
|
|
artis::common::context::Context<artis::common::DoubleTime> context(0, 100);
|
|
artis::common::context::Context<artis::common::DoubleTime> context(0, 100);
|
|
|
|
|
|
@@ -161,11 +154,9 @@ void test_predator_prey()
|
|
// run_predator_prey(new_context, parameters);
|
|
// run_predator_prey(new_context, parameters);
|
|
}
|
|
}
|
|
|
|
|
|
-class PredatorPreySmartGardenerView : public artis::observer::View<artis::common::DoubleTime>
|
|
|
|
-{
|
|
|
|
|
|
+class PredatorPreySmartGardenerView : public artis::common::observer::View<artis::common::DoubleTime> {
|
|
public:
|
|
public:
|
|
- PredatorPreySmartGardenerView()
|
|
|
|
- {
|
|
|
|
|
|
+ PredatorPreySmartGardenerView() {
|
|
selector("PredatorView",
|
|
selector("PredatorView",
|
|
{PreyPredatorSmartGardenerGraphManager::PREY_PREDATOR,
|
|
{PreyPredatorSmartGardenerGraphManager::PREY_PREDATOR,
|
|
PreyPredatorGraphManager::PREDATOR, PredatorGraphManager::submodel::S_Integrator,
|
|
PreyPredatorGraphManager::PREDATOR, PredatorGraphManager::submodel::S_Integrator,
|
|
@@ -177,40 +168,37 @@ public:
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-void test_predator_prey_smart_gardener()
|
|
|
|
-{
|
|
|
|
|
|
+void test_predator_prey_smart_gardener() {
|
|
PreyPredatorSmartGardenerGraphManagerParameters parameters = {{{{45.},
|
|
PreyPredatorSmartGardenerGraphManagerParameters parameters = {{{{45.},
|
|
- {true, true, 0.1, 3},
|
|
|
|
- {0.5, 0.01, 0.01, 0.2}},
|
|
|
|
- {{5000.},
|
|
|
|
- {true, true, 1, 3},
|
|
|
|
- {0.5, 0.01, 0.01, 0.2}}},
|
|
|
|
|
|
+ {true, true, 0.1, 3},
|
|
|
|
+ {0.5, 0.01, 0.01, 0.2}},
|
|
|
|
+ {{5000.},
|
|
|
|
+ {true, true, 1, 3},
|
|
|
|
+ {0.5, 0.01, 0.01, 0.2}}},
|
|
{2000, 0.25, 0.75, 5}};
|
|
{2000, 0.25, 0.75, 5}};
|
|
|
|
|
|
artis::common::context::Context<artis::common::DoubleTime> context(0, 100);
|
|
artis::common::context::Context<artis::common::DoubleTime> context(0, 100);
|
|
artis::common::RootCoordinator<
|
|
artis::common::RootCoordinator<
|
|
- artis::common::DoubleTime, artis::pdevs::Coordinator<
|
|
|
|
- artis::common::DoubleTime,
|
|
|
|
- PreyPredatorSmartGardenerGraphManager,
|
|
|
|
- PreyPredatorSmartGardenerGraphManagerParameters>
|
|
|
|
|
|
+ artis::common::DoubleTime, artis::pdevs::Coordinator<
|
|
|
|
+ artis::common::DoubleTime,
|
|
|
|
+ PreyPredatorSmartGardenerGraphManager,
|
|
|
|
+ PreyPredatorSmartGardenerGraphManagerParameters>
|
|
> rc(context, "root", parameters, artis::common::NoParameters());
|
|
> rc(context, "root", parameters, artis::common::NoParameters());
|
|
|
|
|
|
- rc.attachView("Value2", new PredatorPreySmartGardenerView());
|
|
|
|
|
|
+// rc.attachView("Value2", new PredatorPreySmartGardenerView());
|
|
|
|
|
|
rc.run(context);
|
|
rc.run(context);
|
|
|
|
|
|
- artis::observer::Output<artis::common::DoubleTime,
|
|
|
|
- artis::observer::TimedIterator<artis::common::DoubleTime>>
|
|
|
|
- output(rc.observer());
|
|
|
|
-
|
|
|
|
- output(context.begin(), context.end(), {context.begin(), 0.1});
|
|
|
|
|
|
+// artis::common::observer::Output<artis::common::DoubleTime,
|
|
|
|
+// artis::common::observer::TimedIterator<artis::common::DoubleTime>>
|
|
|
|
+// output(rc.observer());
|
|
|
|
+//
|
|
|
|
+// output(context.begin(), context.end(), {context.begin(), 0.1});
|
|
}
|
|
}
|
|
|
|
|
|
-class MixedPredatorPreyView : public artis::observer::View<artis::common::DoubleTime>
|
|
|
|
-{
|
|
|
|
|
|
+class MixedPredatorPreyView : public artis::common::observer::View<artis::common::DoubleTime> {
|
|
public:
|
|
public:
|
|
- MixedPredatorPreyView()
|
|
|
|
- {
|
|
|
|
|
|
+ MixedPredatorPreyView() {
|
|
selector("PredatorView",
|
|
selector("PredatorView",
|
|
{MixedPreyPredatorGraphManager::PREDATOR, DiscretePredatorGraphManager::PREDATOR,
|
|
{MixedPreyPredatorGraphManager::PREDATOR, DiscretePredatorGraphManager::PREDATOR,
|
|
DiscretePredator::VALUE});
|
|
DiscretePredator::VALUE});
|
|
@@ -220,36 +208,33 @@ public:
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-void test_mixed_predator_prey()
|
|
|
|
-{
|
|
|
|
|
|
+void test_mixed_predator_prey() {
|
|
MixedPreyPredatorGraphManagerParameters parameters = {{0.0001, 45., 0.5, 0.01, 0.01, 0.2},
|
|
MixedPreyPredatorGraphManagerParameters parameters = {{0.0001, 45., 0.5, 0.01, 0.01, 0.2},
|
|
{{5000.},
|
|
{{5000.},
|
|
- {true, true, 1, 3},
|
|
|
|
- {0.5, 0.01, 0.01, 0.2}}};
|
|
|
|
|
|
+ {true, true, 1, 3},
|
|
|
|
+ {0.5, 0.01, 0.01, 0.2}}};
|
|
artis::common::context::Context<artis::common::DoubleTime> context(0, 100);
|
|
artis::common::context::Context<artis::common::DoubleTime> context(0, 100);
|
|
artis::common::RootCoordinator<
|
|
artis::common::RootCoordinator<
|
|
- artis::common::DoubleTime, artis::pdevs::Coordinator<
|
|
|
|
- artis::common::DoubleTime,
|
|
|
|
- MixedPreyPredatorGraphManager,
|
|
|
|
- MixedPreyPredatorGraphManagerParameters>
|
|
|
|
|
|
+ artis::common::DoubleTime, artis::pdevs::Coordinator<
|
|
|
|
+ artis::common::DoubleTime,
|
|
|
|
+ MixedPreyPredatorGraphManager,
|
|
|
|
+ MixedPreyPredatorGraphManagerParameters>
|
|
> rc(context, "root", parameters, artis::common::NoParameters());
|
|
> rc(context, "root", parameters, artis::common::NoParameters());
|
|
|
|
|
|
- rc.attachView("Value3", new MixedPredatorPreyView());
|
|
|
|
|
|
+// rc.attachView("Value3", new MixedPredatorPreyView());
|
|
|
|
|
|
rc.run(context);
|
|
rc.run(context);
|
|
|
|
|
|
- artis::observer::Output<artis::common::DoubleTime,
|
|
|
|
- artis::observer::TimedIterator<artis::common::DoubleTime>>
|
|
|
|
- output(rc.observer());
|
|
|
|
-
|
|
|
|
- output(context.begin(), context.end(), {context.begin(), 0.1});
|
|
|
|
|
|
+// artis::common::observer::Output<artis::common::DoubleTime,
|
|
|
|
+// artis::common::observer::TimedIterator<artis::common::DoubleTime>>
|
|
|
|
+// output(rc.observer());
|
|
|
|
+//
|
|
|
|
+// output(context.begin(), context.end(), {context.begin(), 0.1});
|
|
}
|
|
}
|
|
|
|
|
|
-class MultiPredatorPreyView : public artis::observer::View<artis::common::DoubleTime>
|
|
|
|
-{
|
|
|
|
|
|
+class MultiPredatorPreyView : public artis::common::observer::View<artis::common::DoubleTime> {
|
|
public:
|
|
public:
|
|
- MultiPredatorPreyView()
|
|
|
|
- {
|
|
|
|
|
|
+ MultiPredatorPreyView() {
|
|
selector("PredatorView",
|
|
selector("PredatorView",
|
|
{MultiPreyPredatorGraphManager::submodel::S_Integrator,
|
|
{MultiPreyPredatorGraphManager::submodel::S_Integrator,
|
|
artis::qss::Integrator<artis::common::DoubleTime>::var::VALUE});
|
|
artis::qss::Integrator<artis::common::DoubleTime>::var::VALUE});
|
|
@@ -265,37 +250,40 @@ public:
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-void test_multi_predator_prey()
|
|
|
|
-{
|
|
|
|
|
|
+void test_multi_predator_prey() {
|
|
artis::qss::MultiQSSParameters<PreyPredatorParameters> parameters = {
|
|
artis::qss::MultiQSSParameters<PreyPredatorParameters> parameters = {
|
|
- {{5000.}, {45.}},
|
|
|
|
- {{true, true, 1, 3}, {true, true, 0.1, 3}},
|
|
|
|
- {0.5, 0.01, 0.01, 0.2}
|
|
|
|
|
|
+ {{5000.}, {45.}},
|
|
|
|
+ {{true, true, 1, 3}, {true, true, 0.1, 3}},
|
|
|
|
+ {0.5, 0.01, 0.01, 0.2}
|
|
};
|
|
};
|
|
artis::common::context::Context<artis::common::DoubleTime> context(0, 100);
|
|
artis::common::context::Context<artis::common::DoubleTime> context(0, 100);
|
|
artis::common::RootCoordinator<
|
|
artis::common::RootCoordinator<
|
|
- artis::common::DoubleTime, artis::pdevs::Coordinator<
|
|
|
|
- artis::common::DoubleTime,
|
|
|
|
- MultiPreyPredatorGraphManager,
|
|
|
|
- artis::qss::MultiQSSParameters<PreyPredatorParameters>>
|
|
|
|
|
|
+ artis::common::DoubleTime, artis::pdevs::Coordinator<
|
|
|
|
+ artis::common::DoubleTime,
|
|
|
|
+ MultiPreyPredatorGraphManager,
|
|
|
|
+ artis::qss::MultiQSSParameters<PreyPredatorParameters>>
|
|
> rc(context, "root", parameters, artis::common::NoParameters());
|
|
> rc(context, "root", parameters, artis::common::NoParameters());
|
|
|
|
|
|
- rc.attachView("Value4", new MultiPredatorPreyView());
|
|
|
|
|
|
+// rc.attachView("Value4", new MultiPredatorPreyView());
|
|
|
|
|
|
rc.run(context);
|
|
rc.run(context);
|
|
|
|
|
|
- artis::observer::Output<artis::common::DoubleTime,
|
|
|
|
- artis::observer::TimedIterator<artis::common::DoubleTime>>
|
|
|
|
- output(rc.observer());
|
|
|
|
-
|
|
|
|
- output(context.begin(), context.end(), {context.begin(), 0.1});
|
|
|
|
|
|
+// artis::common::observer::Output<artis::common::DoubleTime,
|
|
|
|
+// artis::common::observer::TimedIterator<artis::common::DoubleTime>>
|
|
|
|
+// output(rc.observer());
|
|
|
|
+//
|
|
|
|
+// output(context.begin(), context.end(), {context.begin(), 0.1});
|
|
}
|
|
}
|
|
|
|
|
|
-int main()
|
|
|
|
-{
|
|
|
|
|
|
+int main() {
|
|
|
|
+ std::cout << "test_parabola START" << std::endl;
|
|
test_parabola();
|
|
test_parabola();
|
|
|
|
+ std::cout << "test_predator_prey START" << std::endl;
|
|
test_predator_prey();
|
|
test_predator_prey();
|
|
|
|
+ std::cout << "test_predator_prey_smart_gardener START" << std::endl;
|
|
test_predator_prey_smart_gardener();
|
|
test_predator_prey_smart_gardener();
|
|
|
|
+ std::cout << "test_mixed_predator_prey START" << std::endl;
|
|
test_mixed_predator_prey();
|
|
test_mixed_predator_prey();
|
|
|
|
+ std::cout << "test_multi_predator_prey START" << std::endl;
|
|
test_multi_predator_prey();
|
|
test_multi_predator_prey();
|
|
}
|
|
}
|