2

I have the following concave function

$$f(x)=\frac{ax}{cx+d}$$

where $a, c, d > 0$ and $0 \le x \le 1$. How can I use CVX tools to maximize $f(x)$?

It seems that the CVX does not support such structure even if $f(x)$ is concave.

Dave
  • 606
  • 1
    I have no idea about CVX or optimization, but maybe you could invert the function and then determine its minimum? Then $\min_{x}1/f(x)=\frac{c}{a}+\frac{d}{a}\frac{1}{x} $? So you actually only need to minimize $\frac{d}{a}\frac{1}{x}$. – MrYouMath Sep 26 '17 at 12:10
  • If $f$ concave, then $-f$ is convex. Can you solve $\min_x -f$? – EarthwormA3aan Sep 26 '17 at 12:54
  • I do know that $f$ is an increasing function. I just want to know how to max this kind of function using CVX. – Dave Sep 26 '17 at 13:24
  • @RodrigodeAzevedo I think the op just wants to learn cvx. – MrYouMath Mar 30 '18 at 13:37
  • I think "math.stackexchange.com" is not the right site for questions not focusing on the mathematical background but specifically on Matlab programming. Maybe "stackoverflow.com" or "superuser.com" are matching better in this case. – Martin Rosenau Mar 30 '18 at 14:43

1 Answers1

1

$$\begin{array}{ll} \text{maximize} & \dfrac{c x}{a x + b}\\ \text{subject to} & 0 \leq x \leq 1\end{array}$$

where $a, b, c > 0$ are given. Note that

$$\dfrac{c x}{a x + b} = \cdots = \frac ca - \frac{bc}{a} \left(\frac{1}{a x + b}\right)$$

Since $ \frac{bc}{a} > 0$, we have the following minimization problem

$$\begin{array}{ll} \text{minimize} & \dfrac{1}{a x + b}\\ \text{subject to} & 0 \leq x \leq 1\end{array}$$

As $-\frac ba \notin [0,1]$, we have the following linear maximization problem

$$\begin{array}{ll} \text{maximize} & a x + b\\ \text{subject to} & 0 \leq x \leq 1\end{array}$$

and, thus, the maximum is attained at $x = 1$.


Code

Since I do not have CVX in this machine, I will use CVXPY instead. Let $a = b = 1$. Thus,

>>> from cvxpy import *
>>> x = Variable()
>>> objective = Minimize( inv_pos(x+1) )
>>> constraints = [ x >= 0, x <= 1 ]
>>> prob = Problem(objective,constraints)
>>> prob.solve()
0.4999999999223261
>>> x.value
1.0000000000418874

Note that the minimum is attained at $x = 1$.