MCordingley\Regression\Algorithm\GradientDescent\StoppingCriteria\MaxTime::converged PHP Method

converged() public method

public converged ( array $gradient, array $coefficients ) : boolean
$gradient array
$coefficients array
return boolean
    public function converged(array $gradient, array $coefficients) : bool
    {
        $time = time();
        if (!$this->startTime) {
            $this->startTime = $time;
        }
        $elapsed = $time - $this->startTime;
        return $elapsed >= $this->seconds;
    }

Usage Example

Exemplo n.º 1
0
 public function testConverged()
 {
     $criteria = new MaxTime(1);
     static::assertFalse($criteria->converged([], []));
     sleep(2);
     static::assertTrue($criteria->converged([], []));
 }