{"id":31363794,"url":"https://github.com/tm-1-3/delivery-truck-pallet-packing-optimization-tool","last_synced_at":"2026-07-19T16:32:00.893Z","repository":{"id":316318447,"uuid":"1062887962","full_name":"TM-1-3/Delivery-Truck-Pallet-Packing-Optimization-Tool","owner":"TM-1-3","description":"Delivery Truck Pallet Packing Optimization Tool Using Various Programming Approaches, Developed for the L.EIC016 - Algorithm Design Course","archived":false,"fork":false,"pushed_at":"2025-09-24T17:32:00.000Z","size":3831,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-24T19:28:21.529Z","etag":null,"topics":["algorithm-analysis","algorithm-comparison","algorithm-design","approximation","brute-force","cpp","dynamic-programming","greedy","integer-linear-programming","knapsack-problem","time-complexity"],"latest_commit_sha":null,"homepage":"","language":"C++","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/TM-1-3.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T21:49:15.000Z","updated_at":"2025-09-24T17:35:19.000Z","dependencies_parsed_at":"2025-09-26T00:16:08.351Z","dependency_job_id":null,"html_url":"https://github.com/TM-1-3/Delivery-Truck-Pallet-Packing-Optimization-Tool","commit_stats":null,"previous_names":["tm-1-3/delivery-truck-pallet-packing-optimization","tm-1-3/delivery-truck-pallet-packing-optimization-tool"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/TM-1-3/Delivery-Truck-Pallet-Packing-Optimization-Tool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TM-1-3%2FDelivery-Truck-Pallet-Packing-Optimization-Tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TM-1-3%2FDelivery-Truck-Pallet-Packing-Optimization-Tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TM-1-3%2FDelivery-Truck-Pallet-Packing-Optimization-Tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TM-1-3%2FDelivery-Truck-Pallet-Packing-Optimization-Tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TM-1-3","download_url":"https://codeload.github.com/TM-1-3/Delivery-Truck-Pallet-Packing-Optimization-Tool/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TM-1-3%2FDelivery-Truck-Pallet-Packing-Optimization-Tool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277184144,"owners_count":25775286,"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","status":"online","status_checked_at":"2025-09-27T02:00:08.978Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["algorithm-analysis","algorithm-comparison","algorithm-design","approximation","brute-force","cpp","dynamic-programming","greedy","integer-linear-programming","knapsack-problem","time-complexity"],"created_at":"2025-09-27T05:21:11.960Z","updated_at":"2025-09-27T05:21:16.949Z","avatar_url":"https://github.com/TM-1-3.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src='https://sigarra.up.pt/feup/pt/imagens/LogotipoSI' width=\"30%\"/\u003e\n\n\u003cdiv align=\"center\"\u003e\n🌍 \u003ca href=\"README.md\"\u003eEnglish\u003c/a\u003e | 🇵🇹 \u003ca href=\"README.pt.md\"\u003ePortuguês\u003c/a\u003e\n\u003c/div\u003e\n\n\u003ch3 align=\"center\"\u003eBSc in Informatics and Computing Engineering\u003cbr\u003e L.EIC016 - Algorithm Design\u003cbr\u003e 2024/2025 \u003c/h3\u003e\n\n---\n\u003ch3 align=\"center\"\u003e Collaborators \u0026#129309 \u003c/h2\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n| Name          | Number      |\n|---------------|-------------|\n| Bárbara Gomes | up202305089 |\n| Tomás Morais  | up202304692 |\n| Tomás Silva   | up202307796 |\n\nGrade : 15,6\n\n\u003c/div\u003e\n\n# Delivery Truck Pallet Packing Optimization Tool Report\n\n- [Class Diagram](#class-diagram)  \n- [User Interface](#user-interface)  \n- [Reading the Dataset](#reading-the-dataset)  \n- [Programming Approaches](#programming-approaches)  \n  - [Brute-Force (Exhaustive)](#brute-force-exhaustive)  \n  - [Dynamic Programming](#dynamic-programming)  \n  - [Approximation (Greedy Approach)](#approximation-greedy-approach)  \n  - [Integer Linear Programming](#integer-linear-programming)  \n\n\u003ca id=\"class-diagram\"\u003e\u003c/a\u003e\n## Class Diagram\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg width=\"1694\" height=\"786\" alt=\"Captura de ecrã de 2025-09-23 23-04-24\" src=\"https://github.com/user-attachments/assets/77e01a75-7744-461c-88da-635eceafa60e\" /\u003e\n\u003c/div\u003e\n\n\u003ca id=\"user-interface\"\u003e\u003c/a\u003e\n## User Interface\n\n- ✅ When starting the program, a menu is displayed with the options `Exit` (terminate program) and `Select Data Files`;  \n- ✅ If `Select Data Files` is chosen, all available datasets in the same directory as the source code are listed;  \n- ✅ After dataset selection, algorithmic approaches are shown for the user to choose from, with an option to return to `Select Data Files`;  \n- ✅ Once the algorithm runs, the solution is shown (including total profit) and an option to process another dataset is offered.  \n\n\u003ca id=\"reading-the-dataset\"\u003e\u003c/a\u003e\n## Reading the Dataset\n\nAfter the selection of the ﬁles to process:\n\n- ✅ `pair\u003cvector\u003cint\u003e, vector\u003cint\u003e\u003e extractPalletValues(const string\u0026 palletsFileName)`  \n  Opens and reads each line of the `Pallets` ﬁle, extracting each pallet’s `weight` and `profit`, storing them in vectors `weights` and `profits`. Returns a `pair` of these vectors for use in other functions.  \n\n- ✅ `int extractTruckCapacity(const string\u0026 truckFileName)`  \n  Extracts and returns the truck’s maximum weight capacity from the `Truck` ﬁle.  \n\n\u003ca id=\"programming-approaches\"\u003e\u003c/a\u003e\n## Programming Approaches\n\n\u003ca id=\"brute-force-exhaustive\"\u003e\u003c/a\u003e\n### Brute-Force (Exhaustive)\n\n- ✅ Iterates through all subsets of the given items;  \n- ✅ For each subset, calculates the total `weight` and `profit`;  \n- ✅ If the total weight is within the allowed capacity and profit is greater than the current best, updates the best subset;  \n- ✅ Outputs the indices, weights, profits of selected items, and the maximum achievable profit.  \n\n**Time Complexity:** `O(n 2^n)`  \n**Space Complexity:** `O(n)`  \n\n**Data Structures:**  \n- Input: 2 vectors (`profit`, `weight`) + integer (`maximum capacity`).  \n- Output: same 2 vectors + vector of selected indices + integer (`maximum profit`).  \n\n\u003ca id=\"dynamic-programming\"\u003e\u003c/a\u003e\n### Dynamic Programming\n\n- ✅ Takes as input profits, weights, and knapsack capacity;  \n- ✅ Builds a DP table to compute the maximum profit without exceeding capacity;  \n- ✅ Backtracks through the table to find items in the optimal solution;  \n- ✅ Outputs selected items (index, weight, profit) and total profit;  \n- ✅ More efficient than brute-force for larger inputs.  \n\n**Time Complexity:** `O(nW)`  \n**Space Complexity:** `O(nW)`  \n\n**Data Structures:**  \n- Input: 2 vectors (`profit`, `weight`) + integer (`maximum capacity`).  \n- Output: same 2 vectors + vector of selected indices + integer (`total profit`).  \n\n\u003ca id=\"approximation-greedy-approach\"\u003e\u003c/a\u003e\n### Approximation (Greedy Approach)\n\n**Greedy Algorithm A**  \n- ✅ Sort by `weight-to-profit` ratio (ascending).  \n- ✅ Select items while they fit in the truck.  \n\n**Greedy Algorithm B**  \n- ✅ Sort by `profit` (ascending).  \n- ✅ Select items while they fit in the truck.  \n\n**Approximation Algorithm**  \n- ✅ Picks the better solution between Greedy A and Greedy B.  \n\n**Time Complexity:** `O(n log n)`  \n**Space Complexity:** `O(n)`  \n\n**Data Structures:**  \n- Each greedy returns a `pair` (selected items, total profit).  \n- Approximation Algorithm returns the most profitable `pair`.  \n\n\u003ca id=\"integer-linear-programming\"\u003e\u003c/a\u003e\n### Integer Linear Programming\n\n#### Item Struct  \n- ✅ Stores `index`, `profit`, `weight`, and `profit-to-weight ratio`.  \n- ✅ Items are sorted in descending order.  \n\n#### Branch and Bound  \n- ✅ Explores item inclusion in the knapsack to maximise profit.  \n- ✅ Prunes unpromising branches.  \n\n#### knapsackILP` \n- ✅ Main function solving `0/1 knapsack` using Branch and Bound ILP approach.  \n\n**Time Complexity:** `O(n log n + 2^n)`  \n**Space Complexity:** `O(n)`  \n\n**Data Structures:**  \n- Branch and Bound: vectors of integers and `Items` (current solution + items).  \n- knapsackILP: vectors of `profits`, `weights`, current solution, and processed `Items`.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftm-1-3%2Fdelivery-truck-pallet-packing-optimization-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftm-1-3%2Fdelivery-truck-pallet-packing-optimization-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftm-1-3%2Fdelivery-truck-pallet-packing-optimization-tool/lists"}