Optimization of the log-absolute: reformulating to DCP-compliant on Julia

I am trying to reformulate this optimization problem in order to get a DCP-complaint expression on Julia (I am using the Conjex.jl package)

$$\text{Minimize}\;\;\; \mid\log(x)\mid$$

The code

p = Variable()
f = abs(log(p))


Prompts to a warning

WARNING: Expression not DCP compliant. Trying to solve non-DCP compliant problems can lead to unexpected behavior.

I am beginner regarding convex optimization. But, as far as I read

CVX-family does not consider a function to be convex or concave if it is so only over a portion of its domain, even if the argument is constrained to lie in one of these portions

Hence, the function $$\mid x\mid$$ is nonincreasing for $$x < 0$$, and nondecreasing for $$x>0$$. I suppose that the composite property fails because of it.

How to reformulate it in order to get DCP-compliant expresison?

PS: solutions using other scientific programming languages (Matlab, R, Python...) is welcome too.

• log(x) is not convex anywhere (it is concave). So |log(x)| is also not convex. Dec 9, 2022 at 3:41
• @ErwinKalvelagen nice, so how to reformulate this expression? Dec 9, 2022 at 11:51
• Not all problems are convex or can be convexified. (After all, why would global solvers exist). Dec 9, 2022 at 11:55
• @ErwinKalvelagen and can this problem be convexified? Dec 9, 2022 at 11:58
• @ErwinKalvelagen yeah, that is my question, can I state that this problem is equivalent to? $$\text{Minimize}\;\;\; \mid x - 1 \mid$$ Dec 9, 2022 at 12:00

I agree that the problem is nonconvex, but since the function is piecewise monotone, you could separately solve

$$\min x$$

subject to

$$x\geq 1$$

plus other constraints

and

$$\max x$$

subject to

$$x <= 1$$

plus other constraints

and pick the better of the two solutions.

• Or use binary to solve as a single MIDCP formulation. Dec 10, 2022 at 1:25