I have a hard time expressing this in CVX.
It is the third solution proposed here https://or.stackexchange.com/questions/6428/how-to-partition-a-graph-with-optimal-number-of-groups
I could solve the first two with CVX with MOSEK, but could not manage to implement the third solution.
It corresponds to finding optimal groups from a graph. The graph has N nodes, and the edges connecting two nodes has a weight.
Let G be the set of all potential groups (node subsets of sizes 1, 2, or 3). For g\in G, let N_g be the nodes in group g, let E_g be the edges in group g, and let binary variable u_g indicate whether group g is used. The problem is to maximize
\sum_{g\in G} \left(\sum_{(i,j)\in E_g} w_{i,j}\right) u_g
subject to
\sum_{g\in G:\ i\in N_g} u_g = 1 \text{ for all } i
Any suggestion!
Let M=|G| be the cardinality of G.
variable u(M)
N_g is of varying sizes, I can put the index of the nodes in a group by defining a cell structure.
N_Matrix=cell(M,1);
for m=1:M
cell{m}=indexes of the nodes in group m
end
I am not sure how should I express E so that I can implement in CVX…