How can I define the variables express this in CVX.

\min\sum_{g=1}^G\sum_{i=1}^{N-1}\sum_{j=i+1}^{N}d_{ij}z_{ijg}

Here, d_{ij} are known and z_{ijg} are binary integer variables.

I define the variable as

```
variable Z(N,N,G) binary
```

But not able to express the objective function.

You are allowed to use as many levels of for loop as you wish.

First formulate what you want presuming that Z is a numerically populated MATLAB double precision variable. Once you have done that, it should work when Z is instead declared a MATLAB variable. Any vectorization you do is a speed bonus, but not needed for correctness.

Thanks. For now speed is not an issue. I just want correctness. Do I need to define an expression to be able to put as objective, as I cannot put nested for in the objective?

Before for loop

`Objective = 0;`

% no need to declare Objective as an expression because it is a scalar.

Inside for loops:

`Objective = Objective + something;`