473,395 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

model implementation

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
Jul 22 '05 #1
3 1244

"Pieter Provoost" <pi************@tiscali.be> wrote in message
news:40**********************@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


Jul 22 '05 #2

"Howard" <al*****@hotmail.com> schreef in bericht
news:4M*********************@bgtnsc04-news.ops.worldnet.att.net...

"Pieter Provoost" <pi************@tiscali.be> wrote in message
news:40**********************@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
Jul 22 '05 #3

"> >
// 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);
}


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

Pieter


I think there's an error in my code (it was purely from memory). I think
that the calculation was actually:

new_content += factor[b,i] * content[b,t-1] * content[i,t-1];

But, I'm not positive on that.

The idea was that the new content would be influenced BOTH by the previous
content of the GIVEN level AND by the previous content of the OTHER level
(for each "other" level).

For example, the number of primary consumers added would be relative to both
the number of producers previously present AND by the number of primary
consumers previously present, (because a given amount of primary consumers
could eat more than a fewer number of primary consumers).

Basically, it's saying that the amount added (or subtracted) due to a
specific "other" level is the given constant of interaction between the two
times the product of actual previous values for the interacting levels.
(The more you *have* to eat, the more you *can* eat, and the more there
*are* of you that are eating, the more you all *will* eat.)

The equations came from a sheet I was given that also included the
constants, and if you're working from such a sheet or book, it should
provide the actual equations. You just need to make them fit with the
arrays you define.

-Howard


Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tony Marston | last post by:
For those who you thought my method of implementing OO principles in PHP was totally wrong - see http://www.tonymarston.co.uk/php-mysql/good-bad-oop.html for details, you can now read...
34
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. ...
3
by: Stephen S M WONG | last post by:
As C++ program supports objects with constructors/destructors/methods and data items, I'll assume C++ implementation on segment model computer, like a 80286 with different access restrictions on...
3
by: Raghu | last post by:
Does XmlTextReader class in .net represent SAX implementation? If yes, are there any performance gains if I use C++ SAX implementation in msxml4.dll versus XmlTextReader in .net? Did any one try...
4
by: Griff | last post by:
Two questions really, the first one "conceptual" and the other more involved with design: 1 - There are two schools of thought where I work on the role of the "controller" task. The first is...
8
by: al.cpwn | last post by:
Which sections of the 2003 standard should I study to understand the object model? I am looking to find information similar to that in Stanley B. Lippman's book, "Inside the C++ Object Model"
122
by: Edward Diener No Spam | last post by:
The definition of a component model I use below is a class which allows properties, methods, and events in a structured way which can be recognized, usually through some form of introspection...
12
by: Doug | last post by:
Hi, I learned a little about the model view presenter pattern at a conference this last week and am experimenting with it. It's working pretty well but I have a question. I am trying to use...
23
by: tonytech08 | last post by:
What I like about the C++ object model: that the data portion of the class IS the object (dereferencing an object gets you the data of a POD object). What I don't like about the C++ object...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.