org.decisiondeck.xmcda_oo.structure
Class OrderedInterval

java.lang.Object
  extended by org.decisiondeck.xmcda_oo.structure.OrderedInterval
All Implemented Interfaces:
IOrderedInterval
Direct Known Subclasses:
IntegerStepScaleToDel

public class OrderedInterval
extends Object
implements IOrderedInterval

An interval on the set of reals, with a preference direction, typically attached to a criterion. The preference direction indicates if an alternative, when evaluated on that criterion, is preferred to an other one if its evaluation is higher (preference direction is to Maximize) or if it is lower (preference direction is to Minimize) than an other one. The interval indicates the set of values that any evaluation may lie into. When considering the criterion as an evaluation function, it is the codomain of the criterion. This object may have a preference direction set, or the interval set (if not set, this is equivalent to the whole set of real numbers with infinite minimum and maximum), or both, or nothing (be empty), and is immutable. The minimum value, when set, is the first value this interval accepts, thus it is minimum inclusive. The same holds for the maximum. With a preference direction and an interval defined, it is possible to query this object for the worst value and the best value supplementary to the minimum and maximum value. The maximum must be greater than or equal to the minimum, regardless of the preference direction of the bound criterion.

This object may also have a step size, that permits it to define a discrete interval, e.g. a subset of the set of integers when using an integer step size and an integer minimum value.

Because this object accepts a minimum value equal to the maximum, this interval may represent a single point.


Constructor Summary
OrderedInterval(Criterion.PreferenceDirection preferenceDirection, double minimum, double maximum, Double stepSize)
           
 
Method Summary
 boolean equals(Object obj)
           
 DiscreteOrderedInterval getAsDiscreteInterval()
           This interval must have a step size.
 IntegerStepScaleToDel getAsIntegerStepScale()
           
 double getBest()
           The preference direction must be set.
 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, or negative infinity.
 Criterion.PreferenceDirection getPreferenceDirection()
          Retrieves the preference direction associated to this interval.
 Double getStepSize()
          Retrieves the step size bound to this interval, or null if no step size is defined.
 double getWorst()
           The preference direction must be set.
 int hashCode()
           
 boolean isInteger()
           
static OrderedInterval newDirection(Criterion.PreferenceDirection direction)
          Creates a new real interval, with no minimum or maximum bounds, representing the given preference direction.
static OrderedInterval newDiscreteInterval(Criterion.PreferenceDirection direction, double minimum, double maximum, double stepSize)
           
static OrderedInterval newInterval(Criterion.PreferenceDirection direction, double minimum, double maximum)
           
static OrderedInterval newMaximizeDirection()
           
static OrderedInterval newMinimizeDirection()
           
static OrderedInterval newRealsInterval()
          Creates an interval with infinite lower and upper bounds, representing the whole set of real numbers, and without a preference direction.
static OrderedInterval newUnrestrictedInterval(Criterion.PreferenceDirection direction, double minimum, double maximum)
          Creates an interval with possibly infinite lower and upper bounds.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OrderedInterval

public OrderedInterval(Criterion.PreferenceDirection preferenceDirection,
                       double minimum,
                       double maximum,
                       Double stepSize)
Parameters:
preferenceDirection - null for not set.
minimum - Double.NEGATIVE_INFINITY for not set.
maximum - Double.POSITIVE_INFINITY for not set.
stepSize - null for not set, or must be greater than zero, in which case minimum must be set.
Method Detail

newDirection

public static OrderedInterval newDirection(Criterion.PreferenceDirection direction)
Creates a new real interval, with no minimum or maximum bounds, representing the given preference direction.

Parameters:
direction - null for not set.
Returns:
a new interval.

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.

newDiscreteInterval

public static OrderedInterval newDiscreteInterval(Criterion.PreferenceDirection direction,
                                                  double minimum,
                                                  double maximum,
                                                  double stepSize)
Parameters:
direction - may be null.
minimum - a real number, not infinite.
maximum - a real number, or positive infinity.
stepSize - a real number, not infinite.
Returns:
a new interval representing the given data.

newUnrestrictedInterval

public static OrderedInterval newUnrestrictedInterval(Criterion.PreferenceDirection direction,
                                                      double minimum,
                                                      double maximum)
Creates an interval with possibly infinite lower and upper bounds.

Parameters:
direction - may be null.
minimum - a real number, or negative infinity.
maximum - a real number, or positive infinity.
Returns:
a new interval.

newMaximizeDirection

public static OrderedInterval newMaximizeDirection()

newMinimizeDirection

public static OrderedInterval newMinimizeDirection()

isInteger

public boolean isInteger()

getAsIntegerStepScale

public IntegerStepScaleToDel getAsIntegerStepScale()

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.

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()
Description copied from interface: IOrderedInterval
Retrieves the minimum value included in this interval, or negative infinity. The returned value is necessarily smaller than or equal to IOrderedInterval.getMaximum().

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

getStepSize

public Double getStepSize()
Description copied from interface: IOrderedInterval
Retrieves the step size bound to this interval, or null if no step size is defined. If the step size is defined, the minimum of this interval is a real, thus non-infinite, number.

Specified by:
getStepSize in interface IOrderedInterval
Returns:
null for no step size, or a number greater than zero.

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.

newInterval

public static OrderedInterval newInterval(Criterion.PreferenceDirection direction,
                                          double minimum,
                                          double maximum)
Parameters:
direction - may be null.
minimum - a real number, not infinite.
maximum - a real number, not infinite.
Returns:
a new interval representing the given data.

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.

equals

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

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

newRealsInterval

public static OrderedInterval newRealsInterval()
Creates an interval with infinite lower and upper bounds, representing the whole set of real numbers, and without a preference direction.

Returns:
a new interval.


Copyright © 2011. All Rights Reserved.