.. _problems: Problems ======== :Author: Antonio J. Nebro :Date: 2023-09-14 All the problems in jMetal implement the `Problem `_ interface: .. code-block:: java package org.uma.jmetal.problem; /** * Interface representing a multi-objective optimization problem * * @author Antonio J. Nebro * * @param Encoding */ public interface Problem extends Serializable { /* Getters */ int numberOfVariables() ; int numberbjectives() ; int numberOfConstraints() ; String name() ; /* Methods */ void evaluate(S solution) ; S createSolution() ; } Every problem is characterized by the number of decision variables, the number of objective functions and the number of constraints, so getter methods for returning those values have to be defined. The genetic type `S` allows to determine the encoding of the solutions of the problem. This way, a problem must include a method for evaluating any solution of class `S` as well as providing a `createSolution()` method for creating a new solution. A class named `AbstractGenericProblem `_ containing setter and getter method implementations for the problem fields is provided. If a problem has side constraints, it is assumed that the overall constraint degree of a given solution is computed inside the ``evaluate()`` method. jMetal provides currently the following interfaces representing types of problems (all of them extending ``Problem``), and the available implementations of them: * `BinaryProblem `_ * `AbstractBinaryProblem `_: Each problem variable is a bit string, and the class includes methods such as ``getBitsFromVariable(int index)`` and ``getTotalNumberOfBits()``. * `IntegerProblem `_ * `AbstractIntegerProblem `_: The problem variables are integer values in a given range defined by a lower and upperbound. This means that this class is not adequate for combinatorial problems based on integer values. * `DoubleProblem `_ * `AbstractDoubleProblem `_: The problem variables are double values in a given range defined by a lower and upperbound. * `ComposableDoubleProblem `_: This class allows to define a double problem in a dynamic way, as shown in this code snippet: .. code-block:: java ComposableDoubleProblem problem = new ComposableDoubleProblem() .setName("Srinivas") .addVariable(-20.0, 20.0) .addVariable(-20.0, 20.0) .addFunction((x) -> 2.0 + (x[0] - 2.0) * (x[0] - 2.0) + (x[1] - 1.0) * (x[1] - 1.0)) .addFunction((x) -> 9.0 * x[0] - (x[1] - 1.0) * (x[1] - 1.0)) .addConstraint((x) -> 1.0 - (x[0] * x[0] + x[1] * x[1]) / 225.0) .addConstraint((x) -> (3.0 * x[1] - x[0]) / 10.0 - 1.0)) ; * `DummyDoubleProblem `_: This class is intended to be used in unit testing code (to avoid having to define it many times). * `PermutationProblem `_ * `AbstractIntegerPermutationProblem `_: The problem variables are permutations of integer values. * `SequenceProblem `_ * `CharSequenceProblem `_: The problem variables are sequences of chars. All the problems provided by jMetal are included in the ``org.uma.jmetal.problem`` package located in the ``jmetal-problem`` sub-project. The package includes the sub-packages ``multiobjective`` and ``singleobjective``, which contains the codes of the problems. You can find both individual problems (e.g., *Kursawe*, *Sphere*, etc.) and benchmarks suites (such as *ZDT*, *DTLZ* or *LZ09*). The lists of single- and multi-objective problems are included in the next figures: .. figure:: resources/figures/singleObjectiveProblems.png :scale: 90 % :alt: Single-objective problems. .. figure:: resources/figures/multiObjectiveProblems.png :scale: 90 % :alt: Multi-objective problems.