# OPAL++ - Initialize Optimization with Constrains

If you have an OPAL++ case with a large amount of constrains it might be necessary to specify, that the case should be initialized only with valid individuals. If this is not specified for the first generation, OPAL++ will generate individuals in the complete range of variables, without omitting the individuals that violate the constrains.

For example: If it is specified that the first Generation should have 100 individuals, it is possible that only 10/100 individuals are valid, while 90 violate the constrains. Therefore, the first generation will run with only 10 individuals. When specifying the constrained initialization as described here, OPAL++ will only allow the generation of valid individuals.Therefore the first generation will have the desired 100 individuals.

#### XIII.13 Constrained initialization

When you start an optimization with huge number of constraints, it happens often, that the first generations only contain a couple of individuals, which do not violate constraints. Although the algorithms will slowly find their way to the feasible regions and individuals, but it is still advantageous to start the optimization with feasible individuals, and thus the cross-over and mutation operators can start immediately with feasible individuals. For this reason, OPAL++ offers a so-called constrained initialization, in which the starting generation will contain only feasible individuals.

#### IX.3.2.5.2 Command: ''CONSTRAINED''

• Type of parameters: TYPE = %e
• Input parameters:
• logical_value - %b: value to define, whether constrained initialization is to be used
• Description:
• Using this command, the user can define if OPAL++ should perform a constrained initialization or a normal one.

## Steps

• Example:
OPAL2.SETUP PROBLEM.CONSTRAINS.ADD({36-(X2-X1)*(X2-X1)-(Y2-Y1)*(Y2-Y1)},DESIGN,1.0)
OPAL2.SETUP PROBLEM.CONSTRAINS.FINALIZED=TRUE
2. Finalize the definition of the problem
• Example:
OPAL2.SETUP PROBLEM.FINALIZED=TRUE
3. If necessary change the solver settings for the number of individuals in a single generation as well as the number of maximum generations
• Example:
OPAL2.SETUP SOLVER.CHANGE_SETTINGS(N,40)
OPAL2.SETUP SOLVER.CHANGE_SETTINGS(GENERATION_MAX,205)
4. Define the initialization method if another method instead of random sequence is desirable (see manual page 98)
• Example:
OPAL2.SETUP SOLVER.INITIALIZATION.TYPE=SOBOL
5. To only allow the generation of valid individuals in the first generation, set the constrained initialization to true:
• OPAL2.SETUP SOLVER.INITIALIZATION.CONSTRAINED=TRUE