Polynomial expressions
Starting from YALMIP 3, polynomial expressions are supported. These
nonlinear expressions can be used for, e.g., SDPs with BMI constraints,
quadratic programming, or
to solve sum-of-squares problems.
Nonlinear expressions are built using
sdpvar objects, and are manipulated in same way
x = sdpvar(1,1);
y = sdpvar(1,1);
p = 1+x*y+x^2+y^3;
Y = sdpvar(3,3);
Z = Y*Y+Y.*Y;
|
A convenient command is
sdisplay (symbolic display)
sdisplay(p)
ans =
'1+xy+x^2+y^3'
|
Some simple operators for polynomials have been implemented, such as
differentiation.
dp = jacobian(p);
d2p = jacobian(jacobian(p)');
|
Checking the degree is easily done
degree(p)
ans =
3
degree(p,x)
ans =
2
|
Of course, all standard operators applies to the nonlinear objects.
x = sdpvar(3,1);
p = 5*trace(x*x') + jacobian(sum(x.^4))
|
Clear the internals of YALMIP on a regular basis with
the command yalmip('clear') when working with polynomial
expressions. The reason is that every time a nonlinear variable is defined,
a description on how it is created is saved inside YALMIP (all monomials
generate new variables). With many
nonlinear terms this list grows fast, making YALMIP slower and slower since
the list has to be searched in when polynomial expressions are manipulated.
The current implementation of the
polynomial objects is inefficient for large problems. Multiplying two
matrices of dimension, say 20, takes several seconds. But if you have a
problem with this type of non-linearity, the solver will probably be the
bottle-neck anyway...
|