node_state_vars Module¶
Overview¶
This module contains the NodeStateVars class, which keeps track of the state variables
for a node during a simulation.
Note
The terms “node” and “stage” are used interchangeably in the documentation.
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).
API Reference¶
- class NodeStateVars(node=None, period=None)[source]¶
The
NodeStateVarsclass contains values of the state variables for a supply chain node during a simulation. All state variables refer to their values at the end of a period (except during the period itself, in which case the values might be intermediate until the period is complete).- node¶
The node the state variables refer to.
- Type
- period¶
The period of the simulation that the state variables refer to.
- Type
int
- inbound_shipment_pipeline¶
inbound_shipment_pipeline[p][rm][r]= shipment quantity of raw materialrmarriving from predecessor nodepinrperiods from the current period. IfpisNone, refers to external supplier.- Type
dict
- inbound_shipment¶
inbound_shipment[p][rm]= shipment quantity of raw materialrmarriving at node from predecessor nodepin the current period. IfpisNone, refers to external supplier.- Type
dict
- inbound_order_pipeline¶
inbound_order_pipeline[s][prod][r]= order quantity for productprodarriving from successor nodesinrperiods from the current period. IfsisNone, refers to external demand. Ifsis single-product or external demand,prod=None.- Type
dict
- inbound_order¶
inbound_order[s][prod]= order quantity for productprodarriving at node from successor nodesin the current period. IfsisNone, refers to external demand. Ifsis single-product or external demand,prod=None.- Type
dict
- demand_cumul¶
demand_cumul[prod]= cumulative demand (from all sources, internal and external) for productprodfrom period 0 through the current period. If node is single-product,prod=None. (Used forfill_ratecalculation.)- Type
float
- outbound_shipment¶
outbound_shipment[s][prod]= outbound shipment of productprodto successor nodes. IfsisNone, refers to external demand. If node is single-product,prod=None.- Type
dict
- on_order_by_predecessor¶
on_order_by_predecessor[p][rm]= on-order quantity (items that have been ordered from predecessor nodepbut not yet received) for raw materialrmat node. IfpisNone, refers to external supply.- Type
dict
- inventory_level¶
inventory_level[prod]= inventory level (positive, negative, or zero) of productprodat node.- Type
float
- backorders_by_successor¶
backorders_by_successor[s][prod]= number of backorders of productprodfor successors. IfsisNone, refers to external demand.- Type
dict
- outbound_disrupted_items¶
outbound_disrupted_items[s][prod]= number of items of productprodheld for successorsdue to a type-SP disruption ats. (Since external demand cannot be disrupted,outbound_disrupted_items[None][prod]always = 0.) Items held for successor are not included inbackorders_by_successor. Sum over all successors ofbackorders_by_successor + outbound_disrupted_itemsshould always equal max{0, -inventory_level}.- Type
dict
- inbound_disrupted_items¶
inbound_disrupted_items[p][rm]= number of items of raw materialrmfrom predecessorpthat are being held before receipt due to a type-RP disruption at the node.- Type
dict
- raw_material_inventory¶
raw_material_inventory[rm]= number of units of raw materialrmfrom _all_ predecessors in raw-material inventory at node.- Type
dict
- pending_finished_goods¶
pending_finished_goods[prod]= number of units of productprodthat are waiting to be produced from raw materials. (This is used internally to ensure that raw materials are used to produce the finished goods that they were originally ordered for.)- Type
dict
- disrupted¶
Trueif the node was disrupted in the period,Falseotherwise.- Type
bool
- holding_cost_incurred¶
Holding cost incurred at the node in the period.
- Type
float
- stockout_cost_incurred¶
Stockout cost incurred at the node in the period.
- Type
float
- in_transit_holding_cost_incurred¶
In-transit holding cost incurred at the node in the period.
- Type
float
- fixed_cost_incurred¶
fixed cost incurred at the node in the period.
- Type
float
- revenue_earned¶
Revenue earned at the node in the period.
- Type
float
- total_cost_incurred¶
Total cost (less revenue) incurred at the node in the period.
- Type
float
- demand_met_from_stock¶
demand_met_from_stock[prod]= demand for productprodmet from stock at the node in the period. If node is single-product,prod=None.- Type
float
- demand_met_from_stock_cumul¶
demand_met_from_stock_cumul[prod]= cumulative demand for productprodmet from stock from period 0 through the current period. If node is single-product,prod=None. (Used forfill_ratecalculation.)- Type
float
- fill_rate¶
fill_rate[prod]= cumulative fill rate for productprodin periods 0, …, period. If node is single product,prod=None.- Type
float
- order_quantity¶
order_quantity[p][rm]= order quantity for raw materialrmplaced by the node to predecessorpin period. IfpisNone, refers to external supplier.- Type
dict
- order_quantity_fg¶
order_quantity_fg[prod]= finished-goods order quantity for productprodat the node in period.- Type
dict
- get_inbound_shipment_pipeline(periods_from_now, predecessor=None, raw_material=None)[source]¶
Shortcut to
self.inbound_shipment_pipeline[predecessor][raw_material][periods_from_now]that does not requirepredecessororraw_materialto be specified if they are inferrable.- Parameters
periods_from_now (int) – Get pipeline inventory arriving this many periods into the future.
predecessor (
SupplyChainNodeor int, optional) – Predecessor node (as aSupplyChainNode) or its index, orNone(the default) to detect predecessor automatically for a single-predecessor node. If node has both an external supplier and a predecessor node andpredecessorisNone, returns the external supplier.raw_material (
SupplyChainProductor int, optional) – Raw material (as aSupplyChainProduct) or its index, orNone(the default) to detect raw material automatically for a single-raw material node (including a dummy product).
- Returns
Inbound shipment pipeline.
- Return type
float
- get_inbound_shipment(predecessor=None, raw_material=None)[source]¶
Shortcut to
self.inbound_shipment[predecessor][raw_material]that does not requirepredecessororraw_materialto be specified if they are inferrable.- Parameters
predecessor (
SupplyChainNodeor int, optional) – Predecessor node (as aSupplyChainNode) or its index, orNone(the default) to detect predecessor automatically for a single-predecessor node. If node has both an external supplier and a predecessor node andpredecessorisNone, returns the external supplier.raw_material (
SupplyChainProductor int, optional) – Raw material (as aSupplyChainProduct) or its index, orNone(the default) to detect raw material automatically for a single-raw material node (including a dummy product).
- Returns
Inbound shipment.
- Return type
float
- get_inbound_order_pipeline(periods_from_now, successor=None, product=None)[source]¶
Shortcut to
self.inbound_order_pipeline[successor][product][periods_from_now]that does not requiresuccessororproductto be specified if they are inferrable.- Parameters
periods_from_now (int) – Get pipeline order arriving this many periods into the future.
successor (
SupplyChainNodeor int, optional) – Successor node (as aSupplyChainNode) or its index, orNone(the default) to detect successor automatically for a single-successor node. If node has both an external customer and a successor node andsuccessorisNone, returns the external customer.product (
SupplyChainProductor int, optional) – Product (as aSupplyChainProduct) or its index, orNone(the default) to detect product automatically for a single-product node (including a dummy product).
- Returns
Inbound order pipeline.
- Return type
float
- get_inbound_order(successor=None, product=None)[source]¶
Shortcut to
self.inbound_order[successor][product]that does not requiresuccessororproductto be specified if they are inferrable.- Parameters
successor (
SupplyChainNodeor int, optional) – Successor node (as aSupplyChainNode) or its index, orNone(the default) to detect successor automatically for a single-successor node. If node has both an external customer and a successor node andsuccessorisNone, returns the external customer.product (
SupplyChainProductor int, optional) – Product (as aSupplyChainProduct) or its index, orNone(the default) to detect product automatically for a single-product node (including a dummy product).
- Returns
Inbound order.
- Return type
float
- get_demand_cumul(product=None)[source]¶
Shortcut to
self.demand_cumul[product]that does not requireproductto be specified if it is inferrable.- Parameters
product (
SupplyChainProductor int, optional) – Product (as aSupplyChainProduct) or its index, orNone(the default) to detect product automatically for a single-product node (including a dummy product).- Returns
Cumulative demand.
- Return type
float
- get_outbound_shipment(successor=None, product=None)[source]¶
Shortcut to
self.outbound_shipment[successor][product]that does not requiresuccessororproductto be specified if they are inferrable.- Parameters
successor (
SupplyChainNodeor int, optional) – Successor node (as aSupplyChainNode) or its index, orNone(the default) to detect successor automatically for a single-successor node. If node has both an external customer and a successor node andsuccessorisNone, returns the external customer.product (
SupplyChainProductor int, optional) – Product (as aSupplyChainProduct) or its index, orNone(the default) to detect product automatically for a single-product node (including a dummy product).
- Returns
Outbound shipment.
- Return type
float
- get_on_order_by_predecessor(predecessor=None, raw_material=None)[source]¶
Shortcut to
self.on_order_by_predecessor[predecessor][raw_material]that does not requirepredecessororraw_materialto be specified if they are inferrable.- Parameters
predecessor (
SupplyChainNodeor int, optional) – Predecessor node (as aSupplyChainNode) or its index, orNone(the default) to detect predecessor automatically for a single-predecessor node. If node has both an external supplier and a predecessor node andpredecessorisNone, returns the external supplier.raw_material (
SupplyChainProductor int, optional) – Raw material (as aSupplyChainProduct) or its index, orNone(the default) to detect raw material automatically for a single-raw material node (including a dummy product).
- Returns
On order by predecessor.
- Return type
float
- get_inventory_level(product=None)[source]¶
Shortcut to
self.inventory_level[product]that does not requireproductto be specified if it is inferrable.- Parameters
product (
SupplyChainProductor int, optional) – Product (as aSupplyChainProduct) or its index, orNone(the default) to detect product automatically for a single-product node (including a dummy product).- Returns
Inventory level.
- Return type
float
- get_backorders_by_successor(successor=None, product=None)[source]¶
Shortcut to
self.backorders_by_successor[successor][product]that does not requiresuccessororproductto be specified if they are inferrable.- Parameters
successor (
SupplyChainNodeor int, optional) – Successor node (as aSupplyChainNode) or its index, orNone(the default) to detect successor automatically for a single-successor node. If node has both an external customer and a successor node andsuccessorisNone, returns the external customer.product (
SupplyChainProductor int, optional) – Product (as aSupplyChainProduct) or its index, orNone(the default) to detect product automatically for a single-product node (including a dummy product).
- Returns
Backorders by successor.
- Return type
float
- get_outbound_disrupted_items(successor=None, product=None)[source]¶
Shortcut to
self.outbound_disrupted_items[successor][product]that does not requiresuccessororproductto be specified if they are inferrable.- Parameters
successor (
SupplyChainNodeor int, optional) – Successor node (as aSupplyChainNode) or its index, orNone(the default) to detect successor automatically for a single-successor node. If node has both an external customer and a successor node andsuccessorisNone, returns the external customer.product (
SupplyChainProductor int, optional) – Product (as aSupplyChainProduct) or its index, orNone(the default) to detect product automatically for a single-product node (including a dummy product).
- Returns
Outbound disrupted items.
- Return type
float
- get_inbound_disrupted_items(predecessor=None, raw_material=None)[source]¶
Shortcut to
self.inbound_disrupted_items[predecessor][raw_material]that does not requirepredecessororraw_materialto be specified if they are inferrable.- Parameters
predecessor (
SupplyChainNodeor int, optional) – Predecessor node (as aSupplyChainNode) or its index, orNone(the default) to detect predecessor automatically for a single-predecessor node. If node has both an external supplier and a predecessor node andpredecessorisNone, returns the external supplier.raw_material (
SupplyChainProductor int, optional) – Raw material (as aSupplyChainProduct) or its index, orNone(the default) to detect raw material automatically for a single-raw material node (including a dummy product).
- Returns
Inbound disrupted items.
- Return type
float
- get_raw_material_inventory(raw_material=None)[source]¶
Shortcut to
self.raw_material_inventory[raw_material]that does not requireraw_materialto be specified if it is inferrable.- Parameters
raw_material (
SupplyChainProductor int, optional) – Raw material (as aSupplyChainProduct) or its index, orNone(the default) to detect raw material automatically for a single-raw material node (including a dummy product).- Returns
Raw material inventory.
- Return type
float
- get_pending_finished_goods(product=None)[source]¶
Shortcut to
self.pending_finished_goods[product]that does not requireproductto be specified if it is inferrable.- Parameters
product (
SupplyChainProductor int, optional) – Product (as aSupplyChainProduct) or its index, orNone(the default) to detect product automatically for a single-product node (including a dummy product).- Returns
Pending finished goods.
- Return type
float
- get_demand_met_from_stock(product=None)[source]¶
Shortcut to
self.demand_met_from_stock[product]that does not requireproductto be specified if it is inferrable.- Parameters
product (
SupplyChainProductor int, optional) – Product (as aSupplyChainProduct) or its index, orNone(the default) to detect product automatically for a single-product node (including a dummy product).- Returns
Demand met from stock.
- Return type
float
- get_demand_met_from_stock_cumul(product=None)[source]¶
Shortcut to
self.demand_met_from_stock_cumul[product]that does not requireproductto be specified if it is inferrable.- Parameters
product (
SupplyChainProductor int, optional) – Product (as aSupplyChainProduct) or its index, orNone(the default) to detect product automatically for a single-product node (including a dummy product).- Returns
Cumulative demand met from stock.
- Return type
float
- get_fill_rate(product=None)[source]¶
Shortcut to
self.fill_rate[product]that does not requireproductto be specified if it is inferrable.- Parameters
product (
SupplyChainProductor int, optional) – Product (as aSupplyChainProduct) or its index, orNone(the default) to detect product automatically for a single-product node (including a dummy product).- Returns
Fill rate.
- Return type
float
- get_order_quantity(predecessor=None, raw_material=None)[source]¶
Shortcut to
self.order_quantity[predecessor][raw_material]that does not requirepredecessororraw_materialto be specified if they are inferrable.- Parameters
predecessor (
SupplyChainNodeor int, optional) – Predecessor node (as aSupplyChainNode) or its index, orNone(the default) to detect predecessor automatically for a single-predecessor node. If node has both an external supplier and a predecessor node andpredecessorisNone, returns the external supplier.raw_material (
SupplyChainProductor int, optional) – Raw material (as aSupplyChainProduct) or its index, orNone(the default) to detect raw material automatically for a single-raw material node (including a dummy product).
- Returns
Order quantity.
- Return type
float
- get_order_quantity_fg(product=None)[source]¶
Shortcut to
self.order_quantity_fg[product]that does not requireproductto be specified if it is inferrable.- Parameters
product (
SupplyChainProductor int, optional) – Product (as aSupplyChainProduct) or its index, orNone(the default) to detect product automatically for a single-product node (including a dummy product).- Returns
Finished-goods order quantity.
- Return type
float
- property on_hand¶
Current on-hand inventory at node. If node is single-product, returns the on-hand inventory as a singleton. If node is multi-product, returns dict whose keys are product indices and whose values are the corresponding on-hand inventory levels. Read only.
- property backorders¶
Current number of backorders. Should always equal sum over all successors
sofbackorders_by_successor[s]+outbound_disrupted_items[s]. If node is single-product, returns the backorders as a singleton. If node is multi-product, returns dict whose keys are product indices and whose values are the corresponding numbers of backorders. Read only.
- in_transit_to(successor, product=None)[source]¶
Return current total inventory of
productin transit tosuccessor. Includes items that will be/have been delivered during the current period.If the node is single-product, either set
productto the single product, or toNoneand the function will determine the product automatically.- Parameters
successor (
SupplyChainNode) – The successor node.product (
SupplyChainProductor int, optional) – The outbound product (as aSupplyChainProductobject or index), orNoneifsuccessoris single-product.
- Returns
The current inventory in transit to the successor.
- Return type
float
- in_transit_from(predecessor=None, raw_material=None)[source]¶
Return current total inventory of
raw_materialin transit from a given predecessor. Includes items that will be/have been delivered during the current period.Set
predecessortoNoneif the predecessor is the external supplier. If the node has a single raw material, either setraw_materialto the single raw material, or toNoneand the function will determine the raw material automatically.- Parameters
predecessor (
SupplyChainNode) – The predecessor node.raw_material (
SupplyChainProductor int, optional) – The inbound raw_material (as aSupplyChainProductobject or index), orNoneifpredecessorhas a single product or external supplier.
- Returns
The current inventory in transit from the predecessor.
- Return type
float
- in_transit(product=None)[source]¶
Current inventory of raw materials for
productthat is in transit to the node. Read only.In-transit items are counted using the “units” of the node (or node-product pair) itself. That is, each in-transit quantity is divided by the number of units of the inbound item required to make one unit of
productat this node, according to the bill of materials; and then the sum of those quantities is divided by the total number of raw materials required for this node (or node-product pair).For example, if the bill of materials specifies that to make one unit at the node requires 2 units from predecessor node A and 6 units from predecessor node B, and if there are 10 in-transit units from A and 18 from B, then
in_transitequals\[\frac{\frac{10}{2} + \frac{18}{6}}{2} = 4\]If the node is single-product, either set
productto the single product, or toNoneand the function will determine the product automatically.If the node has multiple products that use the same raw material, this function includes all units of that raw material, even though some of them may wind up being used to make products other than
product.To get the number of units in transit by predecessor and/or product, use
in_transit_from().Changed in version 1.0: This was previously a property and is now a function.
- Parameters
product (
SupplyChainProductor int, optional) – The product (as aSupplyChainProductobject or index), orNoneto set the product automatically if node is single-product.- Returns
The current inventory in transit from predecessors.
- Return type
float
- on_order(product=None)[source]¶
Current inventory of raw materials for
productthat is on order to the node. Read only.On-order items are counted using the “units” of the node (or node-product pair) itself. That is, each on-order quantity is divided by the number of units of the inbound item required to make one unit of product
productat this node, according to the bill of materials; and then the sum of those quantities is divided by the total number of raw materials required for this node (or node-product pair).For example, if the bill of materials specifies that to make one unit at the node requires 2 units from predecessor node A and 6 units from predecessor node B, and if there are 10 on-order units from A and 18 from B, then
on_orderequals\[\]frac{frac{10}{2} + frac{18}{6}}{2} = 4
If the node is single-product, either set
productto the single product, or toNoneand the function will determine the product automatically.If the node has multiple products that use the same raw material, this function includes all units of that raw material, even though some of them may wind up being used to make products other than
product.Changed in version 1.0: This was previously a property and is now a function.
- Parameters
product (
SupplyChainProductor int, optional) – The product (as aSupplyChainProductobject or index), orNoneto set the product automatically if node is single-product.- Returns
The current inventory on order from predecessors.
- Return type
float
- raw_material_aggregate(product=None)[source]¶
Current raw materials for
productthat are in raw-material inventory at the node. Read only.Raw materials are counted using the “units” of the node (or node-product pair) itself. That is, each raw material quantity is divided by the number of units of the raw material required to make one unit of product
productat this node, according to the bill of materials; and then the sum of those quantities is divided by the total number of raw materials required for this node (or node-product pair).For example, if the bill of materials specifies that to make one unit at the node requires 2 units from predecessor node A and 6 units from predecessor node B, and if there are 10 node-A units and 18 node-B units in raw material inventory at the node, then
raw_material_aggregateequals\[\]frac{frac{10}{2} + frac{18}{6}}{2} = 4
If the node is single-product, either set
productto the single product, or toNoneand the function will determine the product automatically.If the node has multiple products that use the same raw material, this function includes all units of that raw material, even though some of them may wind up being used to make products other than
product.Changed in version 1.0: This was previously a property and is now a function.
- Parameters
product (
SupplyChainProductor int, optional) – The product (as aSupplyChainProductobject or index), orNoneto set the product automatically if node is single-product.- Returns
The current raw material inventory.
- Return type
float
- inbound_disrupted_items_aggregate(product=None)[source]¶
Current total inbound disrupted inventory of raw materials for
product. Read only.Inbound items are counted using the “units” of the node (or node-product pair) itself. That is, each inbound quantity is divided by the number of units of the inbound item required to make one unit of
productat this node, according to the bill of materials; and then the sum of those quantities is divided by the total number of raw materials required for this node (or node-product pair).For example, if the bill of materials specifies that to make one unit at the node requires 2 units from predecessor node A and 6 units from predecessor node B, and if there are 10 inbound disrupted units from A and 18 from B, then
inbound_disrupted_items_aggregateequals\[\]frac{frac{10}{2} + frac{18}{6}}{2} = 4
If the node is single-product, either set
productto the single product, or toNoneand the function will determine the product automatically.If the node has multiple products that use the same raw material, this function includes all disrupted units of that raw material, even though some of them may wind up being used to make products other than
product.Changed in version 1.0: This was previously a property and is now a function.
- Parameters
product (
SupplyChainProductor int, optional) – The product (as aSupplyChainProductobject or index), orNoneto set the product automatically if node is single-product.- Returns
The current disrupted inventory from predecessors.
- Return type
float
- inventory_position(product=None, exclude_earmarked_units=False)[source]¶
Current (local) inventory position at node for
product. Equals inventory level plus pipeline inventory. (Pipeline inventory equals on-order inventory of the raw material, raw material inventory that has not yet been processed, and inbound disrupted items of the raw material due to type-RP disruptions). Inventory position is expressed in the units of the product (not the raw materials).If the product uses multiple raw materials, the pipeline inventory is the maximum number of units of the product that can be produced, given the quantities of raw materials in the pipeline. For example, suppose product A requires 10 units of product B and 5 units of product C; there are 4 units of product A on hand; and there are 20 units of product B and 15 units of product C in the pipeline. The the inventory level is 4, and the pipeline inventory contains enough raw materials to make 2 units of product A. So, the inventory position is 6.
If
exclude_earmarked_unitsisTrue, raw materials that are already “earmarked” for a different product at this node are excluded from the pipeline inventory. In particular, the pipeline of a given raw material is reduced by the sum, over all _other_ products at the node, of the number of units of that product that are pending times the NBOM for that product/raw material.If the node is single-product, either set
productto the single product, or toNoneand the function will determine the product automatically. If the node is multi-product,productmust be set to a single product at the node.If the node has multiple products that use the same raw material, the inventory position returned by this function includes all units of that raw material, even though some of them may wind up being used to make products other than
product.- Parameters
product (
SupplyChainProductor int, optional) – The product (as aSupplyChainProductobject or index), orNoneto set the product automatically if node is single-product.- Returns
The inventory position.
- Return type
float
- property echelon_on_hand_inventory¶
Current echelon on-hand inventory at node. Equals on-hand inventory at node and at or in transit to all of its downstream nodes. If node is single-product, returns the echelon on-hand inventory as a singleton. If node is multi-product, returns dict whose keys are product indices and whose values are the corresponding echelon on-hand inventory levels. Read only.
- property echelon_inventory_level¶
Current echelon inventory level at node. Equals echelon on-hand inventory minus backorders at terminal node(s) downstream from node. If node is single-product, returns the echelon inventory level as a singleton. If node is multi-product, returns dict whose keys are product indices and whose values are the corresponding echelon inventory levels. Read only.
- echelon_inventory_position(product=None, predecessor=None, raw_material=None)[source]¶
Current echelon inventory position at node for product with index
product. Equals echelon inventory level plus on order items.On-order includes raw material inventory that has not yet been processed, as well as inbound disrupted items due to type-RP disruptions.
If the node is single-product, either set
productto the single product, or toNoneand the function will determine the product automatically. If the node is multi-product,productmust be set to a single product at the node.If the node has a single predecessor, which provides a single raw material, either set
predecessorandraw_materialto the appropriate indicies, or set them toNoneand the function will determine them automatically. If the node has multiple predecessors and/or raw materials, either setpredecessorandraw_materialto the indices of a single predecessor and raw material (to get the raw-material-specific inventory position) or set both toNoneto use the aggregate on-order and raw material inventory for all predecessors and raw materials (counting such items using the “units” of the node itself; see documentation foron_order()for more details).predecessorandraw_materialmust both either beNoneor notNone.If the node has multiple products that use the same raw material, this function includes all units of that raw material, even though some of them may wind up being used to make products other than
product.- Parameters
product (
SupplyChainProductor int, optional) – The product (asSupplyChainProductobject or index), orNoneto set the product automatically if node is single-product.predecessor (
SupplyChainNodeor int, optional) – Predecessor (asSupplyChainNodeobject or index) to consider in inventory position calculation (including all others), orNoneto include all predecessors.raw_material (
SupplyChainProductor int, optional) – Raw material (asSupplyChainProductor index) to consider in inventory position calculation (excluding all others), orNoneto include all raw materials.
- Returns
The echelon inventory position.
- Return type
float
- Raises
ValueError – If
predecessor is Noneandraw_material is not None, or vice-versa.
- to_dict()[source]¶
Convert the
NodeStateVarsobject to a dict. List and dict attributes are deep-copied so changes to the original object do not get propagated to the dict. Thenodeattribute 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
NodeStateVarsobject with attributes copied from the values inthe_dict. List and dict attributes are deep-copied so changes to the original dict do not get propagated to the object.The
nodeattribute 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.- Parameters
the_dict (dict) – Dict representation of a
NodeStateVars, typically created usingto_dict().- Returns
The object converted from the dict.
- Return type
- reindex_state_variables(old_to_new_dict, old_to_new_prod_dict)[source]¶
Change indices of node-based state variable dict keys using
old_to_new_dictand indices of product-based state variable dict keys usingold_to_new_prod_dict.- Parameters
old_to_new_dict (dict) – Dict in which keys are old node indices and values are new node indices.
old_to_new_prod_dict (dict) – Dict in which keys are old product indices and values are new product indices.
- deep_equal_to(other, rel_tol=1e-08)[source]¶
Check whether object “deeply equals”
other, i.e., if all attributes are equal, including attributes that are lists or dicts.Note the following caveats:
Checks the equality of
node.indexbut not the entirenodeobject.
- Parameters
other (
NodeStateVars) – The state variables to compare this one to.rel_tol (float, optional) – Relative tolerance to use when comparing equality of float attributes.
- Returns
Trueif the two state variables objects are equal,Falseotherwise.- Return type
bool