May 7, 2022

# Linear Constraint Handling in Parametric Studies in pSeven

## Introduction

In most simulation tasks we should limit not only variables but set constraints on response function to eliminate infeasible solutions. Lower and upper bounds on continuous and stepped variables (see more about variables types) restrict a design space by “box” from which design points can be generated. Response constraints can linearly or quadratically depend on variables, and if the dependency is more complex, we speak about constraints of general type.

Let’s illustrate the definitions in a simple example. Suppose we've got a single-objective optimization problem with two design variables (Fig. 1). x1 and x2 are variables that defined in certain ranges. These ranges form the bounds. Imagine the objective function depends on two parameters linearly. In that case, the point corresponding to the optimal configuration would have been in the upper-left corner of the design space. Imagine also we have three generic constraints that divide the design space into feasible and infeasible areas. In accordance with the constraints, the optimal design is located on the green constraint line on the left.

*Fig. 1. Setting constraints in the single-objective optimization problem*

Box bounds are the simplest type of constraints. They are implicitly assumed and respected always. It is guaranteed that no one problem data evaluation could happen outside imposed box bounds.

Constraint responses are compatible with all design space exploration techniques in pSeven but are handled differently depending on the technique type.

- Non-adaptive DoE techniques and Adaptive design for GP use constraints to check generated designs for feasibility. That means they first generate all design points according to the Number of designs setting, and evaluate constraints after the generation phase finishes. These techniques allow constraints with no bounds and treat them as always satisfied.
- Constraint bounds are also checked when evaluating an initial sample. Points of the initial sample with constraint values out of bounds are considered infeasible and are excluded from the feasible and optimal result matrices.
- Optimization techniques and Adaptive design evaluate constraints during the optimization (generation) phase and actively use this information to discover the feasibility domain. These techniques require at least one finite bound for every constraint (every response component, in the case of multi-dimensional constraints).

Let’s continue the considering of constraints evaluation in optimization and Adaptive design techniques.

Generic constraints normally are violated until a solution is found. Violation during the optimization process depends upon the details of the particular algorithm used. The degree of violation could greatly vary depending on user settings.

Another situation is with linear and quadratic constraints. Let’s consider it in the next section.

## Linear and Quadratically Constraints in Optimization and Adaptive design studies

The Adaptive design, Gradient-based optimization, and Surrogate-based optimization techniques have the ability to create internal models of linear and quadratic responses and use these models instead of evaluating the actual response.

Based on this idea linear and quadratic constraints can be calculated separately from the simulation model that allows saving budget and computational time significantly. Linear constraints are respected always after restoration. It’s very important in engineering applications – the use of them allows to avoid degenerated designs.

Let’s consider optimization of a high-speed rotation disk geometry (Fig. 2). Disk geometry is described by 6 radii (r1 – r6) and 3 thicknesses (t1, t3, t5). The parameters r1, r5, r6, and t5 define the contact zone of rim and blades and cannot be varied, so the design variables are r2, r3, r4, t1, t3. The disk is subjected to inertial load and additional load from blades mounted on the disk. The total mass of blades (Mb), disk rotational speed (N), and material properties are additional parameters. The aim of the study is to minimize disk mass taking into account constraints on maximum radial displacement and maximum stress. Parameters constant values you can find in Table 1.

*Fig. 2. Rotating disk geometry*

*Table 1. Constant parameters values*

Each variable (r2, r3, r4, t1, t3) has their own range that specifies allowed values for it, however, as it seen from Fig. 2 r4 > r3 and r3 > r2. Thus, we can set up the same lower and upper bounds for all the radii in Design space exploration block (DSE) configuration, and add two linear constraints functions in addition, setting them in a separate block (Fig. 3):

c1 = r3 – r2 > 0,

c2 = r4 – r3 > 0.

*Fig. 3. Design space exploration block configuration*

To enable a linear type of constraints the Function type hint should be switched to Linear (Fig. 3). Use this Hint pane to enable Quadratic type also. Special port with the corresponding postfix. Linear will appear on the Ports and parameters tab that allows connecting the constraint to another block which calculates the corresponding value. Since the inequalities are strict, float value 10e-4 is set as a lower bound.

To define the linear constraints PythonScript block can be used (Fig. 4).

*Fig. 4. Defining of linear constraints*

An autolink is enabled during the connection because variables names both in DSE and PythonScript blocks are the same (Fig. 5).

*Fig. 5. Optimizer and LinearConstraints blocks connection*

After the workflow finished, we see that the number of linear constraints evaluations is 6 (Fig. 6). That is because the dimension of variables space is N_{dim }= 5, and a number of linear constraints evaluations is N = N_{dim}+1.

*Fig. 6. Number of blocks iterations with linear constraints*

The fundamental idea of the story is the following: it’s not necessary to evaluate linear constraints as much as the model (187 times as see from Fig.6)! In pSeven linear constraints can be reconstructed one time before the blackbox evaluation if handled separately, and then respected.

## Conclusion

In this Tech Tip, we have talking about different types of constraints and considered an example of using linear constraints in the single-objective optimization problem. The main idea of the study is to show how pSeven handles constraints, and what way we can use to state our problem correctly to obtain the best solution in a short time. As it was said above, we can treat linear and quadratic constraints using a special approach that helps to save computational budget.