Tutorial Modefrontier
Tutorial Modefrontier
Requirements
In this tutorial modeFRONTIER version 4.5.3 and Hopsan version 0.6.8 on a Windows operating
system are used. It should, however, work on Linux systems with some minor modifications. Some
basic knowledge of Hopsan and design optimization is also required. It is recommended to do the
"Getting Started", "Advanced Usage" and "Optimization" tutorials before this one.
Hopsan and modeFRONTIER will communicate by using comma-separated files (.csv). Before
we create the modeFRONTIER project we will need to extract two files from Hopsan to use as
templates.
Open a command prompt in Windows
Go to the folder you created
Execute HopsanCLI with the following command (change the Hopsan installation path to
the one you have):
c :\" Program Files ( x86 ) "\ hopsan \ bin \ HopsanCLI -- hmf PositionServo . hmf
-- simulate hmf -- re su l ts Fi na l CS V resultsFinal . csv
-- p ar am et e rE xp or t parameters . csv
This will open the model, simulate it and generate .csv files for parameters and final values of
the data variables.
2. Build the modeFRONTIER project
Now it is time to build the project in modeFRONTIER.
Open modeFRONTIER
Create a new project and save it in the folder you created
Add the following process nodes:
Scheduler
DOS Batch Script
Logic End
Add the following nodes for input data:
2x Input Variable
Input File
Support File
Add the following nodes for output data:
Output File
Output Variable
Design Objective
Connect the nodes as shown in the picture below
2
This will tell HopsanCLI to load the specified model, load parameters from parameters.csv,
simulate the model and then write the final values of all data variables to resultsFinal.csv.
Click "Ok" twice
10. Choose initial distribution and algorithm
Finally, we must configure the optimization in modeFRONTIER. For this example we will use
a random initial distribution and the Simplex algorithm. It is of course possible to use other
distributions and algorithms as well.
Double-click on the DOE node
DOE
Select "Random" under "Space Fillers" to the left
Click on "Add DOE Sequence"
Click "Ok"
Double-click on the scheduler node
Scheduler
Select "Simplex" under "Heuristic Optimizers"
Click "Ok"
11. Run an optimization
Now everything is prepared for starting the optimization!
Make sure the model is saved
Go to the "Run Analysis" mode
Start the optimization by clicking on the green arrow to the top right of the workspace
Run/Stop
This will generate a file called "resultsFinal.csv", which we will use below.
3. Modify the HopsanCLI script
Now we must modify the script where modeFRONTIER calls HopsanCLI, so that the full result
file is updated after each simulation.
Double-click on the script node
DOS Batch Script
Click on "Edit DOS Batch Script"
Modify the command to the following:
C :\" Program Files ( x86 ) "\ Hopsan \ bin \ HopsanCLI -- hmf PositionServo . hmf
-- simulate hmf -- re sultsFul lCSV resultsFull . csv
-- p ar am et e rI mp or t parameters . csv