Convert optimization problem or equation problem to solver form

,
for any input arguments, specifies additional options using one or more name-value
pair arguments. For example, for a nonlinear optimization problem, `problem`

= prob2struct(___,`Name,Value`

)```
problem
= prob2struct(prob,'ObjectiveFunctionName','objfun1')
```

specifies that
`prob2struct`

creates an objective function file named
`objfun1.m`

in the current folder.

If you call

`prob2struct`

multiple times in the same MATLAB^{®}session for nonlinear problems, use the`ObjectiveFunctionName`

or`'EquationFunctionName'`

arguments, and, if appropriate, the`ConstraintFunctionName`

argument. Specifying unique names ensures that the resulting problem structures refer to the correct objective and constraint functions. Otherwise, subsequent calls to`prob2struct`

can cause the generated nonlinear function files to overwrite existing files.To avoid causing an infinite recursion, do not call

`prob2struct`

inside an objective or constraint function.When calling

`prob2struct`

in parallel for nonlinear problems, ensure that the resulting objective and constraint function files have unique names. Doing so avoids each pass of the loop writing to the same file or files.

The basis for the problem structure is an implicit ordering of all problem variables
into a single vector. The order of the problem variables is the same as the order of the
`Variables`

property in `prob`

. See `OptimizationProblem`

. You can also find the order by using `varindex`

.

For example, suppose that the problem variables are in this order:

`x`

— a 3-by-2-by-4 array`y`

— a 3-by-2 array

In this case, the implicit variable order is the same as if the problem variable is
`vars = [x(:);y(:)]`

.

The first 24 elements of `vars`

are equivalent to
`x(:)`

, and the next six elements are equivalent to
`y(:)`

, for a total of 30 elements. The lower and upper bounds
correspond to this variable ordering, and each linear constraint matrix has 30
columns.

For problems with general nonlinear objective or constraint functions,
`prob2struct`

creates function files in the current folder or in
the folder specified by `FileLocation`

. The returned
`problem`

structure refers to these function files.