# Xopt (User-Defined Optimization Engine)

In this section, you will find detailed information on how to setup and use the “User” optimization method in HyperStudy.

In HyperStudy, you can link to an external optimizer to use in the optimization approach. This is called a User method.

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.

- 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
- Total number of input variables.
- Number_of_constraints
- Total number of constraints.
- Variable_number
- An integer value.
- initial_value
- Initial value for the input variable.
- lower_bound
- Lower limit for the input variable.
- upper_bound
- Upper limit for the input variable.
- Constraint_number
- An integer value.
- ibound
- Either 1 or -1, this specifies whether the constraint is an upper bound or lower bound constraint, respectively.
- constraint_value
- Bound value for the constraint.

- 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:

where:`keyword Variable_number,value Variable_number,value ...`

- Keyword
- 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
- An integer value corresponding to the value assigned in the extrnopt.des file. This identifies the input variables.
- value
- 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. - 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:

where:`Number_of_constraints Constraint_number,value Constraint_number,value ... Objective_value`

- Number_of_constraints
- Total number of constraints. There must be a
"
`Constraint_number,value`

" line for each constraint. - Constraint_number
- An integer value corresponding to the value assigned in the extrnopt.dat file. This identifies the constraint.
- value
- Value of the constraint from the latest solver run.
- Objective_value
- 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. - The user-defined optimizer must always try to minimize the objective value
given in the extrnopt.rsp file.
- Minimize
- If Minimize is chosen from the HyperStudy interface, the objective is written out as the value of the objective output response.
- Maximize
- 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).
- System Identification
- If System Identification is chosen from the HyperStudy interface, the objective is calculated as:

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.