x = (maximum possible) operations per day
y = units used per operation
z = units used per day (x * y)
u = units of resources available
4x * 1y = 4z
This results in you being unable to smelt / process resources, if z is higher than the amount of resources you have, despite you having enough for 1 operation, aka. the value of y
This could maybe be avoided if you do something like this:
At the end of the day, you check IF dividing u by y is <1. If yes, then don't process the resource, as a "full" operation cycle can't be performed.
If no, then round down the result r1 = upper limited of operation cycles based on remaining resources
Do the same with any secondary resources needed in producing a resource, like f.e. the transplutonics in the process of making supplies to deduce r2, r3, r4 etc.
Let's do a new calculation, with the following variables:
p = units produced per operation
f = free cargo / fuel space available (depending on the resulting product in question)
Check IF dividing f by p is <1. If yes, then don't process the resource, as a "full" operation cycle would result in the cargo / fuel going over the limit.
If no, then round down the result s = upper limit of operation cycles based on remaining space
Now check which is the smallest number between all of the r1, r2, r3 etc., the upper limit for operation cycles based on remaining space s and x. This will be called m (multiplier)
Multiply the resources needed for an operation cycle, each individually by m to get the total used and produced goods per day.
Of course that's one hell of a bother and I don't know if it would cause any lag or if it's even in your interest as the maker of this mod. As always, I really love your mods dude. Sorry if this was intrusive / rude.