HyperStudy

Xopt (User-defined Optimization Engine)

Xopt (User-defined Optimization Engine)

Previous topic Next topic Expand/collapse all hidden text  

Xopt (User-defined Optimization Engine)

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

In HyperStudy, you can link to an external optimizer to use in the optimization approach. This is called a User method. In this section, you will find detailed information on how to setup and use the “User” optimization method in HyperStudy.  

When you select User method in HyperStudy, HyperOpt is invoked to manage the optimization process using the external optimizer. HyperOpt manages the optimization by providing information on problem definition to the external optimizer, initializing solver runs using input variable values obtained from the external optimizer, and providing results from analyses to the external optimizer.  The external optimizer performs the optimization using problem definition and analysis result information provided by HyperOpt.  It determines when the optimization has converged and relates this to HyperOpt, which then terminates the study.

In order for a user-defined optimizer to interface with HyperStudy/HyperOpt, four things are required:

1.The user-defined optimizer must be able to interpret the problem definition as exported by HyperStudy, to the extrnopt.dat file.

The format of the extrnopt.dat file is:

Number_of_variables

Number_of_constraints

Variable_number,initial_value,lower_bound,upper_bound

Variable_number,initial_value,lower_bound,upper_bound

...

Constraint_number,ibound,constraint_value

Constraint_number,ibound,constraint_value

...

where:

Number_of_variables is the total number of input variables.  There must be a "Variable_number,initial_value,lower_bound,upper_bound" line for each input variable.
Number_of_constraints is the total number of constraints.  There must be a "Constraint_number,ibound,constraint_value" line for each constraint.
Variable_number is an integer value.  Each input variable is assigned a variable number, starting from 1.  This number is used to identify the variable.
initial_value is the initial value for the input variable.
lower_bound is the lower limit for the input variable.
upper_bound is the upper limit for the input variable.
Constraint_number is an integer value.  Each constraint is assigned a constraint number, starting from 1.  This number is used to identify the constraint.
ibound is either 1 or -1, this specifies whether the constraint is an upper bound or lower bound constraint, respectively.
constraint_value is the bound value for the constraint.
2.The user-defined optimizer must provide design point information in a format readable by HyperStudy, in a file named extrnopt.des.

The format of the extrnopt.des file is:

keyword

Variable_number,value

Variable_number,value

...

where:

Keyword is one of design, intermediate and stop. These stand for design point, intermediate point, and converged result, respectively. Intermediate points are design points that are not stored in the iteration history (points which may be required for finite difference calculations).
Variable_number is an integer value corresponding to the value assigned in the extrnopt.dat file.  This identifies the input variables.
value is the value of the input variable for the next solver run.
Note:The format of the extrnopt.des file can be repeated to handle multiple run points.
3.The user-defined optimizer must be able to read results output by HyperStudy to the extrnopt.rsp file.

The format of the extrnopt.rsp file is:

Number_of_constraints

Constraint_number,value

Constraint_number,value

...

Objective_value

where:

Number_of_constraints is the total number of constraints.  There must be a "Constraint_number,value" line for each constraint.
Constraint_number is an integer value corresponding to the value assigned in the extrnopt.dat file.  This identifies the constraint.
value is the value of the constraint from the latest solver run.
Objective_value is the value of the objective function from the latest solver run.  Remember the optimization is to minimize this value.
Note:The format of the extrnopt.rsp file can be repeated to handle multiple run points.
4.The user-defined optimizer must always try to minimize the objective value given in the extrnopt.rsp file.
If Minimize is chosen from the HyperStudy interface, the objective is written out as the value of the objective output response.
If Maximize is chosen from the HyperStudy interface, the objective is written out with the opposite sign.  (i.e, an objective output response value of 100.0 would be written to the extrnopt.rsp file as -100.0, and an objective output response of -45.0 would be written to the extrnopt.rsp file as 45.0).
If System Identification is chosen from the HyperStudy interface, the objective is calculated as:
interfacing

An optimizer will only appear in the user-defined pull-down menu if it is registered in the current preference file.

An example of a user-defined optimizer is provided with HyperStudy.  This optimizer is called Xopt.

hmtoggle_plus1How Xopt Interfaces with HyperStudy

The files hopt_lock and extopt_lock are opened alternately to switch between the operations of HyperOpt and Xopt.  In addition, the files hopt_run and extopt_run identify if either process is still active.  Both the HyperOpt and Xopt processes are outlined below; remember that since the HyperOpt process is fixed, the user-defined optimizer must be written to work with this process.

The following flowchart illustrates the two processes:

xopt_flow

Details of each step for the two parallel processes (Xopt and HyperOpt) are provided below.  

 

HyperOpt Process

1.HyperStudy invokes HyperOpt.

Information is provided to HyperOpt on input variables, constraints, and the objective through the .opt file.

2.HyperOpt creates the files hopt_run and hopt_lock.
hopt_run indicates that HyperOpt is running.  This file is automatically deleted if HyperOpt terminates.
extopt_lock indicates that HyperOpt must wait for Xopt.
3.HyperOpt creates the file extrnopt.dat.

Xopt will read some key data (number of variables, variable bounds, constraints, etc.) from extrnopt.dat.

4.set ndes = 0.
5.HyperOpt invokes Xopt.
6.if ndes > 0, create extrnopt.rsp which contains the output response values.
7.HyperOpt creates the file extopt_lock and deletes the file hopt_lock.
8.HyperOpt checks for the existence of extopt_run; if extopt_run does not exist, go to step 14.
9.HyperOpt checks for the existence of extopt_lock.

If extopt_lock exists then HyperOpt waits, continually checking for the existence of extopt_lock.  It continues on to step 10 when extopt_lock no longer exists.

10.HyperOpt creates the file hopt_lock.
11.HyperOpt reads the file extrnopt.des; if the keyword "stop" is found in the file, go to step 14.
12.HyperOpt invokes the solver defined in the HyperStudy interface.
13.ndes = ndes + 1.

if ndes < MAXDES (maximum number of iterations), go to step 6.

14.The process ends here.

 

Xopt Process

1.Xopt creates the file extopt_run.

extopt_run indicates that Xopt is running.

2.Xopt checks for the existence of hopt_lock.

If hopt_lock exists then Xopt sleeps for 0.1 seconds and repeats step 2.

3.Xopt reads extrnopt.dat which is essential for optimization (number of variables, variable bounds, constraints, etc.).
4.Xopt performs optimization iteration.
5.Xopt writes out the next design point that needs to be analyzed to the file extrnopt.des.
6.Xopt creates the file hopt_lock.

hopt_lock indicates that Xopt must wait for HyperOpt (see step 9).

7.Xopt deletes extopt_lock.

This allows HyperOpt to continue.

8.Xopt checks for the existence of hopt_run; if hopt_run does not exist, then Xopt terminates as HyperOpt has been terminated irregularly.
9.Xopt checks for the existence of hopt_lock; if hopt_lock exists then Xopt sleeps for 0.1 seconds and repeats this step.
10.Xopt creates the file extopt_lock.

extopt_lock indicates that HyperOpt must wait for Xopt.

Xopt must remove the file extopt_lock in case of process termination.  For example, if Xopt is written using Fortran, use of the statement 'dispose = "delete"' is required.

11.Xopt reads in output responses from the file extrnopt.rsp.
12.If the optimization process has not reached convergence, go to step 4.
13.The process ends here.