![]() ![]() BRAHMS
User Guide » Developing Processes » Tutorials » Rabbits And Foxes
This documentation is offline - click here to go online
Index | Search: Go online to use Search
| ||
OverviewFind this tutorial at Rabbits And Foxes illustrates designing your own BRAHMS processes and shows how to knit them together into a computable system. The script that executes this tutorial is
BRAHMS native language is C. However, a Matlab Component Binding (1258) is provided that lets us quickly develop (or prototype) Processes in Matlab, and run them under BRAHMS. We will use this binding in this tutorial. The Dynamical SystemThis tutorial shows how to implement a dynamical system using BRAHMS Processes. The system is a simple model of population dynamics for the predator-prey relationship between a population of foxes and a population of rabbits (this is the famous Lotka-Volterra model). The two-dimensional system of ordinary differential equations (ODEs) is: ![]() ![]() In words, this system describes the following. Both the change in number of rabbits over time ( Because these two ODEs are coupled, they cannot be solved exactly. Instead we need to solve them numerically, using some numerical method - to keep things simple we use the forward Euler method here: Implementation in Matlab (not BRAHMS)Let's get a handle on how to implement this system in a Matlab script before we tackle a BRAHMS Process. The code that does this is included in First we set up the initial size of the populations, the sample rate ( M Source Code
rabbits
Implementing the Euler method to solve the equations over the execution length is as follows. M Source Code
trace
Finally, we plot the results. M Source Code
subplot
The plot shows the progression of the system, with rabbits in blue and foxes in red. It is shown below. ![]() Implementation in BRAHMSFor the purposes of this tutorial, we shall construct the ODE system using two BRAHMS processes, one per equation. For such a computationally simple system, this incurs a big processing overhead, but that doesn't matter for our purposes here. You will notice that the BRAHMS version runs much slower than the Matlab version, for this reason. Both processes will be authored against the 1258 Matlab Component Bindings. The example script, Open and examine the Matlab files that make up this example. Specifically, OutputMatlab Console
Binding iteration time
----------------------
This is an estimate of the maximum total processing
overhead, including all BRAHMS framework overheads
and the overhead due to calling the language engine.
Your workstation: 1.049ms
My workstation: ~1.2ms
AcknowledgementsMitch originally ripped this example off from this page. The documentation for this example is courtesy of Mark Humphries. |
||
This is a documentation page for the BRAHMS Modular Execution (Simulation) Framework. For details of licensing and distribution, please click here. To advise of an error or omission, please click here. |