Package org.opt4j.core
Class Objectives
- java.lang.Object
-
- org.opt4j.core.CriterionSet<Objective>
-
- org.opt4j.core.Objectives
-
public class Objectives extends CriterionSet<Objective>
TheObjectivescontains theObjective-Values pairs of anIndividual. Additionally, the feasibility of theObjectivescan be set. The feasibilityisFeasible()istrueby default. Set this value tofalseto indicate that the correspondingIndividualis infeasible (e.g., it violates constraints).
-
-
Field Summary
Fields Modifier and Type Field Description protected Constraintsconstraintsprotected DominationStrategydominationStrategyprotected booleanfeasibleprotected 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 voidadd(Objective objective, double value)Adds the objective with the specified double value.voidadd(Objective objective, int value)Adds the objective with the specified integer value.voidadd(Objective objective, Value<?> value)Adds the objective with the specified value.voidadd(Objectives objectives)Deprecated.renamed toaddAll(Objectives)voidaddAll(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.doubledistance(Objectives other)Calculates the euclidean distance of twoObjectives.booleandominates(Objectives opponent)Returnstrueif this objectives dominate the specified objectives.Value<?>get(Objective objective)Returns the value that is assigned to the given objective.Objectiveget(Value<?> value)Returns the objective that is assigned to the given value.ConstraintsgetConstraints()Returns the constraints.DominationStrategygetDominationStrategy()Returns the domination strategy of the Objective.Collection<Objective>getKeys()Returns all objectives.Collection<Value<?>>getValues()Returns all values.booleanisEqual(Objectives opponent)Returnstrueif this objectives are equal to the specified objectives.booleanisFeasible()Returns the feasibility.Iterator<Map.Entry<Objective,Value<?>>>iterator()voidsetConstraints(Constraints constraints)Sets the constraints.voidsetFeasible(boolean feasible)Sets the feasibility.intsize()Returns the number of setObjectives.protected voidsubmit()Calculates the array.StringtoString()booleanweaklyDominates(Objectives opponent)Returnstrueif 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 createObjectivesobjects 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:
arrayin 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 setObjectives.- Overrides:
sizein classCriterionSet<Objective>- Returns:
- the number of set objectives
-
getKeys
public Collection<Objective> getKeys()
Returns all objectives.- Overrides:
getKeysin classCriterionSet<Objective>- Returns:
- all objectives
-
getValues
public Collection<Value<?>> getValues()
Returns all values.- Overrides:
getValuesin classCriterionSet<Objective>- Returns:
- all values
-
get
public Value<?> get(Objective objective)
Returns the value that is assigned to the given objective. Returnsnullif the objective does not exist.- Overrides:
getin 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. Returnsnullif the value does not exist.- Overrides:
getin 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:
addin 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:
addin 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:
addin 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)
Returnstrueif this objectives weakly dominates the specified objectives. This comparison depends on the chosenDominationStrategy.- Parameters:
opponent- other objectives- Returns:
trueif this objectives weakly dominate theopponent
-
dominates
public boolean dominates(Objectives opponent)
Returnstrueif this objectives dominate the specified objectives. This comparison depends on the chosenDominationStrategy.- Parameters:
opponent- other objectives- Returns:
trueif these objectives dominate theopponent
-
isEqual
public boolean isEqual(Objectives opponent)
Returnstrueif this objectives are equal to the specified objectives. This comparison is based on thearray()values.- Parameters:
opponent- other objectives- Returns:
trueif 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
-
-