Hoa central
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Hoa\Realdom\Boundinteger Class Reference
Inheritance diagram for Hoa\Realdom\Boundinteger:

Public Member Functions

 getLowerBound ()
 
 getUpperBound ()
 
 reduceRightTo ($value)
 
 reduceLeftTo ($value)
 
 discredit ($value)
 
 getSize ()
 
 getIterator ()
 
- Public Member Functions inherited from Hoa\Realdom\Realdom
 __construct ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 getArguments ()
 
 count ()
 
 getName ()
 
 setSampler (Math\Sampler $sampler)
 
 getSampler ()
 
 getValue ()
 
 reset ()
 
 predicate ($q)
 
 sample (Math\Sampler $sampler=null)
 
 intersectWith (Realdom $realdom)
 
 setConstraints (Array &$constraints)
 
 propagateConstraints ($type, $index)
 
 is ($qualifier)
 
 setHolder (IRealdom\Holder $holder)
 
 getHolder ()
 
 setPraspelVisitor (Visitor\Visit $visitor)
 
 getPraspelVisitor ()
 
 accept (Visitor\Visit $visitor, &$handle=null, $eldnah=null)
 
- Public Member Functions inherited from Hoa\Visitor\Element
 accept (Visit $visitor, &$handle=null, $eldnah=null)
 

Public Attributes

const NAME = 'boundinteger'
 
- Public Attributes inherited from Hoa\Realdom\Integer
const NAME = 'integer'
 
- Public Attributes inherited from Hoa\Realdom\Realdom
const NAME = '(null)'
 

Protected Member Functions

 construct ()
 
 _predicate ($q)
 
 _sample (Math\Sampler $sampler)
 
- Protected Member Functions inherited from Hoa\Realdom\Integer
 _predicate ($q)
 
 _sample (Math\Sampler $sampler)
 
- Protected Member Functions inherited from Hoa\Realdom\Realdom
 construct ()
 
 setValue ($sampled)
 
 resetArguments ()
 
 _predicate ($q)
 
 _sample (Math\Sampler $sampler)
 
getConstraints ()
 
 _propagateConstraints ($type, $index, Array &$constraints)
 

Protected Attributes

 $_arguments
 
 $_discredited = []
 
- Protected Attributes inherited from Hoa\Realdom\Realdom
 $_arguments = null
 
 $arguments = null
 
 $__sampler = null
 
 $_value = null
 
 $_constraints = null
 
 $_holder = null
 
 $_constructed = false
 
 $_praspelVisitor = null
 

Additional Inherited Members

- Static Public Member Functions inherited from Hoa\Realdom\Realdom
static autoBoxing (Array &$arguments, Realdom $self=null)
 
static setDefaultSampler (Math\Sampler $sampler)
 
static getDefaultSampler ()
 
static setMaxTry ($maxtry)
 
static getMaxTry ()
 
static setDefaultPraspelVisitor (Visitor\Visit $visitor)
 
static getDefaultPraspelVisitor ()
 
- Static Protected Attributes inherited from Hoa\Realdom\Realdom
static $_sampler = null
 
static $_maxtry = 64
 
static $_defaultPraspelVisitor = null
 

Detailed Description

Class .

Realistic domain: boundinteger.

Definition at line 50 of file Boundinteger.php.

Member Function Documentation

Hoa\Realdom\Boundinteger::_predicate (   $q)
protected

Predicate whether the sampled value belongs to the realistic domains.

Parameters
mixed$qSampled value.
Returns
boolean

Definition at line 110 of file Boundinteger.php.

111  {
112  return
113  parent::_predicate($q) &&
114  $q >= $this['lower']->getConstantValue() &&
115  $q <= $this['upper']->getConstantValue();
116  }
Hoa\Realdom\Boundinteger::_sample ( Math\Sampler  $sampler)
protected

Sample one new value.

Parameters
\Hoa\Math\Sampler$samplerSampler.
Returns
mixed

Definition at line 124 of file Boundinteger.php.

125  {
126  return $sampler->getInteger(
127  $this['lower']->sample($sampler),
128  $this['upper']->sample($sampler),
129  $this->_discredited
130  );
131  }
sample(Math\Sampler $sampler=null)
Definition: Realdom.php:686

Here is the call graph for this function:

Hoa\Realdom\Boundinteger::construct ( )
protected

Construct a realistic domain.

Returns
void

Definition at line 88 of file Boundinteger.php.

89  {
90  $lower = $this['lower']->getConstantValue();
91  $upper = $this['upper']->getConstantValue();
92 
93  if ($lower > $upper) {
94  throw new Exception\InvalidArgument(
95  '$lower must be strictly lower than $upper; given %d and %d.',
96  0,
97  [$lower, $upper]
98  );
99  }
100 
101  return;
102  }
Hoa\Realdom\Boundinteger::discredit (   $value)

Discredit a value.

Parameters
mixed$valueValue to discredit.
Returns

Implements Hoa\Realdom\IRealdom\Nonconvex.

Definition at line 199 of file Boundinteger.php.

200  {
201  if (true === in_array($value, $this->_discredited) ||
202  false === $this->predicate($value)) {
203  return $this;
204  }
205 
206  $this->_discredited[] = $value;
207 
208  return $this;
209  }

Here is the call graph for this function:

Hoa\Realdom\Boundinteger::getIterator ( )

Enumerate.

Returns

Definition at line 230 of file Boundinteger.php.

231  {
232  $discredited = &$this->_discredited;
233 
234  return
235  new Iterator\CallbackFilter(
236  new Iterator\Counter(
237  $this['lower']->getConstantValue(),
238  $this['upper']->getConstantValue() + 1,
239  1
240  ),
241  function ($value) use (&$discredited) {
242  return false === in_array($value, $discredited);
243  }
244  );
245  }
Hoa\Realdom\Boundinteger::getLowerBound ( )

Get lower bound of the domain.

Returns

Implements Hoa\Realdom\IRealdom\Interval.

Definition at line 138 of file Boundinteger.php.

139  {
140  return $this['lower']->getConstantValue();
141  }
Hoa\Realdom\Boundinteger::getSize ( )

Get size of the domain.

Returns
int

Implements Hoa\Realdom\IRealdom\Finite.

Definition at line 216 of file Boundinteger.php.

217  {
218  return
219  $this['upper']->getConstantValue() -
220  $this['lower']->getConstantValue() -
221  count($this->_discredited) +
222  1;
223  }

Here is the call graph for this function:

Hoa\Realdom\Boundinteger::getUpperBound ( )

Get upper bound of the domain.

Returns

Implements Hoa\Realdom\IRealdom\Interval.

Definition at line 148 of file Boundinteger.php.

149  {
150  return $this['upper']->getConstantValue();
151  }
Hoa\Realdom\Boundinteger::reduceLeftTo (   $value)

Reduce the upper bound.

Parameters
int$valueValue.
Returns
bool

Implements Hoa\Realdom\IRealdom\Interval.

Definition at line 179 of file Boundinteger.php.

180  {
181  $lower = max($this['lower']->getConstantValue(), $value);
182  $upper = $this['upper']->getConstantValue();
183 
184  if ($lower > $upper) {
185  return false;
186  }
187 
188  $this['lower'] = new Constinteger($value);
189 
190  return true;
191  }
Hoa\Realdom\Boundinteger::reduceRightTo (   $value)

Reduce the lower bound.

Parameters
mixed$valueValue.
Returns
bool

Implements Hoa\Realdom\IRealdom\Interval.

Definition at line 159 of file Boundinteger.php.

160  {
161  $lower = $this['lower']->getConstantValue();
162  $upper = min($this['upper']->getConstantValue(), $value);
163 
164  if ($lower > $upper) {
165  return false;
166  }
167 
168  $this['upper'] = new Constinteger($value);
169 
170  return true;
171  }

Member Data Documentation

Hoa\Realdom\Boundinteger::$_arguments
protected
Initial value:
= [
'Constinteger lower' => PHP_INT_MIN

Definition at line 69 of file Boundinteger.php.

Hoa\Realdom\Boundinteger::$_discredited = []
protected

Definition at line 79 of file Boundinteger.php.

const Hoa\Realdom\Boundinteger::NAME = 'boundinteger'

Realistic domain name.

string

Definition at line 62 of file Boundinteger.php.


The documentation for this class was generated from the following file: