in reply to Re^11: Tricky chemicals optimization problem
in thread Tricky chemicals optimization problem
I can answer these two questions tonight, the others will have to wait until Friday.
Which array is this in the code you provided?
If you look at the second block of output (100,000 nearest to your 85,000 machine limit) in Re^6: Tricky chemicals optimization problem, and I reformat the first line for machine E001 thus:
E001 => { " total" => 99982.9104, C015 => [24504.1632, 14837.91, 13323.6396, 12250.6656, 6234.5772, +5720.64, 5255.838, 4380.3252, 3468.138, 2386.0308, 1716.192, 1501.668 +, 1436.2488, 1430.16, 791.19, 703.4688], C064 => [42.0552] },
You can see that although the machine has 17 flows from the original dataset, they are made up of just two chemicals. So, by your latest description, that machine only requires two nozzles.
I hear what you are saying but I'm failing to see what the gap might be if we made minimizing the lines higher precedence... I.e., is the fact that your code is doing a good job of minimizing the nozzles a side effect of the operation , or are you purposefully designing it to do that -if so can you point out the line that provides that effect?
The fact that the loops of code attempt to fill each machine from flows of Cnnn first (largest first due to the sorting), and only switches to other chemicals when there are either no flows for this chemical left; or there are no flows of the current chemical that will fit in the remaining space, means that the very act of attempting to use the minimal number of machines will also ensure that each chemical is spread to as few machines as possible (within the limitations of the greedy algorithm).
The upshot of that is that is all the flows of particular chemical on any given machine can be combined into one nozzle; and thus minimizing the number of machines also tends to minimize the number of nozzles. (Again, within the limitations of the greedy algorithm.
Those greedy algorithm limitations mean that it may be possible to reduce the nozzle count a little by juggling the smaller components around; but it will only be a very small percentage.
If that was actually necessary; then you move into the realms of either:
Try swapping a few things around in a few random combinations and then discard the some of the least good ones. Rinse and repeat until either no further improvement has been seen for some number of iterations; or until some time limit is reached.
This method is guaranteed to find the absolute optimum solution. Eventually! But even for the relatively small number of thing you are dealing with, it is apt to take many days or even weeks to run.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^13: Tricky chemicals optimization problem
by Anonymous Monk on Jan 16, 2017 at 01:55 UTC | |
by BrowserUk (Patriarch) on Jan 16, 2017 at 03:13 UTC | |
by Anonymous Monk on Jan 16, 2017 at 05:26 UTC | |
by BrowserUk (Patriarch) on Jan 16, 2017 at 21:56 UTC |