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