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
Policyobject 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
- product_index¶
The index of the product the policy refers to. The product must be handled by
node. May set toNonefor 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
- 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
Policyobject to a dict. Thenodeattribute 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
Policyobject with attributes copied from the values inthe_dict. Thenodeattribute is set to the index of the node, like it is in the dict, but should be converted toSupplyChainNodeobjecs if this function is called recursively from aSupplyChainNode’sfrom_dict()method.
- 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,productmay be set toNoneand the function will determine the product automatically. IftypeisNone, returnsNone.If
include_raw_materialsisFalse(the default), returns a singleton that equals the order quantity forproduct. Ifinclude_raw_materialsisTrue, returns a nested dict such thatget_order_quantity[p][rm]is the order quantity to place to predecessorpfor raw material productrm, expressed in units ofrm. The dict includes an entry in whichpredandrmare bothNone, which corresponds to the order quantity of the product itself, expressed in units of the product.If
order_capacityis 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
nodeattribute isNone, the returned dict only containsproductitself, no raw materials.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/product or network are provided or have no state variables objects. Ifinventory_positionandechelon_inventory_position_adjustedareNone(which is the typical use case), the current state variables will be used.- Parameters
product (
SupplyChainProductor int, optional) – The product (as aSupplyChainProductobject or index) for which the order quantity should be calculated. If the node is single-product, either setproductto the index of the single product, or toNoneand the function will determine the index automatically.order_capacity (float, optional) – Maximum number of units of
productthat can be ordered in the current period.include_raw_materials (bool, optional) – If
False, the function will return the order quantity forproduct, as a singleton float. IfTrue, 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
productifinclude_raw_materialsisFalse; or, ifinclude_raw_materialsisTrue, a nested dict such thatget_order_quantity[p][rm]is the order quantity to place to predecessorpfor raw material productrm, expressed in units ofrm. The dict includes an entry in whichpredandrmare bothNone, 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
nodeattribute (orproductattribute, ifnodeis multi-product) isNoneandinventory_positionor other required state variables areNone.