Package org.opt4j.core
Class CriterionSet<T extends Criterion>
- java.lang.Object
-
- org.opt4j.core.CriterionSet<T>
-
- Direct Known Subclasses:
Constraints
,Objectives
public abstract class CriterionSet<T extends Criterion> extends Object implements Iterable<Map.Entry<T,Value<?>>>
Superclass forCriterion
-Values
pairs. Provides methods for the administration of these pairs.
-
-
Constructor Summary
Constructors Constructor Description CriterionSet()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
add(CriterionSet<T> criterionSet)
Adds all Criterions with the specified value specified incriterionSet
.void
add(T criterion, double value)
Adds the Criterion with the specified double value.void
add(T criterion, int value)
Adds the Criterion with the specified integer value.void
add(T criterion, Value<?> value)
Adds the Criterion with the specified value.abstract double[]
array()
Returns an array of all CriterionSet values.double
distance(CriterionSet<T> other)
Calculates the euclidean distance of twoCriterionSet
s.T
get(Value<?> value)
Returns the Criterion that is assigned to the given value.Value<?>
get(T criterion)
Returns the value that is assigned to the givenCriterion
.Collection<T>
getKeys()
Returns allCriterion
s.Collection<Value<?>>
getValues()
Returns all values.boolean
isEqual(CriterionSet<T> opponent)
Returnstrue
if this CriterionSet is equal to the specified CriterionSet.Iterator<Map.Entry<T,Value<?>>>
iterator()
int
size()
Returns the number of setCriterion
s.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
array
public abstract double[] array()
Returns an array of all CriterionSet values.- Returns:
- an array containing CriterionSet values
-
size
public int size()
Returns the number of setCriterion
s.- Returns:
- the number of set
Criterion
s
-
getKeys
public Collection<T> getKeys()
Returns allCriterion
s.- Returns:
- all
Criterion
s
-
getValues
public Collection<Value<?>> getValues()
Returns all values.- Returns:
- all values
-
get
public Value<?> get(T criterion)
Returns the value that is assigned to the givenCriterion
. Returnsnull
if theCriterion
does not exist.- Parameters:
criterion
- the given criterion- Returns:
- the value
-
get
public T get(Value<?> value)
Returns the Criterion that is assigned to the given value. Returnsnull
if the value does not exist.- Parameters:
value
- the given value- Returns:
- the Criterion
-
add
public void add(T criterion, Value<?> value)
Adds the Criterion with the specified value.- Parameters:
criterion
- the criterionvalue
- the value
-
add
public void add(T criterion, double value)
Adds the Criterion with the specified double value.- Parameters:
criterion
- the criterionvalue
- the value
-
add
public void add(T criterion, int value)
Adds the Criterion with the specified integer value.- Parameters:
criterion
- the criterionvalue
- the value
-
add
public void add(CriterionSet<T> criterionSet)
Adds all Criterions with the specified value specified incriterionSet
.- Parameters:
criterionSet
- the criterionSet
-
isEqual
public boolean isEqual(CriterionSet<T> opponent)
Returnstrue
if this CriterionSet is equal to the specified CriterionSet. This comparison is based on the#array()
values.- Parameters:
opponent
- other CriterionSet- Returns:
true
if the CriterionSets are equal
-
distance
public double distance(CriterionSet<T> other)
Calculates the euclidean distance of twoCriterionSet
s. This calculation is based on the#array()
values.- Parameters:
other
- the second CriterionSet- Returns:
- the euclidean distance
-
-