Fix dockblocks and minor bugs

This commit is contained in:
Dennis Eichhorn 2016-12-22 21:16:05 +01:00
parent 746130671b
commit 777f084a39
86 changed files with 1279 additions and 291 deletions

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com
*/
namespace phpOMS\Algorithm\Knappsack;
use phpOMS\Algorithm\AlgorithmType;
/**
* Knappsack algorithm implementations

View File

@ -39,7 +39,7 @@ abstract class SettingsAbstract implements OptionsInterface
/**
* Cache manager (pool).
*
* @var \phpOMS\DataStorage\Cache\Pool
* @var \phpOMS\DataStorage\Cache\CachePool
* @since 1.0.0
*/
protected $cache = null;

View File

@ -1146,7 +1146,7 @@ class DataMapperAbstract implements DataMapperInterface
{
$query = new Builder(self::$db);
$query->prefix(self::$db->getPrefix())
->random(static::$primaryKey)
->random(static::$primaryField)
->from(static::$table)
->limit($amount);

View File

@ -126,7 +126,7 @@ class L11nManager
public function loadLanguageFromFile(string $language, string $from, string $file) /* : void */
{
$lang = [];
if (file_exists(file)) {
if (file_exists($file)) {
/** @noinspection PhpIncludeInspection */
$lang = include $file;
}

View File

@ -143,8 +143,6 @@ class Localization
/**
* Constructor.
*
* @param L11nManager $l11nManager Localization manager
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Finance\Forecasting;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class AR
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Finance\Forecasting;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class ARCH
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Finance\Forecasting;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class ARFIMA
{

View File

@ -1,13 +1,34 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
namespace phpOMS\Math\Finance\Forecasting;
use phpOMS\Math\Statistic\Average;
class ARIMA
{
private $data = [];
private $order = 0;
public function __construct(array $data, int $order = 12)
{
$this->data = $data;
$this->order = $order;
if ($order !== 12 && $order !== 4) {
throw new \Exceptions('ARIMA only supports quarterly and monthly decomposition');
throw new \Exception('ARIMA only supports quarterly and monthly decomposition');
}
}
@ -67,7 +88,7 @@ class ARIMA
private function removeOutliers(array $data, float $deviation = 0.5) : array
{
$avg = AVerage::arithmeticMean($data);
$avg = Average::arithmeticMean($data);
foreach ($data as $key => $value) {
if ($value / $avg - 1 > $deviation) {

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Finance\Forecasting;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class ARMA
{

View File

@ -1,19 +1,96 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
use phpOMS\Math\Statistic\Average;
/**
* Classical decomposition class.
*
* This can be used to simplify time series patterns for forecasts.
*
* @category Framework
* @package phpOMS\Math\Finance\Forecasting
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @see https://www.otexts.org/fpp/6/1
* @since 1.0.0
*/
class ClassicalDecomposition
{
/**
* Decomposition mode.
*
* @var int
* @since 1.0.0
*/
/* public */ const ADDITIVE = 0;
/**
* Decomposition mode.
*
* @var int
* @since 1.0.0
*/
/* public */ const MULTIPLICATIVE = 1;
/**
* Decomposition mode.
*
* @var int
* @since 1.0.0
*/
private $mode = self::ADDITIVE;
/**
* Raw data.
*
* @var array
* @since 1.0.0
*/
private $data = [];
/**
* Order or seasonal period.
*
* @var int
* @since 1.0.0
*/
private $order = 0;
/**
* Raw data size.
*
* @var int
* @since 1.0.0
*/
private $dataSize = 0;
/**
* Constructor.
*
* @param array $data Historic data
* @param int $order Seasonal period (e.g. 4 = quarterly, 12 = monthly, 7 = weekly pattern in daily data)
* @param int $mode Decomposition mode
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function __construct(array $data, int $order, int $mode = self::ADDITIVE)
{
$this->mode = $mode;
@ -23,12 +100,20 @@ class ClassicalDecomposition
$this->dataSize = count($data);
}
/**
* Get decomposition.
*
* @return array Returns an array containing the trend cycle component, detrended series, seasonal component and remainder component.
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getDecomposition() : array
{
$trendCycleComponent = self::computeTrendCycle($this->data, $this->order);
$detrendedSeries = self::computeDetrendedSeries($this->data, $trendCycleComponent, $this->mode);
$seasonalComponent = $this->computeSeasonalComponent($detrendedSeries, $this->order);
$remainderComponent = $this->computeRemainderComponent($trendCycleComponent, $seasonalComponent);
$remainderComponent = self::computeRemainderComponent($this->data, $trendCycleComponent, $seasonalComponent, $this->mode);
return [
'trendCycleComponent' => $trendCycleComponent,
@ -38,13 +123,36 @@ class ClassicalDecomposition
];
}
/**
* Calculate trend cycle
*
* @param array $data Data to analyze
* @param int $order Seasonal period (e.g. 4 = quarterly, 12 = monthly, 7 = weekly pattern in daily data)
*
* @return array Total moving average 2 x m-MA
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function computeTrendCycle(array $data, int $order) : array
{
$mMA = Average::totalMovingAverage($data, $order, null, true);
return $order % 2 === 0 ? Average::totalMovingAverage($mMA, 2, null, true) : $mMA;
return $order % 2 === 0 ? Average::totalMovingAverage($mMA, $order, null, true) : $mMA;
}
/**
* Calculate detrended series
*
* @param array $data Data to analyze
* @param array $trendCycleComponent Trend cycle component
* @param int $mode Detrend mode
*
* @return array Detrended series / seasonal normalized data
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function computeDetrendedSeries(array $data, array $trendCycleComponent, int $mode) : array
{
$detrended = [];
@ -59,23 +167,46 @@ class ClassicalDecomposition
}
/**
* Moving average can't start at index 0 since it needs to go m indices back for average -> can only start at m
* Calculate the data start point for the decomposition
*
* By using averaging methods some initial data get's incorporated into the average which reduces the data points.
*
* @param int $dataSize Original data size
* @param int $trendCycleComponents Trend cycle component size
*
* @return int New data start index
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function getStartOfDecomposition(int $dataSize, int $trendCycleComponents) : int
{
return ($dataSize - $trendCycleComponents) / 2;
}
private function computeSeasonalComponent() : array
/**
* Calculate the seasonal component
*
* Average of the detrended values for every month, quarter, day etc.
*
* @param array $detrendedSeries Detrended series
* @param int $order Seasonal period (e.g. 4 = quarterly, 12 = monthly, 7 = weekly pattern in daily data)
*
* @return array
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
private function computeSeasonalComponent(array $detrendedSeries, int $order) : array
{
$seasonalComponent = [];
$count = count($this->data);
$count = count($detrendedSeries);
for ($i = 0; $i < $this->dataSize; $i++) {
for ($i = 0; $i < $order; $i++) {
$temp = [];
for ($j = $i * $this->order; $j < $count; $j += $this->order) {
$temp[] = $this->data[$j];
for ($j = $i; $j < $count; $j += $order) {
$temp[] = $detrendedSeries[$j];
}
$seasonalComponent[] = Average::arithmeticMean($temp);
@ -84,15 +215,29 @@ class ClassicalDecomposition
return $seasonalComponent;
}
public static function computeRemainderComponent(array $trendCycleComponent, array $seasonalComponent) : array
/**
* Calculate the remainder component or error
*
* @param array $data Raw data
* @param array $trendCycleComponent Trend cycle component
* @param array $seasonalComponent Seasonal component
* @param int $mode Detrend mode
*
* @return array All remainders or absolute errors
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function computeRemainderComponent(array $data, array $trendCycleComponent, array $seasonalComponent, int $mode = self::ADDITIVE) : array
{
$dataSize = count($data);
$remainderComponent = [];
$count = count($trendCycleComponent);
$start = self::getStartOfDecomposition($this->dataSize, $count);
$start = self::getStartOfDecomposition($dataSize, $count);
$seasons = count($seasonalComponent);
for ($i = 0; $i < $count; $i++) {
$remainderComponent[] = $this->mode === self::ADDITIVE ? $this->data[$start + $i] - $trendCycleComponent[$i] - $seasonalComponent[$i % $seasons] : $this->data[$start + $i] / ($trendCycleComponent[$i] * $seasonalComponent[$i % $seasons]);
$remainderComponent[] = $mode === self::ADDITIVE ? $data[$start + $i] - $trendCycleComponent[$i] - $seasonalComponent[$i % $seasons] : $data[$start + $i] / ($trendCycleComponent[$i] * $seasonalComponent[$i % $seasons]);
}
return $remainderComponent;

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Finance\Forecasting;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class ExponentialSmoothing
{

View File

@ -1,8 +1,22 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
namespace phpOMS\Math\Finance\Forecasting;
use phpOMS\Math\Finance\Forecasting\SmoothingType;
use phpOMS\Math\Statistic\Average;
use phpOMS\Math\Statistic\Forecast\Error;
class Brown
{
@ -19,10 +33,10 @@ class Brown
private $mae = 0.0;
private $sse = 0.0;
public function __construct(array $data, int $cycle = 0)
{
$this->data = $data;
$this->data = $data;
$this->cycle = $cycle;
}
@ -33,7 +47,7 @@ class Brown
public function getRMSE() : float
{
return $this->getRMSE;
return $this->rmse;
}
public function getMSE() : float
@ -58,13 +72,13 @@ class Brown
public function getForecast(int $future = 1, int $smoothing = SmoothingType::CENTERED_MOVING_AVERAGE) : array
{
$trendCycle = $this->getTrendCycle($this->$cycle);
$seasonality = $this->getSeasonality($trendCycle);
$seasonalityIndexMap = $this->generateSeasonalityMap($this->cycle, $seasonality);
$trendCycle = $this->getTrendCycle($this->cycle);
$seasonality = $this->getSeasonality($trendCycle);
$seasonalityIndexMap = $this->generateSeasonalityMap($this->cycle, $seasonality);
$adjustedSeasonalityIndexMap = $this->generateAdjustedSeasonalityMap($this->cycle, $seasonalityIndexMap);
$seasonalIndex = $this->getSeasonalIndex($this->cycle, $adjustedSeasonalityIndexMap);
$adjustedData = $this->getAdjustedData($this->cycle, $seasonalIndex);
$optimizedForecast = $this->getOptimizedForecast($future, $adjustedData);
$seasonalIndex = $this->getSeasonalIndex($this->cycle, $adjustedSeasonalityIndexMap);
$adjustedData = $this->getAdjustedData($this->cycle, $seasonalIndex);
$optimizedForecast = $this->getOptimizedForecast($future, $adjustedData);
return $this->getReseasonalized($optimizedForecast, $seasonalIndex);
}
@ -74,8 +88,8 @@ class Brown
$centeredMovingAverage = [];
$length = count($this->data);
for($i = $cycle; $i < $length - $cycle; $i++) {
$centeredMovingAverage[$i] = Average::arithmetic(array_slice($this->data, $i - $cycle, $cycle));
for ($i = $cycle; $i < $length - $cycle; $i++) {
$centeredMovingAverage[$i] = Average::arithmeticMean(array_slice($this->data, $i - $cycle, $cycle));
}
return $centeredMovingAverage;
@ -84,21 +98,21 @@ class Brown
private function getSeasonality(array $trendCycle) : array
{
$seasonality = [];
foreach($trendCycle as $key => $value) {
$seasonality[$key] = $this->data[$key]/$value;
foreach ($trendCycle as $key => $value) {
$seasonality[$key] = $this->data[$key] / $value;
}
return $seasonality;
}
private function generateSeasonality(int $cycle, array $seasonality) : array
private function generateSeasonalityMap(int $cycle, array $seasonality) : array
{
$map = [];
foreach($seasonality as $key => $value) {
foreach ($seasonality as $key => $value) {
$map[$key % $cycle][] = $value;
}
foreach($map as $key => $value) {
foreach ($map as $key => $value) {
$map[$key] = Average::arithmeticMean($value);
}
@ -109,7 +123,7 @@ class Brown
{
$total = array_sum($seasonality);
foreach($seasonality as $key => $value) {
foreach ($seasonality as $key => $value) {
$seasonality[$key] = $cycle * $value / $total;
}
@ -120,7 +134,7 @@ class Brown
{
$index = [];
foreach($this->data as $key => $value) {
foreach ($this->data as $key => $value) {
$index[$key] = $seasonalityMap[$key % $cycle];
}
@ -131,7 +145,7 @@ class Brown
{
$adjusted = [];
foreach($this->data as $key => $value) {
foreach ($this->data as $key => $value) {
$adjusted[$key] = $this->data[$key] / $seasonalIndex[$key];
}
@ -141,7 +155,7 @@ class Brown
private function forecast(int $future, float $alpha, array $data, array &$error) : array
{
$forecast = [];
$length = count($data) + $future;
$length = count($data) + $future;
$forecast[0] = $data[0];
$forecast[1] = $data[1];
@ -149,46 +163,46 @@ class Brown
$error[0] = 0;
$error[1] = $data[1] - $forecast[1];
for($i = 2; $i < $length; $i++) {
$forecast[$i] = 2 * $data[$i-1] - $data[$i - 2] - 2 * (1 - $alpha) * $error[$i-1] + pow(1-$alpah, 2) * $error[$i - 2];
$error[$i] = $data[$i] - $forecast[$i];
for ($i = 2; $i < $length; $i++) {
$forecast[$i] = 2 * $data[$i - 1] - $data[$i - 2] - 2 * (1 - $alpha) * $error[$i - 1] + pow(1 - $alpha, 2) * $error[$i - 2];
$error[$i] = $data[$i] - $forecast[$i];
}
return $forecast;
}
}
private function getOptimizedForecast(int $future, array $adjustedData) : array
{
$rmse = 0;
$alpha = 0.00;
$forecast = [];
$this->rmse = 0;
$alpha = 0.00;
$forecast = [];
$error = [];
while($alpha < 1) {
$error = [];
while ($alpha < 1) {
$tempForecast = $this->forecast($future, $alpha, $adjustedData, $error);
$alpha += 0.01;
$tempRMSE = Error::getRootMeanSquaredError($error);
if($tempRMSE < $this->rmse) {
if ($tempRMSE < $this->rmse) {
$this->rmse = $tempRMSE;
$forecast = $tempForecast;
$forecast = $tempForecast;
}
}
$this->errors = $error;
$this->mse = Error::getMeanSquaredError($error);
$this->mae = Error::getMeanAbsoluteError($error);
$this->sse = Error::getSumSquaredError($error);
$this->mse = Error::getMeanSquaredError($error);
$this->mae = Error::getMeanAbsoulteError($error);
$this->sse = Error::getSumSquaredError($error);
return $forecast;
}
private function getReseasonalized(array $forecast, array $seasonalIndex) : array
private function getReseasonalized(array $forecast, array $seasonalIndex) : array
{
$reSeasonalized = [];
foreach($forecast as $key => $value) {
foreach ($forecast as $key => $value) {
$reSeasonalized[$key] = $value * $seasonalIndex[$key];
}

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Finance\Forecasting;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class GARCH
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Finance\Forecasting;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class MA
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Finance\Forecasting;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class NAR
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Finance\Forecasting;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class NMA
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Finance\Forecasting;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class SARIMA
{

View File

@ -231,7 +231,7 @@ class Functions
*
* @param int $a Value to test
*
* @return int
* @return bool
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
@ -250,7 +250,7 @@ class Functions
*
* @param int $a Value to test
*
* @return int
* @return bool
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
@ -270,7 +270,9 @@ class Functions
* @example The relative fiscal month (August) in a company where the fiscal year starts in July.
* @example 2 = getRelativeDegree(8, 12, 7);
*
* @param int $a Value to test
* @param mixed $value Value to get degree
* @param mixed $length Circle size
* @param mixed $start Start value
*
* @return int
*

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\Graph;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Graph;
class Dijkstra
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\Graph;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Graph;
class FloydWarshall
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\Knappsack;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Knappsack;
class Backpack
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\Knappsack;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Knappsack;
class BruteForce
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\Knappsack;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Knappsack;
class GA
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\Knappsack;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Knappsack;
class Item
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\Knappsack;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Knappsack;
class ItemPool
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\Knappsack;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Knappsack;
class Population
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\ShiftScheduling;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\ShiftScheduling;
class BruteForce
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\ShiftScheduling;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\ShiftScheduling;
class GA
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\ShiftScheduling;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\ShiftScheduling;
class Population
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\ShiftScheduling;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\ShiftScheduling;
class Workday
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\ShiftScheduling;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\ShiftScheduling;
class Worker
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Optimization\ShiftScheduling;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\ShiftScheduling;
class WorkerPool
{

View File

@ -28,6 +28,13 @@ namespace phpOMS\Math\Shape\D2;
*/
class Polygon implements D2ShapeInterface
{
/**
* Epsilon for float comparison.
*
* @var float
* @since 1.0.0
*/
/* public */ const EPSILON = 0.00001;
/**
* Coordinates.
@ -123,28 +130,44 @@ class Polygon implements D2ShapeInterface
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function pointInPolygon(array $point) : int
public function pointInPolygon(array $point) : int
{
$length = count($this->coord);
return self::isPointInPolygon($point, $this->coord);
}
/**
* Point polygon relative position
*
* @param array $point Point location
* @param array $polygon Polygon definition
*
* @return int
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function isPointInPolygon(array $point, array $polygon) : int
{
$length = count($polygon);
// Polygon has to start and end with same point
if ($this->coord[0]['x'] !== $this->coord[$length - 1]['x'] || $this->coord[0]['y'] !== $this->coord[$length - 1]['y']) {
$this->coord[] = $this->coord[0];
if ($polygon[0]['x'] !== $polygon[$length - 1]['x'] || $polygon[0]['y'] !== $polygon[$length - 1]['y']) {
$polygon[] = $polygon[0];
}
// On vertex?
if (self::isOnVertex($point, $this->coord)) {
if (self::isOnVertex($point, $polygon)) {
return 0;
}
// Inside or ontop?
$countIntersect = 0;
$this->coord_count = count($this->coord);
$polygon_count = count($polygon);
// todo: return based on highest possibility not by first match
for ($i = 1; $i < $this->coord_count; $i++) {
$vertex1 = $this->coord[$i - 1];
$vertex2 = $this->coord[$i];
for ($i = 1; $i < $polygon_count; $i++) {
$vertex1 = $polygon[$i - 1];
$vertex2 = $polygon[$i];
if (abs($vertex1['y'] - $vertex2['y']) < self::EPSILON && abs($vertex1['y'] - $point['y']) < self::EPSILON && $point['x'] > min($vertex1['x'], $vertex2['x']) && $point['x'] < max($vertex1['x'], $vertex2['x'])) {
return 0; // boundary
@ -180,9 +203,25 @@ class Polygon implements D2ShapeInterface
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
private static function isOnVertex(array $point) : bool
public function onVertex(array $point) : bool
{
foreach ($this->coord as $vertex) {
return self::isOnVertex($point, $this->coord);
}
/**
* Is point on vertex?
*
* @param array $point Point location
* @param array $polygon Polygon definition
*
* @return bool
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
private static function isOnVertex(array $point, array $polygon) : bool
{
foreach ($polygon as $vertex) {
if (abs($point['x'] - $vertex['x']) < self::EPSILON && abs($point['y'] - $vertex['y']) < self::EPSILON) {
return true;
}

View File

@ -1,5 +1,19 @@
<?php
namespace phpOMS\Math\Shape\D2;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Shape\D2;
class Quadrilateral implements D2ShapeInterface
{

View File

@ -1,5 +1,19 @@
<?php
namespace phpOMS\Math\Shape\D3;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Shape\D3;
class Prism implements D3ShapeInterface
{

View File

@ -19,7 +19,7 @@ namespace phpOMS\Math\Shape\D3;
* Sphere shape.
*
* @category Framework
* @package phpOMS\DataStorage\Database
* @package phpOMS\Math\Shape
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
@ -28,7 +28,22 @@ namespace phpOMS\Math\Shape\D3;
*/
class Sphere implements D3ShapeInterface
{
/**
* Radius.
*
* @var float
* @since 1.0.0
*/
private $radius = 0.0;
/**
* Constructor.
*
* @param float $radius Sphere radius
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function __construct(float $radius)
{
$this->radius = $radius;
@ -68,11 +83,31 @@ class Sphere implements D3ShapeInterface
return $angle * $radius;
}
/**
* Create sphere by radius
*
* @param float $r Radius
*
* @return Sphere
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function byRadius(float $r) : Sphere
{
return new self($r);
}
/**
* Create sphere by volume
*
* @param float $v Sphere volume
*
* @return Sphere
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function byVolume(float $v) : Sphere
{
return new self(self::getRadiusByVolume($v));
@ -81,25 +116,35 @@ class Sphere implements D3ShapeInterface
/**
* Radius
*
* @param float $V Volume
* @param float $v Volume
*
* @return float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function getRadiusByVolume(float $V) : float
public static function getRadiusByVolume(float $v) : float
{
return pow($V * 3 / (4 * pi()), 1 / 3);
return pow($v * 3 / (4 * pi()), 1 / 3);
}
/**
* Create sphere by surface
*
* @param float $s Sphere surface
*
* @return Sphere
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function bySurface(float $s) : Sphere
{
return new self(self::getRadiusBySurface($s));
}
/**
* Radius
* Get radius by sphere
*
* @param float $S Surface
*
@ -113,13 +158,21 @@ class Sphere implements D3ShapeInterface
return sqrt($S / (4 * pi()));
}
/**
* Get volume
*
* @return float Sphere volume
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getVolume() : float
{
return self::getVolumeByRadius($this->radius);
}
/**
* Volume
* Get sphere volume by radius
*
* @param float $r Radius
*
@ -133,11 +186,27 @@ class Sphere implements D3ShapeInterface
return 4 / 3 * pi() * $r ** 3;
}
/**
* Get radius
*
* @return float Sphere radius
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getRadius() : float
{
return $this->radius;
}
/**
* Get surface
*
* @return float Sphere surface
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getSurface() : float
{
return self::getSurfaceByRadius($this->radius);

View File

@ -20,7 +20,7 @@ namespace phpOMS\Math\Statistic;
* Average class.
*
* @category Framework
* @package phpOMS\DataStorage\Database
* @package phpOMS\Math\Statistic
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
@ -61,9 +61,19 @@ class Average
}
/**
* t = 3 and p = 3 means -1 0 +1, t = 4 and p = 2 means -1 0
* periods should be replaced with order than it's possible to test for even or odd m
* todo: maybe floor()?
* Moving average of dataset
*
* @param array $x Dataset
* @param int $order Periods to use for average
* @param array $weight Weight for moving average
* @param bool $symmetric Cyclic moving average
*
* @return array Moving average of data
*
* @throws \Exception
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function totalMovingAverage(array $x, int $order, array $weight = null, bool $symmetric = false) : array
{
@ -79,15 +89,15 @@ class Average
}
/**
* Moving average or order m.
* Moving average of element in dataset
*
* @param array $x Dataset
* @param int $t Current period
* @param int $periods Periods to use for average
* @param int $order Periods to use for average
* @param array $weight Weight for moving average
* @param bool $symmetric Cyclic moving average
*
* @return float
*
* @todo : allow counter i also to go into the future... required for forecast how? should be doable!
* @return float Moving average
*
* @throws \Exception
*
@ -107,7 +117,7 @@ class Average
$end = $order % 2 === 0 ? $end - 1 : $end;
$start = $t - 1 - ($periods - 2);
if (isset($weight)) {
if (!empty($weight)) {
return self::weightedAverage(array_slice($x, $start, $end - $start), array_slice($weight, $start, $end - $start));
} else {
return self::arithmeticMean(array_slice($x, $start, $end - $start));

View File

@ -16,7 +16,7 @@
namespace phpOMS\Math\Statistic\Forecast;
use phpOMS\Math\Functions;
use phpOMS\Math\Functions\Functions;
use phpOMS\Math\Statistic\Average;
use phpOMS\Math\Statistic\MeasureOfDispersion;
@ -124,6 +124,21 @@ class Error
return Average::arithmeticMean(Functions::abs($errors));
}
/**
* Get mean squared error (MSE).
*
* @param array $errors Errors
*
* @return float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function getMeanSquaredError(array $errors) : float
{
return Average::arithmeticMean(self::square($errors));
}
/**
* Get root mean squared error (RMSE).
*
@ -136,7 +151,6 @@ class Error
*/
public static function getRootMeanSquaredError(array $errors) : float
{
// sqrt(Average::getVariance($error)+pow(Average::arithmeticMean($error), 2));
return sqrt(Average::arithmeticMean(self::square($errors)));
}
@ -195,6 +209,18 @@ class Error
return $error;
}
/**
* Get R Bar Squared
*
* @param float $R R
* @param int $observations Amount of observations
* @param int $predictors Amount of predictors
*
* @return float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function getRBarSquared(float $R, int $observations, int $predictors) : float
{
return 1 - (1 - $R * ($observations - 1) / ($observations - $predictors - 1));
@ -203,6 +229,14 @@ class Error
/**
* Get Aike's information criterion (AIC)
*
* @param float $sse SSE
* @param int $observations Amount of observations
* @param int $predictors Amount of predictors
*
* @return float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function getAkaikeInformationCriterion(float $sse, int $observations, int $predictors) : float
{
@ -213,6 +247,15 @@ class Error
* Get corrected Aike's information criterion (AIC)
*
* Correction for small amount of observations
*
* @param float $aic AIC
* @param int $observations Amount of observations
* @param int $predictors Amount of predictors
*
* @return float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function getCorrectedAkaikeInformationCriterion(float $aic, int $observations, int $predictors) : float
{
@ -222,6 +265,14 @@ class Error
/**
* Get Bayesian information criterion (BIC)
*
* @param float $sse SSE
* @param int $observations Amount of observations
* @param int $predictors Amount of predictors
*
* @return float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function getSchwarzBayesianInformationCriterion(float $sse, int $observations, int $predictors) : float
{

View File

@ -18,7 +18,7 @@ namespace phpOMS\Math\Statistic\Forecast;
use phpOMS\Datatypes\Enum;
/**
* Address type enum.
* Prediction interval multiplier.
*
* @category Framework
* @package phpOMS\Datatypes

View File

@ -29,10 +29,11 @@ namespace phpOMS\Math\Statistic\Forecast;
class Forecasts
{
/**
* Get forecast interval.
* Get forecast/prediction interval.
*
* @param array $observed Dataset
* @param array $forecasted Forecasted
* @param float $forecast Forecast value
* @param float $standardDeviation Standard Deviation of forecast
* @param float $interval Forecast multiplier for prediction intervals
*
* @return array
*

View File

@ -39,7 +39,7 @@ class LevelLogRegression extends RegressionAbstract
}
for ($i = 0; $i < $c; $i++) {
$x[$i] = log($x[i]);
$x[$i] = log($x[$i]);
}
return parent::getRegression($x, $y);

View File

@ -39,7 +39,7 @@ class LogLevelRegression extends RegressionAbstract
}
for ($i = 0; $i < $c; $i++) {
$y[$i] = log($y[i]);
$y[$i] = log($y[$i]);
}
return parent::getRegression($x, $y);

View File

@ -39,8 +39,8 @@ class LogLogRegression extends RegressionAbstract
}
for ($i = 0; $i < $c; $i++) {
$x[$i] = log($x[i]);
$y[$i] = log($y[i]);
$x[$i] = log($x[$i]);
$y[$i] = log($y[$i]);
}
return parent::getRegression($x, $y);

View File

@ -1,6 +1,21 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Statistic\Forecast\Regression;
namespace phpOMS\Math\Statistic\Forecast\Regression;
use phpOMS\Math\Matrix\Matrix;
class MultipleLinearRegression
{
@ -10,14 +25,14 @@ class MultipleLinearRegression
public static function getRegression(array $x, array $y) : array
{
$X = new Matrix(count($x), count($x[0]));
$X->setArray($x);
$X->setMatrix($x);
$XT = $X->transpose();
$Y = new Matrix(count($y));
$Y->setArray($y);
$Y->setMatrix($y);
return $XT->mult($X)->inverse()->mult($XT)->mult($Y)->toArray();
return $XT->mult($X)->inverse()->mult($XT)->mult($Y)->getMatrix();
}
public static function getVariance() : float

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Statistic\Forecast\Regression;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Statistic\Forecast\Regression;
use phpOMS\Math\Statistic\Average;
use phpOMS\Math\Statistic\Forecast\ForecastIntervalMultiplier;
@ -18,6 +31,8 @@ abstract class RegressionAbstract
*
* @return array [b0 => ?, b1 => ?]
*
* @throws \Exception
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Stochastic\Distribution;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class BetaDistribution
{

View File

@ -16,7 +16,7 @@
namespace phpOMS\Math\Stochastic\Distribution;
use phpOMS\Math\Functions;
use phpOMS\Math\Functions\Functions;
/**
* Binomial distribution.

View File

@ -16,7 +16,7 @@
namespace phpOMS\Math\Stochastic\Distribution;
use phpOMS\Math\Functions;
use phpOMS\Math\Functions\Functions;
/**
* Chi squared distribution.

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Stochastic\Distribution;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class FDistribution
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Stochastic\Distribution;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class GammaDistribution
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Stochastic\Distribution;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class HypergeometricDistribution
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Stochastic\Distribution;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class LogDistribution
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Stochastic\Distribution;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class LogNormalDistribution
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Stochastic\Distribution;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class LogisticDistribution
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Stochastic\Distribution;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class ParetoDistribution
{

View File

@ -16,7 +16,7 @@
namespace phpOMS\Math\Stochastic\Distribution;
use phpOMS\Math\Functions;
use phpOMS\Math\Functions\Functions;
/**
* Well known functions class.

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Stochastic\Distribution;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class TDistribution
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Math\Stochastic\Distribution;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class WeibullDistribution
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Message\Mail;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Message\Mail;
class OAuth
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Message\Mail;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Message\Mail;
class Pop3
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Message\Mail;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Message\Mail;
class Smtp
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Message\Socket;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Message\Socket;
class Request
{

View File

@ -1,6 +1,19 @@
<?php
namespace phpOMS\Message\Socket;
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Message\Socket;
class Response
{

View File

@ -35,7 +35,7 @@ class ActivateAbstract
/**
* Deactivate module.
*
* @param Pool $dbPool Database instance
* @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info
*
* @return void
@ -68,7 +68,7 @@ class ActivateAbstract
/**
* Deactivate module in database.
*
* @param Pool $dbPool Database instance
* @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info
*
* @return void

View File

@ -35,7 +35,7 @@ class DeactivateAbstract
/**
* Deactivate module.
*
* @param Pool $dbPool Database instance
* @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info
*
* @return void
@ -68,7 +68,7 @@ class DeactivateAbstract
/**
* Deactivate module in database.
*
* @param Pool $dbPool Database instance
* @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info
*
* @return void

View File

@ -38,7 +38,7 @@ class InstallerAbstract
/**
* Register module in database.
*
* @param Pool $dbPool Database instance
* @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info
*
* @return void
@ -91,7 +91,7 @@ class InstallerAbstract
* Install module.
*
* @param string $routePath Route Path
* @param Pool $dbPool Database instance
* @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info
*
* @return void
@ -109,7 +109,7 @@ class InstallerAbstract
/**
* Activate after install.
*
* @param Pool $dbPool Database instance
* @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info
*
* @return void

View File

@ -34,7 +34,7 @@ class UninstallAbstract
/**
* Install module.
*
* @param Pool $dbPool Database instance
* @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info
*
* @return void

View File

@ -34,7 +34,7 @@ class UpdateAbstract
/**
* Install module.
*
* @param Pool $dbPool Database instance
* @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info
*
* @return void

View File

@ -271,7 +271,7 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab
/**
* Get collection that contains every n-th element.
*
* @param $int $n Every n-th element
* @param int $n Every n-th element
*
* @return Collection
*
@ -622,12 +622,16 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab
/**
* Offset to retrieve
* @link http://php.net/manual/en/arrayaccess.offsetget.php
* @param mixed $offset <p>
* The offset to retrieve.
* </p>
*
* @param mixed $offset The offset to retrieve.
*
* @return mixed Can return all value types.
* @since 5.0.0
*
* @throws \Exception
*
* @link http://php.net/manual/en/arrayaccess.offsetget.php
*
* @since 1.0.0
*/
public function offsetGet($offset)
{

View File

@ -46,7 +46,7 @@ class BinaryTree extends Tree
/**
* Get left node of a node.
*
* @param Node $node Tree node
* @param Node $base Tree node
*
* @return Node Left node
*
@ -64,7 +64,7 @@ class BinaryTree extends Tree
/**
* Get right node of a node.
*
* @param Node $node Tree node
* @param Node $base Tree node
*
* @return Node Right node
*
@ -73,7 +73,7 @@ class BinaryTree extends Tree
*/
public function getRight(Node $base)
{
$neighbors = $base->getNeighbors($base);
$neighbors = $this->getNeighbors($base);
// todo: index can be wrong, see setLeft/setRight
return $neighbors[1] ?? null;
@ -93,7 +93,7 @@ class BinaryTree extends Tree
public function setLeft(Node $base, Node $left) : BinaryTree
{
if($this->getLeft($base) === null) {
$this->addNode($base, $left);
$this->addNodeRelative($base, $left);
// todo: doesn't know that this is left
// todo: maybe need to add numerics to edges?
} else {
@ -117,7 +117,7 @@ class BinaryTree extends Tree
public function setRight(Node $base, Node $right) /* : void */
{
if($this->getRight($base) === null) {
$this->addNode($base, $right);
$this->addNodeRelative($base, $right);
// todo: doesn't know that this is right
// todo: maybe need to add numerics to edges?
} else {
@ -196,6 +196,8 @@ class BinaryTree extends Tree
*
* @param Node $node1 Tree node1
* @param Node $node2 Tree node2 (optional, can be different tree)
*
* @return bool True if tree is symmetric, false if tree is not symmetric
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>

View File

@ -54,30 +54,46 @@ class Graph
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function addNode(Node $node) : Graph
public function addNode(Node $node) : Graph
{
$this->nodes[] = $node;
$this->nodes[] = $node;
return $this;
}
return $this;
}
/**
* Set node in graph.
* Add node to graph.
*
* @param mixed $key Key of node
* @param Node $node Graph node
* @param Node $relative Relative graph node
* @param Node $node Graph node
*
* @return Graph
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setNode($key, Node $node) : Graph
public function addNodeRelative(Node $relative, Node $node) : Graph
{
$this->nodes[$key] = $node;
return $this;
}
return $this;
}
/**
* Set node in graph.
*
* @param mixed $key Key of node
* @param Node $node Graph node
*
* @return Graph
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setNode($key, Node $node) : Graph
{
$this->nodes[$key] = $node;
return $this;
}
/**
* Add edge to graph.
@ -91,28 +107,28 @@ class Graph
*/
public function addEdge(Edge $edge) : Graph
{
$this->edges[] = $edge;
$this->edges[] = $edge;
return $this;
}
return $this;
}
/**
* Set edge in graph.
*
* @param mixed $key Edge key
* @param Edge $edge Edge to set
* @param mixed $key Edge key
* @param Edge $edge Edge to set
*
* @return Graph
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setEdge($key, Edge $edge) /* : void */
public function setEdge($key, Edge $edge) /* : void */
{
$this->edges[$key] = $edge;
$this->edges[$key] = $edge;
return $this;
}
return $this;
}
/**
* Get graph node
@ -124,10 +140,23 @@ class Graph
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getNode($key) : Node
{
return $this->nodes[$key];
}
public function getNode($key) : Node
{
return $this->nodes[$key];
}
/**
* Get graph nodes
*
* @return Node[]
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getNodes() : array
{
return $this->nodes;
}
/**
* Get graph edge.
@ -139,10 +168,10 @@ class Graph
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getEdge($key) : Edge
{
return $this->edges[$key];
}
public function getEdge($key) : Edge
{
return $this->edges[$key];
}
/**
* Get all edges of a node
@ -154,17 +183,17 @@ class Graph
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getEdgesOfNode($node) : array
public function getEdgesOfNode($node) : array
{
if(!($node instanceof Node)) {
if (!($node instanceof Node)) {
$node = $this->getNode($node);
}
$edges = [];
foreach($this->edges as $edge) {
foreach ($this->edges as $edge) {
$nodes = $edge->getNodes();
if($nodes[0] === $node || $nodes[1] === $node) {
if ($nodes[0] === $node || $nodes[1] === $node) {
$edges[] = $edge;
}
}
@ -182,21 +211,21 @@ class Graph
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getNeighbors($node) : array
public function getNeighbors($node) : array
{
if(!($node instanceof Node)) {
if (!($node instanceof Node)) {
$node = $this->getNode($node);
}
$edges = $this->getEdgesOfNode($node);
$edges = $this->getEdgesOfNode($node);
$neighbors = [];
foreach($edges as $edge) {
foreach ($edges as $edge) {
$nodes = $edge->getNodes();
if($nodes[0] !== $node && $nodes[0] !== null) {
if ($nodes[0] !== $node && $nodes[0] !== null) {
$neighbors[] = $nodes[0];
} elseif($nodes[1] !== $node && $nodes[0] !== null) {
} elseif ($nodes[1] !== $node && $nodes[0] !== null) {
$neighbors[] = $nodes[1];
}
}
@ -212,7 +241,7 @@ class Graph
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getDimension() : int
public function getDimension() : int
{
// todo: implement
return 0;
@ -240,7 +269,7 @@ class Graph
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getKruskalMinimalSpanningTree() : Tree
public function getKruskalMinimalSpanningTree() : Tree
{
// todo: implement
return new Tree();
@ -254,7 +283,7 @@ class Graph
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getPrimMinimalSpanningTree() : Tree
public function getPrimMinimalSpanningTree() : Tree
{
// todo: implement
return new Tree();
@ -268,7 +297,7 @@ class Graph
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getCircle() : array
public function getCircle() : array
{
// todo: implement
}
@ -281,7 +310,7 @@ class Graph
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getFloydWarshallShortestPath() : array
public function getFloydWarshallShortestPath() : array
{
// todo: implement
}
@ -307,7 +336,7 @@ class Graph
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function depthFirstTraversal() : array
public function depthFirstTraversal() : array
{
// todo: implement
}
@ -320,7 +349,7 @@ class Graph
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function breadthFirstTraversal() : array
public function breadthFirstTraversal() : array
{
// todo: implement
}
@ -398,9 +427,9 @@ class Graph
{
$diameter = 0;
foreach($this->nodes as $node1) {
foreach($this->nodes as $node2) {
if($node1 === $node2) {
foreach ($this->nodes as $node1) {
foreach ($this->nodes as $node2) {
if ($node1 === $node2) {
continue;
}

View File

@ -231,7 +231,7 @@ class Tree extends Graph
}
$callback($node);
$neighbors = $this->getNeighbors();
$neighbors = $this->getNeighbors($node);
foreach($neighbors as $neighbor) {
// todo: get neighbors needs to return in ordered way
@ -253,7 +253,7 @@ class Tree extends Graph
return;
}
$neighbors = $this->getNeighbors();
$neighbors = $this->getNeighbors($node);
foreach($neighbors as $neighbor) {
// todo: get neighbors needs to return in ordered way

View File

@ -16,7 +16,7 @@
namespace phpOMS\Stdlib\Queue;
/**
* Router class.
* Priority queue class.
*
* @category Framework
* @package phpOMS\Stdlib
@ -45,15 +45,13 @@ class PriorityQueue implements \Countable, \Serializable
*/
private $queue = [];
private $mode = 0;
/**
* Constructor.
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function __construct($mode = '')
public function __construct()
{
}

View File

@ -397,6 +397,7 @@ class Directory extends FileAbstract implements DirectoryInterface
*/
public static function name(string $path) : string
{
// todo: name doesn' t make sense
// TODO: Implement name() method.
}

View File

@ -225,6 +225,21 @@ class File extends FileAbstract implements FileInterface
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function dirname(string $path) : string
{
return basename(dirname($path));
}
/**
* Gets the directory path of a file.
*
* @param string $path Path of the file to get the directory name for.
*
* @return string Returns the directory name of the file.
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function dirpath(string $path) : string
{
return dirname($path);
}
@ -287,11 +302,27 @@ class File extends FileAbstract implements FileInterface
return true;
}
/**
* Gets the directory name of a file.
*
* @return string Returns the directory name of the file.
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getDirName() : string
{
return basename(dirname($this->path));
}
/**
* Gets the directory path of a file.
*
* @return string Returns the directory path of the file.
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getDirPath() : string
{
return dirname($this->path);

View File

@ -227,10 +227,8 @@ class ArrayUtils
*
* Useful for parsing command line parsing
*
* @param array $data Data to convert
* @param string $delimiter Delim to use
* @param string $enclosure Enclosure to use
* @param string $escape Escape to use
* @param string $id Id to find
* @param array $args CLI command list
*
* @return string
*
@ -251,7 +249,7 @@ class ArrayUtils
*
* Reduces multi dimensional array to one dimensional array. Flatten tries to maintain the index as far as possible.
*
* @param array $array Multi dimensional array to flatten
* @param array $array Multi dimensional array to flatten
*
* @return array
*
@ -278,18 +276,25 @@ class ArrayUtils
}
/**
* todo: what did i smoke? what is this?
* Sum of array elements
*
* @param array $array Array to sum
* @param int $start Start index
* @param int $count Amount of elements to sum
*
* @return int|float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function arraySum(array $array, int $start = 0, int $count = 0)
{
$count = $count === 0 ? count($array) : $count;
$sum = 0.0;
$sum = 0;
$array = array_values($array);
for ($i = $start; $i <= $count - 1; $i++) {
if (!isset($array[$i])) {
continue;
}
$sum += $array[$i];
}

View File

@ -124,7 +124,8 @@ abstract class C128Abstract
* Constructor
*
* @param string $content Content to encrypt
* @param int $size Barcode height
* @param int $width Barcode width
* @param int $height Barcode height
* @param int $orientation Orientation of the barcode
*
* @todo : add mirror parameter
@ -142,7 +143,7 @@ abstract class C128Abstract
/**
* Set barcode dimensions
*
* @param int $width Barcode width
* @param int $width Barcode width
* @param int $height Barcode height
*
* @since 1.0.0
@ -158,7 +159,7 @@ abstract class C128Abstract
throw new \OutOfBoundsException($height);
}
$this->dimension['width'] = $width;
$this->dimension['width'] = $width;
$this->dimension['height'] = $height;
}

View File

@ -45,12 +45,12 @@ class HIBCC
public function setIdentifier(string $identifier) /* : void */
{
$this->identifer = $identifier;
$this->identifier = $identifier;
}
public function getIdentifier() : string
{
return $this->identifer;
return $this->identifier;
}
public function setProductId(string $id) /* : void */
@ -88,7 +88,7 @@ class HIBCC
$this->expirationDate = $date;
}
public function getExpirationDate() : \Datetime
public function getExpirationDate() : \DateTime
{
return $this->expirationDate;
}

View File

@ -31,8 +31,8 @@ class Schedule extends TaskAbstract implements \Serializable
/**
* Constructor.
*
* @param Interval $interval Interval
* @param string $cmd Command to execute
* @param string $name Schedule name
* @param string $cmd Command to execute
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com
*/
namespace phpOMS\Utils\TaskSchedule;
use phpOMS\System\File\PathException;
/**
* Scheduler abstract.

View File

@ -35,7 +35,7 @@ final class SchedulerFactory
/**
* Create scheduler instance.
*
* @return ScheduleInterface
* @return SchedulerAbstract
*
* @throws \Exception
*

View File

@ -195,7 +195,7 @@ abstract class TaskAbstract
*/
public function setNextRunTime(\DateTime $nextRunTime) /* : void */
{
$this->nextRuntime = $nextRunTime;
$this->nextRunTime = $nextRunTime;
}
/**

View File

@ -38,7 +38,7 @@ final class TaskFactory
* @param string $id Task id
* @param string $cmd Command to run
*
* @return TaskInterface
* @return TaskAbstract
*
* @throws \Exception
*

View File

@ -43,7 +43,7 @@ class TaskScheduler extends SchedulerAbstract
*
* @param string $cmd Command to run
*
* @return array
* @return string
*
* @throws \Exception
*
@ -114,7 +114,7 @@ class TaskScheduler extends SchedulerAbstract
}
if(DateTime::isValid($jobData[5])) {
$job->setLastRunTime(new \DateTime($jobData[5]));
$job->setLastRuntime(new \DateTime($jobData[5]));
}
$job->setAuthor($jobData[7]);
@ -171,7 +171,7 @@ class TaskScheduler extends SchedulerAbstract
public function getAllByName(string $name, bool $exact = true) : array
{
if($exact) {
$lines = $this->run('/query /v /fo CSV /tn ' . escapeshellarg($name));
$lines = explode("\n", $this->normalize($this->run('/query /v /fo CSV /tn ' . escapeshellarg($name))));
unset($lines[0]);
$jobs = [];

View File

@ -197,23 +197,23 @@ class View extends ViewAbstract
}
/**
* @return Request
* @return RequestAbstract
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getRequest() : Request
public function getRequest() : RequestAbstract
{
return $this->request;
}
/**
* @return Response
* @return ResponseAbstract
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getResponse() : Response
public function getResponse() : ResponseAbstract
{
return $this->response;
}