1

I need to solve an optimisation problem of the form:

\begin{align} \textrm{maximize} \quad &\sum_{i=1}^{n} a_i \tanh(c_i x_i/2) \\ \textrm{wrt} \quad &x_i, \quad i \in 1,\dots,n \\ \textrm{subject to} &\sum_{i=1}^{n} x_i = X \\ &x_i \ge 0, \quad i \in 1,\dots,n \end{align}

where $a$, $c$ and $x$ are nonnegative vectors of length $n$, and $X$ is a positive real number. $n$ is about 30 in my case and I have millions of these problems to solve, each with different $a$ and $c$ data, but a fixed $n$.

I would like to use cvxpy and I feel like there should be a way, since my objective is concave on the nonnegative reals.

What I have tried:

  1. Passing an objective of $a_i(-1 + 2/(1 + \exp(-c_i x_i)))$ to cvxpy, version 1.4.1. It complains that the objective is not DCP.

  2. Using scipy.optimize.minimize instead. I ran into more vexing problems with constraints over there, so here I am.

Somehow I need to prove to cvxpy that my problem is DCP, by a clever reformulation. My only idea is to approximate the $\tanh$ as a piecewise linear function. But that sounds both messy and time consuming. Any advice is appreciated.

0 Answers0