Hello,
How can I add this varaible?
factor =eta if u>=0(charging)
factor =1/eta if u<=0(discharding)
I use Big M and by assuming factor=eta^(-1^B), B is a Binary variable:
u>= -M(1-B)
u<=+M(B)
but the main issue the CVX will not be Ok with having B in exponential power.
eta is the efficiency, If I assume eta=1 factor will be one and the problem will be convex.
Is there any way for my optimization to pick one of the two values for the factor-like factor is either 1/eta or eta without using binary variables.
It’s not clear what is input data and what are optimization (CVX) variables.
You should look at pow_p and inv_pos, and determine their applicability.
The cvx variable is u and B (B is binary) and the input is eta.
Thank you for your guidance.
No, eta is the efficiency and always positive.
Thanks
Why did you get the error {negative constant}.^{real affine}?
help inv_pos
inv_pos Reciprocal of a positive quantity.
inv_pos(X) returns 1./X if X is positive, and +Inf otherwise.
X must be real.
For matrices and N-D arrays, the function is applied to each element.
Disciplined convex programming information:
inv_pos is convex and nonincreasing; therefore, when used in CVX
specifications, its argument must be concave (or affine).
because it is eta^(-1^B).
However, I need to linearize my model. I got another idea
factor=B1 (1/eta) + B2 eta
B1, B2 are binary and different. If B1=1 and B2=0, the factor will be 1/eta otherwise it will be eta.
To define that these two binary variables can not equal each other we use the following:
B1<=B2-1
OR
B1>=B2+1
I linearized my mode and add the new constraints using the Big M value and use MOSEK to solve the problem.
Thank you so much!!