[37] | 1 | function F = set(varargin) |
---|
| 2 | %SET Defines a constraint (the feasible set) |
---|
| 3 | % |
---|
| 4 | % F = SET([]) Creates an empty SET-object |
---|
| 5 | % F = SET(X > Y) Constrains X-Y to be positive semi-definite if X-Y is Hermitian, |
---|
| 6 | % interpreted as element-wise constraint otherwise |
---|
| 7 | % F = SET(X==Y) Element-wise equality constraint |
---|
| 8 | % F = SET(CONE(X,Y)) Second order cone constraint ||X||<Y (X column vector, Y scalar) |
---|
| 9 | % |
---|
| 10 | % Constraints can also be generated using string notation (displays nicely with syntax high-lightning) |
---|
| 11 | % F = SET('X>Y') Constrains X-Y to be positive semi-definite if X-Y is Hermitian, |
---|
| 12 | % interpreted as element-wise constraint otherwise |
---|
| 13 | % F = SET('X==Y') Element-wise equality constraint |
---|
| 14 | % F = SET('||X||<Y') Create second order cone constraint (X and Y column vectors) |
---|
| 15 | % F = SET('cone(X,Y)') Create second order cone constraint (X and Y column vectors) |
---|
| 16 | % |
---|
| 17 | % Variables can be constrained to be integer or binary |
---|
| 18 | % F = SET(INTEGER(X)) |
---|
| 19 | % F = SET(BINARY(X)) |
---|
| 20 | % |
---|
| 21 | % Multiple constraints are obtained with overloaded plus |
---|
| 22 | % F = SET(X > 0) + SET(CONE(X(:),1)) + SET(X(1,1) == 1/2) |
---|
| 23 | % |
---|
| 24 | % Double-sided constraint (and extensions) can easily be defined |
---|
| 25 | % The following two comands give equivalent problems |
---|
| 26 | % F = SET(X > 0 > Y > Z < 5 < W) |
---|
| 27 | % F = SET(X > 0) + SET(0 > Y) + SET(Y > Z) + SET(Z < 5) + set(5 < W) |
---|
| 28 | % |
---|
| 29 | % A constraint can be tagged with a name or description |
---|
| 30 | % F = SET(X > Y,'tag') Gives the constraint a description (used in display/checkset) |
---|
| 31 | % |
---|
| 32 | % General info |
---|
| 33 | % |
---|
| 34 | % The right-hand side and left-hand side can be interchanged. Supports {>,<,>=,<=,==}. |
---|
| 35 | % See FAQ for information on strict vs. non-strict inequalities. |
---|
| 36 | % |
---|
| 37 | % Any valid expression built using DOUBLEs & SDPVARs can be used on both sides. |
---|
| 38 | % |
---|
| 39 | % The advantage of using the string notation approach is that more information will be |
---|
| 40 | % shown when the SET is displayed (and in checkset) |
---|
| 41 | % |
---|
| 42 | % See also DUAL, SOLVESDP, INTEGER, BINARY |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | if isa(varargin{1},'blkvar') |
---|
| 47 | varargin{1} = sdpvar(varargin{1}); |
---|
| 48 | end |
---|
| 49 | |
---|
| 50 | switch nargin |
---|
| 51 | case 0 |
---|
| 52 | F = lmi; |
---|
| 53 | case 1 |
---|
| 54 | F = lmi(varargin{1}); |
---|
| 55 | case 2 |
---|
| 56 | F = lmi(varargin{1},varargin{2}); |
---|
| 57 | case 3 |
---|
| 58 | F = lmi(varargin{1},varargin{1},varargin{3}); |
---|
| 59 | otherwise |
---|
| 60 | end |
---|
| 61 | |
---|