Statistical Optimization
This is a basic tutorial of Uptimai software prepared to give a first introduction to the suite,
and how to run its different features. To complete this tutorial there will be needed the
Uptimai software and a *.zip
file with some complementary files required for the example
problem to be solved. The Piston.zip
file can be found inside Uptimai Member Area ->
Downloads -> Tutorial cases.
The Piston.zip
file contains the whole project folder, so the user can start at any step of the given
tutorial. Nevertheless, if the user wants to fulfil the tutorial from the beginning, only the
set of *.txt
files with input matrices will be necessary, as all the other files will be generated
during the process.
This tutorial will show you:
- How to start the project
- How to run each program of the package
- What are the main features of each program and how to use them
- How to create a set of inputs from a previous project
- What are the results you can expect
- How to export and store output data
Part 1: Launcher
1.1: Start the program
Open the Uptimai software. You can use the Start menu or desktop shortcut if this option was selected during the installation process, or find the executable inside the installation folder
1.2: Begin the project
Create a New Project. You will have to choose an empty folder where all the project files will be located. The name of the folder will become the name of the project, in this example, we will use the name Piston. You can create the folder directly from the interface.
To switch between existing projects if needed, close the current one with the Close project button at the bottom left of the window and use the Open button of the Launcher (see Figure 1) to run another one.
Once you have created the project, an *.uptim
file will appear inside your project folder.
That file is used as a flag so the folder is recognized as an Uptimai project, and contains
the information about already available sets of input files, setups, etc.
The basic rule for the
*.uptim
file is the file name that has to be the same as the name of the project folder.
1.3: Proceed to Tools
Now, you have access to all the different features that conform to the Uptimai suite. In this tutorial, we will use them one by one.
Part 2: Input Preprocess
2.1: Open the Input Preprocessor tool
The first step of all projects is always the Input Preprocessor, which can be opened directly from the Launcher. The initial state can be seen in Figure 3. From the proposed Input name you can deduct there is already an existing set of inputs for the data analysis method and a number was appended to the prefix. In this tutorial, we will use the Statistical Optimization method. However, now we will create the initial data for the project from an already existing case.
2.2: Open an existing input
We need to find and select an existing set of input files first to copy them as input files for our case. Here we can select and Continue with the Piston_DA input created within the Data Analysis tutorial. If you've started a separate folder for the current tutorial you are working on right now, click the button Select files manually and search for all the required files.
2.3: Create a copy of input
Now, when an existing input is opened, click the Copy current input on the bottom left. Here we have the possibility to create a set of input files from the existing one, but at this time for the Statistical Optimization method. Change the New input method accordingly by selecting this option from the drop-down menu. Also, let's change the New input name to Piston_SO, so we can easily distinguish between sets of inputs created for different methods.
2.4: Define Input Variables
Although we do not need to Define Input Variables manually, navigate to this section with the item of the fishbone bar on the left. Input variables atmospheric_pressure and ambient_temperature define the environmental conditions. These cannot be optimized in reality, therefore, we need to change their Variable type in Advanced options to Uncertain.
Open to view Input Distributions
Name | Type | Parameter 1 | Parameter 2 |
---|---|---|---|
piston_weight | Uniform | 30.0 | 60.0 |
piston_surface_area | Uniform | 0.005 | 0.02 |
initial_gas_volume | Uniform | 0.002 | 0.01 |
spring_coefficient | Uniform | 1000.0 | 5000.0 |
atmospheric_pressure | Uniform | 90000.0 | 110000.0 |
ambient_temperature | Uniform | 290.0 | 296.0 |
filling_gas_temperature | Uniform | 340.0 | 360.0 |
2.5: Prepare distributions
With all input variables defined completely, pre-generate random distributions of samples that will be later used for statistical analysis and visualizations. You can set the number of generated samples in the # of Monte-Carlo Samples entry at the top of the screen.
The Prepare distributions button will generate all distributions according to the setting and then morph into the Tweak distribution options button.
2.6: Tweak Distribution Options
The Tweak distribution options button in the bottom right of the screen or the item of the fishbone navigation bar on the left switches to the Tweak Distribution Options screen. Boundaries of input distributions are adjusted here as well as the position of the nominal sample.
By default, the nominal sample position is set to be the mean value of each input distribution. It is recommended to keep in not further from this point than 10% of the input distribution range. All input files are created and saved upon the Generate data button clicking. Then, this button's label turns to Define convergence and the following section becomes accessible.
2.7: Define convergence
The next step is defining the Target percentile for each input variable. It is one of the convergence criteria of the optimization process. It defines the ratio between the original range of an input variable and the range after the optimization. The default value of is suitable for typical engineering problems.
2.8: View Data Histogram
Clicking the View Data Histogram button in the bottom right of the screen or the item of the fishbone navigation bar on the left shows the View Data Histogram screen. Check that the histograms presented for each Variable are the probability distributions wanted. You can style the plot using the Plot options section. Clicking points of interest in the plot shows the pop-up with details. Close Preprocessor button ends the current program.
Part 3: Set up the Core Solver
3.1: Start the setup GUI
Once the inputs have been generated, it is time to prepare all the settings for the solver. We can do that using the Core Solver Setup, which once opened from the Uptimai main interface has the appearance as shown in Figure 10.
3.2: Create new setup
Once the program is opened, the first thing we need to do is to create a new setup file. We can change the name of the file to UptimRes_SO to directly address the used method, and then just click on the Create button.
3.3: Select the set of inputs
Now, we will see that the Core Solver Setup has three main tabs. The first one is to select the input files that will be used in this run. In our case, we want to use the set of inputs prepared for the Statistical Optimization method. Confirm the choice with the Select this input button.
3.4: Set up the case
The second tab, which is Cases / Outputs, details all the settings that are used for tuning the core solver to the needs of each specific problem. Thus, there is a setup specific to the Statistical Optimization method we are working with. Also, there is information about which outputs we would like to study. Only the Output 1 is present at the start.
Here we want to minimize the output that represents the piston cycle time. Set the Direction accordingly. For educational purposes, let's also change the Domain convergence ratio to . This is the value of the target size of an input variable range after one iteration of the statistical optimization process. A higher number means a conservative approach and also a slightly higher number of iterations (number of surrogate models created) in total.
The Function approach options are instructions for the method of the Core Solver. Maybe you recognize the setup of the Uncertainty Quantification method. We can leave the setting in default values.
3.5: General setup
Finally, in the third tab, there is information regarding the naming of files and other solver aspects. In
this case, we can shorten the name of the output file prefix to Piston_SO and save the setup.
When we do that,
a UptimRes_SO.json
file will be generated in the project folder containing all the information
that we saved. That file will be used by the solver itself.
Part 4: Run Solver (Automation)
4.1: Create new automation configuration
Now it is time to open the Run Solver (Automation) from the Uptimai main interface. We will create a new automation file, by selecting the Create New button, choosing any name, and storing it in the project folder. Use the ⨂ at the top if you need to close an already opened automation configuration.
4.2: Add a connection
If the Uncertainty Quantification (Adaptive AI) is used as the
function approach of the Statistical Optimization, there must be third-party software that
converts a set of inputs to a set of
outputs to create the model. In this tutorial, this role is played by
a Python script called Piston.py
that you can download from the
Member Area as a part of the tutorial project, so the first step of
this process would
be to download it and paste the script into the project folder.
Then we will press the plus + button, and select the Python feature from the drop-down menu. Make sure that the correct Setup file is selected from the menu at the bottom left.
4.3: Locate the script
Finally, under the Location / CMD box, we will select the Piston.py
script that
we have previously pasted into the project folder. Since the connected script prints only one
output value we want to catch, leave the parsing set to Console There is no need to define
the Output file path or specify the Output column. You can turn on the Enable console
logging switch to print all available messages of the Python script and the Core Solver
to the console.
Display the menu with Advance options to see the Selected Python Executable. Select the system Python from the menu if needed.
4.4: Save the configuration
Clicking the Save & Run button will store all the information in an *.automation
file, and
move to the following screen where the log of the run is shown.
4.5: Run the Solver
Now, it is the moment to click the Run button and wait until the solver finishes. The solver will automatically call the Python script for the samples needed, and build the model. An Everything Finalized message will appear at the end of the log when the solver is finished.
Part 5: Result Postprocess
5.1: Open the Postprocessor
To see the results, we will open the Postprocessor from the Uptimai main interface.
5.2: Iterative file check
First of all, we will start opening the
Iterative file.
To do that we will click on the Piston.itr
file in the project files section.
The iterative files store all the samples that have been computed, so they can be reused in
future projects.
It has two ways of visualizing the data, or within a table which can be exported or as a scatter plot that allows to start visualizing the trends of how the outputs are distributed for each input. Store the table in your HDD with the Export to CSV button at the top of the screen. The plot can be saved with the 💾 icon in the upper left corner of the plot.
5.3: Open the Statistical Optimization results
All the result files generated by the Core Solver are organized in a subfolder called results_so, which can be found in the project directory tree on the left. Multiple sets of results are possible within the project, these are placed in separate folders named according to the Core Solver Setup files used for their creation.
There are two types of results. The *.upst
files are available for each iteration of the
optimization process. These can be opened and postprocessed in the same way as in the case of
standard Uncertainty Quantification results.
The postfix number Ixx represents the iteration for which the model file was generated.
Also, check for corresponding sets of input files that are available in the inputs subfolder.
But for now, we are interested in the *.upsg
file containing the Optimized Histograms.
5.4: Optimized histograms of input variables
The Optimized histograms feature offers three categories of plots that can be switched between with buttons at the top of the control panel on the left. Start with the Input screen, that appears first.
Check out Iterations from the list to see the optimization progress. In the list of Variables right below you can switch between inputs to see those you are the most interested in. The plot shows the modified input variable histograms that are shifting the statistical result closer to the optimum.
5.5: Optimized histograms of results
The second screen, Result, shows the histogram of the output value. In our case, you can observe how the range of results is narrowing from iteration to iteration. From the list of Iterations you can select or deselect histograms included in the plot.
5.6: Saving the optimum
Switching to the Optimum screen shows the very basic table with input and output values of the
Monte Carlo sample closest to the optimum. It is possible to see the optimum found in each Iteration
by clicking the wanted item in the list. Try to save at least one table as a *.csv
file with the
Export data button.