Zistack / Satisfactory-Optimizer

A simple python script that uses scipy.optimize.linprog to calculate and optimize factory plans for Satisfactory with respect to a highly configurable set of constraints.
6 stars 2 forks source link

Well pressurizes share (and duplicate) outputs #2

Closed MeesterDev closed 2 months ago

MeesterDev commented 2 months ago

Hi, great job at implementing the changes for 1.0 so quickly!

I ran the 'the big cheese' example and noticed all well pressurizers get the same output, which is the total of all of them (for each of them).

Excerpt from the output:

        "Pressurize Crude Oil Crude Oil Well 2 Impure 2 Normal 1 Pure": {
            "machine_count": "1.00000000",
            "power_consumption": "503.66213122",
            "overclock_setting": "2.500000",
            "outputs": {
                "Crude Oil": "2550.00000000"
            }
        },
        "Pressurize Crude Oil Crude Oil Well 3 Normal 3 Pure": {
            "machine_count": "1.00000000",
            "power_consumption": "503.66213122",
            "overclock_setting": "2.500000",
            "outputs": {
                "Crude Oil": "2550.00000000"
            }
        },
        "Pressurize Crude Oil Crude Oil Well 6 Impure": {
            "machine_count": "1.00000000",
            "power_consumption": "503.66213122",
            "overclock_setting": "2.500000",
            "outputs": {
                "Crude Oil": "2550.00000000"
            }
        },

I believe the output should be (assuming full extraction):

        "Pressurize Crude Oil Crude Oil Well 2 Impure 2 Normal 1 Pure": {
            "machine_count": "1.00000000",
            "power_consumption": "503.66213122",
            "overclock_setting": "2.500000",
            "outputs": {
                "Crude Oil": "750.00000000"
            }
        },
        "Pressurize Crude Oil Crude Oil Well 3 Normal 3 Pure": {
            "machine_count": "1.00000000",
            "power_consumption": "503.66213122",
            "overclock_setting": "2.500000",
            "outputs": {
                "Crude Oil": "1350.00000000"
            }
        },
        "Pressurize Crude Oil Crude Oil Well 6 Impure": {
            "machine_count": "1.00000000",
            "power_consumption": "503.66213122",
            "overclock_setting": "2.500000",
            "outputs": {
                "Crude Oil": "450.00000000"
            }
        },

I'm executing python .\satisfactory-optimizer.py .\examples\the_big_cheese.json --precision=8 > output.json with Python 3.12.5 on Windows 10.

If I were more skilled at Python I might have had a PR for you, but alas, I'm no good :')

Zistack commented 2 months ago

Good catch. It took me a hot minute to figure out what was going wrong - turns out it was a python-ism that I had forgotten about. I was "copying" a dictionary when specializing well recipes for each configuration, but I wasn't actually copying it, just aliasing it. Every time I specialized with a new well configuration, I was adding the satellite outputs to this single dictionary that was getting shared with every specialization of the recipe.

Adding . copy () to the end of that line fixes the problem. Fixed in commit d1e8eb46f01adbddb583a2cd7bfb261201c68833.

MeesterDev commented 1 month ago

Nice job, thanks for the quick fix!