merschformann / sardine-can

Humble 3D knapsack / bin packing solver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Everything in offload

DrkShadow opened this issue · comments

Unsure what's wrong, everything appears to be placed in "offload".

Keeping the default values in the "Try it!" section, I change containers and add two, and add two pieces to pack, where the pieces both fit into either container. (I've tried 1x1x1, 2x2x2).

  "instance": {
    "name": "string",
    "containers": [
      {
        "id": 0,
        "length": 3,
        "width": 3,
        "height": 3
      },
      {
        "id": 1,
        "length": 4,
        "width": 4,
        "height": 4
      }
    ],
    "pieces": [
      {
        "id": 0,
        "flags": [
          {
            "flagId": 0,
            "flagValue": 0
          }
        ],
        "cubes": [
          {
            "x": 0,
            "y": 0,
            "z": 0,
            "length": 2,
            "width": 2,
            "height": 2
          }
        ]
      },
      {
        "id": 1,
        "flags": [
          {
            "flagId": 0,
            "flagValue": 0
          }
        ],
        "cubes": [
{
            "x": 0,
            "y": 0,
            "z": 0,
            "length": 2,
            "width": 1,
            "height": 1
          }
        ]
      }
    ],

The result is always the same:

{
  "containers": [
    {
      "assignments": []
    },
    {
      "assignments": []
    }
  ],
  "offload": [
    0,
    1
  ]
}

What's up?

Hey! Thanks for trying it. ☺️

Could you maybe share a curl command that leads to the observed behavior for reproduction?

I just ran this one and it seems to be fine:

curl -X 'POST' \
  'http://localhost:4550/Packing/calculations' \
  -H 'accept: text/plain' \
  -H 'Content-Type: application/json' \
  -d '{
    "instance": {
        "name": "string",
        "containers": [
            {
                "id": 0,
                "length": 3,
                "width": 3,
                "height": 3
            },
            {
                "id": 1,
                "length": 4,
                "width": 4,
                "height": 4
            }
        ],
        "pieces": [
            {
                "id": 0,
                "flags": [
                    {
                        "flagId": 0,
                        "flagValue": 0
                    }
                ],
                "cubes": [
                    {
                        "length": 2,
                        "width": 2,
                        "height": 2
                    }
                ]
            },
            {
                "id": 1,
                "flags": [
                    {
                        "flagId": 0,
                        "flagValue": 0
                    }
                ],
                "cubes": [
                    {
                        "length": 2,
                        "width": 1,
                        "height": 1
                    }
                ]
            }
        ]
    }
}'

(It should be your input, I had to fix the json structure a bit)

Getting it via

curl -X 'GET' \
  'http://localhost:4550/Packing/calculations/0/solution' \
  -H 'accept: text/plain'

gives me the following solution:

{
  "containers": [
    {
      "assignments": []
    },
    {
      "assignments": [
        {
          "piece": 0,
          "position": {
            "x": 0,
            "y": 0,
            "z": 0,
            "a": 0,
            "b": 0,
            "c": 0
          }
        },
        {
          "piece": 1,
          "position": {
            "x": 0,
            "y": 2,
            "z": 0,
            "a": 0,
            "b": 0,
            "c": 0
          }
        }
      ]
    }
  ],
  "offload": []
}

(Both pieces assigned to the second container)

I assume that you used the examples from the swagger UI? Those are defaults generated by Swagger and I should definitely look into replacing them. Not sure whether swagger reconfigures something, since it's possible to send a custom configuration alongside the calculation job.

I hope this helps.

I changed the POST example to something more simple. The more detailed schema descriptions are still available below.
However, I certainly should add more docs. Not sure whether/when I can find some time. 😬

I guess this is stale, I will close it for now. Let me know, if there are further problems.

Since this was opened I updated the examples shown in Swagger UI. So, hopefully they resolve this hiccup in getting started. ☺️