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

Incorrect RM to FG conversion during simulation #175

Open
ziegeo opened this issue Oct 9, 2024 · 1 comment
Open

Incorrect RM to FG conversion during simulation #175

ziegeo opened this issue Oct 9, 2024 · 1 comment

Comments

@ziegeo
Copy link

ziegeo commented Oct 9, 2024

In the simulation module, the function raw_materials_to_finished_goods(node) uses the following line to determine the total order placed for a raw material LT periods ago:
units_ordered = sum([node.state_vars[period - OLT - SLT].order_quantity[pred_index][rm_index] for pred_index in node.raw_material_suppliers_by_raw_material(rm_index, return_indices=True, network_BOM=True)])

A few lines later, the variable units_ordered is used to determine share_frac, the fraction of available RM that can be allocated to a specific FG:
share_frac = {prod_index: node.state_vars[period - OLT - SLT].order_quantity_fg[prod_index] * node.NBOM(product=prod_index, predecessor=None, raw_material=rm_index) / units_ordered for prod_index in prods_for_rm}

The variable share_frac is then used to calculate the share of available RM that can be converted to a specific FG:
share[rm_index] = {prod_index: avail_rm * share_frac[prod_index] for prod_index in prods_for_rm}

This can lead to a larger quantity of FG being produced than there is available RM.

I have not looked at the root cause for this in too much detail, but my initial thought is that this is caused when there is a order_quantity_override passed to the function _generate_downstream_orders. It looks to me like the function applies that override to the number of ordered RM, but not to the number of ordered FG, which in turn can lead to the incorrect ratio mentioned above.

@LarrySnyder
Copy link
Owner

@ziegeo Can you share a code snippet that reproduces this bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants