• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Desperately Seeking Algorithm

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Desperately Seeking Algorithm

    I have the following problem to solve and believe that there is probably some standard optimisation algorithm that either meets or would bend to my needs.

    Assume that I have a piece of string of a given length. It must be cut into a number of pieces but each piece must fit within a certain length range. There can be more than one such non-contiguous range.

    For example. Assume I have a piece of string 18.6cm long and that it must be cut so that I get pieces in the range 6-8cm or 9-10cm. This could clearly be done in more than one way (9,9.6 or 9.3,9.3 for example).

    Anyone help?
    "The power of accurate observation is commonly called cynicism by those who have not got it" - George Bernard Shaw

    #2
    To what accuracy you cut the string would have a bearing on the answer - could mean a possible infinite number of lengths could be cut.
    Too close for missiles, I'm switching to guns.

    Comment


      #3
      I am awaiting feedback from my customer as to whether there is any driving factor behind the selected solution. For example, should we aim for equal lengths if possible or least number of pieces, etc.

      I used the piece of string as an analogy. I do not wish to know how many solutions there are but just a solution (as a first step anyway).
      "The power of accurate observation is commonly called cynicism by those who have not got it" - George Bernard Shaw

      Comment


        #4
        This sounds a bit like the knapsack problem (http://en.wikipedia.org/wiki/Knapsack_problem), except the cut strings aren't specific lengths (since they can fall within certain ranges of length).

        Is the objective just to get the maximum total length of strings with the least amount of wastage? Do you favour longer or shorter strings? Do you need at least one falling in each range? If a string needs to be 7-8 cm do you prefer 7cm, 7.5cm, or 8cm? Quite a few things will affect the algorithm's design.

        It's probably best to try it by hand and design your own algorithm from there.

        Comment


          #5
          Hi Thanks for the info.

          I did sit down earlier in the week and came up with a very simple recursive solution which lends itself to tweaks to handle whether the customer prefers a bias towards long or short or mid-range lengths.

          Many thanks to all
          "The power of accurate observation is commonly called cynicism by those who have not got it" - George Bernard Shaw

          Comment

          Working...
          X