473,802 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

model implementation

Hi,

I am looking for c++ implementations of very simple ecosystem or
(meta)populatio n 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 1270

"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)populatio n 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*****@hotmai l.com> schreef in bericht
news:4M******** *************@b gtnsc04-news.ops.worldn et.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)populatio n 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
2372
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 http://www.tonymarston.co.uk/php-mysql/model-view-controller.html and tell me why my implementation of the MVC design pattern is totally wrong. Go on, I dare you. Make my day. -- Tony (a legend in his own lunchtime) Marston
34
7116
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. Yensao
3
1966
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 code segment / data segment / etc., will force all objects to be resided in a code segment, so that executable code can be there as well as data. And effectively bypassing all segment model. Any comments on the above?
3
3177
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 this? If no, what is the .net class that implements SAX model? Thanks. Raghu/..
4
1932
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 that the business object will provide the business rules and that the controller will implement the rules and then pass the result set to the view (i.e. do most of the grunt work).
8
3515
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
7450
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 outside of that class. This structured way allows visual tools to host components, and allows programmers to build applications and libraries visually in a RAD environment. The Java language has JavaBeans as its component model which allows Java...
12
7505
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 it to reset info in a combo box. Below is some sample code for my view interface and the presenter: public interface IDevToolView
23
3153
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 model: that most OO features are not available for class object design without loss of POD-ness. So, I'm more than leaning toward "bad" because of the limitations and
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10538
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10063
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.