Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. algorithm to place N rectilinear blocks in a ring to minimize total area

algorithm to place N rectilinear blocks in a ring to minimize total area

Scheduled Pinned Locked Moved Algorithms
algorithmsperformancehelpquestion
8 Posts 3 Posters 47 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rbuchana
    wrote on last edited by
    #1

    Imagine having ‘N’ rectilinear blocks of varying sizes. 'N' can be any number (< 1000); and of different but similar sizes. See here... blocks — ImgBB[^] I need an algorithm that will place these in a “ring” fashion, such that the area is minimized. White spaces or blank spaces within the ring are fine. Ring picture... ring — ImgBB[^] The constraints are… Each rectilinear block must be placed Minimize the area (x*y) Create a ring such as below Ring implementation Note that my two pictures don't align exactly, meaning not all the blocks in the first picture are placed in the second. These pictures are only provided as reference/examples. I’m not a computer scientist by trade. This would seem to be a cost optimization problem, by I’m having a problem wading through the many optimization algorithms out there. Any guidance on which algorithm would be viable? Thanks!

    L Greg UtasG 3 Replies Last reply
    0
    • R rbuchana

      Imagine having ‘N’ rectilinear blocks of varying sizes. 'N' can be any number (< 1000); and of different but similar sizes. See here... blocks — ImgBB[^] I need an algorithm that will place these in a “ring” fashion, such that the area is minimized. White spaces or blank spaces within the ring are fine. Ring picture... ring — ImgBB[^] The constraints are… Each rectilinear block must be placed Minimize the area (x*y) Create a ring such as below Ring implementation Note that my two pictures don't align exactly, meaning not all the blocks in the first picture are placed in the second. These pictures are only provided as reference/examples. I’m not a computer scientist by trade. This would seem to be a cost optimization problem, by I’m having a problem wading through the many optimization algorithms out there. Any guidance on which algorithm would be viable? Thanks!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      rbuchana wrote:

      Create a ring such as below

      What exactly is a ring? Of course I looked at the example, but it could be interpreted differently. Can the ring look [like this](https://ibb.co/2qnQ8CZ)? Or [this](https://ibb.co/R6qD5K0)? Maybe like [this](https://ibb.co/wdsKSK9)? Maybe even like [this](https://ibb.co/MVgBJRj)? Are the coordinates/sizes discrete?

      R 1 Reply Last reply
      0
      • L Lost User

        rbuchana wrote:

        Create a ring such as below

        What exactly is a ring? Of course I looked at the example, but it could be interpreted differently. Can the ring look [like this](https://ibb.co/2qnQ8CZ)? Or [this](https://ibb.co/R6qD5K0)? Maybe like [this](https://ibb.co/wdsKSK9)? Maybe even like [this](https://ibb.co/MVgBJRj)? Are the coordinates/sizes discrete?

        R Offline
        R Offline
        rbuchana
        wrote on last edited by
        #3

        Door #3... image — ImgBB[^] Difficult to explain words, but the idea is to have a rectangle in the middle with no protusions. Coordinates/sizes are not discrete.

        1 Reply Last reply
        0
        • R rbuchana

          Imagine having ‘N’ rectilinear blocks of varying sizes. 'N' can be any number (< 1000); and of different but similar sizes. See here... blocks — ImgBB[^] I need an algorithm that will place these in a “ring” fashion, such that the area is minimized. White spaces or blank spaces within the ring are fine. Ring picture... ring — ImgBB[^] The constraints are… Each rectilinear block must be placed Minimize the area (x*y) Create a ring such as below Ring implementation Note that my two pictures don't align exactly, meaning not all the blocks in the first picture are placed in the second. These pictures are only provided as reference/examples. I’m not a computer scientist by trade. This would seem to be a cost optimization problem, by I’m having a problem wading through the many optimization algorithms out there. Any guidance on which algorithm would be viable? Thanks!

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Cut the pieces out, move them around until optimum, then reverse engineer into a software solution.

          It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

          1 Reply Last reply
          0
          • R rbuchana

            Imagine having ‘N’ rectilinear blocks of varying sizes. 'N' can be any number (< 1000); and of different but similar sizes. See here... blocks — ImgBB[^] I need an algorithm that will place these in a “ring” fashion, such that the area is minimized. White spaces or blank spaces within the ring are fine. Ring picture... ring — ImgBB[^] The constraints are… Each rectilinear block must be placed Minimize the area (x*y) Create a ring such as below Ring implementation Note that my two pictures don't align exactly, meaning not all the blocks in the first picture are placed in the second. These pictures are only provided as reference/examples. I’m not a computer scientist by trade. This would seem to be a cost optimization problem, by I’m having a problem wading through the many optimization algorithms out there. Any guidance on which algorithm would be viable? Thanks!

            Greg UtasG Offline
            Greg UtasG Offline
            Greg Utas
            wrote on last edited by
            #5

            Are you stating all of the constraints? To minimize the x*y area, it would often be preferable to have two very long sides and two very short ones for the inner rectangle. For example, say that all rectangles are the same shape and that there are 4n of them. They could be arranged to leave a square in the middle. Let's say the size of the square is a*a and that the four outer areas are also a*a. The x*y area would then be 3a*3a=9a^2. But instead of leaving an inner square, we can reduce two of its sides by 50% and increase the other two by 50%. Now we have an area of (7a/2)(5a/2) = (35/4)a^2, which is slightly smaller. The size of the inner rectangle is now (a/2)*(3a/2) = (3/4)a^2 instead of a^2.

            Robust Services Core | Software Techniques for Lemmings | Articles

            <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
            <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

            R 1 Reply Last reply
            0
            • Greg UtasG Greg Utas

              Are you stating all of the constraints? To minimize the x*y area, it would often be preferable to have two very long sides and two very short ones for the inner rectangle. For example, say that all rectangles are the same shape and that there are 4n of them. They could be arranged to leave a square in the middle. Let's say the size of the square is a*a and that the four outer areas are also a*a. The x*y area would then be 3a*3a=9a^2. But instead of leaving an inner square, we can reduce two of its sides by 50% and increase the other two by 50%. Now we have an area of (7a/2)(5a/2) = (35/4)a^2, which is slightly smaller. The size of the inner rectangle is now (a/2)*(3a/2) = (3/4)a^2 instead of a^2.

              Robust Services Core | Software Techniques for Lemmings | Articles

              R Offline
              R Offline
              rbuchana
              wrote on last edited by
              #6

              You're correct. There is somewhat of a constraint on the aspect ratio (x/y), but also some flexibility. Meaning it doesn't need to be 50%, but 10% or 90% are probably too much. But no hard limit.

              Greg UtasG 2 Replies Last reply
              0
              • R rbuchana

                You're correct. There is somewhat of a constraint on the aspect ratio (x/y), but also some flexibility. Meaning it doesn't need to be 50%, but 10% or 90% are probably too much. But no hard limit.

                Greg UtasG Offline
                Greg UtasG Offline
                Greg Utas
                wrote on last edited by
                #7

                In that case, it's vague (at best) to speak of minimizing the total area.

                Robust Services Core | Software Techniques for Lemmings | Articles

                <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
                <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

                1 Reply Last reply
                0
                • R rbuchana

                  You're correct. There is somewhat of a constraint on the aspect ratio (x/y), but also some flexibility. Meaning it doesn't need to be 50%, but 10% or 90% are probably too much. But no hard limit.

                  Greg UtasG Offline
                  Greg UtasG Offline
                  Greg Utas
                  wrote on last edited by
                  #8

                  If the problem can be stated more clearly, my guess is that it's a variant of the bin packing problem[^]. The article mentions that this problem is NP-hard, which effectively means that the time required to find the optimal solution rises exponentially, although it may be possible to more efficiently find a solution that is known to bounded in terms of how close it is to the optimal one.

                  Robust Services Core | Software Techniques for Lemmings | Articles

                  <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
                  <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups