velliz/timetables 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

velliz/timetables

最新稳定版本:0.1.0

Composer 安装命令:

composer require velliz/timetables

包简介

Timetable algorithm implemented with 2 dimensional cartesius diagram

README 文档

README

Timetable algorithm implemented with 2 dimensional cartesius diagram.

Install

composer require velliz/timetables

Usage

Criteria

Instance a criteria for X and Y dimensions with provided example. You can have your customized TimeDatum and RoomDatum class with extending it to Datum abstraction.

$criteriaX = new \tests\TimeDatum();
$criteriaX->data = 5;
$criteriaX->closeData = array(4, 6);
$criteriaY = new \tests\RoomDatum();
$criteriaY->data = 93;
$criteriaY->closeData = array(92, 94);

$criteriaY->data is what exactly you want to search and $criteriaY->closeData is acceptable if the data not found in the XY dimensions.

Driver

$timetable = new \timetables\TimetableDriver();

Dimensions

This example create a 900 length size random TimeDatum with range value from 0 to 100.

$dimenX = new timetables\cartesius\Dimensions();
for ($i = 0; $i < 900; $i++) {
    $data = new \tests\TimeDatum();
    $data->data = rand(0, 100);
    $timetable->addDimenX($data);
}

This example create a 100 length size random RoomDatum with range value from 0 to 100.

$dimenY = new timetables\cartesius\Dimensions();
for ($i = 0; $i < 500; $i++) {
    $data = new \tests\RoomDatum();
    $data->data = rand(0, 100);
    $timetable->addDimenY($data);
}

Results

Algorithm will find a match TimeDatum with value 5 and RoomDatum with value 93.

$result = $timetable->setCriteriaX($criteriaX)->setCriteriaY($criteriaY)->CalculateTimeTable();

And result from calculation:

array(6) {
  ["BestX"]=>
  int(893)
  ["BestY"]=>
  int(83)
  ["Criteria"]=>
  array(2) {
    ["X"]=>
    int(5)
    ["Y"]=>
    int(93)
  }
  ["Result"]=>
  array(2) {
    ["X"]=>
    int(5)
    ["Y"]=>
    int(93)
  }
  ["Iteration"]=>
  int(13812)
  ["Remark"]=>
  string(5) "CLEAR"
}

Calculation

To create custom comparison rules, you can implement custom classes and extends it to Datum

class CustomRoomDatum extends Datum

and implements CalculateFits function.

public function CalculateFits(Datum $comparator)
{
    //simple comparison logic
    if ($comparator->data === $this->data) {
        return Datum::EQUALS;
    } else if (in_array($this->data, $comparator->closeData)) {
        return Datum::CLOSE;
    }
    return Datum::NOT_MATCH;
}
  • $comparator->data is your criteria passed from function parameter
  • $this->data is primary usage for comparison and populated from the Dimensions

Then return a constant provided:

  • Datum::EQUALS if data is match
  • Datum::CLOSE if data close matched
  • Datum::NOT_MATCH if data not match

统计信息

  • 总下载量: 649
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-11-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固