How to express this objective and constraints in CVX?

MIDCP
Jun 12, 2021
D

i\in\{1,\dots,N\}
g\in\{1,\dots,N\}

x_{i,g} binary decision variable
y_{i,j,g} binary decision variable

I want to maximize \sum_{i<j}\sum_g w_{i,j} y_{i,j,g}

subject to

\begin{align} y_{i,j,g} &\le x_{i,g} &&\text{for all $i<j$ and all $g$} \\ y_{i,j,g} &\le x_{j,g} &&\text{for all $i<j$ and all $g$} \\ \end{align}

I declare the variable as

           variable X(N,G) binary
           variable Y(N,N,G) binary

How can I express the objective and the last two constraints?

M

Constrains and objectibe should be straightforward using for loops. If you can vectorize at all, CVX formulation will be faster.

The objective can be built up in for loop.

Objective = 0;
for ...
  Objective = Objective + ...
end
maximize(Objective)
D
Replying to #2

I am doing this…

  Objective=0;
  for g=1:G
      for i=1:C-1
          for j=i+1:C    
          Objective=Objective+WeightMatrix(i,j)*Y(i,j,g);    
          end
      end
  end

Hopefully I am doing it right…Would you please confirm.

M

It looks o.k., except that C should be N for consistency with your variable declaration for Y