Min using matlab cvx

I am trying to detect communities using binary min cut on users' graph. For this purpose I am trying to use a variant of Fiedler method as shown in this paper. This is how they have formalized it:

enter image description here

Now, I am trying to do this using the CVX package in matlab. Here is my code:

tou = ((beta/ (e' * pi1 * e)) * tou1) + (((1 - beta) / (e' * pi2 * e)) * tou2);
n = 6;
cvx_begin
    variable y(n)
    minimize( y' * tou * y )
    subject to
        y' * pi1 * y == e' * pi1 * e
        y' * pi2 * y == e' * pi2 * e
        y' * pi1 * e == 0
        y' * pi2 * e == 0
cvx_end

But it is showing me the following error:

Disciplined convex programming error:
Invalid constraint: {convex} == {real constant}

Error in ==> cvx.eq at 12
b = newcnstr( evalin( 'caller', 'cvx_problem', '[]' ), x, y, '==' );

Error in ==> fiedler at 16
y' * pi1 * y == e' * pi1 * e

Here A1 is a matrix defined as follows:

A1 = [0 3 2 0 0 0; 3 0 3 1 0 0; 2 3 0 0 0 0; 0 1 0 0 4 2; 0 0 0 4 0 3; 0 0 0 2 3 0];

Similarly A2 = A1.

And pi1 is a matrix is a diagonal matrix whose value is equal to sum of all the values of A1 in that particular row. Doing so I get

pi1 = [5 0 0 0 0 0; 0 7 0 0 0 0; 0 0 5 0 0 0; 0 0 0 7 0 0; 0 0 0 0 7 0; 0 0 0 0 0 5];

Similary, pi1 = pi2.

And tou1 = pi1 - A1, and tou2 = pi2 - A2.

Can someone point out what exactly I am doing wrong. It would be of great help. Thanks in advance !

matlab convex-optimization cvxopt

2 Answers

This issue is that your constraint

  y'* pi1 * y == alpha

(where alpha = e'*pi1*e ) is not a convex constraint. Consider the two dimensional case where size(y) = [2 1] and pi1 is the identity, then your constraint above is

       y(1)^2 + y(2)^2 == alpha

This is equivalent to requiring y to lie on the radius of a circle. This is not convex constraint.

CVX is designed for disciplined convex optimization. This means that you must build your model up from primitives in a way that ensures the model is convex. Since your model includes a constraint that is not convex CVX issues the error: "Disciplined convex programming error".

It also tells you the problem: "Invalid constraint {convex} == {real constant}". That tells you that you are trying to constrain a convex function to be equal to a constant.

If you want to solve this model with CVX you will need to reformulate the model to be convex. If you can't reformulate it, you might try using a nonlinear (noncovex) solver. For example, fmincon included in MATLAB should be able to handle this constraint. Note that fmincon is designed for fairly small scale models, for large scale nonlinear noncovex models you probably want to use a solver like SNOPT or KNITRO.

1,289819

  • @Shai quadprog requires the constraints be linear, these constraints are non-convex quadratic, so the OP will need to use a solver that can handle nonlinear constraints. – codehippo Apr 10 '14 at 17:01

add a comment

For the original problem, the equality constraints can be usually relaxed by replacing equal sign (=) with <=. Most of the time, the solution will satisfy the equality constraints (but not guaranteed).

The original problem can e relaxed as follows:

tou = ((beta/ (e' * pi1 * e)) * tou1) + (((1 - beta) / (e' * pi2 * e)) * tou2);
n = 6;
cvx_begin
 variable y(n)
 minimize( y' * tou * y )
 subject to
     y' * pi1 * y <= e' * pi1 * e
     y' * pi2 * y <= e' * pi2 * e
     y' * pi1 * e <= 0
     y' * pi2 * e <= 0
cvx_end

You need to verify if the solution (or pick one of the solutions) satisfies the equality constraint. Hope it works for the OP.

转:https://stackoverflow.com/questions/19815822/min-cut-using-matlab-cvx

猜你喜欢

转载自blog.csdn.net/eric_e/article/details/85249517