# Fractional objective function in CVX

Let the objective function be \textrm{min}_{x_i,y_i,z_i}\quad \frac{x_i}{y_i}+z_i, i={1,2,\ldots, N} and x_i,y_i,z_i are positive, s.t.-> \sum_{i=1}^{N}x_i \leq x_{\text{max}}, \sum_{i=1}^{N}y_i \leq y_{\text{max}}, and z_i is a function of x_i and y_i. How can I express the objective function in CVX?

Why cannot I use minimize(sum(a*x./y+b*z))?

n = 4;
a=  randn(1,1)
b = randn(1,1)

cvx_begin
variable x(n)
variable y(n)
variable z(n)
minimize(sum(a*x+y+b*z))
subject to
sum(x)<=10
sum(y)<=2
y >= 0
z==2*y
cvx_end

disp( 'Optimal vector:' );
disp( [ '   x     = [ ', sprintf( '%7.4f ', x ), ']' ] );

disp( 'Optimal vector:' );
disp( [ '   y     = [ ', sprintf( '%7.4f ', y ), ']' ] );

disp( 'Optimal vector:' );
disp( [ '   z     = [ ', sprintf( '%7.4f ', z ), ']' ] );

The objective as stated i.e. x/y term is not convex and that is why CVX will not allow you to do it.

To me it seems you can reformulate this is a geometric program(http://cvxr.com/cvx/doc/gp.html) that can be solved by CVX.
Did you try that?

My mistake, z_i is a function of x_i and y_i