{"id":32163131,"url":"https://github.com/fpclass/iterative-forward-search","last_synced_at":"2025-10-21T14:08:34.430Z","repository":{"id":48374638,"uuid":"281683899","full_name":"fpclass/iterative-forward-search","owner":"fpclass","description":"A Haskell constraint satisfaction libary based on the Iterative Forward Search algorithm","archived":false,"fork":false,"pushed_at":"2021-07-29T10:00:44.000Z","size":77,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-26T15:43:23.980Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fpclass.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-22T13:23:22.000Z","updated_at":"2021-07-29T21:48:22.000Z","dependencies_parsed_at":"2022-08-24T14:49:47.424Z","dependency_job_id":null,"html_url":"https://github.com/fpclass/iterative-forward-search","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fpclass/iterative-forward-search","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpclass%2Fiterative-forward-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpclass%2Fiterative-forward-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpclass%2Fiterative-forward-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpclass%2Fiterative-forward-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fpclass","download_url":"https://codeload.github.com/fpclass/iterative-forward-search/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpclass%2Fiterative-forward-search/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280272409,"owners_count":26302274,"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-10-21T02:00:06.614Z","response_time":58,"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":[],"created_at":"2025-10-21T14:08:31.368Z","updated_at":"2025-10-21T14:08:34.424Z","avatar_url":"https://github.com/fpclass.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Iterative Forward Search\n\n![MIT](https://img.shields.io/github/license/fpclass/iterative-forward-search)\n[![CI](https://github.com/fpclass/iterative-forward-search/actions/workflows/haskell.yaml/badge.svg)](https://github.com/fpclass/iterative-forward-search/actions/workflows/haskell.yaml)\n[![stackage-nightly](https://github.com/fpclass/iterative-forward-search/actions/workflows/stackage-nightly.yaml/badge.svg)](https://github.com/fpclass/iterative-forward-search/actions/workflows/stackage-nightly.yaml)\n[![iterative-forward-search](https://img.shields.io/hackage/v/iterative-forward-search)](https://hackage.haskell.org/package/iterative-forward-search)\n\nThis library implements a contraint solver via the [iterative forward search algorithm](https://muller.unitime.org/lscs04.pdf). It also includes a helper module specifically for using the algorithm to timetable events.\n\n## Usage\n\nTo use the CSP solver first create a `CSP` value which describes your CSP, for example\n```haskell\ncsp :: CSP Solution\ncsp = MkCSP {\n    cspVariables = IS.fromList [1,2,3],\n    cspDomains = IM.fromList [(1, [1, 2, 3]), (2, [1, 2, 4]), (3, [4, 5, 6])],\n    cspConstraints = [ (IS.fromList [1, 2], \\a -\u003e IM.lookup 1 a != IM.lookup 2 a)\n                     , (IS.fromList [2, 3], \\a -\u003e IM.lookup 2 a \u003e= IM.lookup 3 a)\n                     ],\n    cspRandomCap = 30, -- 10 * (# of variables) is a reasonable default\n    cspTermination = defaultTermination\n}\n```\n\nThis example represents a CSP with 3 variables, `1`, `2` and `3`, where variable `1` has domain `[1, 2, 3]`, variable `2` has domain `[1, 2, 4]`, and variable `3` has domain `[4, 5, 6]`. The contraints are that variable `1` is not equal to variable `2`, and variable `2` is at least as big as variable `3`. It uses the default termination condition, and performs 30 iterations before we select variables randomly.\n\nYou can then find a solution simply by evaluating `ifs csp`, which will perform iterations till the given termination function returns a `Just` value.\n\n### Timetabling\n\nThe `toCSP` function in `Data.IFS.Timetable` takes a mapping from slot IDs to intervals, a hashmap of event IDs to the person IDs involved, and a map of person IDs to the slots where they are unavailable and generates a CSP which can then be solved with `ifs`. For example:\n\n```haskell\nslotMap :: IntMap (Interval UTCTime)\nslotMap = IM.fromList [(1, eventTime1), (2, eventTime2), (3, eventTime3)]\n\nevents :: HashMap Int [person]\nevents = HM.fromList [(1, [user1, user2]), (2, [user1])]\n\nunavailability :: HashMap person (Set Int)\nunavailability = HM.fromList [(user1, S.empty), (user2, S.fromList [1,3])]\n\ncsp :: CSP r\ncsp = toCSP slotMap events unavailability defaultTermination\n```\n\nThis will generate a CSP that creates a mapping from the events 1 and 2 to the time slots 1, 2 and 3. \n\n## Limitations\n\n- Variables and values must be integers\n- Only hard constraints are supported\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffpclass%2Fiterative-forward-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffpclass%2Fiterative-forward-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffpclass%2Fiterative-forward-search/lists"}