Viewing this page requires a browser capable of displaying frames.
Here is what is on the frame page :
Modeling the Frequency of Bear Contacts in Rocky
Mountain Contacts in Rocky Mountain Residential Areas
Environmental Sciences
New Mexico High School
Supercomputing Challenge
Final Report
April 5, 2000
Team 030
Bosque Preparatory School
Team Members
Samuel Ashmore
Nicole Mumma
Kenny Sutherland
Teachers
Debra M. Loftin
Dorothy Ashmore
Project Mentors
Geoffrey Combers
Hal Meyer
Executive Summary
Our modeling began with a simple Malthusian growth model . In a real
life situation, bears grow with bounds. We then modified it to a Logistic
Growth program which became the core of our program. To accurately model
a bear population, we needed to incorporate variable such as harvest rate,
desired territory, migration rate, territory size, growth rate for the territory
and habitat loss. Our program was basically a logistic growth model with
hunting and habitat loss with regions. The input variables are population
size, growth rate, carrying capacity, cycles, harvest rate, and area reduction
rate/capacity reduction. If you run the program, you get two types of output.
We got our data from trustworthy sources.
Introduction
The purpose of our project is to model the frequency of a mammal coming
in contact with a growing residential area. Some people are concerned that
this behavior could negatively effect the bear population. Albuquerque alone
is supposed to reach a population of one million people by the end of 2001.
Therefore the bears will be left with less open space in the years to come.
In past years, the media has had stories about bears wandering into residential
areas, having to be tranquilized, and relocated. We felt that perhaps the
media was overplaying the intensity of the situation, so we thought we could
write a program that could accurately tell us how rare it would be that
a bear would come in contact with a residential area. A bear may come in
contact with a residential area for many reasons, some of which are a lack
of food, a loss of shelter, or a loss of a battle with another bear.
The Model
Our modeling began with a simple Malthusian growth model. From there
it became a logistic growth model. We used the logistic growth equation
for the basic population modeling equation as the core of our program. To
develop a more complete and accurate model of a real population, more variables
were incorporated into the program. A logistic growth model models a population
with a growth rate and carrying capacity. To accurately model a bear population,
we needed to incorporate variables such as harvest rate, desired territory,
migration rate, territory size, and growth rate for the territory. In our
program the user must input the values for each of the variables. For each
time the user chooses to continue, a new set of data is given and a graph
is produced and updated. The grid shown is divided up into acres. Each acre
is either an open area or a residential area. Each of them is given a "desirability"
value. Desirability is assigned by the following statements: 1) The more
surrounded an open area is by open areas, the more desirable that area becomes.
2) The more surrounded a residential area is by residential areas, the less
desirable that residential area becomes. 3) The more surrounded an open
area is by residential areas, the more desirable the residential areas become.
4) The more surrounded a residential area is by open area, the less desirable
the residential area becomes. 5) The more enclosed an open area is by open
areas, the higher the altitude. Therefore assigning more or less desirability
to specific altitudes is based on which of a bears favorite foods grow at
what altitude.
Project Description
We started out with a simple program comprised of a Mathusian model equation,
a horrible interface, and a horrible output. From here, we swapped out the
equation for a logistic growth model. We improved the interface and the
output. Then for the model we added hunting and designed it to print out
the information into a file. Then we added habitat loss to the program.
After much work, we created a web interface for the program. Then we added
zones and once we had accomplished that we added migration. That is how
our program evolved. During this time we gathered data. After identifying
the useful data, we used it in our project.
Bear Research
To validate our model it was necessary to input real data about bears into
our program. This information needed to include all variables in our program.
To get this specific data we used the internet and email to get the dat
from all of the Game and Fish Departments in the Rocky Mountains, located
inNew Mexico, Colorado, Wyoming, Montana, and parts of Northern Idaho.
We got all of our research from two general areas. The first was generic
bear information. This data included what they eat, their life span, and
territory size. This information was acquired from several different web
sites from all over the country. The information was always from an 'accurate'
place. We looked at the North America Bear Association, and several newspapers
from local areas. What we found, for the most part, is that bears are little
more than herbivores. Less than 2% of their diets include meat. However,
the bears further north in Canada and Alaska eat more fish due to a lack
of plants. The life span of a bear is generally 20-25 years. Cubs spend
the first two or so years with their mothers, then they are left to fend
for themselves. Females can begin to have offspring at around age 4-5. On
average female bears will produce about 3-5 cubs every 3-4 years. The territory
size depends on the region, but on average male bears need about 10-40 square
miles of land, while females need only 2.5-10 square miles. If the capacity
of the region becomes full bears are more inclined to fight with each other
and wander out of their regions into residential areas.
The second set of data that we got was from several Fish and Game Departments.
From them we got information on the variables that we would need to input
into our program to test its accuracy. The population size is first, and
most important, because it is the starting and ending point of our program.
It defines the amount of change that will occur in the program. The next
most important piece of data is the hunting rate. The hunting rate is important
because from it we can extrapolate the number of deaths. When we subtracted
the hunting deaths over an x year span and then divided the two populations,
we derived the growth rate. In this research, carrying capacity is the entire
state.
Population Model Research
Our program started out as a Malthusian growth model. This is not a very
good model because at first it follows the program exactly, but then it
continues to grow exponentially without bounds. To level this out we put
a carrying capacity variable into the program, which limits the amount of
bears that can exist.
C++ Program
We created program from a mathematical model. Mathematical models are usually
one-line equations that researchers can do in excel. However, we used multiple
equations to compute our final answer. We used equations that would change
variables that created a loop by changing a variable that was essential
to anther equation which eventually effects several other variables and
come back and effects the variable that was just changed. This type of program
is known as recursive. We used four equations using the same variables to
compute the population statistics. Our team designed all of these equations
especially for this program.
Our program started out as a simple Malthusian growth program. A Malthusian
model is a model that grows without bounds. Here is and example :. However,
this program was not adequate for our objective because the program would
grow without bounds. In a real life situation, bears grow with bounds. We
then modified it to a logistic growth program. Here we had bounds and the
population was predictable because it would level out based on the carrying
capacity. Our next problem was modeling the hunting. We added a harvest
rate based on the number of pelts hunters collected in a year. We then had
a logistic growth model with harvesting. Now it would level off much lower
and it contained hunting. Then we had to face the problem of cities. We
knew they sometime grew into bear territory, so we had to add habitat loss.
We added it to a logistic growth model with hunting. Our habitat loss rate
was based on very rough data that we have collected over the Internet. At
Regionals, we talked to some scientists who gave us the idea of having multiple
regions instead of one. We modified our program once again by adding regional
logistic growth. Our program was basically a logistic growth model with
hunting and habitat loss with regions. We ultimately wanted to be able to
monitor the number of times a bear would come in contact with a residential
area by migrating in to a new region. We had to add a new variable called
migration. Migration is based on the bears' territory size and how often
and quickly they move. Up until now, there was no place for the bears to
migrate to.
Our program has many different parts. The biggest are input, output, and
the evolution of our program. The input variables are population size, growth
rate, carrying capacity, cycles, harvest rate, and area reduction rate/capacity
reduction. The population size value is the number of bears living in the
modeling space. Growth rate is the rate at which the bear population is
growing. Carrying capacity is the maximum number of bears that the land
can sustain. The cycles are the number of years for which the program to
run (modeled years not actual years). Harvest rate is the percent of bears
killed per year. Area reduction rate is the percent of reduction of the
Carrying Capacity. The Capacity reduction is the same as the area reduction
rate except it is a fixed number. Since the area reduction rate and capacity
reduction have the same purpose, only one can be used, not both.
The output comes in one or two ways; this depends on whether the program
is run or the site. 1) From the site the numbers entered are displayed in
tabular form and a time date stamp. This comes from the file that the program
writes. Underneath the redisplayed input is a table, which displays the
population for each year. Underneath that, if the browser is setup up right,
is a table that is custom designed for the input. 2) If the program is run,
two types of output are given off. One is the table that displays the population
for each year on the screen. The second output is a separate file. This
file has a time date stamp that lets the user know when it was created.
It would be this file that would be imported onto the web page if when the
programis run from the site. This file also has the table and input numbers.
Our equations for population looks like this: population = population +
(growth_rate * population *( (1 - population/carrying_capacity))) - population
* harvest_rate, where population is the population size of the species,
growth_rate is the growth rate, carrying_capacity is the carrying capacity,
and harvest_rate is the percent of bears killed. Our equation for habitat
loss looks like this: carrying_capacity=carrying_capacity*(1-habitat_loss_percent)-habitat_loss_fixed,
where habitat_loss_percent is the percent of the habitat lost, habitat_loss_fixed
is the fixed number of habitats lost. The desire equation is Desirability=
(1- (population/carrying_capacity), where Desirability is the amount desirable.
The migration equation is Population1 = (1- desirability0 /desirability1))
* population0 + population1. Our last equation is Poulation0 = (desirability0
/ desirability1) * population0. This program can be run at mode.lanl.k12.nm.us/
~ch030sra /final.cgi. Here is an example of the zones:
We call this type of model a zone migration model. If our group did not
proceed systematically that our project would have been way over our heads
and we would not understand it as much as we do. From this project we have
learned that you must think big but act slowly and in pieces.
Results and Conclusions
The program that we used worked very well, and it was able to model a bear
population within a reasonable amount of change. Assuming that our program
was flawless, we believe that whatever discrepancies appear come from a
lack of complete data to input into the program. Even so, the only way we
could get a perfect comparison would be if every bear's life was monitored.
Since the purpose of our program is to model a population without having
to go out and watch every one discrepancies have to be allowed.
Now that our program has been completed we can begin to use it in reallife
applications. The first is to monitor a small bear population and see how
long it will take it to be large enough to allow hunting.
Probably the most important use for our program is for construction companies.
If a contractor were planning to build homes near the edge of a city, she/he
could use our program to model the number of bear encounters that the residents
would have, and to determine how appealing the nearby areas would be so
that the bears would find areas other than a city in which to find food
and live in.
Our program is also moldable to several other species. The only things that
the species need to have as part of the species lifestyle are the variables
that are in our program. An example of this usage would be to run the program
on mice that carry the plague in the area of New Mexico. The zones include
city areas like the West Side, or the East Mountains, or counties like Bernalillo
or Sandoval.
Recommendations
We need to make a much more user friendly input because if the user wanted
to run the program with 100 cells it would be difficult.
Acknowledgments
We would like to thank Mrs. Ashmore, Ms Loften, Mr. Comber and Mr Myers
for helping us out though out the project.
References
Practical C++ Programming, O'Reilly,1997, Steve Qualine;
Perl, The Programmer's Companion, Wiley, 1997, Nigel Chapman;
2.3.5Mathematical Modeling, Sandia labs, http://ais.cs.sandia.gov/AiS/textbook/unit2/
projdev2.3.5.html
Bears head south, driven by hunger, mating Experts predict more interaction
with humans as animal's numbers grow, Milwaukee Journal Sentinel; Milwaukee;
Jun 28, 1999; MEG JONES;
BEARS THREATENED BY POACHING, POLLUTION, DEFORESTATION, Columbian; Vancouver;
Aug 1, 1999; AP;
DURANGO Ursine intruders get pretty hard to bear Food shortages boost
contact with humans, Denver Post; Denver, Cob.; Sep 6, 1999; Electa Draper
Denver Post Four Corners Bureaw
OUTDOORS ALMANAC Bear season a bust for many bunters, Star Tribune; Minneapolis,
Minn.; Oct 24, 1999; Doug Smith; Staff Writer;
State considers proposal to allow black bear hunts; Residents say growing
population of animals a nuisance, The Sun; Baltimore, Md.; Jan 20, 2000;
Greg Garland'
California bear hunt shows population is on upswing, Las Vegas Review
- Journal; Las Vegas; Dec 9, 1999; John Kimak;
U.S. authorities report rising cases of bear poaching Hunters make money
off sale of galibladders, paws, claws of animal, Milwaukee Journal Sentinel;
Milwaukee; Feb 21, 1999; MARIA GLOD AND LEEF SMITH;
IT'S A BEAR MARKET BUT WITH THE DROUGHT AFFECTING, Pittsburgh Post -
Gazette; Pittsburgh, Pa.; Nov 14, 1999;
Bear eludes capture in Ramona, The San Diego Union - Tribune; San Diego,
Calif; Nov 9, 1999; Bruce Lieberman;
Biologists, environmentalists debate whether migration will boost bear
numbers, Officials find tagged animals on Canadian soil, Idaho Statesman;
Boise; Nov 16, 1999;
Legal claim says feds can't link grizzly groups Environmentalists say
bear numbers still are too low, Idaho Statesman; Boise; Nov 25, 1999;
Maryland's bear population showing new, bristling health, The Sun; Baltimore,
Md.; Dec 16, 1999; Peter Baker;
NORTH AMERICAN BLACK BEAR, Bear Country USA, http://www.bearcountryusa.com/animals/bear.htm;
Reports/By Date, Unknown, http://domino.htcomp.net/bhn/bear.nsf/861ba1
1601 8cd870862563b00004524d?OpenView;
Reports/By Area, Unknown, http://domino.htcomp.net/bhn/bear.nsf1c39e9f73a9fS
1 5fd8625 63b0000a8 195 ?OpenView
American Black Bears, "THE BEAR DEN", http :I/www. nature-net.
com/bears/black html;
Canadian Grizzly Population Sizes, CERI, http://www.grizzlybear.org/gbmap/cosewics.html
Appendices
Appendix A
//*************************************************************
//
//Bosque Preparatory School Growth Program
//
//*************************************************************
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cassert>
#include <time.h>
#define region 2
#define regions 2
class Territory{
public:
double population ;
double carrying_capacity;
double growth_rate ;
double harvest_rate ;
double desire;
double habitat_loss_rate;
double habitat_loss_fix;
void update();
};
void Territory::update()
{
population = population + (growth_rate * population *(
(1 - population/carrying_capacity))) - population * harvest_rate;
}
Territory area[region][regions];
double cycles =0;
double times =0;
// must be one
double time_interval =1;
int timer =0;
int timers =0;
time_t t;
char* s;
double get_input(char* input_value);
int main()
{
//continue loop (contine is used instead of continue because
continue is a C++ variable)
//Explanation of program
cout << "This is a logistic growth program\n";
cout << "Population is the population at time
0 \n";
cout << "Growth rate is the rate of growth \n";
cout << "Carrying capacity is how much the land
can hold \n";
cout << " Cycles the number of units that you
want it to run \n";
cout << " Harvest rate is the decimal percent
harvested \n";
cout << "Habitat losses are percent for rate
and a interger for fix\n";
for(timer =0; timer < region ; timer ++)
{
for(timers =0; timers < regions; timers ++)
{
cout << "grid" << timer <<
", " << timers << "\n" ;
//Information input
area[timer][timers].population = get_input("population");
area[timer][timers].growth_rate = get_input("growth
rate");
area[timer][timers].carrying_capacity =get_input("carrying
capacity");
area[timer][timers].harvest_rate = get_input( "harvest
rate");
area[timer][timers].habitat_loss_rate= get_input( "habitat
loss rate");
area[timer][timers].habitat_loss_fix= get_input( "habitat
loss fix");
}
}
cycles =get_input("number of cycles");
// the name of output file
cout << "Enter the name of the output file:
";
string outfilename;
cin >> outfilename;
cout << outfilename << endl;
//output file writingi
cout << "0";
ofstream outStream(outfilename.data());
cout << "1";
assert( outStream.is_open());
t = time(NULL);
s= ctime(&t);
outStream << s ;
outStream <<"Logistical Growth Results: \n ";
outStream << "The original population is: ";
for(timer =0; timer <region; timer ++)
{
for(timers =0; timers <regions;timers ++)
{
outStream << area[timer][timers].population <<
"\t";
}
outStream << "\n\t\t\t\t" ;
}
outStream << "\n";
outStream << "The growth rate is: ";
for(timer =0; timer <region; timer ++)
{
for(timers =0; timers <regions;timers ++)
{
outStream << area[timer][timers].growth_rate <<
"\t";
}
outStream << "\n\t\t\t" ;
}
outStream << "\nThe carrying capacity is: ";
for(timer =0; timer <region; timer ++)
{
for(timers =0; timers <regions;timers ++)
{
outStream << area[timer][timers].carrying_capacity
<< "\t";
}
outStream << "\n\t\t\t" ;
}
outStream << "\nThe habitat loss fixed amount
is: ";
for(timer =0; timer <region; timer ++)
{
for(timers =0; timers <regions;timers ++)
{
outStream << area[timer][timers].habitat_loss_fix
<< "\t";
}
outStream << "\n\t\t\t" ;
}
outStream << "\nThe habitat loss rate is: ";
for(timer =0; timer <region; timer ++)
{
for(timers =0; timers <regions;timers ++)
{
outStream << area[timer][timers].habitat_loss_rate
<< "\t";
}
outStream << "\n\t\t\t" ;
}
outStream << "\nThe harvest rate is: ";
for(timer =0; timer <region; timer ++)
{
for(timers =0; timers <regions;timers++)
{
outStream << area[timer][timers].harvest_rate <<
"\t";
}
outStream << "\n\t\t\t" ;
}
outStream << "\nThe number of cycles is: "
<< cycles << "\n";
outStream << "Time \t population\n\n";
cout << "Time \t population \n";
times =0;
//main loop
for(times= 0; times <= cycles; times++)
{
cout << times << "\t ";
outStream << times << "\t ";
for(timer=0; timer < region; timer++)
{
for(timers=0; timers < regions; timers++)
{
outStream << setiosflags(ios::fixed) << setprecision(2)
<< area[timer][timers].population << "\t";
cout << setiosflags(ios::fixed) << setprecision(2)
<< area[timer][timers].population << "\t";
//Time adder
//THE EQUATION
area[timer][timers].update();
area[timer][timers].carrying_capacity = area[timer][timers].carrying_capacity
*(1-area[timer][timers].habitat_loss_rate) -area[timer][timers].habitat_loss_fix;
area[timer][timers].desire = 1-(area[timer][timers].population/area[timer][timers].carrying_capacity);
cout << area[timer][timers].desire << "\t";
if(area[timer][timers].population <0){
area[timer][timers].population = 0;
}
if(area[timer][timers].carrying_capacity < 0){
area[timer][timers].carrying_capacity = 0;
}
}
}
for(timer=0; timer < region; timer++)
{
for(timers =0; timers < regions; timers ++)
{
try
{
if( area[timer][timers].desire > area[timer +1][timers].desire
)
{
area[timer][timers].population =(1-( area[timer +1][timers].desire/area[timer][timers].desire))
* area[timer+1][timers].population + area[timer][timers].population;
area[timer+1][timers].population = ( area[timer+1][timers].desire/area[timer][timers].desire)
* area[timer+1][timers].population;
}
if( area[timer][timers].desire < area[timer +1][timers].desire
)
{
area[timer+1][timers].population =(1-( area[timer ][timers].desire/area[timer+1][timers].desire))
* area[timer][timers].population + area[timer+1][timers].population;
area[timer][timers].population = ( area[timer][timers].desire/area[timer+1][timers].desire)
* area[timer][timers].population;
}
}
catch(...)
{
}
try
{
if( area[timer][timers].desire > area[timer ][timers+1].desire
)
{
area[timer][timers].population =(1-( area[timer ][timers+1].desire/area[timer][timers].desire))
* area[timer][timers+1].population + area[timer][timers].population;
area[timer][timers+1].population = ( area[timer][timers+1].desire/area[timer][timers].desire)
* area[timer][timers+1].population;
}
if( area[timer][timers].desire < area[timer][timers+1].desire
)
{
area[timer][timers+1].population =(1-( area[timer ][timers].desire/area[timer][timers+1].desire))
* area[timer][timers].population + area[timer][timers+1].population;
area[timer][timers+1].population = ( area[timer][timers+1].desire/area[timer][timers+1].desire)
* area[timer][timers].population;
}
}
catch(...)
{
}
}
}
cout << "\n";
outStream << "\n";
}
outStream.close();
return 0;
}
double get_input(char* input_value)
{
// input section
double num;
num = -9991;
//bad number phase
while (num < -9990)
{
cout << "Please enter the "<< input_value
<< " : ";
cin >> num;
if (!cin.good()) {
cout <<"bad input data" << endl;
cin.clear();
cin.ignore(200,'\n');
}
}
// cin.clear();
// cin.ignore(200,'\n');
return num;
}
Apendix B
#!/usr/bin/perl
print "Content-type:text/html\n\n";
print "<html><head><title>Bosque
School's Model</title></head></html>\n";
print "<body>";
print "<center><h1>Model</h1></center>";
print <<EndForm;
@population = ("");
@growth = ("");
@hunting = ("");
@capacity = ("");
@habitatr = ("");
@habitatf = ("");
@years=();
<form action="samuel.cgi" method = "GET">
<pre> population = <input type="number" name ="population00"
value= @population[0]> population = <input type="number"
name ="population00" value=@population[1]>
growth rate = <input type="number" name ="growth00"
value= @growth[0]> growth rate = <input type="number" name
="growth00" value= @growth[1]>
hunting rate = <input type="number" name ="hunting00"
value =@hunting[0]> hunting rate = <input type="number"
name ="hunting00" value =$FORM{'hunting01'}>
carrying capacity = <input type="number" name ="capacity00"
value=@capacity[0]> carrying capacity = <input type="number"
name ="capacity00" value=@capacity[1]>
habitat loss rate= <input type="number" name ="habitat"
value= @habitatr[0] > habitat loss rate= <input type="number"
name ="habitatl" value=@habitatr[1] >
habitat loss fix = <input type="number" name ="habitatr"
value= @habitatf[0] > habitat loss fixed= <input type="number"
name ="habitatr" value= @habitatf[1] >
population = <input type="number" name ="population00"
value=@population[2]> population = <input type="number"
name ="population00" value=@population[3]>
growth rate = <input type="number" name ="growth00"
value= @growth[2]> growth rate = <input type="number" name
="growth00" value= @growth[3]>
hunting rate = <input type="number" name ="hunting00"
value = @hunting[2]> hunting rate = <input type="number"
name ="hunting00" value =@hunting[3]>
carrying capacity = <input type="number" name ="capacity00"
value=@capacity[2]> carrying capacity = <input type="number"
name ="capacity00" value=@capacity[3]>
habitat loss rate= <input type="number" name ="habitat"
value= @habitatr[2] > habitat loss rate= <input type="number"
name ="habitatl" value= @habitatr[3] >
habitat loss fix = <input type="number" name ="habitatr"
value= @habitatf[2] > habitat loss fixed= <input type="number"
name ="habitatr" value= @habitatf[3] >
Number of years = <input type="number" name
="years" value=years>
<input type="submit" value = "Run Modeling Program"></pre>
</form>
EndForm
print "</body></html>";
if (@population[0] eq "" or @population[1] eq
""or @population[2] eq ""or @population[3] eq ""){
print "Please enter the Population and submit";
}
elsif(@growth[0] eq "" or @growth[1] eq "" or @growth[2]
eq "" or @growth[3] eq ""){
print "Please enter the Growth Rate and submit";
}
elsif(@capacity[0] eq "" or @capacity[1] eq ""or @capacity[2]
eq ""or @capacity[3] eq ""){
print "Please enter the Carrying Capacity and submit";
}
elsif($FORM{'years'} eq ""){
print "Please enter the Number of Years and submit";
}
elsif(@hunting[0] eq "" or @hunting[1] eq "" or @hunting[2]
eq "" or @hunting[3] eq ""){
print "Please enter the Hunting Rate and submit";
}
elsif( @habitatr[0] eq "" or @habitatr[1] eq "" or @habitatr[2]
eq "" or @habitatr[0] eq ""){
print "Please enter the Hunting Rate and submit";
}
elsif( @habitatf[0] eq "" or @habitatf[1] eq "" or @habitatf[2]
eq "" or @habitatf[3] eq ""){
print "Please enter the Hunting Rate and submit";
}
else {
open (INPUT, "| ../project/a.out > /dev/null");
print INPUT "@population[0]\n";
print INPUT "@growth[0]\n";
print INPUT "@capacity0]\n";
print INPUT "@hunting[0]\n";
print INPUT "@habitatr[0] \n";
print INPUT "@habitatf[0] \n";
print INPUT "@population[1]\n";
print INPUT "@growth[1]\n";
print INPUT "@capacity[1]\n";
print INPUT "@hunting[1']\n";
print INPUT "@habitatr[1] \n";
print INPUT "@habitatf[1] \n";
print INPUT "@population[2]\n";
print INPUT "@growth[2]\n";
print INPUT "@capacity[2]\n";
print INPUT @hunting[2]\n";
print INPUT "@habitatr[2] \n";
print INPUT "@habitatf[2] \n";
print INPUT "@population[3]\n";
print INPUT "@growth[3]\n";
print INPUT "@capacity[3]\n";
print INPUT "@hunting[3]\n";
print INPUT "@habitatr[3] \n";
print INPUT "@habitatf[3] \n";
print INPUT "@years\n";
print INPUT "./sam.out\n";
close (INPUT);
open (PLOT, "| /usr/bin/gnuplot > /dev/null");
print PLOT "set terminal png\n";
print PLOT "set output './bears.png'\n";
print PLOT "set title 'population' \n";
print PLOT "set xlabel 'years'\n";
print PLOT "set ylabel 'number of bears'\n";
print PLOT "set time\n";
print PLOT "set grid\n";
print PLOT "plot './sam.out' with lines\n";
print PLOT "replot\n";
print PLOT "replot\n";
print PLOT "replot\n";
close (PLOT);
$INPUT_RECORD_SEPARATOR = '\n';
open(INF, "./sam.out");
@b = <INF>;
print <<EndData;
<pre>
@b
<img src="./bears.png" alt="graph"
border=0>
</pre>
EndData
close(INF);
}
print "</body></html>";
Run The Program