HyperStudy

HS-1040: Registering HyperMath Functions in HyperStudy

HS-1040: Registering HyperMath Functions in HyperStudy

Previous topic Next topic Expand/collapse all hidden text  

HS-1040: Registering HyperMath Functions in HyperStudy

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

HyperStudy can be connected to HyperMath either using HyperMath as a solver or by registering HyperMath functions to be used in HyperStudy’s evaluation (this tutorial).  ,+36-9

In this tutorial you will learn how to register a HyperMath function in HyperStudy using the Preference file (.mvw) and then use the registered function for output response evaluation in the study. The Rosenbrock function is defined as an HML script and registered in HyperStudy. The example defines two input variables labeled x and y, respectively.  The objective of the optimization is to minimize f(x,y)= 100*(y-x^2)^2 + (1-x)^2.  The range for x and y is set to [-2 ; 2] , and the start point is [1.2 ; 1.1].

The files used in this tutorial can be found in <hst.zip>/HS-1040/. Copy the tutorial files from this directory to your working directory.

hmtoggle_plus1greyStep 1: Create the HyperMath Function
1.Start HyperMath.
2.From the menu bar, click File > New.
3.In the Create New File dialog, select HyperMath File.
4.Click OK. HyperMath opens a new .hml file.
5.In the editor, enter the following HyperMath commands:

hmathcommands

6.Form the menu bar, click File > Save As.
7.In the Save As dialog, navigate to your working directory and save the file as ros_function.hml.
8.Quit HyperMath by clicking File > Exit from the menu bar.

 

hmtoggle_plus1greyStep 2: Add the Function to the Preference File
1.In a text editor, open the HML_prefs.mvw file.
2.Replace <path> with the actual location of the .hml file.

*Id("HyperStudy v12.0")

  *BeginDefaults()

     *BeginPlotDefaults()

     *RegisterHMATHFunction("ros_eval", "<path>/ros_function.hml", 2)

  *EndPlotDefaults()

*EndDefaults()

3.Save the changes you made to the preference file.
4.Close the text editor.

 

hmtoggle_plus1greyStep 3: Perform the Study Setup
1.Start HyperStudy.
2.From the menu bar, click File > Use Preferences File.
3.In the HyperStudy - Set Preference File dialog, open the HML_prefs.mvw file.
4.To start a new study, click File > New from the menu bar, or click files_new_hst2 on the toolbar.
5.In the HyperStudy – Add dialog, enter a study name, select a location for the study, and click OK.
6.Go to the Define Models step.
7.Add an Internal Math model.
a.Click Add Model.
b.In the HyperStudy - Add dialog, select Internal Math and click OK.
8.Go to the Define Input Variables step.
9.Add input variables.
a.Click Add Input Variable.
b.In the HyperStudy - Add dialog, add two input variables labeled X and Y.
c.Change both input variable's lower, initial and upper bounds to the values indicated in the image below.

hs_1500_bound_values

10.Go to the Specifications step.

 

hmtoggle_plus1greyStep 4: Perform the Nominal Run
1.In the work area, set the Mode to Nominal Run.
2.Click Apply.
3.Go to the Evaluate step.
4.Click Evaluate Tasks. An approach/nom_1/ directory is created inside the study directory.
5.Go to the Define Output Responses step.

 

hmtoggle_plus1greyStep 5: Create and Define Output Responses
1.Click Add Output Response.
2.In the HyperStudy - Add dialog, add one output response.
3.In the Expression column of Response 1, click hs_popupdialogicon.
4.In the Expression Builder, click the Functions tab.
5.From the list of available functions, select ros_eval.
6.Click Insert Varname. The function ros_eval() appears in the Evaluate Expression field.
7.Click the Design Variables tab.
8.In the work area, select the input variables X and Y.
9.Click Insert Varname. The input variables appear in the expression as ros_eval(XY).
10.In the Evaluate Expression field, enter a comma in-between the input variables X and Y.

hs_1500_ros_eval

11.Click Evaluate Expression. The expression ros_eval(X,Y) changes to 404.
12.Click OK. This completes the study setup.

 

hmtoggle_plus1greyStep 6: Run an Optimization Study
1.In the Explorer, right-click and select Add Approach from the context menu.
2.In the HyperStudy - Add dialog, select Optimization and click OK.
3.Go to the Select Output Responses step.
4.Add an objective.
a.Click the Objectives tab.
b.Click Add Objective.
c.In the HyperStudy - Add dialog, add one objective.
d.In the Type column, select Minimize.

hs_1500_objective

5.Click Apply.
6.Go to the Specifications step.
7.In the work area, set the Mode to Adaptive Response Surface Method (ARSM).
Note:Only the methods that are valid for the problem formulation are enabled.
8.Click Apply.
9.Go to the Evaluate step.
10.Click Evaluate Tasks.
11.Optional. Click the Iteration Plot tab to monitor the progress of the optimization.

0050_final

 

 

 

See Also:

HyperStudy Tutorials