net.sourceforge.cilib.util.selection.weighing
Class LinearWeighing<E>

java.lang.Object
  extended by net.sourceforge.cilib.util.selection.weighing.LinearWeighing<E>
Type Parameters:
E - The selection type.
All Implemented Interfaces:
Serializable, Cloneable, Weighing<E>

public class LinearWeighing<E>
extends Object
implements Weighing<E>

Apply a weighting to the provided list of elements. This weighting will be linear with the bounds of the range set to [0,1] in the default case.

Author:
Wiehann Matthysen
See Also:
Serialized Form

Constructor Summary
LinearWeighing()
          Create a new instance with the bounds of [0,1].
LinearWeighing(double min, double max)
          Create a new instance with the linear bounds of [min, max].
LinearWeighing(LinearWeighing<E> copy)
          Create a copy of the provided instance.
 
Method Summary
 LinearWeighing<E> getClone()
          Create a cloned copy of the current object and return it.
 double getMax()
          Get the maximum bound value.
 double getMin()
          Get the minimum bound value.
 void setMax(double max)
          Set the maximum bound value.
 void setMin(double min)
          Set the minimum bound value.
 boolean weigh(List<Selection.Entry<E>> elements)
          Perform a weighing on the provided list of entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearWeighing

public LinearWeighing()
Create a new instance with the bounds of [0,1].


LinearWeighing

public LinearWeighing(double min,
                      double max)
Create a new instance with the linear bounds of [min, max].

Parameters:
min - The lower bound.
max - The upper bound.

LinearWeighing

public LinearWeighing(LinearWeighing<E> copy)
Create a copy of the provided instance.

Parameters:
copy - The instance to copy.
Method Detail

getClone

public LinearWeighing<E> getClone()
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface Cloneable
Specified by:
getClone in interface Weighing<E>
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

setMin

public void setMin(double min)
Set the minimum bound value.

Parameters:
min - The value to set.

getMin

public double getMin()
Get the minimum bound value.

Returns:
The minimum bound value.

setMax

public void setMax(double max)
Set the maximum bound value.

Parameters:
max - The value to set.

getMax

public double getMax()
Get the maximum bound value.

Returns:
The maximum bound value.

weigh

public boolean weigh(List<Selection.Entry<E>> elements)
Perform a weighing on the provided list of entries. Apply a linear weighing that has an equal step size from [min, max].

Specified by:
weigh in interface Weighing<E>
Parameters:
elements - The entries to weigh.
Returns:
true if successful, false otherwise.


Copyright © 2009 CIRG. All Rights Reserved.