PHP code example of velliz / timetables
1. Go to this page and download the library: Download velliz/timetables library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
velliz / timetables example snippets
$criteriaX = new \tests\TimeDatum();
$criteriaX->data = 5;
$criteriaX->closeData = array(4, 6);
$criteriaY = new \tests\RoomDatum();
$criteriaY->data = 93;
$criteriaY->closeData = array(92, 94);
$timetable = new \timetables\TimetableDriver();
$dimenX = new timetables\cartesius\Dimensions();
for ($i = 0; $i < 900; $i++) {
$data = new \tests\TimeDatum();
$data->data = rand(0, 100);
$timetable->addDimenX($data);
}
$dimenY = new timetables\cartesius\Dimensions();
for ($i = 0; $i < 500; $i++) {
$data = new \tests\RoomDatum();
$data->data = rand(0, 100);
$timetable->addDimenY($data);
}
$result = $timetable->setCriteriaX($criteriaX)->setCriteriaY($criteriaY)->CalculateTimeTable();
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"
}
class CustomRoomDatum extends Datum
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;
}
$this->data