Optimization variables and expressions are the basic elements of the Problem-Based Optimization Workflow. For the legal operations on optimization variables and expressions:
y represent optimization
arrays of arbitrary size (usually the same size).
x2D represents a 2-D optimization array.
a is a scalar numeric constant.
M is a constant numeric matrix.
c is a numeric array of the same size as
The problem-based approach does not support complex values in an objective function, nonlinear equalities, or nonlinear inequalities. If a function calculation has a complex value, even as an intermediate value, the final result can be incorrect.
These operations on optimization variables or expressions return an optimization expression.
|Subtract a constant|
|Multiply by a constant scalar|
|Divide by a constant scalar|
|Pointwise multiply by an array|
|Pointwise divide by an array|
|Pointwise multiply variables|
|Matrix multiply variables|
|Matrix multiply variable and matrix|
|Dot product of variable and array|
|Linear combination of variables|
|Product of array elements|
|Trace of matrix|
|Cumulative sum or product|
|Concatenate and Reshape||Transpose|
|Create diagonal matrix or get diagonal elements of matrix|
|Elementary Functions||Power of square matrix|
|Inverse hyperbolic sine|
|Inverse hyperbolic cosine|
|Inverse hyperbolic tangent|
These operations on optimization variables return an optimization variable.
|N-D numeric indexing (includes colon and
|N-D logical indexing|
|N-D string indexing|
|N-D mixed indexing (combination of numeric, logical, colon, end, and string)|
|Linear numeric indexing (includes colon and
|Linear logical indexing|
|Linear string indexing|
Optimization expressions support all the operations that optimization variables
support, and return optimization expressions. Also, you can index into or assign
into an optimization expression using numeric, logical, string, or linear indexing,
including the colon and
end operators for numeric or linear
Constraints are any two comparable expressions that include
one of these comparison operators:
>=. Comparable expressions have the same size, or one of the
expressions must be scalar, meaning of size 1-by-1. For examples, see Expressions for Constraints and Equations.
Internally, some functions and operations call only the documented supported
operations. In these cases you can obtain sensible results from the functions or
operations. For example, currently
squeeze internally calls
reshape, which is a documented supported operation. So if you
squeeze an optimization variable then you can obtain a
If your objective function or nonlinear constraint functions are not supported,
convert a MATLAB® function to an optimization expression by using
fcn2optimexpr. For examples, see Convert Nonlinear Function to Optimization Expression or the
fcn2optimexpr function reference page.