Package org.moeaframework.core.penalty
Class SumOfConstraintsPenaltyFunction
java.lang.Object
org.moeaframework.core.penalty.SumOfConstraintsPenaltyFunction
- All Implemented Interfaces:
PenaltyFunction
Penalty function based on a fixed offset plus the sum of constraint violations.
-
Constructor Summary
ConstructorDescriptionConstructs a new penalty function based on the sum of constraint violations.SumOfConstraintsPenaltyFunction
(double offset) Constructs a new penalty function based on the sum of constraint violations. -
Method Summary
-
Constructor Details
-
SumOfConstraintsPenaltyFunction
public SumOfConstraintsPenaltyFunction()Constructs a new penalty function based on the sum of constraint violations. -
SumOfConstraintsPenaltyFunction
public SumOfConstraintsPenaltyFunction(double offset) Constructs a new penalty function based on the sum of constraint violations.- Parameters:
offset
- the base offset applied to all penalties
-
-
Method Details
-
setOffset
public void setOffset(double offset) Sets the base penalty applied to all infeasible solutions.- Parameters:
offset
- the base offset applied to all penalties
-
getOffset
public double getOffset()Returns the base penalty applied to all infeasible solutions.- Returns:
- the base offset applied to all penalties
-
calculate
Description copied from interface:PenaltyFunction
Calculates the penalty for the given solution. In addition to returning the value to the caller, this method also sets thePenalty
attribute on the solution.Calling this method does not alter the objectives or constraints of the solution. It is the responsibility of the caller to use the penalty value, such as during selection. We encourage implementations to return a value of
0.0
for feasible solutions and> 0.0
for solutions violating constraints.- Specified by:
calculate
in interfacePenaltyFunction
- Parameters:
solution
- the solution- Returns:
- the penalty for the solution
-