Science switcher, selecting science with the best benefit-to-cost ratio

This board is to show, discuss and archive useful combinator- and logic-creations.
Smart triggering, counters and sensors, useful circuitry, switching as an art :), computers.
Please provide if possible always a blueprint of your creation.
Franky.
Burner Inserter
Burner Inserter
Posts: 12
Joined: Fri Dec 06, 2024 3:29 pm
Contact:

Science switcher, selecting science with the best benefit-to-cost ratio

Post by Franky. »

I present another combinator behemoth: My science switcher
20261002204257_1.jpg
20261002204257_1.jpg (1.91 MiB) Viewed 45 times
Design goals:
  • be maintainable in multiplayer
  • check for available science packs, e.g. don't research robot worker speed without electromagnetic science packs.
  • switch between technologies with agricultural science packs and without
  • research the technology with the best benefit-to-cost ratio. (see below for a much longer explanation)
    limited support for one-shot technologies. Those are better researched manually.
The interesting question is how to implement #2 without sacrificing the benefit-to-cost selection. There are two approaches:
  • use a priority system to prioritize technologies containing agricultural science
  • disable individual technologies when agricultural science is present
    The latter is a higher maintenance burden, but I chose it anyway: I saw no way to combine the priority with "research the technology with be best benefit-to-cost ratio."
Each technology is represented by a signal. I mostly chose the symbol that resembles the technology-icon most closely.

I checked a few science switchers after my call in reddit (TODO). I share the most common pattern: for every technology one decider combinator. Every decider combinator gets the same input: The available science packs. All outputs are combined and then the best technology is selected according to benefit-to-cost. (Internally, I express this as an effective cost per benefit; the calculation accounts for the current productivity level and the affected share of production.).

For every research signal, I also output its current level using the same signal with an uncommon quality. This way, you can limit you research to a fixed level or say "only research plastic if its level is at most the level of rocket fuel". A condition like the latter is mostly obsolete with the benefit-to-cost value.

How I calculate benefit-to-cost: amortization

When you have effectively infinite technologies to research, how should you decide which technology to research next?

I'm not asking which technologies you personally prioritize. I'm interested in a way to compare infinite research technologies quantitatively.

A simple approach would be to always research the cheapest available technology. But that ignores how much benefit you get from the research.

For example, Mining Productivity 40 costs about 38k science, but only increases the productivity multiplier from +400% to +410%. That's an increase from 5.0× to 5.1× — only a relative 2% more output.

So the relevant question isn't just:
"How much does this research cost?"
but rather:
"How much does it cost relative to the benefit it provides, and how long does that benefit take to pay back the research investment?"
The simple case: Mining Productivity 1

Mining Productivity 1 costs 250 science and increases mining output by 10%.

How much science do we have to spend before this research has effectively paid for itself?

Without the research, suppose we spend

Code: Select all

x
science on other research.

With Mining Productivity 1, we first spend 250 science on the productivity research, leaving

Code: Select all

x - 250
science for everything else. But because our resource production is 10% higher, we need only

Code: Select all

x / 1.1
science worth of resource production to support the same amount of research.

Equivalently:

Code: Select all

x = 250 + x / 1.1
which gives:

Code: Select all

x = 2750
So after 2750 total science, the 250 science investment in Mining Productivity 1 has paid for itself.

Stepping up: Mining Productivity 2

The interesting part is what happens when we're already at Mining Productivity 1.

Now the alternatives are:

Case 2.1: Don't research the next productivity level.

Code: Select all

x / 1.1
Case 2.2: Spend 500 science on the next productivity level, reaching 20% total productivity.

Code: Select all

500 / 1.1 + x / 1.2
At the break-even point:

Code: Select all

x / 1.1 = 500 / 1.1 + x / 1.2
which gives:

Code: Select all

x = 6000
So Mining Productivity 2 takes 6000 total science to amortize.

This is the important distinction: the relevant cost of an infinite technology is not simply its science cost. It is its cost relative to the incremental benefit, expressed as the amount of subsequent research required to recover that investment.

General amortization rule

For these productivity researches, the general break-even point is:

(current productivity level + 10) × research cost

For example:
  • Mining Productivity 41 costs 39,000 science → 1,950,000 science to amortize
  • Asteroid Productivity 11 costs 86,498 science → 1,729,960 science to amortize
On this metric, these two researches are surprisingly close, despite their very different research costs.

The same thing expressed as cost per percentage point

There is another way to look at exactly the same calculation.

Mining Productivity 41 costs 39,000 science and gives a 2% relative increase in output.

That's:

19,500 science per 1% additional output

Asteroid Productivity 11 costs 86,498 science for a 5% relative increase:

17,299.6 science per 1% additional output

So although Asteroid Productivity 11 costs more than twice as much science, its incremental benefit is also much larger.

This is the point I'm trying to make:
For infinite technologies, comparing research costs directly can be very misleading. You should compare the research cost with the incremental benefit, or equivalently look at the amortization/payback time.
One important caveat: how much production is affected?

The calculation above compares the technologies as if the affected production were equally important.

In an actual factory, that's not necessarily true.

If 90% of your resources come from mining and only 10% from asteroids, then a 1% improvement to mining has a much larger effect on your overall resource production than a 1% improvement to asteroid production.

To weigh this in, the costs are scaled via a further constant combinator containing the production-share weighting. I am scaling by dividing the cost, which also prevents an integer overflow in my most advanced game.

Example condition: Research Scrap recycling productivity if all labs have electromagnetic science and there is less than 1k agricultural science
20261002204440_1.jpg
20261002204440_1.jpg (1.36 MiB) Viewed 45 times
Example showing how to limit a research by level: Artillery range limited to level 8.
20261002204903_1.jpg
20261002204903_1.jpg (1.57 MiB) Viewed 45 times
Blueprint at:
https://factorio-blueprints.com/bluepri ... -selection
Post Reply

Return to “Combinator Creations”