I was wondering if I could get support regarding a model I am doing. My research work lead me to the need to implement a fitting function into my model in CVX, however this fitting function is not convex as it is a sigmoid. I have tried dividing the function into two sections based on my decision variable Di but this does not seem to be working and I am getting the following error: Constraints may not appear in if/then statements.
My problem is quite big so I will just show a fragment of the problem:
for t=1:24
if Di(1,t)<=(param(3))
fsigm = -(param(1)+(param(2)-param(1))./(1+10.^((param(3)-Di(1,t))*param(4))));
M(t)=-(fsigm);
else
fsigm = param(1)+(param(2)-param(1))./(1+10.^((param(3)-Di(1,t))*param(4)));
M(t)=fsigm;
end
end
Mk=ones(300,24).*M;
The goal is to maximize Mk.
Should I switch to YALMIP to be able to still use MATLAB?.
In CVX, you would need to manually do the Big M modeling in order to handle logic constraints. YALMIP has automated tools for that, such as implies, as well as ability to handle non-convex models.
Edit: I just looked more carefully at your model. The two possibilities for fsgm appear to be negatives of each other; therefore, unless param(1)+(param(2)-param(1) == 0, one of these will be convex and the other concave. With the param value you show, that is not the case. Therefore, even with Big M modeling, this would still be a non-convex problem.
Thank you!. Sorry actually the minus sign in the first equation is a mistake. I thought I could divide the decreasing sigmoid function in the inflection point to program this as two separate functions.
Thank you, I omitted the additive term. I get the same error but in a constant constraint ahaha story of my life: Illegal operation: {real constant} + {log-concave} / Error in OptimConcave (line 138) / DCi = 0.042*(BatCi/5000)+((1-Efi^2)/Efi).*Mk;%NXT.
I think I can’t omit the additive term as the optimisation will give me values that do not make sense for what I would like in my optimisation problem.