Convert optimization problem or equation problem to solver form
Use prob2struct
to convert an optimization problem or
equation problem to solver form.
Tip
For the full workflow, see Problem-Based Optimization Workflow or Problem-Based Workflow for Solving Equations.
,
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
argument 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.