A Ruby-based solver that reframes participatory budgeting as the knapsack problem. Instead of letting citizens manually distribute a budget, this tool optimizes item selection based on expressed values.
- Citizens rate how valuable each item/idea is (value score)
- The solver finds the optimal combination of items that maximizes total value while staying within budget
- Returns the top 3 near-optimal solutions for consideration
- Ruby 3.x
- Bundler
bundle installbundle exec rake 'knapsack:solve[path/to/items.csv,budget]'bundle exec rake 'knapsack:solve[example_items.csv,1000]'The input CSV must have the following columns:
| Column | Description |
|---|---|
| Item | Name of the item/idea |
| Value | How valuable the item is (integer) |
| Cost | Cost of the item (integer) |
Example:
Item,Value,Cost
Park renovation,8,5000
New playground,9,3000
Street lighting,7,2000The solver returns the top 3 solutions, each showing:
- Total value achieved
- Total cost vs. budget
- List of selected items with their individual values and costs