Package org.moeaframework.problem
Class ProblemStub
java.lang.Object
org.moeaframework.problem.AbstractProblem
org.moeaframework.problem.ProblemStub
- All Implemented Interfaces:
AutoCloseable
,Named
,Problem
A problem "stub" that is typically used when processing data files when the specific problem type is unknown.
It can be configured with specific variable, objective, and constraint types, if known. However, if specific types
are not provided, functionality may be limited and can result in exceptions.
-
Field Summary
Fields inherited from class org.moeaframework.problem.AbstractProblem
numberOfConstraints, numberOfObjectives, numberOfVariables
-
Constructor Summary
ConstructorDescriptionProblemStub
(int numberOfObjectives) Constructs a problem stub with the specified number of objectives.ProblemStub
(String name, int numberOfVariables, int numberOfObjectives, int numberOfConstraints) Constructs a problem stub with the specified number of variables, objectives, and constraints.ProblemStub
(String name, Solution solution) Constructs a problem stub from the given solution.ProblemStub
(Solution solution) Constructs a problem stub from the given solution. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Evaluates the solution, updating the solution's objectives in place.getName()
Returns the name of this problem.Returns a new solution for this problem.void
setConstraintDefinition
(int index, Constraint constraint) Sets the specific constraint type, if known.void
setObjectiveDefinition
(int index, Objective objective) Sets the specific objective type, if known.void
setVariableDefinition
(int index, Variable variable) Sets the specific variable type, if known.Methods inherited from class org.moeaframework.problem.AbstractProblem
close, getNumberOfConstraints, getNumberOfObjectives, getNumberOfVariables
-
Constructor Details
-
ProblemStub
public ProblemStub(int numberOfObjectives) Constructs a problem stub with the specified number of objectives.- Parameters:
numberOfObjectives
- the number of objectives
-
ProblemStub
public ProblemStub(String name, int numberOfVariables, int numberOfObjectives, int numberOfConstraints) Constructs a problem stub with the specified number of variables, objectives, and constraints.- Parameters:
name
- the problem namenumberOfVariables
- the number of variablesnumberOfObjectives
- the number of objectivesnumberOfConstraints
- the number of constraints
-
ProblemStub
Constructs a problem stub from the given solution.- Parameters:
solution
- a sample or prototype solution for the problem
-
ProblemStub
Constructs a problem stub from the given solution.- Parameters:
name
- the problem namesolution
- a sample or prototype solution for the problem
-
-
Method Details
-
getName
Description copied from interface:Problem
Returns the name of this problem. Whenever possible, this name should match the name recognized byProblemFactory
.- Returns:
- the name of this problem
-
setVariableDefinition
Sets the specific variable type, if known.- Parameters:
index
- the indexvariable
- the variable
-
setObjectiveDefinition
Sets the specific objective type, if known.- Parameters:
index
- the indexobjective
- the objective
-
setConstraintDefinition
Sets the specific constraint type, if known.- Parameters:
index
- the indexconstraint
- the constraint
-
evaluate
Description copied from interface:Problem
Evaluates 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.- Parameters:
solution
- the solution to be evaluated
-
newSolution
Description copied from interface:Problem
Returns 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.- Returns:
- a new solution for this problem
-