JFT146OptimizationWithSurrogateModel e
JFT146OptimizationWithSurrogateModel e
Contents
Overview........................................................................................................................................ 2
1 Function Description ................................................................................................................... 3
1.1 Generating the Sampling Case ........................................................................................... 3
1.2 Creating the Surrogate Model.............................................................................................. 5
1.3 Optimization (Using the Surrogate Model) .......................................................................... 6
2 Performing the Procedure .......................................................................................................... 8
2.1 Starting JMAG-Designer .................................................................................................... 11
2.2 Loading the Model ............................................................................................................. 11
2.3 Checking the Optimization Conditions ............................................................................... 11
2.4 Creating the Sampling Case .............................................................................................. 12
2.5 Adding and Running the Sampling Case ........................................................................... 14
2.6 Creating the Training Data ................................................................................................. 15
2.7 Creating the Surrogate Model............................................................................................ 17
2.8 Evaluating the Accuracy of the Created Surrogate Model ................................................. 19
2.9 Optimization Calculation Using the Selected Surrogate Model ......................................... 21
2.10 Checking the Results ....................................................................................................... 23
Overview
When running optimization calculations using GAs (genetic algorithm: Generation Algorithm),
the population size and the maximum number of generations depend on the number of design
variables. When there are many design variables, this causes an increase in the number of
calculation cases as well as calculation time. In JMAG, optimization calculation times can be
reduced by using surrogate models.
This document describes as the workflow for optimization calculations using surrogate models
creating training data, creating the sample case, and using a surrogate model in running
optimization calculations.
Keywords: Surrogate model, Pre-installed script, Python, Optimization, AI, Machine learning
Important Notes
Surrogate models cannot be used with optimization calculations that correspond to any of
the following.
Topology optimization calculations or topology optimization (sensitivity analysis)
calculations
Parameter optimization studies where values measured from geometry (surface
area, etc.) are included in objective functions and constraints
Optimization calculations that use [Quadratic Response Surface] or [Matlab Global
Optimization] as the [Optimization Engine]
2
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
1 Function Description
1.1 Generating the Sampling Case
[Generate sampling cases (beta version)] is a function for creating calculation cases (sampling
cases) appropriate for use with training data sets (Table 1-1). Sampling case lists are exported
in a CSV file format, and those CSV files can be imported to studies from the [Design Table]
dialog box.
In the [Optimization] dialog box, set the parameter variables to be used and the range of those
parameter variables. Output CSV file formats are the same as those exported from the [Design
Table] in JMAG-Designer. To add generated cases, import CSV files with the [Design Table].
Use either [Latin Hypercube Sampling] or [Random Sampling] as the sampling method.
Compared to [Random Sampling], [Latin Hypercube Sampling] has a tendency to average the
sampling case distribution in the design space. It is for this reason that using [Latin Hypercube
Sampling] is recommended.
Important Notes
Variables to be optimized can be selected in the [Parametric Variable Range] in the
[Constraint Conditions] tab of the [Optimization] dialog box. Variables selected here,
however, must be in the same order as those in the [Design Table]. Ensure that variables
are arranged from the left side in the [Design Table] (Fig. 1-1).
Variables not selected in the [Parametric Variable Range] and variables that are
dependent on other design variables (dependent variables) are not output to the CSV
files of sampling cases. Variables such as these should be added to the CSV files of
sampling cases manually.
It is not entirely necessary to use this function for creating calculation cases for use with
training data sets. When it is difficult to obtain valid geometry, for example, instead create
calculation cases referring to the below function tutorial.
3
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
Only those with check boxes selected are output to CSV files.
and ensure that case list variables are aligned from the left.
Fig. 1-1 Order of the variables for [Optimization] and the [Design Table]
4
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
Variable name Input for the names of response values that are output
Table 1-3 Files output with [Create a surrogate model (beta version)]
Parameter Description
5
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
Important Notes
Variables to be optimized can be selected in the [Parametric Variable Range] in the
[Constraint Conditions] tab of the [Optimization] dialog box. Variables selected here,
however, must be in the same order as those in the [Design Table]. Ensure that variables
are arranged from the left side in the [Design Table] (Fig. 1-1).
When [Use Only Existing Cases] is selected in the [Initial Cases] tab of the [Optimization]
dialog box, all cases that are added to optimization studies are used. It is not possible to
use only selected cases as the initial case.
[Do Not Add Unnecessary Cases Due to Geometry or Constraint Errors] in the [Options]
tab of the [Optimization] dialog box is not supported.
Because environment variables are used to control parameters, multiple optimization
calculations cannot be run simultaneously.
JMAG-RemoteSystem does not support CPU group settings.
6
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
Table 1-4 [Optimization (using surrogate model, beta version)] setting items
Parameter Description
Surrogate model update Specify whether or not to update the surrogate model per a certain
Specify the rate at which to run FEA for cases generated during
FEA execution rate(%)
optimization
SSH execution * Machine names and CPU groups are obtained automatically from
optimization settings
7
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
<Initial conditions>
The following environment is required in order to perform this tutorial.
Versions of Python 3 are required to run the scripts (Python 2.7 is not supported).
The required Python library for running the scripts is installed with JMAG-Designer.
It is necessary however that "tensorflow" and redistributable packages are
positioned by the users themselves on the machines that are to use JMAG.
"tensorflow" and redistributable packages can be obtained from the JMAG website in
a compressed file format (*.zip).
Refer to the ReadMe.txt file located in the compressed files for more information on
the procedures.
JMAG website:
https://www.jmag-international.com/support/en/download/index.html
8
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
Yoke
Magnetization
direction
Cavity part material
(Non-magnetic material)
9
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
Yoke
Magnet
Non-magnetic material
Cavity space
Y
Z X
A B C
Bx
By Degy_theta
B, T
Y
Z X
10
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
1. Start JMAG-Designer.
11
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
a 3 10
Constraint
b 1 10
Conditions
c 1 10
1. Click the [Scripts] tab in the [Toolbar], and right-click [Generate sampling cases (beta
version)] under [Preinstall].
2. Select [Run] from the context menu (Fig. 2-4-1).
The script editor opens.
Ensure that the script editor remains open.
The [Generate sampling cases (beta version)] dialog box appears (Fig. 2-4-2).
3. Set the parameters (Table 2-4-1).
The file name in this example is "JFT146A.csv".
4. Click [OK].
The [Generate sampling cases (beta version)] dialog box closes, and the message box
appears.
5. Click [OK].
The message box closes.
6. Check the created CSV file.
Generate the sampling case based on the [Parametric Variable Range] confirmed in Step
2.3.
12
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
Fig. 2-4-3 Message for completing [Generate sampling cases (beta version)]
Table 2-4-1 [Generate sampling cases (beta version)] dialog box setting values
Parameter Setting
150
13
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
14
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
1. Right-click [Graphs] under [Study] > [Result Items] > [Response Graph] in the [Project
Manager] tree.
2. Select [Generate] from the context menu.
The [Response Graph] dialog box appears.
3. Select "Bmin" for [Y axis] in the [Response Graph] dialog box.
4. Click [OK].
The [Graph] dialog box appears (Fig. 2-6-1).
Check that there are no abnormal values, such as those that are unusually large or small,
or any unusual positive or negative signs
5. Similarly display the "degy_theta" graph and check that the "degy_theta" graph is also
without any unusual values (Fig. 2-6-2).
In the event that there are any unusual values, then delete the cases where these have
occurred, and to compensate, create the training data of the deleted portion again. If
there are no remaining issues, then proceed to the next step.
6. Right-click [Response Data] under [Study] > [Results] > [Response Graph] in the [Project
Manager] tree.
7. Select [View Response Table] from the context menu.
The [Response Table] dialog box appears.
8. Click [Export].
The [Export Data] dialog box appears.
9. Create an arbitrary folder.
The file name in this document is "Response.csv".
10. Click [Save].
The [Export Data] dialog box closes.
11. Click [Close].
The [Response Table] dialog box closes.
15
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
exactly.
exactly.
16
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
1. Click the [Scripts] tab in the [Toolbox] and right-click [Create a surrogate model (beta
version)] under [Preinstall].
2. Select [Run] from the context menu (Fig. 2-7-1).
The [Create a surrogate model (beta version)] dialog box appears (Fig. 2-7-2).
3. Set the parameters (Table 2-7-1).
4. Click [OK].
The [Create a surrogate model (beta version)] dialog box closes.
When the surrogate model has finished being created, the message box appears (Fig. 2-
7-3).
5. Click [OK].
The message box closes.
The CSV and ZIP files are created in the specified folder with the set variable names.
17
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
Fig. 2-7-3 Message for completing [Create a surrogate model (beta version)]
Table. 2-7-1 [Create a surrogate model (beta version)] dialog box setting values
Parameter Setting
Variable Bmin,degy_theta
Number of Divisions 5
Selected
Arbitrary folder
Surrogate model output path
(Example: D:¥JFT146¥JFT146B)
18
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
0.8
0.6
predict
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1
correct
19
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
40
30
predict
20
10
0
0 10 20 30 40
correct
20
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
Fig. 2-9-1 Script for [Optimization (using surrogate model, beta version)]
21
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
Fig. 2-9-2 [Optimization (using surrogate model, beta version)] dialog box
Fig. 2-9-3 Message for completing [Optimization (using surrogate model, beta version)]
Table 2-9-1 [Optimization (using surrogate model, beta version)] dialog box setting values
Parameter Setting
Surrogate model path The folder specified for output in Step 2.7
30
FEA execution rate(%)
* The criteria is 30% or more
22
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
Fig. 2-10-1 Optimization calculation results CSV file using the surrogate model
Because random numbers are used when multi-objective algorithms are selected for the optimization
23
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
30
25
20
size
15
10
0
0 200 400 600 800 1000 1200 1400
case
0.8
0.7
0.6
0.5
Bmin
0.4
0.3
0.2
0.1
0
0 200 400 600 800 1000 1200 1400
case
24
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
4
degy_theta
0
0 200 400 600 800 1000 1200 1400
case
END
25
JFT146-02e
JMAG Function Tutorial - Optimization Calculation Using Surrogate Models -
URL https://www.jmag-international.com/tutorial/
JSOL Corporation
[email protected]
Technical Support
or
A distributor in your country
26
JFT146-02e