sim_io Module¶
Overview¶
The sim_io module contains functions for writing the results of simulations. The main
function is write_results(), which writes a table to stdout (as well as to a CSV file
if requested) that lists the state variables for all nodes in the network and all periods
in the simulation. All state variables refer to their values at the end of the period.
Note
The terms “node” and “stage” are used interchangeably in the documentation.
The table has the following format:
Each row corresponds to a period in the simulation.
Each node is represented by a group of columns.
The node number is indicated in the first column in the group (i.e., i=1).
(node, product) pairs are indicated by a vertical line, so ‘2|20’ means node 2, product 20.
The columns for each node are as follows:
i=<node index>: label for the column group
DISR: was the node disrupted in the period? (True/False)
IO:s|prod: inbound order for productprodreceived from successors
IOPL:s|prod: inbound order pipeline for productprodfrom successors: a list of order quantities arriving from succesorsinrperiods from the period, forr= 1, …,order_lead_time
OQ:p|prod: order quantity placed to predecessorpfor productprod
OQFG:prod: order quantity of finished goodprod(this “order” is never actually placed—onlythe raw material orders in
OQare placed; butOQFGcan be useful for debugging)
OO:p:prod: on-order quantity (items of productprodthat have been ordered from successorpbut not yet received)
IS:p|prod: inbound shipment of productprodreceived from predecessorp
ISPL:p|prod: inbound shipment pipeline for productprodfrom predecessorp: a list of shipment quantities arriving from predecessorpinrperiods from the period, forr= 1, …,shipment_lead_time
IDI:p|prod: inbound disrupted items: number of items of productprodfrom predecessorpthat cannot be received due to a type-RP disruption at the node
RM:prod: number of items of productprodin raw-material inventory at node
PFG:prod: number of items of productprodthat are pending, waiting to be processed from raw materials
OS:s|prod: outbound shipment of productprodto successors
DMFS|prod: demand of productprodmet from stock at the node in the current period
FR|prod: fill rate of productprod; cumulative from start of simulation to the current period
IL|prod: inventory level of productprod(positive, negative, or zero) at node
BO:s|prod: backorders of productprodowed to successors
ODI:s|prod: outbound disrupted items of productprod: number of items held for successorsdue to a type-SP disruption ats
HC: holding cost incurred at the node in the period
SC: stockout cost incurred at the node in the period
ITHC: in-transit holding cost incurred for items in transit to all successors of the node
REV: revenue (Note: not currently supported)
TC: total cost incurred at the node (holding, stockout, and in-transit holding)For state variables that are indexed by successor, if
s=EXT, the column refers to the node’s external customerFor state variables that are indexed by predecessor, if
p=EXT, the column refers to the node’s external supplierNegative product indices are “dummy products”
See also
For an overview of simulation in Stockpyl, see the tutorial page for simulation.
API Reference¶
- write_results(network, num_periods, periods_to_print=None, columns_to_print=None, suppress_dummy_products=True, write_txt=False, txt_filename=None, write_csv=False, csv_filename=None)[source]¶
Write the results of a simulation to the console, as well as to a TXT and/or CSV file if requested.
- Parameters
network (
SupplyChainNetwork) – The multi-echelon inventory network.num_periods (int) – Number of periods in simulation.
periods_to_print (list or int, optional) – A list of period numbers to print, or the number of periods to print. In the latter case, the middle
num_periods–periods_to_printperiods will be skipped. If omitted, will print all periods (the default).columns_to_print (list or str, optional) –
A list of columns to include in the table of results, each indicated as a string using the abbreviations given in the list above. Alternately, a string or a list of strings, which are shortcuts to groups of columns; currently supported strings are:
'basic':'IO','OQ','IS','OS','IL''costs':'HC','SC','TC''all': prints all columns (equivalent to settingcolumns_to_print=None)
Unrecognized strings are ignored. If omitted, will print all columns (the default).
suppress_dummy_products (bool, optional) –
True(default) to omit dummy product indices in column headers,Falseto display them. If dummy product indices are suppressed, raw material inventories are indicated by their predecessor node indices rather than product indices.write_txt (bool, optional) –
Trueto write the output that is printed to the terminal to TXT file also,Falseotherwise. Optional; default =False.txt_filename (str, optional) – Filename to use for TXT file. Required if
write_txt=True; ignored otherwise.write_csv (bool, optional) –
Trueto write to CSV file,Falseotherwise. Optional; default =False.csv_filename (str, optional) – Filename to use for CSV file. Required if
write_csv=True; ignored otherwise.
- write_instance_and_states(network, filepath, instance_name=None, num_periods=None)[source]¶
Write a JSON file containing the instance and all of the history of the state variables. This is mostly used for debugging.
- Parameters
network (
SupplyChainNetwork) – The multi-echelon inventory network.filepath (str) – The filename and path for the saved JSON file.
instance_name (str, optional) – The name of the instance to use when saving.
num_periods (int, optional) – Number of periods of state data to save. If
None, will save all periods in the simulation (even if some are all zeroes).