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 product prod received from successor s

    • IOPL:s|prod: inbound order pipeline for product prod from successor s: a list of order quantities arriving from succesor s in r periods from the period, for r = 1, …, order_lead_time

    • OQ:p|prod: order quantity placed to predecessor p for product prod

    • OQFG:prod: order quantity of finished good prod (this “order” is never actually placed—only

      the raw material orders in OQ are placed; but OQFG can be useful for debugging)

    • OO:p:prod: on-order quantity (items of product prod that have been ordered from successor p but not yet received)

    • IS:p|prod: inbound shipment of product prod received from predecessor p

    • ISPL:p|prod: inbound shipment pipeline for product prod from predecessor p: a list of shipment quantities arriving from predecessor p in r periods from the period, for r = 1, …, shipment_lead_time

    • IDI:p|prod: inbound disrupted items: number of items of product prod from predecessor p that cannot be received due to a type-RP disruption at the node

    • RM:prod: number of items of product prod in raw-material inventory at node

    • PFG:prod: number of items of product prod that are pending, waiting to be processed from raw materials

    • OS:s|prod: outbound shipment of product prod to successor s

    • DMFS|prod: demand of product prod met from stock at the node in the current period

    • FR|prod: fill rate of product prod; cumulative from start of simulation to the current period

    • IL|prod: inventory level of product prod (positive, negative, or zero) at node

    • BO:s|prod: backorders of product prod owed to successor s

    • ODI:s|prod: outbound disrupted items of product prod: number of items held for successor s due to a type-SP disruption at s

    • 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 customer

  • For state variables that are indexed by predecessor, if p = EXT, the column refers to the node’s external supplier

  • Negative 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_periodsperiods_to_print periods 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 setting columns_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, False to 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) – True to write the output that is printed to the terminal to TXT file also, False otherwise. Optional; default = False.

  • txt_filename (str, optional) – Filename to use for TXT file. Required if write_txt = True; ignored otherwise.

  • write_csv (bool, optional) – True to write to CSV file, False otherwise. 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).