# How to solve this problem? Disciplined convex programming error: Cannot perform the operation: {real affine} ./ {real affine}

Recently,I’m coding but I meet the problem:

Disciplined convex programming error:
Cannot perform the operation: {real affine} ./ {real affine}

My code is shown as following,I don’t know where is wrong, and I’m very confused now…

clear all;
clc;

%%
K = 30;
T=[20:10:200]*1e-3;
F = 6e9;
N_0 = 1e-9;
B = 10e6;
beta = ones(1,K);
R = randi([100,500],K,1);
C = randi([500,1500],K,1);
P = unifrnd(0,20e-11,K,1);
F_K = unifrnd(0.1,1.0,K,1);
h = exprnd(1e-6,K,1);
% l = zeros(1,K);
% t = zeros(1,K);

%%
m = R - (T*F_K)./C;
m_plus = max(m,0);

%%
Prameters.K = K;
Prameters.F = F;
Prameters.N_0 = N_0;
Prameters.B = B;
Prameters.R = R;
Prameters.C = C;
Prameters.P = P;
Prameters.F_K = F_K;
Prameters.h = h;
Prameters.m_plus = m_plus;

%%
for i = 1:length(T)
Prameters.T = T(i);
[Solution,obj_E] = my_cvx(Prameters);
obj(i) = obj_E;
end

function [Solution,obj_E] = my_cvx(Prameters)

%%
K = Prameters.K;
T = Prameters.T;
F = Prameters.F;
N_0 = Prameters.N_0;
B = Prameters.B;
R = Prameters.R;
C = Prameters.C;
P = Prameters.P;
F_K = Prameters.F_K;
h = Prameters.h;
m_plus = Prameters.m_plus;

%%
cvx_clear;
cvx_solver Mosek % Gurobi Mosek
cvx_precision high;

%% CVX_Solution
cvx_begin
variable l(K,1);
variable t(K,1);

``````%%  objective function
obj_E = cvx(0);
for k = 1:K
obj_E = obj_E + (t(k)./h(k)).* (f(l(k)./t(k))) + (R(k)-l(k)).*C(k).*P(k);
end
obj_E = sum(obj_E);

%%  minimize
minimize(obj_E)

%% constrains
sum(t) <= T;
sum (C'*l) <= F;
t >= 0;
m_plus <= l <= R;
``````

cvx_end

%% Solutions
Solution.l = l;
Solution.t = t;

end

Perhaps you can handle as a linear fractional function . Perhaps not. I leave the details to you. Section 4.3.2 of https://web.stanford.edu/~boyd/cvxbook/bv_cvxbook.pdf .

Thank you very much! Mark. But it is proved that the problem is a convex problem, so we can solve it with CVX. And this is the presentation of the problem, could you please tell me if the code of the expression is right or not?

`t(k)*f(l(k)/t(k))` is a perspective. What is `f`?

f is a function defined as following：

When minimizing, expression of the form
`y*exp(x/y), y >= 0` can be replaced with `z`, with `z` declared as a variable
and adding the constraint
`{x,y,z} == exponential(1)`

There are examples in posts by me on this forum.

Thank you！Mark, your help is very much appreciated！And I have solved this problem! This method is very useful. Thank you so much!