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 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: inbound order received from successor s

    • IOPL:s: inbound order pipeline 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: order quantity placed to predecessor p in the period

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

    • IS:p: inbound shipment received from predecessor p

    • ISPL:p: inbound shipment pipeline 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: inbound disrupted items: number of items from predecessor p that cannot be received due to a type-RP disruption at the node

    • RM:p: number of items from predecessor p in raw-material inventory at node

    • OS:s: outbound shipment to successor s

    • DMFS: demand met from stock at the node in the current period

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

    • IL: inventory level (positive, negative, or zero) at node

    • BO:s: backorders owed to successor s

    • ODI:s: outbound disrupted items: 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

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, 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).

  • 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).