Skip to content

Conversation

@scottmsul
Copy link
Contributor

@scottmsul scottmsul commented Jul 23, 2025

Oftentimes when using the matrix solver, the factory can enter a linearly dependent state. This happens when certain columns are mathematically redundant.

Columns in the matrix solver can represent recipes that solve to a building count for a given line, or items that solve to a factory's net input or output. When a factory becomes linearly dependent, typically only a small subset of columns are part of this linear dependent group. The UI can be designed to show these problematic recipes or items to the user so they can be informed of how to resolve it.

A common workflow when using the matrix solver is to eliminate the number of net ingredients or byproducts to help balance the factory. Examples might include oil cracking to remove heavy or light oil byproducts, kovarex to eliminate both U-235 and U-238, or voiding in certain mods.

If a recipe is added to eliminate a previously selected unrestricted item, technically this always results in linear dependence. To resolve this, the current logic is to always wipe the unrestricted items and request the user to re-select them, as this preserves the recipe (which the user usually wants) and removes the problematic unrestricted item. However, this is overkill since it forgets all of the user's other choices from previously selected unrestricted items. For vanilla or small factories this isn't too big of a deal, but has received complaints from users playing larger mods with complex setups such as Pyanodons.

The new logic requests the user to resolve issues in the following order:

  1. Unselect any linearly dependent unrestricted items
  2. Remove any linearly dependent recipes
  3. Select any required unrestricted items

For the first option, when a recipe results in only one possible item, the code will automatically select it. For simple setups like cracking or kovarex mentioned above, the workflow should be identical to before. When two or more choices are possible, it uses the bottom of the production box for this selection.

One way to test the new UI functionality is with the following factory:

  • Output plastic, solid fuel, and lubricant (I used 100 for each)
  • Add three recipes to produce these, in order to cause petroleum, light oil, and heavy oil to become ingredients
  • Add advanced oil processing with light oil and heavy oil as unrestricted items (petroleum will then be eliminated)
  • Add heavy oil cracking -> this will force a decision to remove either heavy oil or light oil from the unrestricted items!

Note I only added the english versions for these captions which would need translations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant