Supported Operations for Optimization Variables and Expressions
Notation for Supported Operations
Optimization variables and expressions are the basic elements of the Problem-Based Optimization Workflow. For the legal operations on optimization variables and expressions:
yrepresent optimization arrays of arbitrary size (usually the same size).
y2Drepresent 2-D optimization arrays.
ais a scalar numeric constant.
Mis a constant numeric matrix.
cis 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.
Operations Returning Optimization Expressions
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 secant|
|Inverse hyperbolic cosecant|
|Inverse hyperbolic tangent|
a^x is not supported for an optimization variable
However, if you bound
a to be strictly positive, you can
use the equivalent
Operations Returning Optimization Variables
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|
Operations on Optimization Expressions
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
Operations Returning Constraint Expressions
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.
Some Undocumented Operations Work on Optimization Variables and Expressions
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
Unsupported Functions and Operations Require
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.