March 31, 2023
Train model with input and output constraints
Any technical object is designed in accordance with the operability conditions – the values of all output parameters of the object shall stay within the bounds defined by the requirements of technical documentation. The set of input parameters that provides the fulfillment of the operability conditions determines the operability domain.
Quite often, a surrogate model that substitutes a complex design object is trained for further export and integration into a 1D scheme that model the entire technical unit or technological process. That model shall interact with other blocks in the scheme and altogether reflect the behavior to the real object as close as possible. Therefore when building a surrogate model, it is important to be able to introduce constraints on input and output parameters so that this mathematical model reflects the behavior of the model from a real world perspective.
In pSeven 6.43 release you can now specify valid input ranges and output thresholds for selected input and output parameters by using Build model dialog.
The user can specify input ranges if the model’s input domain shall be limited (figure 1).
Fig 1. Build model dialog in Analyze. Input ranges
The trained model will output NaN if the input point is outside the domain. This possibility allows the user to add so called "common sense" to the model. If the model is integrated into complex scheme as a block, then this behavior allows to investigate the incorrect use of the model and possibly detect the errors in the scheme.
If the user specifies the input ranges for the parameters, the value of option InputDomainType is set to Manual (figure 2). The list of values for this option can be found in the documentation.
Fig 2. Model details
Let’s consider how setting the input ranges reflects the behavior of other values of the InputDomainType option. These examples extend the description in tech tip.
Figure 3 shows prediction of the model built with input ranges presented on figure 1. The model predicts NaN values outside the specified ranges.
Fig 3. Prediction of model with Manual mode
If we set the Box type for the InputDomainType option (figure 4), then the resulting box-bound domain becomes an intersection of the training sample’s bounding box (determined automatically by GTApprox tool) and the input ranges (figure 5).
Fig 4. Build model dialog in Analyze. InputDomainType option
Fig 5. Prediction of model with Box mode
If we set the Auto type for the InputDomainType option, then the previously described box-bound domain becomes additionally bounded by an ellipsoid (quadratic constraints) which envelops the training sample (figure 6). Figure 7 demonstrates the results of prediction with squeezed ranges for input parameters: x1 = [-0.6,0.6], x2 = [-0.6,0.6]. The trained model predicts NaN values for points outside the color region.
Fig 6. Prediction of model with Auto mode
Fig 7. Prediction of model with Auto mode. Input ranges: x1 = [-0.6,0.6], x2 = [-0.6,0.6]
The user can specify output thresholds when it is known that output values must be kept within a certain range. The trained model adjusts to those thresholds so its output values always stay within the specified thresholds.
Let’s consider the case of pultrusion of glass-fiber reinforced profile which is described in detail here. The input parameters are as follows: u – pulling speed; t0 – initial temperature of resin; t1 – die first-zone temperature; t2 – die second-zone temperature. The degree of polymerization (cure) that characterizes the changes of phase state is one of the output parameters of the computational model. The cure degree must be in the range from 0 to 1 by definition. For demonstration purpose, we will consider only this parameter.
Let’s build two models that substitute this complex computational model for the following analysis. The first model is built without any thresholds; the second model is built with the threshold on the cure degree (figure 8).
Fig 8. Build model dialog in Analyze. Output threshold
Histogram plots provide the distribution of prediction of polymerization degree obtained with two models for two DoE sets generated with Latin Hypercube Sampling technique (LHS). Table 1 provides the bounds of input parameters for DoE.
The histograms show that the trained model without constraint predicts the values of polymerization degree outside the threshold [0,1], while the model built with constraint predicts the values that are within the specified threshold [0,1].
Table 1. Bounds of input parameters for DoE (lb – lower bound, ub – upper bound)
Fig 9. Prediction of polymerization degree for trained models without constraint (red) and with constraint (green) on DoE 1
Fig 10. Prediction of polymerization degree for trained models without constraint (red) and with constraint (green) on DoE 2
It should be noted that GTApprox tool does not just "cut" the model at the threshold, instead it builds a model that smoothly tends to the threshold but never violates it, this better matches the behavior of real physical object. This behavior is demonstrated on the slices plotted for cure prediction with three fixed input parameters (t0, t1 and t2) and one variable (u). Table 2 provides the values of the input parameters for DoE.
We see that the trained model without constraint takes values outside the feasible domain, while the model built with constraint smoothly approaches the imposed thresholds [0,1] and stay inside feasible domain.
Table 2. Values of input parameters for DoE
Fig 11. Prediction of polymerization degree for trained models without constraint (red) and with constraint (green) on DoE 3
Fig 12. Prediction of polymerization degree for trained models without constraint (red) and with constraint (green) on DoE 4
In this tech tip, we considered how to specify valid input ranges and output thresholds for selected input and output components of the surrogate model. It is especially useful when the trained model is exported and integrated into another model (i.e. 1D) as a «black box» and supposed to interact with other models in order to reflect the behavior to the real system as close as possible.
By Dinara Shvarts, Application Engineer, DATADVANCE