{"id":17334036,"url":"https://github.com/veni-vidi-code/mmkai","last_synced_at":"2025-03-27T06:45:28.323Z","repository":{"id":197278371,"uuid":"643595619","full_name":"veni-vidi-code/MMKAI","owner":"veni-vidi-code","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-28T14:08:26.000Z","size":311,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T12:08:28.298Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/veni-vidi-code.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,"governance":null}},"created_at":"2023-05-21T16:58:13.000Z","updated_at":"2023-09-29T16:54:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"bda16b49-9720-4473-88b7-24fbc2d81200","html_url":"https://github.com/veni-vidi-code/MMKAI","commit_stats":null,"previous_names":["veni-vidi-code/mmkai"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veni-vidi-code%2FMMKAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veni-vidi-code%2FMMKAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veni-vidi-code%2FMMKAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veni-vidi-code%2FMMKAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/veni-vidi-code","download_url":"https://codeload.github.com/veni-vidi-code/MMKAI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245798539,"owners_count":20673902,"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":[],"created_at":"2024-10-15T15:04:33.603Z","updated_at":"2025-03-27T06:45:28.289Z","avatar_url":"https://github.com/veni-vidi-code.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MMKAI\nThis repository contains the Code to the Bachelorthesis Operationsplanung als Rucksackproblem: Komplexität und Algorithmen für mehrere Rucksäcke (english title: Surgical planning as a Knapsackproblem: Complexity and Algorithms for multiple \nKnapsacks). Different from the Thesis a lot is written in english. The Output of several functions is however still in German.\n\nIt contains one Algorithm for the multiple knapsackproblem with assignment restrictions (MTM EXTENDED) aswell as a matching based algorithm for the multiple knapsackproblem with assignment restrictions and identical Profits (MMKAI).\n\n\n# Installation and Running\n\n1. Install python 3.10 or a higher python 3 version together with pip from https://www.python.org/downloads/\n2. During the install make sure to check the box to add python to the PATH and restart your computer afterwards\n3. Validate the installation by opening a terminal and running `python3 --version` (depending on the installation you\n   might need to use python instead of python3)\n4. Open a terminal and navigate to the folder of this repository (the folder above runtime_visualization, src, etc.) (\n   under Windows CMD is recommended)\n5. Create a virtual environment with `python3 -m venv venv` (depending on the installation you might need to use python\n   instead of python3)\n6. Activate the virtual environment with `source venv/bin/activate` under Unix or `venv\\Scripts\\activate.bat` under\n   Windows if using CMD and `venv\\Scripts\\activate.ps1` under Windows if using Powershell\n7. There should now be a `(venv)` in front of your terminal prompt\n8. Install the requirements with `pip install -r requirements.txt`\n9. To install the additional requirements for the runtime visualisation\n   run `pip install -r runtime_visualization/requirements.txt`\n10. Choose one of the following options and proceed from there. Important: All of these assume you did the installation\n    correctly and you must still be in a terminal in the correct folder with the venv enabled.\n\nSteps 4, 6, 7 need to be repeated every time you want to run the app.\n\n## Run the unit tests\n\nThis will run the unit tests to check the basic functionality of the algorithms.\n\n1. Run `python3 -m unit_tests_MMKAI.__init__` or `python -m unit_tests_MMKAI.__init__` depending on your installation\n2. All unit tests should pass and you should see something like `Ran 70 tests in 23.000s OK`\n\n## Collect runtime results on your own system\n\nThis will run the tests on your own system and collect the results. Please note that this will take a long time (several\nhours to days) and you should not use your system for anything else during this time. This will also require several\ncores and a lot of RAM. If it runs out of RAM it will crash with weird errors. You might consider adjusting the code to\nrun different tests.\n\n1. Delete the results from the original test in runtime_tester/test_results/\n2. Run `python3 -m runtime_tester.run_tests` or `python -m runtime_tester.run_tests` depending on your installation\n3. This will also attempt to run against gurobi. As the instances will likely be quite large for the free version of\n   gurobi this will likely fail. You might want to consider commenting out the gurobi tests in the code. The gurobi\n   output will be redirected into its own file\n\nYou should consider adding the `-u` and possibly the `-OO` flag to the command. This will disable the output buffering\nand optimize the code. \n\n## Create Latex tables from the collected results\n\nThis will create Latex tables from the collected results. They will be saved in MMKAI.tex and\nMTM_EXTENDED.tex.\n\n1. Run `python3 -m runtime_tester.evaluator` or `python -m runtime_tester.evaluator` depending on your installation\n2. The tables should be created\n3. You can now copy the tables into your Latex document. For a list of required packages\n   see https://pandas.pydata.org/docs/reference/api/pandas.io.formats.style.Styler.to_latex.html\n4. You will need to adjust the headers of the tables to be in one line\n\n## Running the webserver for graphs\n\nThis will run a webserver to visualize the results as graphs.\nIf you are using a Unix system you might prefer gunicorn. The following however will only run the server using flask\ndirectly (which is not recommended for production use).\n\n### Start the Server\n\n1. Run `python3 wsgi.py` or `python wsgi.py` depending on your installation\n2. It should print something like `Running on http://...` and you can open the link in your browser\n3. In your browser you can now select the visualization.\n4. To stop the server press `Ctrl+C` in the terminal\n\n### Interact with the website in your browser\n- On all pages you can click on the title to go back to the main page\n- On all pages in the top right corner you can click to navigate to the other pages\n- On the main page you can click on the buttons to navigate to the other pages\n- On all pages there is an Info button in the bottom right corner. Clicking it will open a popup with additional\n  information about the graphs\n- All graphs are interactive. You can simply change your viering perspective, zoom, etc. by using your mouse. Some\n  of the graphs also allow you to change one of the parameters by using a slider above the graph. \n- The graphs are created using plotly. You can find more information about the graphs and how to interact with them\n  here: https://plotly.com/python/\n- Depending on your hardware the graphs might take a while to load. Please be patient.\n- Sometimes there is a lot of information in a graph. To disable a set of Elements in the graph you can click on the\n  corresponding entry in the legend. This will disable the corresponding elements in the graph. You can also click on\n  the corresponding entry in the legend to enable it again.\n\n\n## Using the algorithms in your own code\n\nThis assumes you do know how to use python. As a way of entry take a look at src/test.py. It contains a simple example\nof how to create an instance and run the algorithm. Additionally it also validates the results using gurobi, this is \nhowever only for testing purposes and not required to run the algorithm. \n\n1. Import the algorithm you want to use from src\n2. Create an instance of the algorithms solver class providing the input\n3. call the `solve` method on the solver instance\n4. It will return a tuple containg the optimal value and the optimal solution (dict mapping a list of items to each\n   knapsack)\n\nPlease note that if you are importing the algorithm from a different folder you might need to adjust the imports in the\nalgorithm itself. As an alternative you can also add the folder to the python path.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveni-vidi-code%2Fmmkai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fveni-vidi-code%2Fmmkai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveni-vidi-code%2Fmmkai/lists"}