# How to write the constraint involving indicator functions in CVX?

How to write the following constraints involving indicator functions in CVX?

0 \leq \sum_{i=1}^{m} \omega_{i} \cdot \mathbb{1}_{\{x > D_{i}\}} \leq 1, \forall x \in R,

and

0 \leq \sum_{i=1}^{m} \omega_{i} \cdot \mathbb{1}_{\{ D_{i} < x \leq M_{i}\}} \leq 1, \forall x \in R

where, D and M are given, while \omega is the decision variable.

The concept of indicator constraints is not available in Cvx. You must convert the problem to an ordinary MIP. This often involves using a so-called Big-M formulation

1 Like

It is not clear to me what the constraints are, in particular, what x is.

If x is a CVX (decision) variable or expression, you will have to use Big M, as @Erling suggested. if x is input data (a regular MATLAB variable), then Big M is not necessary, but then the way the constraint is written doesn’t seem to make sense.