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.

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

1 Answer 1


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


$\max x$

subject to

$ x <= 1$

plus other constraints

and pick the better of the two solutions.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.