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
- 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
- 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. Thenode
attribute is set to the index of the node (if any), 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 inthe_dict
. Thenode
attribute is set to the index of the node, like it is in the dict, but should be converted to a node object if this function is called recursively from aSupplyChainNode
’sfrom_dict()
method.
- get_order_quantity(predecessor_index=None, inventory_position=None, echelon_inventory_position_adjusted=None)[source]¶
Calculate order quantity using the policy type specified in
type
. Iftype
isNone
, returnNone
.The method obtains the necessary state variables (typically inventory position, and sometimes others) from
self.node.network
.If
inventory_position
(andechelon_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 or network are provided or have no state variables objects. Ifinventory_position
andechelon_inventory_position_adjusted
are omitted (which is the typical use case), the current state variables will be used.- Parameters
predecessor_index (int, optional) – The predecessor for which the order quantity should be calculated. Use
None
for external supplier, or if node has only one predecessor (including external supplier).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.
- Return type
float
- Raises
AttributeError – If the policy’s
node
attribute isNone
andinventory_position
or other required state variables areNone
.