Package org.opt4j.core
Class Objectives
- java.lang.Object
-
- org.opt4j.core.CriterionSet<Objective>
-
- org.opt4j.core.Objectives
-
public class Objectives extends CriterionSet<Objective>
TheObjectives
contains theObjective
-Value
s pairs of anIndividual
. Additionally, the feasibility of theObjectives
can be set. The feasibilityisFeasible()
istrue
by default. Set this value tofalse
to indicate that the correspondingIndividual
is infeasible (e.g., it violates constraints).
-
-
Field Summary
Fields Modifier and Type Field Description protected Constraints
constraints
protected DominationStrategy
dominationStrategy
protected boolean
feasible
protected SortedMap<Objective,Value<?>>
map
-
Fields inherited from class org.opt4j.core.CriterionSet
array
-
-
Constructor Summary
Constructors Constructor Description Objectives()
Deprecated.Objectives(DominationStrategy strategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(Objective objective, double value)
Adds the objective with the specified double value.void
add(Objective objective, int value)
Adds the objective with the specified integer value.void
add(Objective objective, Value<?> value)
Adds the objective with the specified value.void
add(Objectives objectives)
Deprecated.renamed toaddAll(Objectives)
void
addAll(Objectives objectives)
Adds all objective with the specified value specified inObjectives
.double[]
array()
Returns an array of all values which all have to be minimized.double
distance(Objectives other)
Calculates the euclidean distance of twoObjectives
.boolean
dominates(Objectives opponent)
Returnstrue
if this objectives dominate the specified objectives.Value<?>
get(Objective objective)
Returns the value that is assigned to the given objective.Objective
get(Value<?> value)
Returns the objective that is assigned to the given value.Constraints
getConstraints()
Returns the constraints.DominationStrategy
getDominationStrategy()
Returns the domination strategy of the Objective.Collection<Objective>
getKeys()
Returns all objectives.Collection<Value<?>>
getValues()
Returns all values.boolean
isEqual(Objectives opponent)
Returnstrue
if this objectives are equal to the specified objectives.boolean
isFeasible()
Returns the feasibility.Iterator<Map.Entry<Objective,Value<?>>>
iterator()
void
setConstraints(Constraints constraints)
Sets the constraints.void
setFeasible(boolean feasible)
Sets the feasibility.int
size()
Returns the number of setObjective
s.protected void
submit()
Calculates the array.String
toString()
boolean
weaklyDominates(Objectives opponent)
Returnstrue
if this objectives weakly dominates the specified objectives.-
Methods inherited from class org.opt4j.core.CriterionSet
add, distance, isEqual
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
feasible
protected boolean feasible
-
constraints
protected Constraints constraints
-
dominationStrategy
protected DominationStrategy dominationStrategy
-
-
Constructor Detail
-
Objectives
@Deprecated public Objectives()
Deprecated.Inject aProvider<Objectives>
object instead and createObjectives
objects withprovider.get()
.
-
Objectives
@Inject public Objectives(DominationStrategy strategy)
-
-
Method Detail
-
getConstraints
public Constraints getConstraints()
Returns the constraints.- Returns:
- the constraints
-
setConstraints
public void setConstraints(Constraints constraints)
Sets the constraints.- Parameters:
constraints
- the constraints to set
-
getDominationStrategy
public DominationStrategy getDominationStrategy()
Returns the domination strategy of the Objective.- Returns:
- the domination strategy of the Objective
-
isFeasible
public boolean isFeasible()
Returns the feasibility.- Returns:
- the feasibility
-
setFeasible
public void setFeasible(boolean feasible)
Sets the feasibility.- Parameters:
feasible
- the feasibility to set
-
array
public double[] array()
Returns an array of all values which all have to be minimized. Do not call this method before all objectives were added!- Specified by:
array
in classCriterionSet<Objective>
- Returns:
- an array containing values which have to be minimized
- See Also:
Value.getDouble()
-
submit
protected void submit()
Calculates the array.
-
size
public int size()
Returns the number of setObjective
s.- Overrides:
size
in classCriterionSet<Objective>
- Returns:
- the number of set objectives
-
getKeys
public Collection<Objective> getKeys()
Returns all objectives.- Overrides:
getKeys
in classCriterionSet<Objective>
- Returns:
- all objectives
-
getValues
public Collection<Value<?>> getValues()
Returns all values.- Overrides:
getValues
in classCriterionSet<Objective>
- Returns:
- all values
-
get
public Value<?> get(Objective objective)
Returns the value that is assigned to the given objective. Returnsnull
if the objective does not exist.- Overrides:
get
in classCriterionSet<Objective>
- Parameters:
objective
- the given objective- Returns:
- the value
-
get
public Objective get(Value<?> value)
Returns the objective that is assigned to the given value. Returnsnull
if the value does not exist.- Overrides:
get
in classCriterionSet<Objective>
- Parameters:
value
- the given value- Returns:
- the objective
-
add
public void add(Objective objective, Value<?> value)
Adds the objective with the specified value.- Overrides:
add
in classCriterionSet<Objective>
- Parameters:
objective
- the objectivevalue
- the value
-
add
public void add(Objective objective, double value)
Adds the objective with the specified double value.- Overrides:
add
in classCriterionSet<Objective>
- Parameters:
objective
- the objectivevalue
- the value
-
add
public void add(Objective objective, int value)
Adds the objective with the specified integer value.- Overrides:
add
in classCriterionSet<Objective>
- Parameters:
objective
- the objectivevalue
- the value
-
add
@Deprecated public void add(Objectives objectives)
Deprecated.renamed toaddAll(Objectives)
Adds all objective with the specified value specified inObjectives
.- Parameters:
objectives
- the objectives
-
addAll
public void addAll(Objectives objectives)
Adds all objective with the specified value specified inObjectives
.- Parameters:
objectives
- the objectives
-
weaklyDominates
public boolean weaklyDominates(Objectives opponent)
Returnstrue
if this objectives weakly dominates the specified objectives. This comparison depends on the chosenDominationStrategy
.- Parameters:
opponent
- other objectives- Returns:
true
if this objectives weakly dominate theopponent
-
dominates
public boolean dominates(Objectives opponent)
Returnstrue
if this objectives dominate the specified objectives. This comparison depends on the chosenDominationStrategy
.- Parameters:
opponent
- other objectives- Returns:
true
if these objectives dominate theopponent
-
isEqual
public boolean isEqual(Objectives opponent)
Returnstrue
if this objectives are equal to the specified objectives. This comparison is based on thearray()
values.- Parameters:
opponent
- other objectives- Returns:
true
if these objectives dominate theopponent
-
distance
public double distance(Objectives other)
Calculates the euclidean distance of twoObjectives
. This calculation is based on thearray()
values.- Parameters:
other
- the second objectives- Returns:
- the euclidean distance
-
-