This class allows to define a continuous (double) problem dynamically, by adding the ranges of
every decision variable, the objective functions and the constraints. For example, the Schaffer
unconstrained problem (1 decision variable, two objectives) can be defined as follows:
ComposableDoubleProblem problem = new ComposableDoubleProblem()
.setName("Schaffer")
.addVariable(-10, 10)
.addVariable(-10, 10)
.addFunction((x) -> x[0] * x[0])
.addFunction((x) -> (x[0] - 2.0) * (x[0] - 2.0));
The Srinivas constrained problem can be defined in this way:
ComposableDoubleProblem problem;
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) ;
Note that this class does not inherits from
AbstractDoubleProblem.
As defined, this class would make possible to add more variables, objectives and constraints
to an existing problem on the fly.
This class does not intend to be a replacement of the existing of
AbstractDoubleProblem;
it is merely an alternative way of defining a problem.