Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

So I have a interesting optimization problem I need to do for work.. I'm going to use a stupid analogy to get rid of all the jargon ( its in chemicals manufacturing). Basically I just need some help getting in the right direction of what kind of operations or program I need to write.. I realize this description is not very clear now, but I will update it with code once I have a good idea of where to start

Basically heres the set-up: I have a massive ice-cream store that has X number of ice cream machines (think soft serve) and each machine has Y number of nozzles ( flavors). I need to solve for the minimum number of nozzles possible to meet the days demand. Each machine has a capacity Z, so you cant just put one nozzle for each flavor needed all on one machine because the machine couldnt meet the demand..

Right now things are setup inefficiently (ie., two chocolate nozzles are in use when the capacity on one machine is enough to handle all the choclate flavor on most days. The analysis process is to look at the data for the past six months and show what the setup was on a given day and also show what an optimal solution would have been for that day. This means I have the volume used per nozzle-flavor-machine combination.

At minimum if you have any demand for a flavor it needs to have at least one nozzle, and only the same flavor nozzles can be consolidated as long as the capacity of the machine allows for it on that day.? What is the right programatic technique to solve for the mininmum number of nozzles needed per day? Do I need to do a machine learning optimization technique or can I use min and max functions and HoHoA and for loops to accomplish this effectively?

. Any ideas, modules recs, or links greatly appreciated... I just need to know how to describe this 'class' of problem so I can read up and teach myself how to do it! thanks so much !!

Replies are listed 'Best First'.
Re: Tricky chemicals optimization problem
by MidLifeXis (Monsignor) on Jan 09, 2017 at 23:51 UTC

    This seems to me to be an application of the knapsack or bin-packing problem. Take your needed capacity for each flavor (divided into pieces of max size Z), and distribute among your machines.

    This assumes that there is no cost for having multiple nozzles on a single machine (the machine needs to be scrubbed down to avoid cross contamination between the Peanut Butter Chunk and the Allergen-Free Vanilla flavors, for example ;-b ).

    This may also not be an optimal solution, but, except in obnoxious cases, should get a pretty decent result.

    --MidLifeXis

      This is incredibly helpful thanks so much for answering. I read up on these problems you listed and they are exactly the right area I need to look at. For my issue, the goal actually is to reduce to the fewest nozzles possible. This is because when you have mutiple nozzles on a machine everytime one nozzle runs the others have to run which wastes a lot of money... thats just how the system works ( if we leave the ice cream anaology behind). Given that each flavor ( or chemical) must have its own nozzle, how would I incorporate this extra dimension?

      As a follow on...are there any modules or existing perl help to get me get this coded?
        ... are there any modules ... to ... get this coded?

        Once you (and through you, we) can clearly understand and define what "this" is, I imagine there are many modules that might be helpful. But a clear definition of the problem is the essential first step.


        Give a man a fish:  <%-{-{-{-<

Re: Tricky chemicals optimization problem (operations research)
by LanX (Saint) on Jan 09, 2017 at 23:49 UTC
    I didn't understand your problem completely.

    What's the cost function which needs to be optimized?

    Basically you have to qualify which kind of mathematical optimization problem you have.°

    Finding the best load for a restricted number of machines is a classical school book problem.

    > Any ideas, modules recs, or links greatly appreciated...

    As a starter see Discrete_optimization

    Probably you are already done with Linear programming and Simplex_algorithm

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

    °) best with equations

Re: Tricky chemicals optimization problem
by BrowserUk (Patriarch) on Jan 09, 2017 at 23:58 UTC
    and only the same flavor nozzles can be consolidated as long as the capacity of the machine allows for it on that day

    Can you explain that further?

    • One interpretation is that one machine -- regardless of the number of nozzles it has -- can only supply one flavour.
    • Another interpretation of that, taken in conjunction with other bits of your post, is that a single machine with multiple nozzles can serve multiple flavours.

    I can't decide which interpretation is correct?

    This means I have the volume used per nozzle-flavor-machine combination.

    I realise you've said this is an analogy, but can you adapt some of your real-world chemicals data to that analogy and give us something to play with? It doesn't need to be (shouldn't be) a huge volume of data; the key is that you should be able to also supply your desired output. That means you need to show a set of input data, and a corresponding, good (even if not optimal), set of outputs.

    On first blush this sounds like a variation on the Knapsack problem which is NP-hard, but many variations of that can be "solved" economically given sufficient domain-specific knowledge and insights.

    In essence, I'm saying tell us more about the problem, and give us something real to work on and test our solutions against.


    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.
      Your second interpretation is the correct one. When these machines are setup they are setup with pump lines... each line can only provide one chemical, so its optimial to get as much volume of that chemical out of that particualr line. What happens in many factories is they have two or more machines setup with a line to run chemical X because some days the volume required for chemical X is high enough to justify them all. In reality though this is very rarely the case, and proving that via an optimial solution of their previous 6 months data is the point of the exercise.

      When you have mutiple machines setup with a line(nozzle) to run chemical X but you are not using them it is very costly, so again the idea would be to reduce the number of total lines by collapsing or consolidating all the lines for chemical X(,Y,Z,..n) respectively when there is volume enough available to cover demand on a fewer numebr of nozzles. You cannot colapse Y onto Z..so if we think of the backpack problem, you have 5 colors of weights and the weights can only be consolidated like legos (idk)with their own color.

      Lets say chemical X is run on 5 machines, and on Tuesday you need 100 units of chemical X. The capacity for each machine is 50units per day, thus you would want to use 2 nozzles optimized rather than 4. If the capacity were 100, then the ideal answer would be to have only one nozzle-machine running chemical X, thus when you need X the other machines stay off and you only need that one machine to be on

      I'm totally aware that my description (and understanding) is quite limmited and this is not helpful ( I'm really over my head here with a deadline otherwise Id buy a textbook and learn it the proper way). I very much appreciate you guys helping me anyways it has already been HUGELY helpful.

      As far as data goes, I cannot provide the real data but will do my best to mock up a dummmy dataset that represents similar idea and post ASAP

      Thanks again for bearing with me!

        I read and re-read your further description, but I cannot make any sense of it.

        As far as data goes, I cannot provide the real data but will do my best to mock up a dummmy dataset that represents similar idea and post ASAP

        You wouldn't need to identify exactly what the data represented, so it would be useless to a competitor.

        The problem with "mocked up" data is that unless the mocking up is done with an good understanding of the problem -- which you've identified you do not yet have -- it usually misses the subtleties of the real problem; and you end up wasting time solving the wrong problem.

        The purpose of asking for data and required output was to allow us to perhaps help you arrive at your understanding of the problem by getting many brains looking at the problem.

        One thing that I've learnt over the years -- probably above all other hard won lessons -- is that until you understand the problem you are trying to solve to the level you can adequately explain it to others, you stand very little chance of finding a good solution.

        At this point, on the basis of the information so far, I personally have literally no idea where to start, nor even what questions to ask.


        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.