Package org.moeaframework.problem
Class ProblemWrapper
java.lang.Object
org.moeaframework.problem.ProblemWrapper
- All Implemented Interfaces:
AutoCloseable,Named,Problem
- Direct Known Subclasses:
DistributedProblem,RotatedProblem,ScaledProblem
Wraps a problem instance to modify or extend its functionality.
All methods invoke the corresponding method on the inner problem. Subclasses need only override the methods they need to change.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProblemWrapper(Problem problem) Constructs a new problem wrapper to modify or extend the functionality of the given problem. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes any underlying resources used by this problem.voidEvaluates the solution, updating the solution's objectives in place.getName()Returns the name of this problem.intReturns the number of constraints defined by this problem.intReturns the number of objectives defined by this problem.intReturns the number of decision variables defined by this problem.Returns a new solution for this problem.
-
Field Details
-
problem
The original problem instance.
-
-
Constructor Details
-
ProblemWrapper
Constructs a new problem wrapper to modify or extend the functionality of the given problem.- Parameters:
problem- the problem being modified or extended
-
-
Method Details
-
getName
Description copied from interface:ProblemReturns the name of this problem. Whenever possible, this name should match the name recognized byProblemFactory. -
getNumberOfVariables
public int getNumberOfVariables()Description copied from interface:ProblemReturns the number of decision variables defined by this problem.- Specified by:
getNumberOfVariablesin interfaceProblem- Returns:
- the number of decision variables defined by this problem
-
getNumberOfObjectives
public int getNumberOfObjectives()Description copied from interface:ProblemReturns the number of objectives defined by this problem.- Specified by:
getNumberOfObjectivesin interfaceProblem- Returns:
- the number of objectives defined by this problem
-
getNumberOfConstraints
public int getNumberOfConstraints()Description copied from interface:ProblemReturns the number of constraints defined by this problem.- Specified by:
getNumberOfConstraintsin interfaceProblem- Returns:
- the number of constraints defined by this problem
-
evaluate
Description copied from interface:ProblemEvaluates the solution, updating the solution's objectives in place. Algorithms must explicitly call this method when appropriate to evaluate new solutions or reevaluate modified solutions. -
newSolution
Description copied from interface:ProblemReturns a new solution for this problem. Implementations must initialize the variables so that the valid range of values is defined, but typically leave the actual value at a default or undefined state.- Specified by:
newSolutionin interfaceProblem- Returns:
- a new solution for this problem
-
close
public void close()Description copied from interface:ProblemCloses any underlying resources used by this problem. Once closed, further invocations of any methods on this problem may throw exceptions.While most problems do not use any disposable resources and this method can simply no-op, the best practice is wrapping the constructed problem instance inside a try-with-resources block so it is automatically closed. Java may flag offending code with a warning. Implementations that do require closing should indicate this in any documentation.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceProblem
-