Hello,

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:

param=[9.76584915402396,27.9904155442713,0.252459657607282,-39.8453332837601];

cvx_begin

variable Di(N,T)

expression Mk(N,T)

expression M(N,T)

expression fsigm(1,T)

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?.

Thanks a lot!