Group of variables with same value

I have a group of integer variables in matrix X, that should all have the same value. Let I be their respective indices. The way I approach this, is to create a new unconstrained integer variable temp and make every value of X equal to temp.

X(I) == temp; . I suspect that this is probably the most inefficient way to do this, but I have not found any keyword that could imply this. I have the feeling that somehow the nice structure of the problem does not get taken into consideration with my formulation.

Any suggestions? Is there a better way to approach this?

PS:Another effort was to create a diagonal matrix out of X(I) and multiply it with an all ones matrix, demanding equality to an all temp value matrix, but of course this is absolutely the same and didn’t improve my running time at all.

I don’t know how much specific help anyone can provide without seeing your model. However, note that mixed (integer) programming problems can sometimes take a long time to solve. The choice of solver, plus luck, can also play a critical role. You ought to be able to get some kind of idea how much running time is consumed by CVX vs. the solver it calls. I suspect the solver may neutralize most of your modeling differences in the pre-solve, which for difficult problems probably takes little time vs. the main solve.