{"id":27125055,"url":"https://github.com/pwalig/graphsack","last_synced_at":"2025-10-18T00:13:58.103Z","repository":{"id":285192809,"uuid":"957344896","full_name":"pwalig/graphsack","owner":"pwalig","description":"Solver for multiple knapsack problem variations","archived":false,"fork":false,"pushed_at":"2025-04-06T07:20:56.000Z","size":48,"stargazers_count":0,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T08:26:10.736Z","etag":null,"topics":["c-plus-plus","combinatorial-optimization","combinatorics","cplusplus","cpp","graph","graph-algorithms","graphs","knapsack-problem","knapsack-solver"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pwalig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-30T05:58:21.000Z","updated_at":"2025-04-06T07:20:59.000Z","dependencies_parsed_at":"2025-04-06T08:21:45.310Z","dependency_job_id":null,"html_url":"https://github.com/pwalig/graphsack","commit_stats":null,"previous_names":["pwalig/graphsack"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwalig%2Fgraphsack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwalig%2Fgraphsack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwalig%2Fgraphsack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwalig%2Fgraphsack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pwalig","download_url":"https://codeload.github.com/pwalig/graphsack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247669118,"owners_count":20976328,"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":["c-plus-plus","combinatorial-optimization","combinatorics","cplusplus","cpp","graph","graph-algorithms","graphs","knapsack-problem","knapsack-solver"],"created_at":"2025-04-07T14:29:07.439Z","updated_at":"2025-10-18T00:13:58.098Z","avatar_url":"https://github.com/pwalig.png","language":"C++","readme":"# graphsack\n\nSolver for multiple knapsack problem variations.\n\n# Problem\n\nThe main problem that this solver attempts to solve is a graph modification on the knapsack problem.\n\nItems, apart from having value and weight, are also vertices in an directed graph. The goal is to find such cycle in the graph that items coresponding to selected vertices have the largest possible value, while fitting in the knapsack.\n\nAdditionaly instead of weights being single values, they are vectors of values. In order to fit inside the knpasack, vector sum of weights must be smaller than knapsack size vector in every dimension. This modification is known as a [multidimentional knapsack problem](https://en.wikipedia.org/wiki/Knapsack_problem#Multi-dimensional_weight).\n\n# Implemented Algorithms / Solvers\n\n## Helper algorithms\n\n* DFS (is_structure) (both iterative and recursive)\n* DFS (is_structure_possible) (recursive)\n* Bitonic sort (CUDA)\n* GNP graph generator\n* Pick best element reduction (CUDA)\n\n## Problem solving algorithms\n\n* Brute Force (Iterative)\n* Parallel Brute Force (Open MP)\n* Parallel Brute Force (CUDA)\n* Greedy Randomized Adaptive Search\n* Parallel Greedy Randomized Adaptive Search (Open MP)\n* Parallel Greedy Randomized Adaptive Search (CUDA)\n* Greedy Algorithm\n* Greedy Heuristic Search (recursive)\n* Dynamic Programming\n* Path constructing Brute Force (recursive)\n\n# Implementation\n\nAlgoritms are designed in such a way that they can accept instances of the problem in any form as long as they follow a common interface. Instance interface description can be found [here](./src/inst/README.md). Instances may differ for example in memory layout or graph representation, common interface allows algorithms to interact with any type of instance. Mechamism implemented with C++ templates. Static dispatch based on graph representation is yet to be implemented. For now algorithms are more or less geared for operating on adjacency list.\n\nAdditionaly solvers can operate on any solution type (again, thanks to the common interface described [here](./src/res/README.md)). Solution to the knapsack problem can be represented in multiple ways:\n\n* bit vector\n* set of selected item id's\n* list of selected items\n\nSince graph modification and multidimentionality are generalizations of the knapsack problem, solver can solve the base problem too.\n\n# Building\n\n## Dependencies\n\nProject depends on [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit) being installed on your system.\n\n## CMake\n\nProject can be built with [CMake](https://cmake.org).\n\nRun the following.\n\n```\ngit clone https://github.com/pwalig/graphsack.git\ncd graphsack\nmkdir build\ncd build\ncmake ..\ncmake --build .\n```\n\nto get release build with MSVC on Windows use:\n```\ncmake --build . --config Release\n```\n\n## Visual Studio 2022\n\nProject can be built with [Visual Studio](https://visualstudio.microsoft.com/).\n\nJust open grahpsack.sln and run.\n\nTested only on Visual Studio 2022 other versions are not guaranteed not work.\n\n# [Code Documentation](./src/README.md)\n\n* [Instances](./src/inst/README.md)\n* [Solutions](./src/res/README.md)\n* [Solvers](./src/solvers/README.md)\n* [SolverRunner](/src/README.md#solver-runner)\n* [Validator](/src/README.md#validator)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwalig%2Fgraphsack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwalig%2Fgraphsack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwalig%2Fgraphsack/lists"}