Search code examples
c++data-structuresgenetic-algorithmevolutionary-algorithm

Data structure to represent a solution of 2D material cutting?


I am working on the cutting problem, and I need to figure out how to represent the solution.

For example look at this image, where the gray areas are unused material.

enter image description here

Can you please recommend me possible representations? By the way I am using c++ for this.

Thanks


Solution

  • You could use a vector of structs std::vector<sub> areas; like

    struct sub
    {
      size_t x, y;
      size_t extent_x, extent_y;
      sub (void) : x(0U), y(0U), extent_x(0U), extent_y(0U) { }
    };
    

    Where (x,y) as well as (x+extent_x, y+extent_y) are mapped on the Points of the total image. This vector may either store used or unused parts of the Image.