in reply to Re^12: Tricky chemicals optimization problem
in thread Tricky chemicals optimization problem
Hey UK, Is there any chance you can suggest which parts of the code I need to focus on to accomplish the change to minimizing nozzles before minimizing number of machines? Even if it's simpler to minimize nozzles and not worry about machines I can probably take it further from that point - I'm a bit stuck at the moment
thanks again for the help /thoughts
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^14: Tricky chemicals optimization problem
by BrowserUk (Patriarch) on Jan 16, 2017 at 03:13 UTC | |
which parts of the code I need to focus on to accomplish the change to minimizing nozzles before minimizing number of machines? Well, the minimum number of nozzles is simply the number of chemicals; plus that number required to ensure that no single nozzle is delivering more than your machine limit. This code, simply reads your sample data, discards any 'zero flows' and accumulates all flows for each chemical.
But now, some of the machines (eg.those running C057 & C039) are grossly under-utilised and those chemicals need to be combined into fewer machines. The simplest approach to that is a variation of the greedy knapsack algorithm which I will call (because I haven't seen it described anywhere) and the max-min algorithm. Basically you order the nozzles largest to smallest. You look at the largest and then track backward from the smallest until you find the largest (single chemical) nozzle that can be combined with that largest nozzle without breaking the machine limit. Combine them into a single machine and remove the small one from them from consideration. Rinse and repeat. When the smallest left is too big to be combined, remove the current largest from consideration also. Rinse and repeat until no nozzles are left. This isn't guaranteed to produce the absolute optimal solution in terms of minimizing the number of machines, but it will always produce the minimum number of nozzles and very close to the minimal number of machines. I don't have code for this approach this evening, but I'll try to post some tomorrow. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
by Anonymous Monk on Jan 16, 2017 at 05:26 UTC | |
| [reply] |
by BrowserUk (Patriarch) on Jan 16, 2017 at 21:56 UTC | |
You'll probably have questions, but rather than me trying to guess what they are and answering all the wrong ones, I'll just post the code and then answer any you ask: <Reveal this spoiler or all in this thread>
Output:
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |