I want to code so that if my variable is positive, it’s multiplied by price1. However, if it’s negative, it’s multiplied by price2. Is that possible? How?
cvx_begin ;
cvx_solver Mosek
variable pch(10,24)
minimize (pch*price1+pch*price2)
I understand that defining two variables, pch and pdis, and implementing the code as shown below is possible, but adding binary values can result in longer computation times
cvx_begin ;
cvx_solver Mosek
variable z(12,2) binary
variable p(10,24)
p=pch+pdis
minimize (*z(:,1)*pch*price1+*z(:,2)*pdis*price2)
subject to
sum(z,2) <= 1