Message Boards Message Boards

0
|
2287 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Indirect constraint on a variable in RegionPlot?

Posted 8 years ago

I am trying to first define a matrix variable X symbolically as follows: $X=x*x^T$, where X is a matrix and x is a vector in $R^2$ and defined as $x=[x_1\ \ x_2]^T$. Then, I want to impose constraints on X but use RegionPlot to plot $x_1$ and $x_2$. Below is a code that I am using now but whenever I run it, I don't get any plot. What am I doing wrong and could anyone help me with this? Please note that I am trying to plot the feasible region of the SDP relaxation of a QCQP.

    X == Transpose[{{x1, x2}}].{{x1, x2}};

    regiondescriptor = Tr[{{0.09, 0}, {0, 7}}.X] >= 1 && Tr[{{7, 0}, {0, 0.09}}.X] >= 1 && Tr[{{1.05, -0.95}, {-0.95, 1.05}}.X] >= 1 && Tr[{{1.05, 0.95}, {0.95, 1.05}}.X] >= 1  ;

    RegionPlot[regiondescriptor, {x1, -10, 10}, {x2, -10, 10}, BoundaryStyle -> Black]
6 Replies

Hi Abdulrahman,

with my last answer I was not really satisfied. Maybe we come a bit closer with the following:

ClearAll["Global`*"]

regiondescriptor[x11_, x12_, x21_, x22_] :=
  Tr[{{0.09`, 0}, {0, 7}}.{{x11, x12}, {x21, x22}}] >= 1 && 
  Tr[{{7, 0}, {0, 0.09`}}.{{x11, x12}, {x21, x22}}] >= 1 &&
  Tr[{{1.05`, -0.95`}, {-0.95`, 1.05`}}.{{x11, x12}, {x21, x22}}] >=  1 &&
  Tr[{{1.05`, 0.95`}, {0.95`, 1.05`}}.{{x11, x12}, {x21,  x22}}] >= 1 &&
  (*MatrixRank[{{x11,x12},{x21,x22}}, Tolerance\[Rule]0]==1&&*)      
  Min[Eigenvalues[{{x11, x12}, {x21, x22}}]] >= 0

As you see I "commented out" the MatrixRank condition, because RegionPlot can only handle inequalities. For equalities one better uses ContourPlot, and there, when plotting, the option Tolerance -> 0 does not make much sense.

I was unable to find a general form of a 2x2 matrix with rank 1. I think there is no such two parameter form, but I may be wrong. Perhaps depending on your problem you know constraints for the parameters x21 and x12; here I just choose them somehow. Then I get:

enter image description here

Maybe that helps, regards -- Henrik

POSTED BY: Henrik Schachner

Thanks a lot for your follow up on this. I tried it and it is working perfectly and now it makes sense why when the Rank is added, there is nothing to be plot since the intersection between the rank and the the other constraints is empty set.

I was also working on other solution that could enable me to project a 4D region onto a 3D region and so enable me to change all 4 variables. This is the code:

    X = {{x, y}, {z, w}};
    \[ScriptCapitalR] = ImplicitRegion[
    Tr[{{0.09, 0}, {0, 7}}.X] >= 1 && Tr[{{7, 0}, {0, 0.09}}.X] >= 1 && 
    Tr[{{1.05, -0.95}, {-0.95, 1.05}}.X] >= 1 && 
    Tr[{{1.05, 0.95}, {0.95, 1.05}}.X] >= 1  &&  
    Min[Eigenvalues[X]] >= 0  , {x, y, z, w}];

    RegionPlot3D[Resolve[\!\(\*SubscriptBox[\(\[Exists]\), \(x\)]\({x, y, z, w} \[Element] \[ScriptCapitalR]\)\), Reals], {y, -10, 10}, {z, -10, 10}, {w, -10, 10}];

The code is working but I was trying to combine your method with this so I could also plot the region for the Rank constraint also but it is not working. This is the code which I am trying to combine your method with Resolve but it is not working:

    ClearAll["Global`*"]

    regiondescriptor[x11_, x12_, x21_, x22_] := 
    Tr[{{0.09`, 0}, {0, 7}}.{{x11, x12}, {x21, x22}}] >= 1 && 
    Tr[{{7, 0}, {0, 0.09`}}.{{x11, x12}, {x21, x22}}] >= 1 && 
    Tr[{{1.05`, -0.95`}, {-0.95`, 1.05`}}.{{x11, x12}, {x21, x22}}] >= 1 &&
    Tr[{{1.05`, 0.95`}, {0.95`, 1.05`}}.{{x11, x12}, {x21, x22}}] >= 1 && Min[Eigenvalues[{{x11, x12}, {x21, x22}}]] >= 0;

    RegionPlot3D[Resolve[\!\(\*SubscriptBox[\(\[Exists]\), \(x12\)]\({x11, x12, x21, x22} \[Element] regiondescriptor[x11, x12, x21,x22]\)\), Reals], {x11, -10, 10}, {x21, -10, 10}, {x22, -10, 10}]

Any idea if this possible? I am sorry for asking a lot but I really want to plot this.

Hi Abdulrahman,

first thing I am noticing: You cannot ask whether {x11, x12, x21, x22} is an element of regiondescriptor, because this is not a region but a function which gives True or False. I think you rather mean "Is there an x12 for which regiondescriptor evaluates to True":

RegionPlot3D[Resolve[Exists[x12, regiondescriptor[x11, x12, x21, x22]], Reals], {x11, -10, 10}, {x21, -10, 10}, {x22, -10, 10}]

The syntax now seems to be correct, but the plot will not show anything. Whenever this happens it is a good idea to take an explicit look at the values. For doing so one simply replaces RegionPlot3D with Table:

enter image description here

Here we see: Some points evaluate to True, some to False, and some cannot be decided - I guess because of the roots which can be imaginary. So - again - I am afraid the problem needs to be reformulated ...

Regards -- Henrik

POSTED BY: Henrik Schachner

Thanks Henrik. I realized that there is something wrong with the formulation and the correct way is the following code:

    regiondescriptor = Tr[{{0.09, 0}, {0, 7}}.X] >= 1 && Tr[{{7, 0}, {0, 0.09}}.X] >= 1 && Tr[{{1.05, -0.95}, {-0.95, 1.05}}.X] >= 1 && Tr[{{1.05, 0.95}, {0.95, 1.05}}.X] >= 1   && MatrixRank[X, Tolerance -> 0] == 1 && Min[Eigenvalues[X]] >= 0  ;

    RegionPlot[regiondescriptor, {X[[1, 1]], -4, 4}, {X[[2, 2]], -4, 4}, BoundaryStyle -> Black]

I removed the vectors completely and I am just considering now the matrix variable X. I want to plot the entries X(1,1) and X(2,2) but I am getting the following error:

     RegionPlot::write: "Tag Part in X[[1,1]] is Protected."

Do you know why is this happening? Can't I change the values of the entries of the matrices and plot them?

Hi Abdulrahman,

there are a few issues here:

  • according to my understanding one cannot invoke X[[n,m]] without having defined X as a matrix before;
  • after having defined e.g.: X = {{x11, x21}, {x12, x22}} then MatrixRank[X, Tolerance -> 0] == 1 and consequently the whole regiondescriptor evaluates to False;
  • without that condition the expression Min[Eigenvalues[X]] >= 0 depends on all four elements of X and therefore the same holds for regiondescriptor, which then again gives an expression which cannot be plottet as such.

So I think the whole problem needs to be reformulated.

Regards -- Henrik

POSTED BY: Henrik Schachner

In your first line there is simply a typo. Write

X = Transpose[{{x1, x2}}].{{x1, x2}}

instead of

X == Transpose[{{x1, x2}}].{{x1, x2}};
POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract