Skip to main content

FEL program of grocery shop



FEL is Future event list. A list of event notices for future events. The event notice must contain all the information necessary to execute the event (in particular the time it is scheduled to occur).  The event list is the main data structure in a  discrete-event simulator  so its important to code for FEL.



#include<stdio.h>
#include<conio.h>
/*****************************FEL for a grocery shop!!**********************************/

//Defining structure for customer!!
typedef struct
{
int cno,inter_arr,arr_time,ser_time,beg_time,wait_time,end_time,sys_time,idle_time;
}cust;


//Defining structure for FEL because we have entries for arrival,departure,end & their respective time!!
typedef struct
{
char ename;
int time;
}event;


//For lookup function for inter-arrival time!!
int lookup_interarr(int i)
{
if(i>=0 && i<13)
return 1;
else if(i>=13 && i<25)
return 2;
else if(i>=25 && i<38)
return 3;
else if(i>=38 && i<50)
return 4;
else if(i>=50 && i<63)
return 5;
else if(i>=63 && i<75)
return 6;
else if(i>=75 && i<87)
return 7;
else
return 8;
}


//Lookup function for service time!!
int lookup_service(int s)
{
if(s>=0 && s<11)
return 1;
else if(s>=11 && s<31)
return 2;
else if(s>=31 && s<61)
return 3;
else if(s>=61 && s<86)
return 4;
else if(s>=86 && s<96)
return 5;
else
return 6;
}



//Function for printing customer details!!
void print_cust(cust c)
{
getch();
printf("\n");
printf("%d\t",c.cno);
printf("%d\t",c.inter_arr);
printf("%d\t",c.arr_time);
printf("%d\t",c.ser_time);
printf("%d\t",c.beg_time);
printf("%d\t",c.wait_time);
printf("%d\t",c.end_time);
printf("%d\t",c.sys_time);
printf("%d\t",c.idle_time);
}


//For customer one we assign the variables!!
cust initial_cust(cust c)
{
c.cno=1;
c.inter_arr=0;
c.arr_time=0;
c.ser_time=lookup_service(rand()%100);
c.beg_time=0;
c.wait_time=0;
c.end_time=c.ser_time;
c.sys_time=c.ser_time;
c.idle_time=0;
print_cust(c);
return c;
}


//Function for checking max among two!!
int maximum(int end,int arr)
{
return end>=arr?end:arr;
}


//Function for printing FEL!!
void print_fel(event fel[],int t)
{
int i,temp;
char tmp;
if(fel[0].time>fel[1].time)
 {
  temp=fel[0].time;
  fel[0].time=fel[1].time;
  fel[1].time=temp;
  tmp=fel[0].ename;
  fel[0].ename=fel[1].ename;
  fel[1].ename=tmp;
 }
for(i=0;i<3;i++)
printf("(%c,%d)",fel[i].ename,fel[i].time);
printf("\n%d\t",t);
}


//Main body!!
void main()
{
cust c[30];
event fel[3];
int i,t=0,inter=1,depr=0;
clrscr();
printf("\n\n\nNOTE:""Press any key to see entries one by one!!""");
getch();
clrscr();
printf("\n*************************Grocery Shop Simulation Entries**********************\n");
printf("Custno\tIntrAr\tArr\tSerTime\tBeg\tWait\tEnd\tSysTime\tIdle");
c[0]=initial_cust(c[0]);
for(i=1;i<30;i++)
 {
c[i].cno=i+1;
c[i].inter_arr=lookup_interarr(rand()%100);
c[i].arr_time=c[i-1].arr_time+c[i].inter_arr;
c[i].ser_time=lookup_service(rand()%100);
c[i].beg_time=maximum(c[i-1].end_time,c[i].arr_time);
c[i].wait_time=c[i].beg_time-c[i].arr_time;
c[i].end_time=c[i].beg_time+c[i].ser_time;
c[i].sys_time=c[i].ser_time+c[i].wait_time;
c[i].idle_time=c[i-1].beg_time>c[i].arr_time?0:c[i].arr_time-c[i-1].beg_time;
print_cust(c[i]);
 }
printf("\n******************************************************************************");
printf("\n\nPress any key if you  want to see FEL!!");
getch();
fel[0].ename='A';
fel[0].time=0;
fel[1].ename='D';
fel[1].time=c[0].ser_time;
fel[2].ename='E';
fel[2].time=60;
clrscr();
printf("\n***********************FEL***********************\n");
printf("Time \tFEL\n%d\t",t);
while(t<60)
 {       //If its a inter_arrival event add to arrival!! As we do as (A,30) for example!!

if(fel[0].time==t)
{
fel[0].time=t+c[inter].inter_arr;
inter++;
}
//If its a departure event add to departure!! As we do as (D,30) for example!!
{
if(fel[1].time==t)
{
fel[1].time= t+c[depr].ser_time;
depr++;
}
  t++;
  print_fel(fel,t);
 }
getch();
}
printf("\n\n****************************************************************");



}

by Aanchal Gupta(MCA/4510/11)

Comments

Popular posts from this blog

Advantages and Disadvantages of EIS Advantages of EIS Easy for upper-level executives to use, extensive computer experience is not required in operations Provides timely delivery of company summary information Information that is provided is better understood Filters data for management Improves to tracking information Offers efficiency to decision makers Disadvantages of EIS System dependent Limited functionality, by design Information overload for some managers Benefits hard to quantify High implementation costs System may become slow, large, and hard to manage Need good internal processes for data management May lead to less reliable and less secure data

CONCEPTUAL VIEW OF MIS

The concept is a blend of principles, theories and practices of management, information and system giving rise to a single product called MANAGEMENT INFORMATION SYSTEM . The concept of management gives high regard to the individual and his ability to use the information. MIS gives information through data analysis. While analyzing the information, it relies on many academic disciplines like management science, OR, organization behavior, psychology, etc. The foundation of MIS is the principles of management and its practices. MIS uses the concept of management control in its design and relies heavily on the fact that the decision maker is a human being and is a human processor of information. A MIS can be evolved for a specific objective it is evolved after systematic planning and design. It calls for an analysis of business, management views and policies, organization culture and the management style. The MIS,therefore relies heavily on systems theory.The systems theory offers soluti

Inter-Organizational Value Chain

The value chain of   a company is part of over all value chain. The over all competitive advantage of an organization is not just dependent on the quality and efficiency of the company and quality of products but also upon the that of its suppliers and wholesalers and retailers it may use. The analysis of overall supply chain is called the value system. Different parts of the value chain 1.  Supplier     2.  Firm       3.   Channel 4 .   Buyer