Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make lead times specific to raw material and upstream node, not finished product and downstream node #149

Open
LarrySnyder opened this issue May 10, 2024 · 2 comments
Assignees
Labels
coming soon Plan to do this in a not-too-distant release enhancement New feature or request

Comments

@LarrySnyder
Copy link
Owner

LarrySnyder commented May 10, 2024

See implications, e.g., at

for prod_index in self.node.product_indices:
if rm_index in self.node.raw_materials_by_product(product=prod_index, return_indices=True, network_BOM=True) and \
p_index in self.node.raw_material_suppliers_by_raw_material(raw_material=rm_index, return_indices=True, network_BOM=True):
# Get lead times for this product. # TODO: shouldn't inbound shipment pipeline only use shipment LT, not order LT?
order_lead_time = (self.node.get_attribute('order_lead_time', product=prod_index) or 0)
shipment_lead_time = (self.node.get_attribute('shipment_lead_time', product=prod_index) or 0)
self.inbound_shipment_pipeline[p_index][rm_index] = [0] * (order_lead_time + shipment_lead_time + 1)

# Get lead times and product index (for convenience).
# TODO: LTs should live with the RM, not the FG. Otherwise, different RMs can't have different LTs. (But this doesn't mean interpret LT as applying to the outbound link instead of the inbound.)
order_lead_time = node.get_attribute('order_lead_time', prod) or 0
shipment_lead_time = node.get_attribute('shipment_lead_time', prod) or 0

# TODO: fix this
prod = node.products_by_raw_material(rm_index)[0]
OLT = node.get_attribute('order_lead_time', prod) or 0
SLT = node.get_attribute('shipment_lead_time', prod) or 0

stockpyl/src/stockpyl/sim.py

Lines 1079 to 1086 in 26792d6

# Find a product at successor node that uses prod_index from node as a raw material,
# and use its lead time. If there is more than one such product, use the last one found.
# This is a little klugey. # TODO: improve? should LTs be an attribute of the RM, not the product?
for FG_index in s.product_indices:
if prod_index in s.raw_materials_by_product(product=FG_index, return_indices=True, network_BOM=True) and \
node.index in s.raw_material_suppliers_by_raw_material(raw_material=prod_index, return_indices=True, network_BOM=True):
# Get lead time for this product.
shipment_lead_time = (s.get_attribute('shipment_lead_time', product=FG_index) or 0)

Note: This doesn't mean we should interpret the LT as applying to the outbound link instead of the inbound link.

@LarrySnyder LarrySnyder added enhancement New feature or request coming soon Plan to do this in a not-too-distant release labels May 10, 2024
@LarrySnyder LarrySnyder self-assigned this May 10, 2024
@LarrySnyder
Copy link
Owner Author

Related: shouldn't inbound shipment pipeline only use shipment LT, not order LT? (see line 180 above)

@LarrySnyder LarrySnyder changed the title Make lead times an attribute of raw material and upstream node, not finished product and downstream node Make lead times specific to raw material and upstream node, not finished product and downstream node May 10, 2024
@LarrySnyder
Copy link
Owner Author

self.inbound_order_pipeline[s_index] = {}
for prod_index in self.node.product_indices:
# Does s order prod_index from node?
if prod_index in s.raw_materials_by_product(product='all', return_indices=True, network_BOM=True) \
and node.index in s.raw_material_suppliers_by_raw_material(raw_material=prod_index, return_indices=True, network_BOM=True):
# Find a product at s that orders this raw material at node, to get its order_lead_time.
downstream_prod_index = s.products_by_raw_material(prod_index)[0]
order_lead_time = s.get_attribute('order_lead_time', product=downstream_prod_index) or 0
else:
order_lead_time = 0
self.inbound_order_pipeline[s_index][prod_index] = [0] * (order_lead_time + 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coming soon Plan to do this in a not-too-distant release enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant