{"id":22073921,"url":"https://github.com/igorpejic/visapi","last_synced_at":"2025-07-24T11:31:57.671Z","repository":{"id":37228035,"uuid":"224496779","full_name":"igorpejic/visapi","owner":"igorpejic","description":"Monte Carlo Tree Search on Perfect Rectangle Packing Problem Instances","archived":false,"fork":false,"pushed_at":"2022-12-08T04:22:42.000Z","size":9760,"stargazers_count":9,"open_issues_count":49,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-16T07:06:35.873Z","etag":null,"topics":["bin-packing","binpack","monte-carlo-tree-search","rectangle-packing","rectanglepacking"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igorpejic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-27T18:51:07.000Z","updated_at":"2024-02-22T09:36:36.000Z","dependencies_parsed_at":"2023-01-24T15:45:34.201Z","dependency_job_id":null,"html_url":"https://github.com/igorpejic/visapi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorpejic%2Fvisapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorpejic%2Fvisapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorpejic%2Fvisapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorpejic%2Fvisapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igorpejic","download_url":"https://codeload.github.com/igorpejic/visapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227435016,"owners_count":17776344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bin-packing","binpack","monte-carlo-tree-search","rectangle-packing","rectanglepacking"],"created_at":"2024-11-30T21:25:54.122Z","updated_at":"2024-11-30T21:25:54.721Z","avatar_url":"https://github.com/igorpejic.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monte Carlo Tree Search on Perfect Rectangle Packing Problem Instances\n\n![GitHub Logo](/images/perfect_rectangle_packing.png)\n\n## Dataset\nThe dataset of 1000 Guillotinable and 1000 Braam rectangle packing problems with 20 tiles can be found in [problems](problems/).\n\n## Installation\n```\npip3 install requirements.txt\n```\n\nTo run experiments, you will need to have a PostgreSQL database running.\n\nAfter installing the PostgreSQL database you can create one by logging into the psql shell and running:\n\n```psql\npostgres=# create role binpack_user;\nCREATE ROLE\npostgres=# create database binpack;\nCREATE DATABASE\npostgres=# grant all on database binpack to binpack_user;\nGRANT\npostgres=# alter role binpack_user with login;\npostgres=# alter user binpack_user with password 'password';\n```\n\nCopy the file `visapi/secrets.json.local` to `visapi/secrets.json`:\n\n```\ncp visapi/secrets.json.template visaip/secrets.json\n```\n\nThen edit it with a secret key and the details to connect to the database:\n```\nThe database values meanings are in order:\nHOST, DATABASE_NAME, USER, PASSWORD, PORT\n```\n\nFor the example provided, the contents of the file would be:\n```json\n{\n    \"SECRET_KEY\": \"something_random\",\n    \"DATABASE\": [\"localhost\", \"binpack\", \"binpack_user\", \"password\", \"\"]\n}\n```\n\nTo create a database schema, you will need to run:\n\n```shell\npython3 manage.py migrate\n```\n\nAll experiments results will be saved to the database, in the table `affinity`.\n\nAccess them using the django shell:\n```\npython3 manage.py shell_plus\n```\n\nAnd then:\n\n```python\nResult.objects.all()\n```\n\nSee Django ORM [reference](https://docs.djangoproject.com/en/3.1/topics/db/queries/#making-queries).\n\n\nOr access them using postgresql shell:\n```psql\nselect * from affinity;\n```\n\nAll the problem results will be available in the database with all the metrics needed to finish them (number of tiles placed etc.), and their scores (success / failure).\n\n## Running experiments\n\n### MCTS algorithm\nRun:\n\n```\nPYTHONPATH=engine/ python3 manage.py run_mcts\n```\n\nto see all the options for the runner.\n\nExample: \n\nRun dynamically generated problems:\n```\nPYTHONPATH=engine/ python3 manage.py run_mcts 20 11 11\n```\n\nFrom file:\n```\nPYTHONPATH=engine/ python3 manage.py run_mcts 20 11 11 --from_file\n```\n\n\n\n### Neural Network algorithm\n\nThis algorithm performs only one tile placement.\nTo get the final solution calls the NN predict multiple times.\n\nTo train the neural network you can use:\n```\nPYTHONPATH=engine/ python3 manage.py just_train                                                  \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figorpejic%2Fvisapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figorpejic%2Fvisapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figorpejic%2Fvisapi/lists"}