You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is the correct code for the error I reported - sorry for the confusion! The change is in the line:
products[10].set_bill_of_materials(rm_index=20, num_needed=3) ---> products[10].set_bill_of_materials(raw_material=20, num_needed=3)
@bruskey47 The problem is that you are setting products[20].inventory_policy twice, and the second assignment overwrites the first assignment. So when it finds the order quantity at node 2 it gets confused because the inventory policy at node 2 thinks it lives at node 3 because of the node=nodes[3] argument.
When a node has 2 or more predecessors with the same upstream product, running the simulation results in an error.
For example, in an network defined by:
network = network_from_edges(
edges=[(2, 1), (3, 1)],
node_order_in_lists=[1, 2, 3],
local_holding_cost=[2,4,2],
stockout_cost=[50, 25, 25],
demand_type='UD', # discrete uniform distribution, for easier debugging
lo=1,
hi=5,
shipment_lead_time=[1, 1, 0]
)
nodes = {n.index: n for n in network.nodes}
products = {10: SupplyChainProduct(index=10), 20: SupplyChainProduct(index=20)}
products[10].set_bill_of_materials(rm_index=20, num_needed=3)
nodes[1].add_product(products[10])
nodes[2].add_product(products[20])
nodes[3].add_product(products[20])
products[10].inventory_policy = Policy(type='BS', base_stock_level=10, node=nodes[1], product=products[10])
products[20].inventory_policy = Policy(type='BS', base_stock_level=12, node=nodes[2], product=products[20])
products[20].inventory_policy = Policy(type='BS', base_stock_level=22, node=nodes[3], product=products[20])
I get the error... :
Traceback (most recent call last):
File ..., line 157, in
total_cost = simulation(network, 100, rand_seed=17)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ..., line 115, in simulation
step(network=network, consistency_checks=consistency_checks)
File ..., line 253, in step
_generate_downstream_orders(n.index, network, t, visited, order_quantity_override=order_quantity_override)
File ..., line 431, in _generate_downstream_orders
rm_OQ = order_quantity_dict[p_index][rm_index]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: -5
The text was updated successfully, but these errors were encountered: