org.decisiondeck.xmcda_oo.structure
Class DiscreteOrderedInterval

java.lang.Object
  extended by org.decisiondeck.xmcda_oo.structure.DiscreteOrderedInterval
All Implemented Interfaces:
IOrderedInterval

public class DiscreteOrderedInterval
extends Object
implements IOrderedInterval

A facade to an IOrderedInterval permitting easier use when the interval is discrete.


Constructor Summary
DiscreteOrderedInterval(OrderedInterval delegate)
           
 
Method Summary
 boolean equals(Object obj)
           
 DiscreteOrderedInterval getAsDiscreteInterval()
           This interval must have a step size.
 double getBest()
           The preference direction must be set.
 double getClosest(double value, boolean roundToCeiling)
          Retrieves the value belonging to this discrete interval which is the closest to the given value.
 int getDirectionAsSign()
           The preference direction must be set.
 double getMaximum()
          Retrieves the maximum value included in this interval, or positive infinity.
 double getMinimum()
          Retrieves the minimum value included in this interval.
 int getNbSteps()
           The maximum must be a non infinite number.
 double getNonNullStepSize()
          Retrieves the step size bound to this discrete interval, which is the value returned by getStepSize() with the supplementary guarantee that it is non null.
 Criterion.PreferenceDirection getPreferenceDirection()
          Retrieves the preference direction associated to this interval.
 Double getStepSize()
          Retrieves the step size.
 double getWorst()
           The preference direction must be set.
 int hashCode()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiscreteOrderedInterval

public DiscreteOrderedInterval(OrderedInterval delegate)
Parameters:
delegate - not null, must represent a discrete interval thus must have a step size defined (which also implies a non infinite minimum).
Method Detail

getClosest

public double getClosest(double value,
                         boolean roundToCeiling)
Retrieves the value belonging to this discrete interval which is the closest to the given value. If the given value is smaller than the minimum value allowed in this interval, the minimum value is returned. Similarily for the maximum value.

Parameters:
value - the value to target.
roundToCeiling - in case the given value is exactly between two steps, and this is true, the returned value will be the highest step, if this is false, the smallest one will be returned.
Returns:
a value in this interval.

getAsDiscreteInterval

public DiscreteOrderedInterval getAsDiscreteInterval()
Description copied from interface: IOrderedInterval

This interval must have a step size.

Retrieves a facade permitting easier usage of this interval when it represents a discrete interval.

Specified by:
getAsDiscreteInterval in interface IOrderedInterval
Returns:
not null.

getBest

public double getBest()
Description copied from interface: IOrderedInterval

The preference direction must be set.

Retrieves the maximum value if the preference direction is to maximize, the minimum value if the preference direction is to minimize. If the corresponding bound is not set this method returns a positive or negative infinity.

Specified by:
getBest in interface IOrderedInterval
Returns:
infinity or a real number.

getDirectionAsSign

public int getDirectionAsSign()
Description copied from interface: IOrderedInterval

The preference direction must be set.

Useful for computations depending on the preference direction associated with this interval.

Specified by:
getDirectionAsSign in interface IOrderedInterval
Returns:
1 if the preference direction is to maximize, -1 if it is to minimize.

getMaximum

public double getMaximum()
Description copied from interface: IOrderedInterval
Retrieves the maximum value included in this interval, or positive infinity. The returned value is necessarily greater than or equal to IOrderedInterval.getMinimum().

Specified by:
getMaximum in interface IOrderedInterval
Returns:
Double.POSITIVE_INFINITY or a real number.

getMinimum

public double getMinimum()
Retrieves the minimum value included in this interval. The returned value is necessarily smaller than or equal to getMaximum() and may not be infinity.

Specified by:
getMinimum in interface IOrderedInterval
Returns:
a real number.

getPreferenceDirection

public Criterion.PreferenceDirection getPreferenceDirection()
Description copied from interface: IOrderedInterval
Retrieves the preference direction associated to this interval.

Specified by:
getPreferenceDirection in interface IOrderedInterval
Returns:
null for not set.

getStepSize

public Double getStepSize()
Retrieves the step size.

Specified by:
getStepSize in interface IOrderedInterval
Returns:
not null.

getWorst

public double getWorst()
Description copied from interface: IOrderedInterval

The preference direction must be set.

Retrieves the minimum value if the preference direction is to maximize, the maximum value if the preference direction is to minimize. If the corresponding bound is not set this method returns a positive or negative infinity.

Specified by:
getWorst in interface IOrderedInterval
Returns:
infinity or a real number.

getNbSteps

public int getNbSteps()

The maximum must be a non infinite number.

Retrieves the number of steps this discrete interval accepts. This is necessarily at least one. For example, the number of steps accepted by an interval from 10 to 21 by steps of 5 is three: the step 10, the step 15, the step 20.

Returns:
at least one.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getNonNullStepSize

public double getNonNullStepSize()
Retrieves the step size bound to this discrete interval, which is the value returned by getStepSize() with the supplementary guarantee that it is non null.

Returns:
a number greater than zero.


Copyright © 2011. All Rights Reserved.