Atomic Model

Atomic model

VLE implements the DEVS abstract simulators and more precisely the DSDE which merge Parallel DEVS and DS-DEVS. In VLE, a DEVS atomic model is represented as a object which inherits of the vle::devs::Dynamics C++ class. class MyModel : public vle::devs::Dynamics { public: MyModel(const DynamicsInit& init, const vle::devs::InitEventList& events) : vle::devs::Dynamics(init, events) {} virtual ~MyModel() {} // Process the initialization of the model by // initializing the initial state and return // the duration (or timeAdvance) of the initial // state.

Debug and Log model

Debug model To debug your model, you may use the debug option when you right click on an atomic model under GVLE. Default, the debug file is located at $VLE_HOME/vle-2.0.log but it can be redirected to the standard output with the command line option --log-to- stdout or --log-to-stderr. Log model For example the following atomic model will show always the string “MyModel constructor” but show the string “time is odd” only when time is odd and VLE is launched with vle -v x with x equal 1, 2 or 3.

counter

A simple model that counts events received in any input port. First, we create a new package with the following command: mkdir -p cd $HOME/vle/tutorial cd $HOME/vle/tutorial vle-2.0 -P examples create We add the file counter.cpp and update the CMakeLists.txt file in the src directory. #include <vle/devs/Dynamics.hpp> #include <vle/value/Double.hpp> namespace example { class Counter : public vle::devs::Dynamics { public: Counter(const vle::devs::DynamicsInit& model, const vle::devs::InitEventList& events) : vle::devs::Dynamics(model, events) , m_counter(0), {} virtual ~Counter() = default; virtual vle::devs::Time init(vle::devs::Time& time) override { return 0; } virtual vle::devs::Time timeAdvance() const override { return vle::devs::infinity; } virtual void externalTransition(const vle::devs::ExternalEventList& events, vle::devs::Time time) override { m_counter += events.

Tutorial 01: counter-generator

In this first example, we will create simulation of two models: an event generator and a event counter. First, we need to create a new empty package in the user home directory. cd $HOME/examples vle-1.1 -P generator-counter create vle-1.1 -P generator-counter configure build The binary package is now installed into the VLE’s home ($VLE_HOME/pkgs-1.1 or $HOME/.vle/pkgs-1.1). Now, we need to add two DEVS models, the counter and the generator. Copy the file Simple.

debug model

Debugging Macros To debug your model, you may use the DECLARE_DYNAMICSY_DBG instead of DECLARE_DYNAMICS and use some functions (TraceAlways, TraceModel etc.) to enable debugging of your model in the C++ source code. Default, the debug file is located at $VLE_HOME/vle.log but it can be redirected to the standard output with the command line option --log-to- stdout. Level Description Command line C++ 0 Minimum debug: messages are always printed vle -v 0 or vle TraceAlways() or DTraceAlways() 1 Model Debugging: to be used by model developer vle -v 1 TraceModel() or DTraceModel() 2 Extension debugging: extension functions tracking (e.

Atomic model

VLE implements the DEVS abstract simulators and more precisely the DSDE which merge Parallel DEVS and DS-DEVS. In VLE, a DEVS atomic model is represented as a object which inherits of the vle::devs::Dynamics C++ class. class MyModel : public vle::devs::Dynamics { public: MyModel(const DynamicsInit& init, const vle::devs::InitEventList& events) : vle::devs::Dynamics(init, events) {} virtual ~MyModel() {} // Process the initialization of the model by // initializing the initial state and return // the duration (or timeAdvance) of the initial // state.

Tutorial 02: Lotka-Volterra, observation and conditions

In this tutorial, we create a Lotka-Volterra system solved with Euler. The first part shows you how to develop a such model then we use the experimental conditions to assign value from the VPZ and use it directly from R. First, we develop the model vle -P lotka-volterra create Rename the lotka-volterra/src/Simple.cpp into SystemLotkaVolterra.cpp for example and edit the source code like this: #include <vle/value/Value.hpp> #include <vle/devs/Dynamics.hpp> namespace vd = vle::devs; namespace vv = vle::value; namespace examples { class SystemLotkaVolterra : public vd::Dynamics { double X, Y; double alpha, beta, gamma, delta; double step; public: SystemLotkaVolterra(const vd::DynamicsInit& init, const vd::InitEventList& events) : vd::Dynamics(init, events) { X = 1.

counter

A simple model that counts events received in any input port. First, we create a new package with the following command: mkdir -p cd $HOME/vle/tutorial cd $HOME/vle/tutorial vle -P examples create We add the file “counter.cpp” and update the CMakeLists.txt file in the src directory. #include <vle/devs/Dynamics.hpp> #include <vle/value/Double.hpp> namespace example { class Counter : public vle::devs::Dynamics { public: Counter(const vle::devs::DynamicsInit& model, const vle::devs::InitEventList& events) : vle::devs::Dynamics(model, events) , m_counter(0), {} virtual ~Counter() {} virtual vle::devs::Time init( const vle::devs::Time& /* time */) { return 0; } virtual vle::devs::Time timeAdvance() const { return vle::devs::infinity; } virtual void externalTransition( const vle::devs::ExternalEventList& events, const vle::devs::Time& time) { m_counter += events.