weka.core.setupgenerator
Class SpaceDimension

java.lang.Object
  extended by weka.core.setupgenerator.SpaceDimension
All Implemented Interfaces:
Serializable

public class SpaceDimension
extends Object
implements Serializable

Represents a single dimension in a multi-dimensional space.

Version:
$Revision: 4521 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  String m_Label
          the label for the axis.
protected  String[] m_List
          the underlying list of values.
protected  double m_Max
          the maximum on the axis.
protected  double m_Min
          the minimum on the axis.
protected  double m_Step
          the step size for the axis.
protected  int m_Type
          the type of dimension.
protected  int m_Width
          the number of points on the axis.
 
Constructor Summary
SpaceDimension(AbstractParameter param)
          initializes the dimension (for numeric values).
SpaceDimension(double min, double max, double step, String label)
          initializes the dimension (for numeric values).
SpaceDimension(int min, int max, String[] list, String label)
          initializes the dimension (for list values).
 
Method Summary
 boolean equals(Object o)
          Tests itself against the provided dimension object.
 String getLabel()
          returns the label for the axis.
 String[] getList()
          Returns the list of values, null in case of a numeric dimension that is based on a mathematical function.
 int getLocation(Object value)
          returns the closest index for the given value in the dimension.
 double getMax()
          returns the right border.
 double getMin()
          returns the left border.
 double getStep()
          returns the step size on the axis.
 int getType()
          returns the tye of dimension.
 Object getValue(int x)
          returns the value at the given point in the dimension.
protected  void initFunction(double min, double max, double step, String label)
          initializes the dimension (for numeric values).
protected  void initList(int min, int max, String[] list, String label)
          initializes the dimension (for list values).
 boolean isOnBorder(double value)
          checks whether the given value is on the border of the dimension.
 boolean isOnBorder(int location)
          checks whether the given location is on the border of the dimension.
 SpaceDimension subdimension(int left, int right)
          returns a sub-dimension with the same type/step/list, but different borders.
 String toString()
          Returns a string representation of the dimension.
 int width()
          returns the number of points on the axis (incl.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_Type

protected int m_Type
the type of dimension.


m_Min

protected double m_Min
the minimum on the axis.


m_Max

protected double m_Max
the maximum on the axis.


m_Step

protected double m_Step
the step size for the axis.


m_Label

protected String m_Label
the label for the axis.


m_Width

protected int m_Width
the number of points on the axis.


m_List

protected String[] m_List
the underlying list of values.

Constructor Detail

SpaceDimension

public SpaceDimension(AbstractParameter param)
               throws Exception
initializes the dimension (for numeric values).

Parameters:
param - the search parameter to obtain the data from
Throws:
Exception - if splitting of list fails using Utils.splitOptions(String)
See Also:
AbstractParameter#getList(), Utils.splitOptions(String)

SpaceDimension

public SpaceDimension(double min,
                      double max,
                      double step,
                      String label)
initializes the dimension (for numeric values).

Parameters:
min - the minimum on the axis
max - the maximum on the axis
step - the step size for the axis
label - the label for the axis

SpaceDimension

public SpaceDimension(int min,
                      int max,
                      String[] list,
                      String label)
initializes the dimension (for list values).

Parameters:
min - the minimum index in the list (0-based index)
max - the maximum index in the list (0-based index)
list - the available values
label - the label for the axis
Method Detail

initFunction

protected void initFunction(double min,
                            double max,
                            double step,
                            String label)
initializes the dimension (for numeric values).

Parameters:
min - the minimum on the axis
max - the maximum on the axis
step - the step size for the axis
label - the label for the axis

initList

protected void initList(int min,
                        int max,
                        String[] list,
                        String label)
initializes the dimension (for list values).

Parameters:
min - the minimum index in the list (0-based index)
max - the maximum index in the list (0-based index)
list - the available values
label - the label for the axis

equals

public boolean equals(Object o)
Tests itself against the provided dimension object.

Overrides:
equals in class Object
Parameters:
o - the dimension object to compare against
Returns:
if the two dimensions have the same setup

getType

public int getType()
returns the tye of dimension.

Returns:
the type
See Also:
MultiSearch#TYPE_FUNCTION, MultiSearch#TYPE_LIST

getMin

public double getMin()
returns the left border.

Returns:
the left border

getMax

public double getMax()
returns the right border.

Returns:
the right border

getStep

public double getStep()
returns the step size on the axis.

Returns:
the step size

getLabel

public String getLabel()
returns the label for the axis.

Returns:
the label

width

public int width()
returns the number of points on the axis (incl. borders)

Returns:
the number of points on the axis

getList

public String[] getList()
Returns the list of values, null in case of a numeric dimension that is based on a mathematical function.

Returns:
the list

getValue

public Object getValue(int x)
returns the value at the given point in the dimension.

Parameters:
x - the x-th point on the axis
Returns:
the value at the given position

getLocation

public int getLocation(Object value)
returns the closest index for the given value in the dimension.

Parameters:
value - the value to get the index for
Returns:
the closest index in the dimension

isOnBorder

public boolean isOnBorder(double value)
checks whether the given value is on the border of the dimension.

Parameters:
value - the value to check
Returns:
true if the the value is on the border

isOnBorder

public boolean isOnBorder(int location)
checks whether the given location is on the border of the dimension.

Parameters:
location - the location to check
Returns:
true if the the location is on the border

subdimension

public SpaceDimension subdimension(int left,
                                   int right)
returns a sub-dimension with the same type/step/list, but different borders.

Parameters:
left - the left index
right - the right index
Returns:
the sub-dimension

toString

public String toString()
Returns a string representation of the dimension.

Overrides:
toString in class Object
Returns:
a string representation


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.