How to use conditional (piecewise) function in cvx?

Uncategorized
Jun 14, 2020
D

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.

M

Have you followed the advice to read the link provided in answer to your previous question? How can I maximize a piecewise concave function?

D
Replying to #2

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

However, I do not grasp what should be maximized.