Thursday, September 12, 2013

SIMULATION OF INVENTORY MODEL

#include < stdio.h >
#include < conio.h >
#include < math.h >
#include < stdlib.h >
void main()
 {
     clrscr();
     int day,rday=0,flag=0, stock=80,demand,reorder;
     int  profit=0, cost=0;
     randomize();
     printf("Initial stock is %d\n\n", stock);
     printf("Day    Demand     Profit    Cost    Bal.Stock\n\n");
     for(day=1; day<=30; day++)
     {
       if((day==(rday+3)) && flag==1)
      {
       stock= stock+reorder;
       printf("%d units have been delivered and has been added to the stock\n\n",reorder);
       printf("Current stock (on day %d) is %d\n\n", day,stock);
       printf("Day    Demand     Profit    Cost    Bal. Stock\n\n");
       flag=0;
      }
       demand=rand()%30;
       if (demand<=stock)
     {
     profit = profit+ demand*20;
     cost=cost+(stock-demand)*2;
     stock=stock-demand;
     }
       else
    {
     profit=profit+stock*20;
     cost= cost+(demand-stock)*22;
     stock=0;
    }
       printf("%d      %d         %d       %d        %d\n\n", day,demand,profit,cost,stock);
       /*getch();*/
       if(stock<=50 && flag==0)

      {
     reorder= 50+rand()%30;
     cost=cost+75;
     rday=day;
     flag=1;
     printf("Order given for %d units at the end of day %d \n\n",reorder,day);
     printf("This will be delivered on day %d \n\n",day+3);
     printf("Day    Demand     Profit    Cost    Bal.Stock\n\n");
       }

   }
   printf("\n\nTotal Profit is %d\n\n", profit);
   printf("Total Cost (Loss of Good Will+ Carrying Cost + Reorder Cost) is %d\n\n", cost);
   getch();
 }





Initial stock is 80

Day    Demand     Profit    Cost    Bal.Stock

1      9         180       142        71

2      10         380       264        61

3      3         440       380        58

4      14         720       468        44

Order given for 65 units at the end of day 4

This will be delivered on day 7

Day    Demand     Profit    Cost    Bal.Stock

5      3         780       625        41

6      7         920       693        34

65 units have been delivered and has been added to the stock

Current stock (on day 7) is 99

Day    Demand     Profit    Cost    Bal. Stock

7      3         980       885        96

8      23         1440       1031        73

9      23         1900       1131        50

10      9         2080       1213        41

Order given for 74 units at the end of day 10

This will be delivered on day 13

Day    Demand     Profit    Cost    Bal.Stock

11      8         2240       1354        33

12      24         2720       1372        9

74 units have been delivered and has been added to the stock

Current stock (on day 13) is 83

Day    Demand     Profit    Cost    Bal. Stock

13      0         2720       1538        83

14      27         3260       1650        56

15      9         3440       1744        47

Order given for 63 units at the end of day 15

This will be delivered on day 18

Day    Demand     Profit    Cost    Bal.Stock

16      2         3480       1909        45

17      2         3520       1995        43

63 units have been delivered and has been added to the stock

Current stock (on day 18) is 106

Day    Demand     Profit    Cost    Bal. Stock

18      28         4080       2151        78

19      16         4400       2275        62

20      17         4740       2365        45

Order given for 75 units at the end of day 20

This will be delivered on day 23

Day    Demand     Profit    Cost    Bal.Stock

21      2         4780       2526        43

22      24         5260       2564        19

75 units have been delivered and has been added to the stock

Current stock (on day 23) is 94

Day    Demand     Profit    Cost    Bal. Stock

23      18         5620       2716        76

24      16         5940       2836        60

25      21         6360       2914        39

Order given for 59 units at the end of day 25

This will be delivered on day 28

Day    Demand     Profit    Cost    Bal.Stock

26      6         6480       3055        33

27      27         7020       3067        6

59 units have been delivered and has been added to the stock

Current stock (on day 28) is 65

Day    Demand     Profit    Cost    Bal. Stock

28      10         7220       3177        55

29      22         7660       3243        33

Order given for 63 units at the end of day 29

This will be delivered on day 32

Day    Demand     Profit    Cost    Bal.Stock

30      1         7680       3382        32



Total Profit is 7680

Total Cost (Loss of Good Will+ Carrying Cost + Reorder Cost) is 3382

2 comments:

Unknown said...

can u elaborate all of these topic related to simulation via theory and examples

Unknown said...

It is precious post keep doing more in simulation