Capsim Block Documentation
This star models an inventory system.
int i,j; int samples; float sampleOut; float x; float arrivalInterval; float minTimeNextEvent; float timeSinceLastEvent; float averageOrderingCost; float averageHoldingCost; float averageShortageCost; float delay; float demandSize; complex sampIn; |
|---|
/*
* store as state the number of input/output buffers
*/
if((ibufs = NO_INPUT_BUFFERS()) < 1) {
fprintf(stderr,"inventory: no input buffers\n");
return(2);
}
for (i=0; i |
|---|
/*
* read one sample from each input buffer
*/
for(samples = MIN_AVAIL(); samples >0; --samples) {
/*
* get a customer and arrival interval
* from input buffer
*/
for(i=0; i
|
|---|
/* * Report results */ fprintf(stderr,"\n\nSingle product inventory system. \n"); fprintf(stderr,"Initial inventory level %d items \n", initialInventoryLevel); fprintf(stderr,"Delivery lag ranges %f %f \n", minLag,maxLag); fprintf(stderr,"Length of the simulation %d months \n", numberMonths); fprintf(stderr,"Setup Cost: %f Incremental Cost: %f Holding Cost : %f Shortage Cost: %f\n", setupCost,incrementalCost, holdingCost,shortageCost); averageOrderingCost = totalOrderingCost/numberMonths; averageHoldingCost = holdingCost*areaHolding/numberMonths; averageShortageCost = shortageCost *areaShortage/numberMonths; fprintf(stderr,"\n\n(S,s) (%f,%f) \n", bigs,smalls); fprintf(stderr,"Total Average Cost: %f\n", averageOrderingCost+averageHoldingCost+averageShortageCost); fprintf(stderr,"Average Ordering Cost: %f\n", averageOrderingCost); fprintf(stderr,"Average Holding Cost: %f\n", averageHoldingCost); fprintf(stderr,"Average Shortage Cost: %f\n", averageShortageCost); |
|---|
/* Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
Copyright (C) 1989-2002 XCAD Corporation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
http://capsimtmk.sourceforge.net
XCAD Corporation
Raleigh, North Carolina */
|
|---|
/* inventory.s */
/**********************************************************************
inventory()
***********************************************************************
This star models an inventory system.
The input buffer is the customer inter arrival times and
product demand.
The input are complex with the real part equal to the inter arrival time
and the imaginary part equal to the product demand.
The inventory does not need to output anything but we have chosen to output
the inventory level. Thus by connecting the output of
the inventory star to the plot star, you can observe the inventory level
over time.
Many other output combinations are possible but this star is used to serve
as an example.
The inventory star implements the C code in "Simulation Modeling and Analysis"
by Averill M. Law and W. David Kelton, Second Edition 1991.
We have included original comments.
The parameters are:
(1) Initial inventory level
(2) Number of months
(3) Set up cost
(4) Incremental cost
(5) Holding cost
(6) Shortage cost
(7) Minimum lag
(8) Maximum lag
(9) Order threshold (s)
(10) Inventory Level (S)
(11) Expression for random number generator
(12) Output Request:0=Inventory Level,1=Demand Size
Notes:
(1) The simulation will end when there are no more customers.
However, the simulation can end using parameter 2 as a condition.
The input buffers are arbitrary so that in the future multiple customer
sources may be modeled with a single inventory.
The number of input buffers is arbitrary and determined at run time.
The number of output buffers is also arbitrary (auto-fanout).
|
|---|