I am working on a model likes:
obj = obj + b * Constant;
for i = 1:N
where the value of expression a depends on a step function of the variable p :
a(i) = 0, if p(i)=0
a(i) = 1, if p(i)>0
I have studied the materials on the website of CVX, but still have no idea how to implement a constraint like the above equation. Is it possible to implement such constraints in cvx?
You need to use Big M logic modeling. You will need to declare
a as a binary variable rather than an expression.
p is nonnegative, although you haven’t declared it as such or specified such a constraint. The constraint below will enforce nonnegativity of
U is an upper bound for
U could be a scalar or a vector).
non-zero_threshold be a small positive number, such as 1e-5, for what constitutes the smallest value of
p which is practically speaking positive (keep in mind solver tolerances might allow a variable value of 1e-8 when it is really essentially zero).
non-zero_threshold*a <= p <= U.*a
Thanks for the quick response! The big M modeling does work, but seems a will be set to a small number because of p might get small compared to its upper bound. I specify it as binary and use Mosek to solve the problem. I am also considering using Taylor Series Approximation and penalized the objective function to make it an binary variable.
Is there any better approach to address this problem?
As I wrote, declare
a as binary. Then use a solver, such as Mosek, which can handle binary variables. That should be better than trying to create a penalty term or use a Taylor series approximation. I think Mosek or Gurobi will do a better job of handling binary variables than any "home-brew’ approach you might create.
Got that! Thank you so much, Mark!