Let us consider the function f(x), defined as f(x)=x for negative x+10, f(0)=10, and f(x)=ln(1+x)+10 for positive x. It is clear that f(x) is a concave and smooth function.

I coded it as

if x<0
f=x+10
else
f=ln(1+x)+10
end
maximize f
subject to blah blah blah

However, since x is posed in “if” statement, error occurs. Is there any method to implement CVX for the case where the objective function is differently defined according to design variable’s region.

I already read the MOSEK link which is given in an answer for my previous question. However, since there are no code examples, I cannot implement my program.

The document proposed a method to convert a piecewise function into another form by introducing dummy variable t (based on the epigraph notion).