Package org.moeaframework.problem
Class AbstractProblem
java.lang.Object
org.moeaframework.problem.AbstractProblem
- All Implemented Interfaces:
AutoCloseable,Named,Problem
- Direct Known Subclasses:
Ackley,BBOBFunction,Beale,Belegundu,Binh,Binh2,Binh3,Binh4,CF1,CF10,CF2,CF3,CF4,CF5,CF6,CF7,CF8,CF9,DTLZ,Fonseca,Fonseca2,Griewank,Himmelblau,Jimenez,Kita,Kursawe,Laumanns,Lis,LZ,MaF13,MaF8,MaF9,Murata,Obayashi,OKA1,OKA2,Osyczka,Osyczka2,Poloni,ProblemStub,Quagliarella,Rastrigin,Rendon,Rendon2,Rosenbrock,Schaffer,Schaffer2,Schwefel,Sphere,Srinivas,StackedProblem,Tamaki,Tanaka,UF1,UF10,UF11,UF12,UF2,UF3,UF4,UF5,UF6,UF7,UF8,UF9,Viennet,Viennet2,Viennet3,Viennet4,WFG,Zakharov,ZCAT,ZDT
Abstract class for a
Problem. For simplicity, most problems should extend AbstractProblem rather
than implement the Problem interface directly. At a minimum, only the Problem.newSolution() and
Problem.evaluate(org.moeaframework.core.Solution) methods need to be defined.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intThe number of constraints defined by this problem.protected final intThe number of objectives defined by this problem.protected final intThe number of variables defined by this problem. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractProblem(int numberOfVariables, int numberOfObjectives) Constructs an unconstrained abstract problem with the specified number of decision variables and objectives.AbstractProblem(int numberOfVariables, int numberOfObjectives, int numberOfConstraints) Constructs an abstract problem with the specified number of decision variables, objectives and constraints. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes any underlying resources used by 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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.moeaframework.problem.Problem
evaluate, getName, isType, newSolution
-
Field Details
-
numberOfVariables
protected final int numberOfVariablesThe number of variables defined by this problem. -
numberOfObjectives
protected final int numberOfObjectivesThe number of objectives defined by this problem. -
numberOfConstraints
protected final int numberOfConstraintsThe number of constraints defined by this problem.
-
-
Constructor Details
-
AbstractProblem
public AbstractProblem(int numberOfVariables, int numberOfObjectives) Constructs an unconstrained abstract problem with the specified number of decision variables and objectives.- Parameters:
numberOfVariables- the number of decision variablesnumberOfObjectives- the number of objectives
-
AbstractProblem
public AbstractProblem(int numberOfVariables, int numberOfObjectives, int numberOfConstraints) Constructs an abstract problem with the specified number of decision variables, objectives and constraints.- Parameters:
numberOfVariables- the number of decision variablesnumberOfObjectives- the number of objectivesnumberOfConstraints- the number of constraints
-
-
Method Details
-
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
-
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
-