FactoryPlanner icon indicating copy to clipboard operation
FactoryPlanner copied to clipboard

Negative power usage and items that do not sum to 0

Open matjojo opened this issue 1 year ago • 7 comments

Problem Description

I have a calculation in SeaBlock that made the matrix solver return one recipe that is used a negative amount of times, and one item that is created 1.6 times per second, consumed 1.5, but is not in the byproducts list.

Is there some way to fix this? Can I tell the solver the try another solution somehow? If not, does the order of the recipes influence the solver in some way? Maybe I can finesse the solver into giving a good result like that.

I have included an image, the subfactory string, and the save below.

image

subfactory string
eNrtW+tv2zYQ/1cCf448vR8F9qVZuw1rhqzpt6IwaImyuVKiRlJJ3CD/+44POZLiYEHtOk7mBEig4/F4vPvdHR/S7aRixewKc0FYPXkz8abeNPEnpxN80zAuZ9AqsJy8uZ3MkcCWIc2AYY6pdK6IaBEl3zDXTf7Uc1UTm5NaYC5BbCfTkCmZc8RXlhgD8RdG6sWnJfwRb1e/obqwgpQO724aygS5wifvbnJ0heS9jik0l4g7HKN8aWmqSwkjwKM79fyp0vL9n+9+18/h1IPHJaYwo47BUxx/XM4u2LWegDuNNNdfLW7xJ/aes1r++avhTqcBtEh8IxuKJBaaGq/ni2tcESx6E1PEf1rSVLiWQzLjA8YS5ZLxFYita2tH64NzQrGQrLbswdRXo32E4c8QzVvQgyl+oGvlQPRat95wEq8tZClICFzN6WqkLcW5hCmTfCSAsgUR8gG5IjV4bUhrrCV7Luf4ClXNkO0acXAe7hEvc4LrHJ8xIT9dY/QV83Pb2lkY/NbSwdxQvcBUcFx2iminhkpag3J8zopOxJq5wTDDfIkrzZ1NfcX9AVBXEkovEKllJynScDK9UFGwWjjgCo4WWDe7Ri/TLiqIha5jPPXVeODjrxAEzj3iAW/TaN1nTlgDqmAhuo6J0eaM8Lwl8mLYGOqunVAwh+hJvMToLWX51w7CQY/VjGaZ415DzqoGImpOKJGdellP2DmW6AJpocqG4eTudCLauUGrhvrn20mNKmWPz6Ra/Ewkrn4SEmPqaBh+OblUDyf64aTkrDoRtC3AgBBHpMIiRxQ6e6eTmhnQK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v6xg5JrIDraydd7aurY47dbPBTxolaeaFkZ+GSZZkWeynfpQkkQdVNg2DZH+ltb8xsuu/BvJ2CZ7efgWYs1q01Q8Fp35RaRMkzVwkx0jq9ySPwNyw6JvGw0Wfm6apl6ShlyWwAvQjP/CDIM3cKAjCMPHjKH7iqu/Rjbg9HCDf8G5WBYG/nT4G7DtSxvP8vQWu3autarnEgohjFTnMYP0RKPPT4V4NqojvJW4WBm4Iv24SBlBFQojhxN3rPq17M5MhevCFw76p3nv/0fHG1xGofMm3yo9JfaaV6lN8av14TDLPtSLY4xaof+e6uyPtPWSO45H2Fnvs6XAflAWhl0ZpFgdRlkLF8j0vCwJPPcWBn+6zeNncYQr2FYOst2nFetjQBMF8AzQfTO1/XdLGRUL7uv/Riy53Wx/67bHeleB29dGJ+qZqk+MHU311vn/0KyebNLzea6X6U5+eoMvus7MVJJG7fwE6bPwg
[Seablock.zip](https://github.com/ClaudeMetz/FactoryPlanner/files/12540775/Seablock.zip)

Reproduction

No response

matjojo avatar Sep 06 '23 17:09 matjojo

Just hit this as well. Playing on latest (1.1.100) with Bob's Mods. This works:

Screenshot_2024-01-01-14-39-46

But when you allow not only heavy but also light oil cracking, suddenly the thing produces water, which sounds a little bit weird:

Screenshot_2024-01-01-14-42-37

I can send you my save in case it helps with debugging, just ask :)

Btw, happy new year :fireworks:

msrd0 avatar Jan 01 '24 13:01 msrd0

Simple Example

All the examples I've seen of this are overly complicated, so I'm providing the simplest possible example to maybe help in finding a solution:

brine-example

This example uses the following three recipes from the Nullius mod:

  • soda ash, which consumes brine and produces hydrogen chloride as a byproduct
  • hydrogen chloride neutralization, which consumes hydrogen chloride to produce some of the needed brine
  • brine disposal, which dumps excess brine into the sea

Notice that the brine disposal recipe is silently being calculated as negative in the above image. The factory should list 23.4 brine fluid as a required ingredient. Disabling the top recipe avoids the problem, and requires an unconstrained variable, which should be required regardless, because you could use either brine or hydrogen chloride as an ingredient.

Hilariously Confusing Example

barrel-confusion

Barrel filling and emptying are basically the same thing, right? x)

Generic Version of the Problem

("ingredient" refers to the same ingredient throughout this description)

The problem arises when:

  1. x of ingredient creates some byproduct
  2. that byproduct creates y of ingredient
  3. some other recipe consumes ingredient, which gets calculated to be z of ingredient where z = y - x
  4. if y < x, then z gets calculated to be negative, which unfortunately isn't possible to build

Proposed Pseudo-Solutions

  • After the calculations are completed: detect which recipes are negative, automatically mark them disabled, and rerun the calculations (forcing the user to choose more unconstrained variables). This seems much better than leaving people confused or blindsided by broken calculations, but it might also be very annoying. Maybe make it a preference setting? "Automatically disable useless recipes in matrix mode"?
  • Make a negatively consumed ingredient automatically require an extra unconstrained variable that's either the ingredient or one of the products/byproducts that produces the ingredient. I think this will work, but implementation might be very complicated, and I haven't actually worked out all the math so don't take my word for it.

Good luck, hope this helped!

CorbinSteele avatar Jan 17 '24 21:01 CorbinSteele

Just hit this today, here's my example if it helps. image

All mods/basegame up to date.

amckinley avatar Mar 30 '24 18:03 amckinley

Vanilla recipes happens when prod is above 20% image

RedCMD avatar Jun 17 '24 04:06 RedCMD