Re: [OT] Re: model implementation

From: Pieter Provoost (pieterprovoost_at_tiscali.be)
Date: 06/02/04


Date: Wed, 2 Jun 2004 22:38:01 +0200


"Howard" <alicebt@hotmail.com> schreef in bericht
news:4Mqvc.116823$hH.2045892@bgtnsc04-news.ops.worldnet.att.net...
>
> "Pieter Provoost" <pieterprovoost@tiscali.be> wrote in message
> news:40bd1b63$0$9527$a0ced6e1@news.skynet.be...
> > Hi,
> >
> > I am looking for c++ implementations of very simple ecosystem or
> > (meta)population models. I want to know the very basics of model
> > implementation.
> >
> > For example, if my model consists of a number of units that hold a
certain
> > amount of nutrients, and there are flows between the units that depend
on
> > the contents of the units (dU1 = U1 - 5*U2 for example) - how do I
> implement
> > this?
> >
> > Is it correct that I should represent these units by objects of the same
> > class, which has properties such as "contents", "how much is the flow to
> U1
> > dependent on the contents of this unit", "how much is the flow to U1
> > dependent on the contents of U1"...? If that is correct, how do I start
a
> > simulation or calculate the change in the units over time?
> >
> > I have just started with c++ so please keep it very basic :)
> >
> > Thanks in advance,
> > Pieter
> >
>
> This is rather off-topic for this newsgroup, but I actually wrote this
exact
> program for the Ecology classes at my university once, intended as a
> training device for students, so I thought I'd pass my thoughts along.
>
> What I did was create a two-dimensional array of double values, with one
> index representing the different levels (indexed 0..4, if I recall, from
> producers to top consumers), and the other index representing time (in
> days). The values stored in this array were the "contents" for the given
> level on the given day.
>
> The total length of the simulation was a value I let the user decide, but
I
> limited it to 10 years I think (since this was on a Apple IIe, and didn't
> have much memory). You could make a longer maximum, or dynamically
allocate
> the array after asking for the simulation length in days.
>
> Then I had another two-dimensional square array, also of double values,
> indexed in both directions by the biotic (?) level. This array was used
to
> indicate the amount of the content of each of the levels to be added (or
> subtracted) from this level's "content" when calculating the next day's
> "content". These values are constants given by formulas in a book I used
to
> model the ecosystem. (But I had some fun playing with them, so I decided
to
> put them into a configuration file that the user could modify if desired,
> and read the file into the array at startup.)
>
> I allowed the user to "seed" the initial starting content values, and then
> simply started the simulation by stepping forward in time (and thus in the
> array), calculating each level's new content based entirely on the values
> for the previous day and the values in the square array. Changing the
> initial values allowed the user to see how well the system recovered from
> things like over-predation of a given level (such as by humans killing
half
> the top consumers by hunting, for example).
>
> The basic calculation was something like this (leaving out some neat
> features I added):
>
> // 0 index is the "seed" and is already set
> for (int t = 1; t < max_time; ++t)
> {
> for (int b = 0; b < num_levels; ++b)
> {
> double new_content = 0;
> for (int i = 0; i < num_levels; ++i)
> // here's the caluclation(s):
> // add amount of given level's content,
> // multiplied by appropriate factor
> // (note: factor could be negative,
> // if preyed upon by other level!)
> new_content += factor[b,i] * content[b,t-1];
> content[b,t] = new_content;
> }
> display_content(t);
> }
>
> As added complexity and flexibility, I also included things like modifying
> the producer content based on solar input, and let the user specify the
day
> in the year that the smulation was to start, and the amount (and timing)
of
> the solar fluctuation (to account for latitude, for example). I also
added
> other features, such as varying the "constants" according to annual
changes
> (such as hibernation periods), but this is the basic idea of the system.
>
> Good luck!
>
> -Howard
>

Thank you very much, I'm going to experiment a bit with your concept!

Pieter



Relevant Pages

  • Adding Threads to a Sequential Program help!
    ... A basic thread question that i can't seem to find an answer to in the ... I've written a MonteCarlo simulation program in Java (with minimal use ... by index or value, "casting" an array of floats to ints, etc. ... Fundamentally, then, what I want to do is run doSimulation twice (each ...
    (comp.lang.java.programmer)
  • Re: large data in memory
    ... It sounds like you will be making inefficient use of a significant amount of space. ... For example you may find that you can access only the records actually required with a single query by using an "inner join". ... If you are using only a few elements from a very large array, a "hash table" might provide a better storage solution. ... The id is only a 27 char string. ...
    (microsoft.public.vb.general.discussion)
  • Re: how to vary sorts block?
    ... I want to be able to sort that array by ... def initialize ... Thing = Struct.new(:name,:amount) ...
    (comp.lang.ruby)
  • Re: Date representation
    ... allocate the arrays, rewind the file and read in the data. ... the amount of data is not very large. ... Previously I just allocated some ridicously big array and it also ... Below you will find a routine to convert the dates to JULDAG. ...
    (comp.lang.fortran)
  • Re: complicated array
    ... > the columns are account name and amount of order. ... > I need the section where this array would be to look as ... > could refer to that cell to understand its associated ...
    (microsoft.public.excel.worksheet.functions)