How to use Machine Learning as OptiStruct Response

Charles Mortished_21141
Charles Mortished_21141
Altair Employee

Wouldn’t it be great to be able to use a Machine Learning model as a response within OptiStruct? A regression model could be used to to represent a Key Performance Indicator (KPI) that could not otherwise be considered in your optimization, or a classification model could be used to define a constraint that would otherwise be difficult to define using normal responses. This blog post describe how a PhysicsAI Expert Emulation classifier can be used as a response within an OptiStruct optimisation to differentiate between two different deformation shapes. 

PhysicsAI Expert Emulation, read more here, takes a Design of Experiments (DOE), reads the results files and uses clustering to visualize the different behaviours within your design space. It then allows you to create a classifier which describes your desired behaviour that can then be used to automatically identify the behaviour of a new analysis. 

How do we couple with OptiStruct with our external our machine learning model? The answer is the DRESP3 card (external response), which allows us to create a bridge to Excel, Fortran, C or Altair Compose. To use the Altair PhysicsAI Machine Learning libraries we must be able to access python, a C or Fortran library would require compiling, but Altair Compose has a built in bridge to python – no compiling required! This gives us the following workflow,

 

image

 

To test this workflow we need a model, so lets use an example from the OptiStruct help, OS-E: 0930, which explains how to create a DRESP3 that interfaces with Compose. This example contains a quarter of a radar dish under gust loading. Symmetry conditions are applied on the horizontal and vertical webs, the support beam is fully fixed at ground and loading is applied via a pressure load on the dish's skin. Gauge design variables are defined on the skin and the webs and a discrete design variable is defined on the materials Young's modulus. 

image 

 

To create our PhysicsAI Expert Emulation machine learning model, we will need to create a dataset. We can do this by running a Design of Experiments (DOE) in HyperStudy where each point is an analysis only of the above radar dish with different values for the design variables at each design point. This DOE can then be post-processed by the PhysicsAI Expert Emulation in HyperWorks Desktop, shown below,

 

 image

 

Interrogating the displacement shape we can see that there are two main behaviours within the design space, one with a smooth displacement and another with displacement concentrated in the top right hand corner of the radar. PhysicsAI Expert Emulation can create a classifier which can predict class membership not only from a results file but also from an internal field predictor (read more about field prediction here).

Using the internal field prediction will allow us to perform a classification from design variable values rather than from a new result file. For this example model, the classification model has an accuracy of 100% when predicting from both the result file and internal field predictor on a test set and the internal field predictor has an R2 value of 0.93, so we can be confident that we will get accurate predictions.

Now that we have our classification model we must link it to our OptiStruct model using a DRESP3. To do this we will use Compose and its python bridge functionality. In Compose we create the following function to be called from OptiStruct, as shown below, where our design variable inputs are contained within “rparam” and the output is saved to “rresp”. We export the design variables to python, run a script which runs our PhysicsAI – Expert Emulation classifier, and then returns the probability that the design is in the group we want from the “class_probability” variable.

 

 image

 

We can then reference our function in OptiStruct as a library with the following line in the optimisation header,

image

and then create the design response which refences that library with the following card in the bulk data.

image

Now we can treat our machine learning response in the same way as any other response. In this case the DRESP3 will return the probability that the design is in the desired class, this is preferable to just the class label (eg, group 1 or 2) as the probability will be continuous allowing for optimizer to calculate gradients.  

Lets test the classification response by setting up two optimizations, one targeting each deformation group. We will target each group by adding a constraint that the probability that the design is a member of that group is over 60%. For the first optimization we will minimize the mass and target Group 1. The results can be seen below, 

image

We achieve a design that visually meets the requirement of Group 1, with a smooth displacement gradient increasing towards the right hand edge. 

For the second optimization we will target Group 2, however targeting Group 2 and minimizing mass would not conflict so the optimizer would just set all of the design variables to their lower bound. Changing the objective function to maximize the mass will conflict with targeting Group 2 so we can be sure that the classification constraint is active. 

image

Visually we can see that the optimizer has produced a result in Group 2, with displacement concentrated in the top right corner of the radar. Optimization 1 has a lower mass than Optimization 2 so we can be confident that we are not simply finding solutions which meet our group requirement by globally increasing or reducing thicknesses, showing that our classification constraint is active and effective. Note that the classification is based on the displacement shape rather than simply the magnitude of the displacement, something that would be difficult to do using KPI based constraints.

 

This approach is not limited to PhsyicsAI Expert Emulation, any library or function that can be called from Python could be used. Maybe you could include a regression model to bring in representation a KPI of a different physics to your optimization, for example, a regression fit of a Electro-Magnetic KPI within a Structural optimisation. Do you have any optimisations which could benefit from using machine learning? Please comment below or get in touch.