policy Module

Overview

This module contains the Policy class. A Policy object is used to encapsulate inventory policy calculations and to make order quantity calculations.

Note

The notation and references (equations, sections, examples, etc.) used below refer to Snyder and Shen, Fundamentals of Supply Chain Theory (FoSCT), 2nd edition (2019).

Example: Create a Policy object representing a base-stock policy with base-stock level 60. Calculate the order quantity if the current inventory position is 52.5.

>>> pol = Policy(type='BS', base_stock_level=60)
>>> pol.get_order_quantity(inventory_position=52.5)
7.5

API Reference

class Policy(**kwargs)[source]

A Policy object is used to encapsulate inventory policy calculations and to make order quantity calculations.

Parameters

**kwargs – Keyword arguments specifying values of one or more attributes of the DemandSource, e.g., type='BS'.

type

The policy type, as a string. Currently supported strings are:

  • None

  • ‘BS’ (base stock)

  • ‘sS’ (s, S)

  • ‘rQ’ (r, Q)

  • ‘FQ’ (fixed quantity)

  • ‘EBS’ (echelon base-stock)

  • ‘BEBS’ (balanced echelon base-stock)

Type

str

node

The node the policy refers to.

Type

SupplyChainNode

product_index

The index of the product the policy refers to. The product must be handled by node. May set to None for single-product models.

Type

int, optional

base_stock_level

The base-stock level used by the policy, if applicable. Required if type == ‘BS’, ‘EBS’, or ‘BEBS’.

Type

float, optional

order_quantity

The order quantity used by the policy, if applicable. Required if type == ‘FQ’ or ‘rQ’.

Type

float, optional

reorder_point

The reorder point used by the policy, if applicable. Required if type == ‘sS’ or ‘rQ’.

Type

float, optional

order_up_to_level

The order-up-to level used by the policy, if applicable. Required if type == ‘sS’.

Type

float, optional

initialize()[source]

Initialize the parameters in the object to their default values.

validate_parameters()[source]

Check that appropriate parameters have been provided for the given policy type. Raise an exception if not.

to_dict()[source]

Convert the Policy object to a dict. The node attribute is set to the indices of the node, rather than to the object.

Returns

The dict representation of the object.

Return type

dict

classmethod from_dict(the_dict)[source]

Return a new Policy object with attributes copied from the values in the_dict. The node attribute is set to the index of the node, like it is in the dict, but should be converted to SupplyChainNode objecs if this function is called recursively from a SupplyChainNode’s from_dict() method.

Parameters

the_dict (dict) – Dict representation of a Policy, typically created using to_dict().

Returns

The object converted from the dict.

Return type

Policy

get_order_quantity(product=None, order_capacity=None, include_raw_materials=False, inventory_position=None, echelon_inventory_position_adjusted=None)[source]

Calculate order quantity for the product using the policy type specified in type. If the node is single-product, product may be set to None and the function will determine the product automatically. If type is None, returns None.

If include_raw_materials is False (the default), returns a singleton that equals the order quantity for product. If include_raw_materials is True, returns a nested dict such that get_order_quantity[p][rm] is the order quantity to place to predecessor p for raw material product rm, expressed in units of rm. The dict includes an entry in which pred and rm are both None, which corresponds to the order quantity of the product itself, expressed in units of the product.

If order_capacity is provided, the FG order quantity returned will not exceed this capacity, and the RM order quantities will be scaled accordingly.

If there are multiple predecessors that supply the same raw material, this function will, in general, order all required units of that raw material from a single supplier. The function can be overloaded to specify an allocation rule.

The method obtains the necessary state variables (typically inventory position, and sometimes others) from self.node.network. The order quantities are set using the bill of materials structure for the node/product.

If the policy’s node attribute is None, the returned dict only contains product itself, no raw materials.

If inventory_position (and echelon_inventory_position_adjusted, for balanced echelon base-stock policies) are provided, they will override the values indicated by the node’s current state variables. This allows the policy to be queried for an order quantity even if no node/product or network are provided or have no state variables objects. If inventory_position and echelon_inventory_position_adjusted are None (which is the typical use case), the current state variables will be used.

Parameters
  • product (SupplyChainProduct or int, optional) – The product (as a SupplyChainProduct object or index) for which the order quantity should be calculated. If the node is single-product, either set product to the index of the single product, or to None and the function will determine the index automatically.

  • order_capacity (float, optional) – Maximum number of units of product that can be ordered in the current period.

  • include_raw_materials (bool, optional) – If False, the function will return the order quantity for product, as a singleton float. If True, the function will return a dict indicating the order quantities for all raw materials and predecessors.

  • inventory_position (float, optional) – Inventory position immediately before order is placed (after demand is subtracted). If provided, the policy will use this IP instead of the IP indicated by the current state variables.

  • echelon_inventory_position_adjusted (float, optional) – Adjusted echelon inventory position at node i+1, where i is the current node. If provided, the policy will use this EIPA instead of the EIPA indicated by current state variables. Used only for balanced echelon base-stock policies.

Returns

order_quantity – The order quantity for product if include_raw_materials is False; or, if include_raw_materials is True, a nested dict such that get_order_quantity[p][rm] is the order quantity to place to predecessor p for raw material product rm, expressed in units of rm. The dict includes an entry in which pred and rm are both None, which corresponds to the order quantity of the product itself, expressed in units of the product.

Return type

float or dict

Raises

AttributeError – If the policy’s node attribute (or product attribute, if node is multi-product) is None and inventory_position or other required state variables are None.