/** * Prepare an LRSDP object to solve the Lovasz-Theta SDP in the manner detailed * in Monteiro + Burer 2004. The list of edges in the graph must be given; that * is all that is necessary to set up the problem. A matrix which will contain * initial point coordinates should be given also. */ void SetupLovaszTheta(const arma::mat& edges, LRSDP<SDP<arma::mat>>& lovasz) { // Get the number of vertices in the problem. const size_t vertices = max(max(edges)) + 1; // C = -(e e^T) = -ones(). lovasz.SDP().C().ones(vertices, vertices); lovasz.SDP().C() *= -1; // b_0 = 1; else = 0. lovasz.SDP().SparseB().zeros(edges.n_cols + 1); lovasz.SDP().SparseB()[0] = 1; // A_0 = I_n. lovasz.SDP().SparseA()[0].eye(vertices, vertices); // A_ij only has ones at (i, j) and (j, i) and 0 elsewhere. for (size_t i = 0; i < edges.n_cols; ++i) { lovasz.SDP().SparseA()[i + 1].zeros(vertices, vertices); lovasz.SDP().SparseA()[i + 1](edges(0, i), edges(1, i)) = 1.; lovasz.SDP().SparseA()[i + 1](edges(1, i), edges(0, i)) = 1.; } // Set the Lagrange multipliers right. lovasz.AugLag().Lambda().ones(edges.n_cols + 1); lovasz.AugLag().Lambda() *= -1; lovasz.AugLag().Lambda()[0] = -double(vertices); }