Пример #1
0
 /**
  * Constructor of the realistic domain.
  *
  * @return  void
  */
 protected function construct()
 {
     parent::construct();
     $this->adjustLength();
     return;
 }
Пример #2
0
 /**
  * Sample a new value.
  *
  * @param   \Hoa\Math\Sampler  $sampler    Sampler.
  * @return  mixed
  * @throws  \Hoa\Realdom\Exception
  */
 public function sample(Math\Sampler $sampler = null)
 {
     if (empty($this->_realdoms)) {
         throw new Exception('Cannot sample because the disjunction is empty.', 3);
     }
     if (null === $sampler && null === ($sampler = Realdom::getDefaultSampler())) {
         throw new Exception('No sampler set. Please, use the %s::setDefaultSampler() ' . 'method.', 4, __NAMESPACE__);
     }
     $m = count($this->_realdoms) - 1;
     $i = $sampler->getInteger(0, $m);
     $this->_chosenRealdom = $this->_realdoms[$i];
     return $this->_chosenRealdom->sample($sampler);
 }