{"id":20018921,"url":"https://github.com/wyatt-howe/bu-hub-greedy-algorithm","last_synced_at":"2026-02-25T02:33:26.629Z","repository":{"id":134385855,"uuid":"316304550","full_name":"wyatt-howe/BU-HUB-greedy-algorithm","owner":"wyatt-howe","description":"An algorithm to help knock out your non-major graduation requirements","archived":false,"fork":false,"pushed_at":"2020-11-27T16:50:13.000Z","size":900,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-08T01:43:03.491Z","etag":null,"topics":["boston-university","gen-eds","greedy-algorithm","python","set-covering-problem"],"latest_commit_sha":null,"homepage":"","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/wyatt-howe.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}},"created_at":"2020-11-26T18:04:50.000Z","updated_at":"2023-10-31T05:01:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"b36e6b0c-ca1d-45fe-bdce-5bf23385298e","html_url":"https://github.com/wyatt-howe/BU-HUB-greedy-algorithm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wyatt-howe/BU-HUB-greedy-algorithm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wyatt-howe%2FBU-HUB-greedy-algorithm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wyatt-howe%2FBU-HUB-greedy-algorithm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wyatt-howe%2FBU-HUB-greedy-algorithm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wyatt-howe%2FBU-HUB-greedy-algorithm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wyatt-howe","download_url":"https://codeload.github.com/wyatt-howe/BU-HUB-greedy-algorithm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wyatt-howe%2FBU-HUB-greedy-algorithm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29809086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T22:43:48.403Z","status":"online","status_checked_at":"2026-02-25T02:00:07.329Z","response_time":61,"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":["boston-university","gen-eds","greedy-algorithm","python","set-covering-problem"],"created_at":"2024-11-13T08:24:57.548Z","updated_at":"2026-02-25T02:33:26.614Z","avatar_url":"https://github.com/wyatt-howe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BU HUB greedy algorithm\nA greedy approach to the BU HUB requirements\n\n\u003e \"The BU Hub is Boston University’s University-wide general education program that emphasizes working across disciplines to prepare for a complex and diverse world. Students can explore a variety of courses and innovative learning experiences while developing six essential capacities and fulfilling Hub requirements. Explore these six capacities, Hub learning outcomes, and how the Hub works below.\"\n-https://www.bu.edu/hub/hub-courses/\n\n```\n├── README.md\n├── catalog\n│   ├── catalog.json  (full catalog scraped from the BU course catalog)\n│   └── catalog_sorted.json  (all HUB courses as of fall 2020 - 100-level and up)\n│\n├── search.js  (catalog in JavaScript for easy map/reduce/filter-ing)\n│\n└── set_cover.py (the actual algorithm)\n```\n\nBU students know how annoying the HUB is, and how confusing it is to ensure they aren't forgetting any requirements, as even one overlooked unit necessitates a whole extra 4 credit class.\n\n### The Problem\n\nOne way to formulate the BU HUB course selection problem is as a graph problem.  Given a graph G={U,V,E}, let U be the available courses, V be the set of required HUB units, and E connect courses to the units they fulfill.  A solution is any subset of U that collectively neighbors all of V.\n\n### A Solution\n\nUnfortunately this description is of an NP-complete problem, as it is mutually reducible to ordinary set coverage.  And even though we may be able to narrow down BUs thousands of courses to a couple hundred, it's still intractable to solve exhaustively—or guarantee the most optimal solution.\n\nThankfully however, we don't necessarily need to guarantee *most* optimal course-selection, just a good enough one for a recommendation, and there's a nice little greedy algorithm for finding sets that are pretty close if not indeed correct on occasion.\n\nThe reduction to make use of this algorithm is simply rewriting the courses as sets of the HUB units they provide and remembering to look up the indexes of the chosen classes at the end.\n\n### Probabilistic Techniques\n\nOften, there is more than one most optimal solution, and we can run the algorithm again over a differently ordering of the catalog to see the others.  Alternatively if the algorithm fails to find a good-enough solution on the sorted list, where the easiest classes would get considered first, we can rerun it nondeterministically on randomly shuffled inputs until it either halts with a great schedule, or our patience runs out.  It can take as many as 400+ tries sometimes on the default set with strict requirements, so don't always expect a loop.\n\n### Notes about the included data set\n\nSocial Inquiry and Scientific Inquiry are not both required—only one of them.  Thankfully this is easily fixable with a quick preprocessing step, which combines the two into a \"Social/Scientific Inquiry II\" as a single unit.  Managing doubled requirements, however, does not have such a simple reduction, and I took the naive (but not unbearably inefficient) approach of rerunning the algorithm until it finds a selection with the desired multiplicity of HUB units (for example \"Writing-Intensive Course\" is needed twice).\n\n```json\nNumber of courses offering each unit\n------------------------------------\n   5 First-Year Writing Seminar\n  11 Writing, Research, and Inquiry\n  65 Scientific Inquiry II\n  73 Quantitative Reasoning I\n  77 Scientific Inquiry I\n  82 Quantitative Reasoning II\n  84 Philosophical Inquiry and Life's Meanings\n  97 Digital/Multimedia Expression\n 110 Social Inquiry II\n 132 Creativity/Innovation\n 134 Social Inquiry I\n 146 Ethical Reasoning\n 158 Oral and/or Signed Communication\n 167 Teamwork/Collaboration\n 183 Writing-Intensive Course\n 209 The Individual in Community\n 223 Research and Information Literacy\n 273 Historical Consciousness\n 286 Aesthetic Exploration\n 296 Global Citizenship and Intercultural Literacy\n 320 Critical Thinking\n```\n\n### Usage\n\nRun [`set_cover.py`](https://github.com/wyatt-howe/BU-HUB-greedy-algorithm/blob/master/set_cover.py#L81-L114) in your favorite python interpreter.  You will want to edit the file and fill in which HUB units are already completed.\n\n\u003c!-- ```sh\npython set_cover.py catalog.json\n``` --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwyatt-howe%2Fbu-hub-greedy-algorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwyatt-howe%2Fbu-hub-greedy-algorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwyatt-howe%2Fbu-hub-greedy-algorithm/lists"}