Está en la página 1de 5

P14: Draw a flowchart, write an algorithm develop and execute a program for Laplace Decision

Criteria.
#include<iostream.h>
#include<conio.h>
#include<math.h>
class laplace
{
public:
long np[20][20],i,j,x,y,ord[20],dem[20];
void getdata();
void display();
void makeMatrix();
void initial();
void matrixCalculation();
void daily_pro();
long o_fr,o_to,ostep,dstep,d_fr,d_to,pur,sel,ex,opp;
long r,c,pro_pri_mark,pro_sec_mark,p,sum,q,max,v;
};

void laplace::daily_pro()
{
cout<<"\n\nThe expected daily net profit with repect to each order size ";
cout<<"is computed as below:\n\n";
for(p=1;p<=r;p++)
{
sum=0;
cout<<"E(Q"<<p<<")= ( ";
for(q=1;q<=c;q++)
{
if(np[p][q]>=0)
{
if(q==1)
cout<<np[p][q];
else
cout<<"+"<<np[p][q];
}
else
cout<<np[p][q];
sum=np[p][q]+sum;
}
sum=sum/c;
if(p==1)
{

v=p;
max=sum;
}
else
{
if(sum>max)
{
v=p;
max=sum;
}
}
cout<<")/"<<c<<"= "<<sum<<"\n\n";
}
cout<<"The expected daily net ";
if(sum<0)
cout<<"loss is minimum";
else
cout<<"profit is maximum";
cout<<" when the order size is Q";
cout<<v<<"\n, which is equal to "<<ord[v]<<" kg. So, the store should place";
cout<<" \nan order of "<<ord[v]<<" kg of the perishable item , daily.";
}
void laplace::display()
{
cout<<endl<<endl;
cout<<"\n______________________________________________________";
cout<<"______________\n";
cout<<"\t\t!!!SUMMARY OF DAILY NET PROFIT!!!";
cout<<"\n______________________________________________________";
cout<<"______________\n\n\n";
for(p=1;p<=c;p++)
{
cout<<"\t"<<dem[p];
}
cout<<"\n------------------------------------------------------------\n";
for(p=1;p<=r;p++)
{
cout<<ord[p]<<" |\t";
for(long q=1;q<=c;q++)
{
cout<<np[p][q]<<"\t";
}

cout<<endl;
}
}
void laplace::getdata()
{
cout<<"\n\t\tWelcome to LAPLACE DECISION CRITERION\n";
cout<<"______________________________________________________________\n";
cout<<"\nPossible Value Of Order Size From: ";
cin>>o_fr;
cout<<" to: ";
cin>>o_to;
cout<<" in step of: ";
cin>>ostep;
cout<<"\nEntering DEMAND!!"<<endl<<endl;
cout<<"Demand Varies From :";
cin>>d_fr;
cout<<" to: ";
cin>>d_to;
cout<<" in step of: ";
cin>>dstep;
cout<<"\nEnter Purchase Value: ";
cin>>pur;
cout<<endl<<"Enter Selling Value: ";
cin>>sel;
cout<<endl<<"Enter Price if Quantity is Excess than Demand in 2ndDry Market"<<endl;
cin>>ex;
cout<<endl<<"Oppertunity Cost For the store is Rs. :";
cin>>opp;
}
void laplace::initial()
{
r=((o_to-o_fr)/ostep)+1;
c=((d_to-d_fr)/dstep)+1;
pro_pri_mark=sel-pur;
pro_sec_mark=ex-pur;
}
void laplace::matrixCalculation()
{
ord[1]=o_fr;
for(i=2;i<=r;i++)
{

ord[i]=ostep+ord[i-1];
}
dem[1]=d_fr;
for(i=2;i<=c;i++)
{
dem[i]=dstep+dem[i-1];
}
for(i=1;i<=r;i++)
{
for(j=1;j<=c;j++)
{
if(ord[i]>=dem[j])
np[i][j]=((dem[j]*pro_pri_mark)+(abs(ord[i]-dem[j])*(pro_sec_mark)));
else if(dem[j]>=ord[i])
np[i][j]=((ord[i]*pro_pri_mark)-(abs(dem[j]-ord[i])*opp));
}
}
}
void main()
{
laplace obj;
clrscr();
obj.getdata();
obj.initial();
obj.matrixCalculation();
obj.display();
obj.daily_pro();
getch();
}

OUTPUT

Welcome to LAPLACE DECISION CRITERION


______________________________________________________________
Possible Value Of Order Size From: 75
to: 300
in step of: 75
Entering DEMAND!!
Demand Varies From :50
to: 250
in step of: 50
Enter Purchase Value: 80
Enter Selling Value: 100
Enter Price if Quantity is Excess than Demand in 2ndDry Market
75
Oppertunity Cost For the store is Rs. :15

____________________________________________________________________
!!!SUMMARY OF DAILY NET PROFIT!!!
____________________________________________________________________
50
100 150 200 250
-----------------------------------------------------------75 | 875 1125 375 -375 -1125
150 | 500 1750 3000 2250 1500
225 | 125 1375 2625 3875 4125
300 | -250 1000 2250 3500 4750
The expected daily net profit with repect to each order size is computed as belo
w:
E(Q1)= ( 875+1125+375-375-1125)/5= 175
E(Q2)= ( 500+1750+3000+2250+1500)/5= 1800
E(Q3)= ( 125+1375+2625+3875+4125)/5= 2425
E(Q4)= ( -250+1000+2250+3500+4750)/5= 2250
The expected daily net profit is maximum when the order size is Q3
, which is equal to 225 kg. So, the store should place an order of
225 kg of the perishable item, daily.

También podría gustarte