Experiment 1 Simulate CPU Scheduling Algorithm and Using Queuing System A) Fcfs
Experiment 1 Simulate CPU Scheduling Algorithm and Using Queuing System A) Fcfs
a) FCFS
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int bt[20],tat[20],wt[20],n,sumw=0,sumt=0;
cout<<"\n Enter the no. of process to be executed: ";
cin>>n;
cout<<"\n Enter their burst times: \n";
for(int i=0;i<n;i++)
{
cout<<" P"<<(i+1)<<": ";
cin>>bt[i];
}
cout<<"\n Implementing FCFS Scheduling.\n";
cout<<"\n START: ";
for(i=0;i<n;i++)
{
if(i==0)
wt[i]=0;
else
wt[i]=tat[i-1];
tat[i]=bt[i]+wt[i];
cout<<" -->P"<<(i+1);
}
cout<<" :END\n";
cout<<"Process Burst Time Waiting Time Turn Around Time";
for(i=0;i<n;i++)
{
cout<<"\nP"<<(i+1)<<"\t\t"<<bt[i]<<"\t
\t"<<wt[i]<<"\t
\t"<<tat[i];
sumw+=wt[i];
sumt+=tat[i];
}
cout<<"\nAvg Waiting Time: "<<(double)sumw/n<<" ms";
cout<<"\nAvg Turn Around Time: "<<(double)sumt/n<<" ms";
getch();
}
OUTPUT
Enter the no. of process to be executed: 3
Enter their burst times:
P1:4
P2:3
P3:5
b) SJF
#include<iostream.h>
#include<conio.h>
#include<limits.h>
void main()
{
clrscr();
int bt[10],tat[10],wt[10],n,start=0,sumb=0,sumw=0,sumt=0;
int small,pos;
for(int i=0;i<10;i++)
{
bt[i]=INT_MAX;
}
cout<<"\n Enter the no. of process to be executed: ";
cin>>n;
cout<<"\n Enter their burst times: \n";
for(i=0;i<n;i++)
{
cout<<" P"<<(i+1)<<": ";
cin>>bt[i];
sumb+=bt[i];
}
cout<<"\n Implementing SJF Scheduling.\n\n";
cout<<" START: ";
while(sumb>start)
{
small=INT_MAX;
for(i=0;i<n;i++)
{
if(small>bt[i])
{
small=bt[i];
pos=i;
}
}
cout<<" -->P"<<(pos+1);
bt[pos]=INT_MAX;
wt[pos]=start;
tat[pos]=wt[pos]+small;
start+=small;
}
cout<<" : END";
cout<<"\n\n\n Process\t Waiting Time\tTurn Around
Time";
for(i=0;i<n;i++)
{
cout<<"\n P"<<(i+1)<<"\t\t\t"<<wt[i]<<"\t\t\t
"<<tat[i
];
sumw+=wt[i];
sumt+=tat[i];
}
cout<<"\n Avg Waiting Time: "<<(double)sumw/n<<" ms";
cout<<"\n Avg Turn Around Time: "<<(double)sumt/n<<" ms";
getch();
}
OUTPUT
Enter the no. of process to be executed: 3
Enter their burst times:
P1:4
P2:3
P3:5
OUTPUT
Enter the no. of process to be executed: 3
Enter their burst times:
P1:4
Priority: 5
P2:3
Priority: 4
P3:5
Priority: 2
Program:
#include<conio.h>
#include<iostream.h>
class Queue
{
public:
char ptr[20];
int rear,front;
Queue()
{
rear=-1;
front=-1;
}
void insert(char in)
{
rear++;
if(rear==0)
front=0;
ptr[rear]=in;
}
char remove()
{ return ptr[front++];
}
};
void mux(Queue q1,Queue q2,Queue q3,Queue q4)
{
Queue qout;
for(int i=0;i<3;i++)
{
qout.insert(q1.remove());
qout.insert(q2.remove());
qout.insert(q3.remove());
qout.insert(q4.remove());
}
for(i=0;i<12;i++)
{
cout<<qout.remove()<<(i/4)+1<<" ";
}
}
void main()
{
clrscr();
Queue q1,q2,q3,q4;
for(int i=0;i<3;i++)
{
q1.insert('A');
q2.insert('B');
q3.insert('C');
q4.insert('D');
}
mux(q1,q2,q3,q4);
getch();
}
Output :
A1 B1 C1 D1 A2 B2 C2 D2 A3 B3 C3 D3
Experiment 3
class sender
{
private:
int datas[6];
public:
void getbits()
{
int i;
cout<<"\nEnter the data you want to send";
for(i=0;i<6;i++)
{
cin>>datas;
}
}
void printdatas()
{
cout<<"value you have entered is\n";
for(int j=0;j<6;j++)
{
cout<<"\n"<<datas[j];
}
cout<<"\n\nsender is ready to send the data";
delay(2000);
}
friend int* enqueue(sender&,bucket&,receiver&);
};
class bucket
{
private:
int datab[4];
public:
friend int* enqueue(sender&,bucket&,receiver&);
};
class receiver
{
private:
int datar[6];
public:
void askinformation()
{
cout<<"Enter data you want to send from this end";
for(int k=0;k<6;k++)
{
cin>>datar[k];
}
cout<<"\n\nReceiver is ready to send the data to
sender";
}
void printinformation()
{
for(k=0;k<6;k++)
{
cout<<"\n"<<datar[k];
}
cout<<"value you have entered is";
}
friend int* enqueue(sender&,bucket&,receiver&);
};
int main()
{
clrscr();
int n=0;
sender s;
bucket b;
receiver r;
s.getbits();
s.printdatas();
int*k =enqueue(s,b,r);
while(n<4)
{
cout<<"\ndata received by receiver is"<<(*k);
k++;
n++;
}
getch();
return 0;
}
Output
Enter the data you want to send: 12 23 34 45 56 67
value you have entered is
12
23
34
45
56
67
while(ch)
{
printf("Enter the current head position: ");
scanf("%d",&head); h=head;
printf("Enter the number of requests: ");
scanf("%d",&n); k=0; move=0;
printf("Total number of cylinders: 200.");
printf("Enter the requests (1 to 200):");
req:
for(i=0;i<n;i++)
{
scanf("%d",&req[i]);
if(req[i]>200||req[i]<1)
{
printf("Enter requests only between 1-200.");
goto req;
}
}
switch(ch)
{
case 1:
outtextxy(270,10,"SEEK PATTERN FOR LOOK");
max=req[0]; min=req[0]; t2=1; c=0;
for(i=1;i<n;i++)
{
max=max>req[i]?max:req[i];
min=min<req[i]?min:req[i];
}
if(max<=head) t2=0;
while(k<n)
{
t1=0;
for(i=0;i<n;i++)
{
if(t2)
{
if(req[i]&&req[i]>=head)
{
if(req[i]<req[t1]) t1=i;
if(req[i]==max)
{ t2=0; g[c]=1; c++; }
}
}
else
{
if(req[i]&&req[i]<=head)
{
if(req[i]>req[t1]) t1=i;
if(req[i]==min)
{ t2=1; g[c]=200; c++; }
}
}
}/*for*/
printf("%d ",req[t1]);
g[c]=req[t1]; c++;
move+=abs(head-req[t1]);
req[t1]=0; k++;
head=req[t1];
if(head==max) t2=0;
}/*while*/
break;
case 2:
outtextxy(270,10,"SEEK PATTERN FOR CLOOK");
max=req[0]; min=req[0]; t2=1; c=0;
for(i=1;i<n;i++)
{
max=max>req[i]?max:req[i];
min=min<req[i]?min:req[i];
}
while(k<n)
{
t1=0;
if(!t2) head=min;
for(i=0;i<n;i++)
{
if(req[i]&&req[i]>=head)
{
if(req[i]<req[t1]) t1=i;
else if(req[i]==max)
{ head=1; g[c]=1; c++; }
}
}/*for*/
printf("%d ",req[t1]);
move+=abs(head-req[t1]);
head=req[t1];
g[c]=req[t1]; c++;
req[t1]=0; k++;
if(head==max) t2=0;
}/*while*/
break;
case 3:
outtextxy(270,10,"SEEK PATTERN FOR FCFS");
for(i=0,c=0;i<n;i++,c++)
{
printf("%d ",req[i]);
move+=abs(head-req[i]);
head=req[i];
g[c]=req[i];
}
break;
}/*switch*/
printf("Order of servicing:");
printf("%d: ",h);
for(i=0;i<n;i++)
printf("%d ",g[i]);
printf("Total Head Movements: %d",move);
x=getmaxx();
y=getmaxy();
rectangle(0,20,x-5,y-5);
a1=(x-30)/10;
for(i=0;i<n;i++)
{
int x1=g[i]+(3*a1);
fillellipse(x1,y1,2,2);
line(a,b,x1,y1);
a=x1; b=y1;
y1+=15;
}
getch();
clrscr(); clearviewport();
printf("(1) LOOK (2) CLOOK (3) FCFS (0) EXIT
Enter your choice:");
scanf("%d",&ch);
}/*while*/
getch();
}/*main*/
Output:
(1) LOOK (2) C-LOOK (3) FCFS (0) EXIT
Enter your choice:3
Enter The current head position:199
Enter no. of request:4
Enter the request:180 1 140 100
void main()
{
int link=0,block=0,success=0;
void gens1(),gend1(),gent1(),gens2(),gend2(),gent2(),
gens3(),gend3(),gent3(),tim(),wind(),print();
wind();
randomize();
do
{
delay(100);
tim();
if(link==3 && random(100)%9==0)
block++;
print();
gotoxy(56,17);
printf("%d",s1+1);
gotoxy(63,17);
printf("%d",d1+1);
gotoxy(70,17);
printf("%02d",t1);
gotoxy(56,19);
printf("%d",s2+1);
gotoxy(63,19);
printf("%d",d2+1);
gotoxy(70,19);
printf("%02d",t2);
gotoxy(56,21);
printf("%d",s3+1);
gotoxy(63,21);
printf("%d",d3+1);
gotoxy(70,21);
printf("%02d",t3);
gotoxy(72,29);
printf("%d",(success+block+busy));
gotoxy(72,31);
printf("%d",success);
gotoxy(72,33);
printf("%d",block);
gotoxy(72,35);
printf("%d",busy);
gotoxy(72,45);
printf("%d",link);
if(link==0)
{
gens1();
gend1();
gent1();
++link;
++success;
continue;
}
if(link==1)
{
gens2();
gend2();
gent2();
++link;
++success;
continue;
}
if(link==2)
{
gens3();
gend3();
gent3();
++link;
++success;
continue;
}
--t1;
--t2;
--t3;
if(t1<=0)
{
gotoxy(56,17);
printf(" ");
gotoxy(63,17);
printf(" ");
gotoxy(70,17);
printf(" ");
}
if(t2<=0)
{
gotoxy(56,19);
printf(" ");
gotoxy(63,19);
printf(" ");
gotoxy(70,19);
printf(" ");
}
if(t3<=0)
{
gotoxy(56,21);
printf(" ");
gotoxy(63,21);
printf(" ");
gotoxy(70,21);
printf(" ");
}
if(t1<=0 && (t2>=0 || t3>=0))
{
--link;
s1=s2;
d1=d2;
t1=t2;
s2=s3;
d2=d3;
t2=t3;
s3=-1;
d3=-1;
t3=0;
}
if(t2==0 && (t1>=0 || t3>=0))
{
--link;
s2=s3;
d2=d3;
t2=t3;
s3=-1;
d3=-1;
t3=0;
}
if(t3<=0)
{
--link;
}
} while(!kbhit());
}
void print()
{
textcolor(RED);
gotoxy(11,29);
cprintf("%d",s1+1);
gotoxy(11,35);
cprintf("%d",s2+1);
gotoxy(11,41);
cprintf("%d",s3+1);
gotoxy(41,29);
cprintf("%d",d1+1);
gotoxy(41,35);
cprintf("%d",d2+1);
gotoxy(41,41);
cprintf("%d",d3+1);
textcolor(s1+1);
gotoxy(10,30);
cprintf("%c%c%c",219,219,219);
textcolor(s2+1);
gotoxy(10,36);
cprintf("%c%c%c",219,219,219);
textcolor(s3+1);
gotoxy(10,42);
cprintf("%c%c%c",219,219,219);
textcolor(d1+1);
gotoxy(40,30);
cprintf("%c%c%c",219,219,219);
textcolor(d2+1);
gotoxy(40,36);
cprintf("%c%c%c",219,219,219);
textcolor(d3+1);
gotoxy(40,42);
cprintf("%c%c%c",219,219,219);
}
void gens1()
{
randomize();
s1=random(8);
}
void gend1()
{
do
{
d1=random(8);
}while(s1==d1);
}
void gent1()
{
t1=0;
t1=random(30)+1;
}
void gens2()
{
do
{
s2=random(8);
} while(s2==s1 || s2==d1);
}
void gend2()
{
do
{
d2=random(8);
if(d2==d1 || d2==s1)
busy++;
} while(d2==s2 || d2==d1 || d2==s1);
}
void gent2()
{
t2=0;
t2=random(30)+1;
}
void gens3()
{
do
{
s3=random(8);
} while(s3==s1 || s3==s2 || s3==d1 || s3==d2);
}
void gend3()
{
do
{
d3=random(8);
if(d3==s1 || d3==s2 || d3==d1 || d3==d2)
busy++;
} while(d3==s3 || d3==s1 || d3==s2 || d3==d1 || d3==d2);
}
void gent3()
{
t3=0;
t3=random(30)+1;
}
void tim()
{
struct time t;
gettime(&t);
gotoxy(39,7);
printf("%02d:%02d:%02d",t.ti_hour, t.ti_min, t.ti_sec);
}
void wind()
{
int x,y=0;
clrscr();
textcolor(YELLOW);
for(x=1;x<=79;x++)
{
gotoxy(x,1);
cprintf("%c",205);
gotoxy(x,10);
cprintf("%c",205);
gotoxy(x,50);
cprintf("%c",205);
}
for(x=1;x<=49;x++)
{
gotoxy(x,20);
cprintf("%c",205);
}
for(x=2;x<=49;x++)
{
gotoxy(1,x);
cprintf("%c",186);
gotoxy(79,x);
cprintf("%c",186);
}
for(x=11;x<=49;x++)
{
gotoxy(50,x);
cprintf("%c",186);
}
gotoxy(1,1);
cprintf("%c",201);
gotoxy(79,1);
cprintf("%c",187);
gotoxy(1,50);
cprintf("%c",200);
gotoxy(79,50);
cprintf("%c",188);
gotoxy(1,10);
cprintf("%c",204);
gotoxy(79,10);
cprintf("%c",185);
gotoxy(50,10);
cprintf("%c",203);
gotoxy(50,50);
cprintf("%c",202);
// End of window system//
textcolor(RED);
gotoxy(25,3);
cprintf("SIMULATION OF TELEPHONE SYSTEM");
gotoxy(24,5);
cprintf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
gotoxy(32,7);
textcolor(BLUE);
cprintf("CLOCK :");
// End of heading//
gotoxy(22,12);
textcolor(MAGENTA);
cprintf("TELEPHONES");
gotoxy(22,13);
cprintf("----------");
for(x=1;x<=8;x++)
{
textcolor(x);
gotoxy(y+3,15);
cprintf("%c%c%c",219,219,219);
textcolor(RED);
gotoxy(y+4,17);
cprintf("%d",x);
y=y+6;
}
//End of telephones//
textcolor(MAGENTA);
gotoxy(17,22);
cprintf("TELEPHONE SWITCHING");
gotoxy(17,23);
cprintf("-------------------");
y=0;
for(x=1;x<=3;x++)
{
gotoxy(14,30+y);
printf("%c-----------------------%c",174,175);
gotoxy(23,29+y);
textcolor(GREEN);
cprintf("LINK %d",x);
y=y+6;
}
//End of telephone switching//
textcolor(MAGENTA);
gotoxy(52,12);
cprintf("LIST OF CALLS IN PROGRESS");
gotoxy(52,13);
cprintf("-------------------------");
gotoxy(55,15);
textcolor(BLUE);
cprintf("FROM TO DURATION");
textcolor(YELLOW);
for(x=0;x<=21;x++)
{
gotoxy(x+54,16);
cprintf("%c",196);
gotoxy(x+54,18);
cprintf("%c",196);
gotoxy(x+54,20);
cprintf("%c",196);
gotoxy(x+54,22);
cprintf("%c",196);
}
for(x=0;x<=4;x++)
{
gotoxy(53,x+17);
cprintf("%c",179);
gotoxy(60,x+17);
cprintf("%c",179);
gotoxy(66,x+17);
cprintf("%c",179);
gotoxy(76,x+17);
cprintf("%c",179);
}
//end of progress calls//
textcolor(MAGENTA);
gotoxy(60,26);
cprintf("COUNTERS");
gotoxy(60,27);
cprintf("--------");
gotoxy(53,29);
printf("Processed Calls : ");
gotoxy(53,31);
printf("Successful Calls : ");
gotoxy(53,33);
printf("Blocked Calls : ");
gotoxy(53,35);
printf("Busy Calls : ");
gotoxy(62,40);
textcolor(MAGENTA);
cprintf("LINKS");
gotoxy(62,41);
cprintf("-----");
gotoxy(53,43);
printf("Maximum Links : 3");
}
Output:
Experiment 5
Simulation of a manufacturing shop
Implemented in VC++:
#include <iostream.h>
#include <queue>
#include<stdlib>
int main()
{
queue<int> orders;
queue<int> raw;
queue<int> prod;
do
{
raw.push(rand()*50);
orders.push(rand*50);
cout<<"\nNo. of orders : "<<orders.front();
cout<<"\nUnits of raw material available : "
<<raw.front();
if(orders.front()<=raw.front())
{
int quantity_left=raw.front();
quantity_left-=orders.front();
prod.push(orders.front());
raw.pop();
orders.pop();
raw.push(quantity_left());
}
else
{
prod.push(raw.front());
int pending=orders.front();
pending-=raw.front();
raw.pop();
orders.pop();
orders.push(pending);
}
}while(orders.front()!=0);
cout<<"\nThe order of productions are : ";
while(!prod.empty())
cout<<" "<<prod.front();
return 0;
}
Output :
No. of orders : 5
Units of raw material available : 6
No. of orders : 2
Units of raw material available : 1
The order of productions are : 5 2
Experiment 7
Simulation of Inventory Control System
//inventory simulation
#include<conio.h>
#include<dos.h>
#include<iostream.h>
#include<stdlib.h>
class Shop{
int seats;
int customers_seated;
int customers_waiting;
int totalServed;
public:
void init(int s,int cs,int cw){
seats=s;
customers_seated=cs;
customers_waiting=cw;
totalServed=0;
cout<<"Welcome to icecream shop";
cout<<"\nseats:"<<s;
cout<<"\nCustomers inside shop:"<<(cs+cw);
cout<<"\nPress any key to start simulation...";
getch();
clrscr();
}
void addCustomer(){
if(seats==customers_seated){
customers_waiting++;
}
else{
customers_seated++;
}
}
void serveCustomer(){
int someoneServed=0;
if(rand()%11>5)
{
if(customers_waiting!=0)
{
customers_waiting--;
someoneServed=1;
}
else{
if(customers_seated!=0)
{
customers_seated--;
someoneServed=1;
}
}
if(someoneServed)
totalServed++;
}
}
void showStatus(){
clrscr();
cout<<"\nSeats :
"<<seats;
cout<<"\nNumber of Customers seated currently for being served
: "<<customers_seated;
cout<<"\nNumber of Customers waiting currently for being
seated: "<<customers_waiting;
cout<<"\nNumber of Customers who were served and left the shop
: "<<totalServed;
}
};
void main(){
clrscr();
Shop icecreamShop;
icecreamShop.init(20,0,0);
while(!kbhit()){
if(rand()%11>5)
{
icecreamShop.addCustomer();
}
icecreamShop.showStatus();
delay(500);
if(rand()%11<5)
{
icecreamShop.serveCustomer();
}
icecreamShop.showStatus();
delay(500);
}
}
Output :
Welcome to icecream shop
Seats: 20
Customers inside shop: 0
Press any key to start simulation...
Seats
:20
Number of Customers seated currently for being served : 13
Number of Customers waiting currently for being seated : 0
Number of Customers who were served and left the shop : 3
Experiment 10
Distributed Lag Model and Cobweb model
COBWEB Model
The cobweb model or cobweb theory is an economic model that explains why prices
might be subject to periodic fluctuations in certain types of markets. It describes
cyclical supply and demand in a market where the amount produced must be chosen
before prices are observed. Producers' expectations about prices are assumed to be
based on observations of previous prices. Nicholas Kaldor analyzed the model in
1934, coining the term 'cobweb theorem' (see Kaldor, 1938 and Pashigian, 2008),
citing previous analyses in German by Henry Schultz and U. Ricci.
The model
The cobweb model is based on a time lag between supply and demand decisions.
Agricultural markets are thought to be a situation where the cobweb model might
apply, since there is a lag between planting and harvesting. Suppose for example that
as a result of unexpectedly bad weather, farmers go to market with an unusually small
crop of strawberries (this example follows Kaldor, 1934, p. 134). This shortage,
equivalent to a leftward shift in the market's supply curve, results in high prices. If
farmers expect these high price conditions to continue, then in the following year,
they will raise their production of strawberries relative to other crops. Therefore when
they go to market the supply will be high, resulting in low prices. If they then expect
low prices to continue, they will decrease their production of strawberries for the next
year, resulting in high prices again.
This process is illustrated by the diagram on the right. The equilibrium price is at the
intersection of the supply and demand curves. A poor harvest in period 1 means
supply falls to Q1, so that prices rise to P1. If producers plan their period 2 production
under the expectation that this high price will continue, then the period 2 supply will
be high, at Q2. Prices therefore fall to P2 when they try to sell all their output. Notice
that as this process repeats itself, oscillating between periods of low supply with high
prices and then high supply with low prices, the price and quantity spiral inwards and
the economy converges to the equilibrium price where supply and demand cross.
Simplifying, the cobweb model can have two main types of outcomes:
If the slope of the supply curve is greater than the slope of the demand curve (in
absolute value), then the fluctuations decrease in magnitude with each cycle, so a plot
of the prices and quantities over time would look like an inward spiral, as shown in
the diagram. This is called the stable or convergent case.
If the slope of the supply curve is less than the slope of the demand curve (in absolute
value), then the fluctuations increase in magnitude with each cycle, so that prices and
quantities spiral outwards. This is called the unstable or divergent case.
Two other possibilities are:
Fluctuations may also remain of constant magnitude, so a plot of the equilibria would
produce a simple rectangle, if the supply and demand curves have exactly the same
slope.
If the supply curve is less steep than the demand curve near the point where the two
curves cross, but more steep when we move sufficiently far away, then prices and
quantities will spiral away from the equilibrium price but will not diverge indefinitely;
instead, they may converge to a limit cycle.
In either of the first two scenarios, the combination of the spiral and the supply and
demand curves often looks like a cobweb, hence the name of the theory.
Distributed Lag Model
In statistics and econometrics, a distributed lag model is a model for time series data
in which a regression-like equation is used to predict current values of a dependent
variable based on both the current values of an explanatory variable and the lagged
(past period) values of this explanatory variable.
Unstructured estimation
The simplest way to estimate an equation with a distributed lag is by ordinary least
squares, putting a pre-determined number of lagged values of the independent
variable on the right-hand side of the regression equation, without imposing any
structure on the relationship of the values of the lagged-variable coefficients to each
other. A problem that usually arises with this approach is multicollinearity: the
various lagged values of the independent variable are so highly correlated with each
other that their coefficients can be estimated only very imprecisely. Therefore
researchers often impose structure on the shape of the distributed lag (the relation of
the lagged-variable coefficients to each other). Such a structure is called a distributed
lag model.
Structured distributed lag models come in two types: finite and infinite. Infinite
distributed lags allow the value of the independent variable at a particular time to
influence the dependent variable infinitely far into the future, or to put it another way,
they allow the current value of the dependent variable to be influenced by values of
the independent variable that occurred infinitely long ago; but beyond some lag length
the effects taper off toward zero. Finite distributed lags allow for the independent
variable at a particular time to influence the dependent variable for only a finite
number of periods.
The most important finite distributed lag model is the Almon lag[3]. This model
allows the data to determine the shape of the lag structure, but the researcher must
specify the maximum lag length; an incorrectly specified maximum lag length can
distort the shape of the estimated lag structure as well as the cumulative effect of the
independent variable.
The most common type of infinite distributed lag model is the geometric lag, also
known as the Koyck lag. In this lag structure, the weights (magnitudes of influence)
of the lagged independent variable values decline exponentially with the length of the
lag; while the shape of the lag structure is thus fully imposed by the choice of this
technique, the rate of decline as well as the overall magnitude of effect are determined
by the data. Specification of the regression equation is very straightforward: one
includes as explanators (right-hand side variables in the regression) the one-period-
lagged value of the dependent variable and the current value of the independent
variable. If the estimated coefficient of the lagged dependent variable is λ and the
estimated coefficient of the current value of the independent variable is b, then the
estimated short-run (same-period) effect of a unit change in the independent variable
is b while the long-run (cumulative) effect of a sustained unit change in the
independent variable is b / (1 − λ).
Experiment 9
Study of simulation languages
GPSS
SIMSCRIPT
Though earlier versions were released into the public domain, SIMSCRIPT was
commercialized by Markowitz's company, California Analysis Center, Inc., which
produced proprietary versions SIMSCRIPT I.5 and SIMSCRIPT II.5.
As an aid to making important decisions, the use of computer simulation has grown at
an astonishing rate since its introduction. Simulation is now used in manufacturing,
military, nuclear applications, models relating to urban growth, hydroelectric
planning, transportation systems, election redistricting, cancer and tuberculosis
studies, hospital planning, communications, and multi-computer networks.
SIMSCRIPT III is suitable for building high-fidelity simulation models especially
very large models. SIMSCRIPT III modularity and object-orientated concepts
simplify development, maintenance and code reuse.
SIMSCRIPT III is a language designed specifically for simulation. It is the most
efficient and effective program development technique for simulation, due to the
following properties:
Portability. SIMSCRIPT III development environment, which includes
Development Studio, language compiler and Graphical systems are available on
the various computer systems. This facilitates the development of general-purpose
models and simulation applications that can be moved easily from one site to
another and from one organization to another.
Error Detection. SIMSCRIPT III performs a number of error checks that help to
assure that a simulation model is running correctly. Powerful inline symbolic
debugger speeds up run-time analysis of model behavior.
Statistical Tools. Along with the mathematical and statistical functions most often
used in simulation (exponential functions, random number generators, and so on),
SIMSCRIPT III includes the accumulate and tally statements that allow the model
builder to collect statistics on key variables in his model.
Implementation:
#include<conio.h>
#include<iostream.h>
void main()
{
int a=21,b=53,r;
int seed = 52;
r=seed;
cout<<"Ten random numbers are : \n";
for(int i=0;i<10;i++)
{
r=(a*r+b)%100;
cout<<r<<" ";
}
}
Output:
Ten random numbers are :
45 98 11 84 17 10 63 76 49 82