|
@@ -42,6 +42,13 @@ namespace artis {
|
|
|
typedef dtss::Simulator<Time, Dyn, Parameters> Simulator;
|
|
|
|
|
|
public:
|
|
|
+ struct Observable {
|
|
|
+ unsigned int index;
|
|
|
+ std::string name;
|
|
|
+ };
|
|
|
+
|
|
|
+ typedef std::map<unsigned int, std::string> Observables;
|
|
|
+
|
|
|
Dynamics(const std::string& name, const Context<Time, Dyn, Parameters>& context)
|
|
|
:
|
|
|
_name(name), _simulator(context.simulator()) { }
|
|
@@ -49,12 +56,12 @@ namespace artis {
|
|
|
virtual ~Dynamics() { }
|
|
|
|
|
|
virtual void transition(const common::Bag<Time>& /* x */,
|
|
|
- typename Time::type /* t */) { }
|
|
|
+ const typename Time::type& /* t */) { }
|
|
|
|
|
|
- virtual void start(typename Time::type/* time */) { }
|
|
|
+ virtual void start(const typename Time::type& /* time */) { }
|
|
|
|
|
|
virtual common::Bag<Time> lambda(
|
|
|
- typename Time::type /* time */) const { return common::Bag<Time>(); }
|
|
|
+ const typename Time::type& /* time */) const { return common::Bag<Time>(); }
|
|
|
|
|
|
virtual common::Value observe(const typename Time::type& /* t */,
|
|
|
unsigned int /* index */) const { return common::Value(); }
|
|
@@ -74,6 +81,20 @@ namespace artis {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ void observable(Observable observable)
|
|
|
+ {
|
|
|
+ _observables[observable.index] = observable.name;
|
|
|
+ }
|
|
|
+
|
|
|
+ void observables(std::initializer_list<Observable> list)
|
|
|
+ {
|
|
|
+ for (typename std::initializer_list<Observable>::iterator it = list.begin();
|
|
|
+ it != list.end();
|
|
|
+ ++it) {
|
|
|
+ _observables[it->index] = it->name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
void output_port(common::Port p)
|
|
|
{
|
|
|
_simulator->add_out_port(p);
|
|
@@ -97,9 +118,13 @@ namespace artis {
|
|
|
common::States<Time, Dyn>::save(static_cast<const Dyn*>(this), state);
|
|
|
}
|
|
|
|
|
|
+ const typename Time::type& time_step() const
|
|
|
+ { return _simulator->time_step(); }
|
|
|
+
|
|
|
private:
|
|
|
std::string _name;
|
|
|
Simulator* _simulator;
|
|
|
+ Observables _observables;
|
|
|
};
|
|
|
|
|
|
}
|