Skip to content

Conversation

@ApocDev
Copy link

@ApocDev ApocDev commented Aug 4, 2025

This PR introduces the ability to set a consumption % on items.

image

Given the above, we want 40% of the bitumen to go to Residual mixture, and 60% to dirty syngas.

This PR introduces a new button on the production item dropdown to "Set consumption %"

image

Clicking this immediately sets that item to 50% consumption as shown here:

image

Note: Due to how yafc handles things in the solver, we need to forcefully enable overproduction for the linked item, to ensure the "remaining" product goes to the "extra products". (Eg; send 50% to residual mixture, but save/buffer the other 50% somewhere else)

If you can think of a better way to handle this specifically, let me know. Short of adding a lot of new solver parameters and states/types, I couldn't think of a better solution.

Adding consumption % to dirty syngas, we get this:

image

It now consumes 50% for each (currently have to manually remove the overproduction flag when a 2nd recipe is introduced)

And for 60/40:

image

@ApocDev ApocDev changed the title Feat/percentage based ingredient consumption feat/percentage based ingredient consumption Aug 4, 2025
@ApocDev ApocDev marked this pull request as ready for review August 4, 2025 16:47
@ApocDev ApocDev requested a review from shpaass as a code owner August 4, 2025 16:47
@DaleStan
Copy link
Collaborator

DaleStan commented Aug 4, 2025

It appears that setting "Allow overproduction" isn't sufficient:

image

The expected result was 150/s consumed by each row.

Page share string:

inR0c+YKKMrPSk0uCUhMT+Uy0jM00TPQM+Di4gIAAAD//91Uy27bMBD8luxZFuT4AUfHBjWQQ1C38KUoclhRK3lhilQpMolh6N+7ethxgABuc+yN++DM7A6lIyhrPBm/PdQEKfzEQsWPNicdy408KM/WbDHTBBGUgXPpwSktlsu76ep2Xswpo9UUb5eL2UzR3TKZLZV0sqBCaoLWERisOuQtNV4qIx2kR6DXGk1OAuldoAg0m30D6a8jlNbmcjqCR1eSNMNaC3ecsQ8VGYH5HVCzP0jl+3CKjXUVamgjwMqGjmEySxKJdGkd+10F6TSCppbmDTklGmQVg8b2KQJHimsa6IfzO/4ffeokYOKoYMOmvKJESPrSBdDXPhXn3HjW6K27AlEE0u8ANvaFXExazHSsumtXAPiV8i+BdS56Zb5kTK174AJ1Q2PmwZSOcu7dGazr0+M7OOUygfIXeEO22dmXrfWoH76dQcl07+Zsr+y7Z+czzb01Tajq7om9WdL7fvPO75txmjSJFzJRJXo0vVGHrHQ21Kf4GR2j8Z2VT230N26W2HDBCjshn3ZUOVR7cpNqn8w/5+mO0P+HZv6jY/ItntuPIlrrRzbkJBqVYPB2LekNHjJZ+bgErcnJf0vunWcjvPgLDdFHHY3IPa0A0lUE9pmc45zuHRZeakNXN0nbtn8A

When I've contemplated this feature, I've gotten stuck on what should happen when the user asks for 50% on recipe 1, 50% on recipe 2, and 50% on recipe 3.

if (!hasPercentageConstraint) {
// Show button to set percentage constraint
if (gui.BuildButton("Set consumption %") && gui.CloseDropdown()) {
recipe.RecordUndo().ingredientConsumptionPercentages[goods] = 0.5f; // Default to 50%
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on a little poking around, it appears that a non-zero recipe.fixedBuildings conflicts with percentage constraints. That seems reasonable, so recipe.fixedBuildings should be zeroed here, and the fixedBuildings setter should clear ingredientConsumptionPercentages when given a non-zero value. (Ideally, adding a value to ingredientConsumptionPercentages would zero fixedBuildings, but that will be complicated.)

I'm not sure what should happen with this sort of a table, but "could not solve" is probably not right.
image
Share string

inR0c+YKKMrPSk0uCUhMT+Uy0jM00TPQM+Di4gIAAAD//9WVTW/bMAyGf0t5dgyn+UDq44oF6KFYNuQyDD3QEu0IkSVPltoGgf/76I+kCVAga4YdepMo6uUrPpK9B2GNJ+PXu4oghZ+Yi/jRStIx75BBeGXNGjNNEEERlOQcHNNsPr8bL26n+ZQyWozxdj6bTATdzZPJXHCmYlVITdA6AoNlq7ym2vPKUA7SPdBrhUYSS3oXKAKtzLaG9NceCmslj/bg0RXEybDUXDvOlA8lGZb5HVArv+OV7/0oNtaVqKGJAEsb2gqjSZLwTBfWKb8pIR1HUFecvCIn2AO3ovfYPEXgSKiK+vL9+Kz+jy50MDBylCujTHHBCRfplk6EvnahWKraK43eugsSeSB9JrCyL+Ri0gzTKdFuuyCgXkl+CUpL9lt3TehCy044R13TEHkwhSOpOjo9ui483INDLGMpf6LXR+uNfVlbj/rh21GUTHtvjni535AyEHUsc29NHcqqvWJvSFrubLvkopre9ENWOBuqw/wZnULjW15PTfQ3yAqsVa4EttWuxiYcii25UblNpteB2xD6DxJLPgExuDl7oTfDadIknv0PmN6O6qDz4K4mGarCofwnlNe/wc9A9IPY+BN6TN+zaa0flSHHs8EJBm+XHF7hLuNHNDRBa3L8u+F9x7MRnvw8+tl7GTXbPbQA0kUE9pmcU5LuHeae1/qs9iRN0/wB

Copy link
Author

@ApocDev ApocDev Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to have it so that if you set a "fixed" building, only the remaining products can be split across the other two?

Eg;

30/s for residual (first priority, since it's fixed)
(N-30)*0.5 for Dirty syngas
(N-30)*0.5 for Sulfur

image

For example (which it already does)

@ApocDev
Copy link
Author

ApocDev commented Aug 4, 2025

It appears that setting "Allow overproduction" isn't sufficient:
The expected result was 150/s consumed by each row.

When I've contemplated this feature, I've gotten stuck on what should happen when the user asks for 50% on recipe 1, 50% on recipe 2, and 50% on recipe 3.

If you only add a single recipe as a %, then the expected behavior is actually 50% to residual mixture, and 50% to "extra products". Dirty syngas should have 0, as it doesn't take part in the % calculation.

Only once you set the other recipe to be a % consumption, does it take it into account. This is the only "good" behavior I could come up with that still allows you to have some "excess" for storage, and doesn't break the solver too badly.

That said, it should have calculated the values properly even with what you provided there. I'll check it.

Edit:

It looks like forced consumption has issues... which kind of makes sense.

The % calculation only takes into account those recipes set to have it. If only 1 is using a %, then "where does the other half go?" is a great question...

@ApocDev ApocDev changed the title feat/percentage based ingredient consumption feat: percentage based ingredient consumption Aug 4, 2025
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

Successfully merging this pull request may close these issues.

2 participants