It looks like you're new here. If you want to get involved, click one of these buttons!

- All Categories 2.2K
- Applied Category Theory Course 355
- Applied Category Theory Seminar 4
- Exercises 149
- Discussion Groups 49
- How to Use MathJax 15
- Chat 480
- Azimuth Code Project 108
- News and Information 145
- Azimuth Blog 149
- Azimuth Forum 29
- Azimuth Project 189
- - Strategy 108
- - Conventions and Policies 21
- - Questions 43
- Azimuth Wiki 711
- - Latest Changes 701
- - - Action 14
- - - Biodiversity 8
- - - Books 2
- - - Carbon 9
- - - Computational methods 38
- - - Climate 53
- - - Earth science 23
- - - Ecology 43
- - - Energy 29
- - - Experiments 30
- - - Geoengineering 0
- - - Mathematical methods 69
- - - Meta 9
- - - Methodology 16
- - - Natural resources 7
- - - Oceans 4
- - - Organizations 34
- - - People 6
- - - Publishing 4
- - - Reports 3
- - - Software 21
- - - Statistical methods 2
- - - Sustainability 4
- - - Things to do 2
- - - Visualisation 1
- General 39

Options

I'm vaguely experimenting with a C++ library for doing reasonably efficient discrete time simulation whilst keeping things at a slightly-sub-MATLAB level of readability. (I want it to be reasonably efficient because I want to do lots of simulation runs so the statistics/conclusions drawn from it are reliable.) I'm currently a bit stuck about how to handle systems with "probabilistic control flow" in a SIMD way, so I'm experimenting with a simple system derived from the foxes and rabbits stuff Graham, Staffan, Blake and others have been experimenting with. (This is just to see if the framework would be well-suited for these kind of tasks.) Here's a typical example of what a model-programmer would do. One of the goals is to be able to see how the system behaves as a function of various parameter values, so uppercase like F0 denotes an hyper-grid of system values at various parameters, whilst lowercase like f0 is a "block" designed for optimal low-level machine usage.

```
void
simluateSystem(int noRuns,int noTimesteps,float rfLo,float rfHi,float ffLo,float ffHi,
float initialFoxes,float rabbitsToSustainFox,float maxSupportableRabbits)
{
SysDescription sysDescription;
Parameter RF(LinSpace(rfLo,rfHi,4));
Parameter FF(LinSpace(ffLo,ffHi,4));
sysDescription.cartProdParameters(2,&RF,&FF);
FullTemporary F0(&sysDescription);
FullTemporary F1(&sysDescription);
FullTemporary R0(&sysDescription);
FullTemporary R1(&sysDescription);
Constant c(rabbitsToSustainFox);
Constant capR(maxSupportableRabbits);
Constant zero(0);
URandTemporary u1;
URandTemporary u2;
int i;
for(i=0;i<noRuns;++i){
F0.initialiseConstant(initialFoxes);
F1.initialiseConstant(0);
R0.initialiseConstant(initialFoxes*rabbitsToSustainFox);
R1.initialiseConstant(0);
do{
LL_SIMD f0(F0),f1(F1),ff(FF),r0(R0),r1(R1),rf(RF);
int j;
for(j=0;j<noTimesteps;++j){
LL_SIMD f=f0+f1;//total foxes
LL_SIMD r=r0+r1;//total rabbits
LL_SIMD e=clampAbove(c*f,r);//rabbits eaten this year
//young rabbits/foxes surviing become mature rabbits/foxes
r1=clampBelow(r0-clampBelow(e-r1,zero),zero);
f1=clampAbove(e/c,f0);
//now mature rabbits/foxes breed (if not already wiped out)
r0=onlyIf(r1>zero,clampAbove(rf*r1*u1,capR-r1));
f0=onlyIf(f1>zero,ff*f1*u2);
}
F0.store(f0);
F1.store(f1);
R0.store(r0);
R1.store(r1);
}while(sysDescription.stillWork());
//TODO: do incorporate array of final array of values into accumulator
}
//TODO: do some analysis
}
```

## Comments

On a vaguely related note, my forthcoming series of blog posts on stochastic Petri nets will study mathematical aspects of that "foxes and rabbits stuff", at least insofar as that stuff is described by stochastic Petri nets. The equations Graham used in Quantitative ecology are not of that form, but certain Lotka-Volterra equations are.

`On a vaguely related note, my forthcoming series of blog posts on stochastic [[Petri net|Petri nets]] will study mathematical aspects of that "foxes and rabbits stuff", at least insofar as that stuff is described by stochastic Petri nets. The equations Graham used in [[Quantitative ecology]] are not of that form, but certain [[Lotka-Volterra equations]] are.`

Yes predator prey or Lotka Volterra are the same in this case. There is/was a visual formalism called DEVS - Discrete Event System Specification , which has developed a host of visual tools for modeling and maybe code/stub gen (if i remember correctly. These are other types of Open source packages on wikipedia

The only one I tried is Mason but its Java-based but was good for agent/network sim's. I liked it but it might not be suitable for your purposes

`Yes predator prey or Lotka Volterra are the same in this case. There is/was a visual formalism called DEVS - Discrete Event System Specification , which has developed a host of visual tools for modeling and maybe code/stub gen (if i remember correctly. These are other types of [Open source packages on wikipedia](http://en.wikipedia.org/wiki/List_of_discrete_event_simulation_software) * CD++[1] [2] is an open source based on the DEVS and Cell-DEVS formalisms (a discrete-event specification of cellular automata models). Hundreds of model samples are available. Varied 2D and 3D visualization engines can be used to improve the analysis of the simulation results. * PowerDEVS is an integrated tool for hybrid systems modeling and simulation based on the DEVS formalism. * SimPy is an open source process-oriented discrete event simulation package implemented in Python. It is based on Simula concepts, but goes significantly beyond Simula in its synchronization constructs. * Tortuga is an open source software framework for discrete-event simulation in Java. * Facsimile is a free, open-source discrete-event simulation/emulation library. * Galatea - Galatea is a Agent-based simulation platform. * MASON is a fast discrete-event multiagent simulation library core in Java, designed to be the foundation for large custom-purpose Java simulations. The only one I tried is Mason but its Java-based but was good for agent/network sim's. I liked it but it might not be suitable for your purposes`

Thanks for all the references! I will definitely mention them in future blog articles even if I'm not knowledgeable enough to use them myself. If I think of anything I'm eager to have simulated, I'll let you (and everyone else) know.

I should just mention that the math I'll be describing, which to some unifies quantum field theory and stochastic Petri nets, applies to some cellular automaton predator-prey models as well as the plain old Lotka-Volterra model.

`Thanks for all the references! I will definitely mention them in future blog articles even if I'm not knowledgeable enough to use them myself. If I think of anything I'm eager to have simulated, I'll let you (and everyone else) know. I should just mention that the math I'll be describing, which to some unifies quantum field theory and stochastic Petri nets, applies to some cellular automaton predator-prey models as well as the plain old Lotka-Volterra model.`

cool, so you will bring up the critique on L-V from the later years, that it lacks heterogeneity, granularity, noise, space and adaptation?

See slides from Cosma Shalizi page 6 in this lecture. He was at Santa Fe and did his thesis under James Crutchfield.

`cool, so you will bring up the critique on L-V from the later years, that it lacks heterogeneity, granularity, noise, space and adaptation? See slides from Cosma Shalizi [page 6 in this lecture](http://www.stat.cmu.edu/~cshalizi/462/lectures/22/22.pdf). He was at Santa Fe and did his thesis under James Crutchfield.`

Incidentally, I was pointed out this link to what the high-frequency traders are apparently moving into: writing trading models in a hardware description language for deployment on an FPGA. I completely disagree with what the HFT people are doing in the economy, but the modeling person in me wants one...

`Incidentally, I was pointed out this link to what the high-frequency traders are apparently moving into: [writing trading models in a hardware description language for deployment on an FPGA](http://www.stoneridgetechnology.com/products/pci-e-development-boards/hft-development-kit/). I completely disagree with what the HFT people are doing in the economy, but the modeling person in me wants one...`

Un-be-lievable. While there is still a slim chance that I'll do a project about CFD software at BMW yet, maybe I should look for a project by a bank for HFT - I'm almost starting to regret that I did not move to London city a decade ago.

But seriously, could it be possible to use

game padsfor living-room high performance computations? I mean, if you look for cheap, reliable and very powerful computing equipment, you should find it there, right?`<blockquote> <p> ...writing trading models in a hardware description language for deployment on an FPGA. </p> </blockquote> Un-be-lievable. While there is still a slim chance that I'll do a project about [[CFD]] software at BMW yet, maybe I should look for a project by a bank for HFT - I'm almost starting to regret that I did not move to London city a decade ago. But seriously, could it be possible to use <i>game pads</i> for living-room high performance computations? I mean, if you look for cheap, reliable and very powerful computing equipment, you should find it there, right?`

Game pads, sure. Using GPUs is not quite ubiquitous yet, but is on its way to becoming standard.

Computational Finance

`Game pads, sure. Using GPUs is not quite ubiquitous yet, but is on its way to becoming standard. [Computational Finance](http://www.gpucomputing.net/?q=node/87)`

A collegue of mine works at a company that bridged the economic crisis in 2008 by writing a game for the Wii, it is called Aya and the cubes of light. The game itself is finished, but due to the economic recovery they haven't invested any manpower in doing the necessary quality checks for the publication of the game, so you can't buy it yet.

But I was allowed to play with it, that was the first and only time I ever played with a Wii like game pad!

What I don't know, though, is if there is a low level API for programming for the Wii, the game API is of course rather high level and cannot be used for anything different than game programming. And you need a special license to get the necessary hardware and to be even allowed to program games for the Wii. If there is an appropriate API, I think the cheapest and easiest way to create a little super computer in your living room would be to create a net of game pads.

`A collegue of mine works at a company that bridged the economic crisis in 2008 by writing a game for the Wii, it is called <a href="http://www.cubes-of-light.com/">Aya and the cubes of light</a>. The game itself is finished, but due to the economic recovery they haven't invested any manpower in doing the necessary quality checks for the publication of the game, so you can't buy it yet. But I was allowed to play with it, that was the first and only time I ever played with a Wii like game pad! What I don't know, though, is if there is a low level API for programming for the Wii, the game API is of course rather high level and cannot be used for anything different than game programming. And you need a special license to get the necessary hardware and to be even allowed to program games for the Wii. If there is an appropriate API, I think the cheapest and easiest way to create a little super computer in your living room would be to create a net of game pads.`

The Wii is relatively low computational power: its selling point was the "physical interaction" (recently copied). The PS3 and the XBox 360 are high performance, but they're different chip architectures (Cell and PPC-variant respectively), so if you really care about writing the fastest code you can, you need to spend time investigating their quirks. (Also it's unclear if the cooling is up to running 24/7, like they would on a scientific project rather than gaming.)

`The Wii is relatively low computational power: its selling point was the "physical interaction" (recently copied). The PS3 and the XBox 360 are high performance, but they're different chip architectures (Cell and PPC-variant respectively), so if you really care about writing the fastest code you can, you need to spend time investigating their quirks. (Also it's unclear if the cooling is up to running 24/7, like they would on a scientific project rather than gaming.)`

Staffan wrote:

Yes, I guess so - except for the "adaptation" part, which is beyond my current ability.

Nice. He gives some references I should dig up, about a stochastic model which converges to the Lotka-Volterra model in the limit of large populations, saying:

I think I'm working on the math of this sort of stochastic model right now...

Crutchfield is familiar to me from discussions at the Entropy Club - some members know his work on computational mechanics.

`Staffan wrote: > cool, so you will bring up the critique on L-V from the later years, that it lacks heterogeneity, granularity, noise, space and adaptation? Yes, I guess so - except for the "adaptation" part, which is beyond my current ability. > See slides from Cosma Shalizi page 6 in this lecture. He was at Santa Fe and did his thesis under James Crutchfield. Nice. He gives some references I should dig up, about a stochastic model which converges to the [[Lotka-Volterra model]] in the limit of large populations, saying: > classical theory of this convergence due to Kurtz (1970, 1971, 1981) I think I'm working on the math of this sort of stochastic model right now... Crutchfield is familiar to me from discussions at the Entropy Club - some members know his work on [computational mechanics](http://cse.ucdavis.edu/~chaos/chaos/pubs.htm#CompMech).`

Yes i like Cosma's whole course and I return to it refresh my memory :-) Maybe you should try to interview some of the "doyens" in Complex Adaptive Systems ? I know that you are interviewing mainly experts in climate. But it would be fun to - after finding out if they do care about global warming - see what they can contribute with their multidisciplinary approaches? James Crutchfield, Mark Newman, Cosma Shalizi, all were at SFI and I can come up with several other suggestions!

BTW Cosma and Kristina Klinkner implemented CSSR which seems to be an efficient way of

So tell me more about the Entropy club, when you have more time!

`Yes i like Cosma's [whole course](http://www.stat.cmu.edu/~cshalizi/462/syllabus.html) and I return to it refresh my memory :-) Maybe you should try to interview some of the "doyens" in Complex Adaptive Systems ? I know that you are interviewing mainly experts in climate. But it would be fun to - after finding out if they do care about global warming - see what they can contribute with their multidisciplinary approaches? James Crutchfield, [Mark Newman](http://www-personal.umich.edu/~mejn/), Cosma Shalizi, all were at SFI and I can come up with several other suggestions! BTW Cosma and Kristina Klinkner [implemented CSSR](http://www.cscs.umich.edu/~crshalizi/CSSR/) which seems to be an efficient way of > This is the homepage for CSSR (Causal State Splitting Reconstruction), an algorithm for building recursive hidden Markov models from discrete-valued time series, and other discrete sequential data. Unlike conventional hidden-Markov algorithms, which tune the parameters in a fixed architecture, CSSR is capable of inferring the appropriate architecture as well. In fact, under certain conditions, CSSR will converge on the optimal model of the underlying data-generating process. CSSR has been implemented and successfully tested on a range of different discrete time series and sequential data streams. This page provides the full source code, released under the GNU Public License. So tell me more about the Entropy club, when you have more time!`

Just checking: is there anyone on here who does hardcore C++ template-metaprogramming? (I've reached the point where I want to do something that I think can't be done with template metaprogramming, at least short of implementing almost the entire logic via templates, which is not a good idea.)

`Just checking: is there anyone on here who does hardcore C++ template-metaprogramming? (I've reached the point where I want to do something that I think can't be done with template metaprogramming, at least short of implementing almost the entire logic via templates, which is not a good idea.)`

No :-)

Of course I could transfer a question to some of my collegues, including one who helped in the development of the MP3 file format, who knows a lot about C++.

`<blockquote> <p> Just checking: is there anyone on here who does hardcore C++ template-metaprogramming? </p> </blockquote> No :-) Of course I could transfer a question to some of my collegues, including one who helped in the development of the MP3 file format, who knows a lot about C++.`

Thanks Tim. Since I wasn't sure if there was someone who does all this stuff, I thought it made sense to check. I've had an idea that might work. If it doesn't I may take you up on asking a colleague (although template metaprogramming is one of those corner areas that comes up mostly in writing numeric code, so it's perfectly possible to have an amazing knowledge of C++ but never have worked on anything where template metaprogramming is appropriate.)

`Thanks Tim. Since I wasn't sure if there was someone who does all this stuff, I thought it made sense to check. I've had an idea that might work. If it doesn't I may take you up on asking a colleague (although template metaprogramming is one of those corner areas that comes up mostly in writing numeric code, so it's perfectly possible to have an amazing knowledge of C++ but never have worked on anything where template metaprogramming is appropriate.)`

No :-( I did some C++ project in the early 90s but I haven't kept it live, only reading game programming books w C++, I had an idea in 2006 with a friend to do a simulation game based on Stabilization wedges, but we didn't get any funding.

`No :-( I did some C++ project in the early 90s but I haven't kept it live, only reading game programming books w C++, I had an idea in 2006 with a friend to do a simulation game based on [[Stabilization wedges]], but we didn't get any funding.`