{"id":22266733,"url":"https://github.com/velliz/timetables","last_synced_at":"2025-03-25T14:27:11.726Z","repository":{"id":62543918,"uuid":"157476625","full_name":"Velliz/timetables","owner":"Velliz","description":"Timetable algorithm implemented with 2 dimensional cartesius diagram","archived":false,"fork":false,"pushed_at":"2018-11-14T02:30:51.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T20:49:03.768Z","etag":null,"topics":["algorithm","php-library","timetable"],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/Velliz.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}},"created_at":"2018-11-14T02:13:52.000Z","updated_at":"2018-11-14T02:30:53.000Z","dependencies_parsed_at":"2022-11-02T21:30:33.086Z","dependency_job_id":null,"html_url":"https://github.com/Velliz/timetables","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Velliz%2Ftimetables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Velliz%2Ftimetables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Velliz%2Ftimetables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Velliz%2Ftimetables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Velliz","download_url":"https://codeload.github.com/Velliz/timetables/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245479301,"owners_count":20622117,"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":["algorithm","php-library","timetable"],"created_at":"2024-12-03T10:23:46.824Z","updated_at":"2025-03-25T14:27:11.687Z","avatar_url":"https://github.com/Velliz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Timetables\n\nTimetable algorithm implemented with 2 dimensional cartesius diagram.\n\n### Install\n\n```bash\ncomposer require velliz/timetables\n```\n\n### Usage\n\n**Criteria**\n\nInstance a criteria for X and Y dimensions with provided example.\nYou can have your customized **TimeDatum** and **RoomDatum** class with extending it to ```Datum``` abstraction.\n\n```php\n$criteriaX = new \\tests\\TimeDatum();\n$criteriaX-\u003edata = 5;\n$criteriaX-\u003ecloseData = array(4, 6);\n```\n\n```php\n$criteriaY = new \\tests\\RoomDatum();\n$criteriaY-\u003edata = 93;\n$criteriaY-\u003ecloseData = array(92, 94);\n```\n\n```$criteriaY-\u003edata``` is what exactly you want to search and ```$criteriaY-\u003ecloseData```\nis acceptable if the data not found in the XY dimensions.\n\n**Driver**\n\n```php\n$timetable = new \\timetables\\TimetableDriver();\n```\n\n**Dimensions**\n\nThis example create a 900 length size random **TimeDatum** with range value from 0 to 100. \n\n```php\n$dimenX = new timetables\\cartesius\\Dimensions();\nfor ($i = 0; $i \u003c 900; $i++) {\n    $data = new \\tests\\TimeDatum();\n    $data-\u003edata = rand(0, 100);\n    $timetable-\u003eaddDimenX($data);\n}\n```\n\nThis example create a 100 length size random **RoomDatum** with range value from 0 to 100.\n\n```php\n$dimenY = new timetables\\cartesius\\Dimensions();\nfor ($i = 0; $i \u003c 500; $i++) {\n    $data = new \\tests\\RoomDatum();\n    $data-\u003edata = rand(0, 100);\n    $timetable-\u003eaddDimenY($data);\n}\n```\n\n**Results**\n\nAlgorithm will find a match **TimeDatum** with value 5 and **RoomDatum** with value 93.\n\n```php\n$result = $timetable-\u003esetCriteriaX($criteriaX)-\u003esetCriteriaY($criteriaY)-\u003eCalculateTimeTable();\n```\n\nAnd result from calculation:\n\n```php\narray(6) {\n  [\"BestX\"]=\u003e\n  int(893)\n  [\"BestY\"]=\u003e\n  int(83)\n  [\"Criteria\"]=\u003e\n  array(2) {\n    [\"X\"]=\u003e\n    int(5)\n    [\"Y\"]=\u003e\n    int(93)\n  }\n  [\"Result\"]=\u003e\n  array(2) {\n    [\"X\"]=\u003e\n    int(5)\n    [\"Y\"]=\u003e\n    int(93)\n  }\n  [\"Iteration\"]=\u003e\n  int(13812)\n  [\"Remark\"]=\u003e\n  string(5) \"CLEAR\"\n}\n```\n\n### Calculation\n\nTo create custom comparison rules, you can implement custom classes and *extends* it to **Datum**\n\n```php\nclass CustomRoomDatum extends Datum\n```\n\nand implements **CalculateFits** function.\n\n```php\npublic function CalculateFits(Datum $comparator)\n{\n    //simple comparison logic\n    if ($comparator-\u003edata === $this-\u003edata) {\n        return Datum::EQUALS;\n    } else if (in_array($this-\u003edata, $comparator-\u003ecloseData)) {\n        return Datum::CLOSE;\n    }\n    return Datum::NOT_MATCH;\n}\n```\n\n* ```$comparator-\u003edata``` is your criteria passed from function parameter\n* ```$this-\u003edata``` is primary usage for comparison and populated from the **Dimensions**\n\nThen return a constant provided:\n\n* ```Datum::EQUALS``` if data is match\n* ```Datum::CLOSE``` if data close matched\n* ```Datum::NOT_MATCH``` if data not match","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvelliz%2Ftimetables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvelliz%2Ftimetables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvelliz%2Ftimetables/lists"}