An Exploration of Generalized Lotka-Volterra Equations: an Early Attempt to Model Ecosystems Function

Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: https://technical.swissmicros.com/decoders/dm42/

You can then copy/paste the listing and post it in "code" tags.
whuyse
Posts: 198
Joined: Thu Dec 21, 2017 1:23 pm

Re: An Exploration of Generalized Lotka-Volterra Equations: an Early Attempt to Model Ecosystems Function

Post by whuyse »

Fascinating. This goes into my files ;-)
BTW I wonder what a non-sloppy post by you would look like ;-)

Couldn't help but try my own version, with a 4th-order Runge-Kutta program:

Code: Select all

        X       Y       Z       T       A
In:     x0      y0      h       n       Function Name
Out:    xn      yn      h       n       Function Name

Function accepts Yi in Y and Xi in X

00 { 114-Byte Prgm }
01▸LBL "RK4"
02 LSTO "X"
03 R↓
04 LSTO "Y"
05 R↓
06 2
07 ÷
08 LSTO "h"
09 R↓
10 LSTO "n"
11 LSTO "c"
12 LSTO "k"
13 ASTO ST X
14 LSTO "F"
15▸LBL 02
16 CLX
17 XEQ 11
18 STO "k"
19 XEQ 10
20 STO+ "k"
21 STO+ "k"
22 XEQ 11
23 STO+ ST X
24 STO+ "k"
25 XEQ 10
26 RCL+ "k"
27 3
28 ÷
29 STO+ "Y"
30 DSE "c"
31 GTO 02
32 RCL "n"
33 RCL "h"
34 STO+ ST X
35 RCL "Y"
36 RCL "X"
37 RTN
38▸LBL 10
39 RCL "h"
40 STO+ "X"
41 X<>Y
42▸LBL 11
43 RCL+ "Y"
44 RCL "X"
45 XEQ IND "F"
46 RCL× "h"
47 END
My own version to diagonalize a 1xn or nx1 vector:

Code: Select all

00 { 37-Byte Prgm }
01▸LBL "DIAG"
02 LSTO "."
03 DIM?
04 +
05 ENTER
06 DSE ST X
07 DIM "."
08 X<> "."
09 TRANS
10 X<> "."
11 STO ST Y
12 DIM "."
13 -
14 X<> "."
15 END
The matrices in question:

Code: Select all

M 3x1 [[100]
       [ 10]
       [  1]]
R 3x1 [[ 1  ]
       [-1.5]
       [-1.9]]
A 3x3 [[ 0     -0.1   0   ]
       [ 0.008  0    -0.1 ]
       [ 0      0.02  0   ]]
The function GLV:

Code: Select all

00 { 24-Byte Prgm }
01▸LBL "GLV"
02 RCL ST Y
03 XEQ "DIAG"
04 RCL "A"
05 R^
06 ×
07 RCL+ "R"
08 ×
09 END
Now do:

A: "GLV"
T: 10
Z: 0.1
Y: RCL "M"
X: 0

XEQ "RK4", which results in:

T: 10
Z: 0.1
Y: [[133.2681] [5.1880] [1.724E-1]]
X: 1

do X<>Y EDIT to see the results. If you use only the navigation keys, you'll keep the stack intact.
when done, EXIT and X<>Y again, and do RK4 again for the next interval:

T: 10
Z: 0.1
Y: [[228.0996] [4.6848] [2.8300E-2]]
X: 2

etc.

Thanks for a very informative post!
Werner
Last edited by whuyse on Mon Mar 29, 2021 7:46 am, edited 1 time in total.
41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE, DM15L
User avatar
Walter
Posts: 3070
Joined: Tue May 02, 2017 11:13 am
Location: On a mission close to DRS, Germany

Re: An Exploration of Generalized Lotka-Volterra Equations: an Early Attempt to Model Ecosystems Function

Post by Walter »

Werner,

I must have slept in Linear Algebra decades ago:
whuyse wrote:
Fri Mar 26, 2021 2:33 pm
My own version to diagonalize a 1xn or nx1 vector:
What did I miss about diagonalized vectors? Thanks in advance for enlightenment.
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
whuyse
Posts: 198
Joined: Thu Dec 21, 2017 1:23 pm

Re: An Exploration of Generalized Lotka-Volterra Equations: an Early Attempt to Model Ecosystems Function

Post by whuyse »

Walter, that was shorthand for
'turning a vector into a matrix with its elements on the diagonal'. Indeed, 'diagonalize' is strictly speaking the wrong word in LinAlg speak.
Werner
41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE, DM15L
User avatar
Patrizia_Favaron
Posts: 12
Joined: Thu Mar 11, 2021 9:44 am
Location: Lomagna

Re: An Exploration of Generalized Lotka-Volterra Equations: an Early Attempt to Model Ecosystems Function

Post by Patrizia_Favaron »

Wow!

Very nice program, whyuse! I'll try soon! I feel you reached and surpassed me in "sloppiness"! ;)

Walter, I guess the need of copying a vector into the diagonal part of a matrix is a quite-GLV issue. In a conventional language, e.g. Fortran, I'd rather use a DO loop, encoding the GLV equations "sequentially". But the DM42 allows matrix operations directly, and so it was really tempting to encode the eqns using compact RPN... :)

Besides, modern Fortran does allow to operate on vectors and matrices directly (e.g. by matmul() functions and the like).

But a PC cannot sit very nicely in my purse... :lol:

Patrizia
User avatar
Walter
Posts: 3070
Joined: Tue May 02, 2017 11:13 am
Location: On a mission close to DRS, Germany

Re: An Exploration of Generalized Lotka-Volterra Equations: an Early Attempt to Model Ecosystems Function

Post by Walter »

Patrizia_Favaron wrote:
Fri Mar 26, 2021 4:49 pm
Walter, I guess the need of copying a vector into the diagonal part of a matrix is a quite-GLV issue. In a conventional language, e.g. Fortran, I'd rather use a DO loop, encoding the GLV equations "sequentially". But the DM42 allows matrix operations directly, and so it was really tempting to encode the eqns using compact RPN... :)
Cara Patrizia,

What do you abbreviate by GLV? I checked my favourite acronym decoder but to no avail. Thanks in advance for enlightenment.
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
User avatar
Patrizia_Favaron
Posts: 12
Joined: Thu Mar 11, 2021 9:44 am
Location: Lomagna

Re: An Exploration of Generalized Lotka-Volterra Equations: an Early Attempt to Model Ecosystems Function

Post by Patrizia_Favaron »

That's the acronym we used...

But take into account that on this time dinosaurs still roamed all over continental Europe. ;)
At the Ecology Department, our computer was a Texas TI-59 calculator with printer extension. And somewhat later we bought an Olivetti P6040 (or P4060 - it was a Basic programmable calculator, with 2KByte of RAM and a beautiful, cozy "floppy disk" reader: the "floppies" where just that, mylar disks about 2" wide, on which information was written using a spiral path. Data size was, if I'm right, 2KByte as well. It took some years more for us to see the first Olivetti M20 (an Italian PC, with computing power somewhat comparable to the early IBM PC, but with a true 16 bit procesor, Zilog Z8000).

So, it's quite likely the acronym passed undetected: the overall Generalized Lotka-Volterra modeling business was quite short-lived.

The professor I worked with on those times shortly after I left for working in the industry (about 1987) had already switched to energy fluxes.

I imagine being among the ten or eleven people in the World still using the friendly GLV acronym: as a remind of a beautiful moment in my life.

And we were adventurous! My first assignment, back in 1982, was a statistical study of the properties of genetic code (as known on those days) towards pointwise mutations. I used my personal TI-58C, for the simulations. <3

Then, other little-and-interesting works came.

My friend, professor Guido Pacchetti, urged me to "do the impossible", that is, learn programming. :!: I was that kind of stereotypical "people-oriented good-girl" person... I had fallen in love with science, since I was 7, and found "programming" fascinating since the high school. But in some way I convinced myself I could not learn to really program, even in a million years. My friend Guido's answer: "Well, let's accelerate the process a little bit." And he gave me two huge books with some gene and protein sequences. :lol: :lol:

I can say, it worked: somewhat. From then on, I've programmed things ranging from TI-58C to MicroVAX II passing through iAPX86, microcontrollers, ... Always using them "instrumentally", to solve real-world problems, or to perform automation tasks (my specialty, around 1989, were supervisory control systems mainly for thermo-electrical power plants; to date, it is "strange" turbulence-sensing systems for atmospheric dispersion).

And confidence by confidence, one other personal divinity of mine was my high school sciences teacher, Ms A.R. Nespoli. She noticed I was passionate on life sciences, but without any method, and even less confidence. She devoted much time to me, my formation as a human being and, who knows, maybe a future scientist. It was her, who presented me to a friend of hers who teached in Milan University, Marco Ferraguti, still a goof friend of mine. Her devotion was anti-cyclical: all my other female teachers initially pressured me to follow a human-sciences path. The only male teacher I had, of Maths & Physics, on the contrary tried somewhat to avoid to follow a scientific career (in his view I was not one of the "talented"; interestingly, the only other in my class who enrolled in Mathematics, like me, was another girl, also "non-talented": maybe, being "prof-X-non-talented" was a good predictor of success in a STEM career :lol: ). Eventually, one of the other female teachers foreseeing for me a brilliant "traditionally feminine" academic life understood I was determined to continue in STEM, and also helped a lot "forming" me.

Sorry for saying all this... But I strongly feel we are (mostly, in my view) a consequence of the encounters we made. Mine were really lucky, and I was immensely fortunate. It's a pity, all these wonderful people remain invisible. But without them, I feel the World would be colder, harsher, and more dysfunctional than it already is.

And the GLVs were part of the story...
User avatar
akaTB
Posts: 794
Joined: Tue May 02, 2017 1:56 pm
Location: Milan, Italy

Re: An Exploration of Generalized Lotka-Volterra Equations: an Early Attempt to Model Ecosystems Function

Post by akaTB »

Thanks for the memories Patrizia!
Those were also my days in Via Celoria and surroundings (Chemistry).
My first and beloved HP 41C came from Eliopolitecnica Feci in '79, just on my path from home to Uni...
Greetings,
    Massimo
ajcaton
-+×÷ left is right and right is wrong :twisted: Casted in gold
User avatar
Patrizia_Favaron
Posts: 12
Joined: Thu Mar 11, 2021 9:44 am
Location: Lomagna

Re: An Exploration of Generalized Lotka-Volterra Equations: an Early Attempt to Model Ecosystems Function

Post by Patrizia_Favaron »

The Eliopolitecnica store! I remember it!

How little a World... :) On those days "computing resources" were so scarce, in today's standards.

And computing itself elicited a lot of curiosity...

To some point, transgressive! At least, for me. The TI-58C was a Christmas gift by my parents. But in reality, what we agreed on was a smaller model: I forced things a little bit, and initially my parents were, well, a bit worried. Of the expense (larger), but more importantly, of the apparent craziness I've done. A travel, or some nice dress, would have surely been preferred on that year (4th high school year). (Then they saw my interest, and supported me fully).

Alas, we all have made.

I also remember a store close to Piazza Piola, from the subway to Piazza Leonardo da Vinci: its name, revealing, was "La vetrina del calcolo"... And there, some miniaturized wonders lurking from behind the glass, unreachable.
User avatar
akaTB
Posts: 794
Joined: Tue May 02, 2017 1:56 pm
Location: Milan, Italy

Re: An Exploration of Generalized Lotka-Volterra Equations: an Early Attempt to Model Ecosystems Function

Post by akaTB »

A tiny world indeed.

My 41 was a Xmas present from my parents, too; I still cannot understand how I could convince them to shell out that much money. I surely pictured it as an indespensable tool for my courses. And, in retrospect, it really has been! In those days during classes but, especially, for my future career in IT.
Yes, there were a few shops, all around Uni buildings, that showed those small wonders on their shelves. How much time spent staring at them, as if they were delicious cakes! :mrgreen:

At the time it even didn't exist an Informatics course, it was established during my second year.

Again, sweet memories from a time frame when all seemed possible.

Grazie Patrizia e buon weekend.
Greetings,
    Massimo
ajcaton
-+×÷ left is right and right is wrong :twisted: Casted in gold
Post Reply