# Cannot perform the operation {convex}*{convex}

Hi all,

My objective function is
\sum_{i = 1}^n t_i \left(a (\frac{d_i}{t_i})^2 + b(\frac{d_i}{t_i}) + c\right)

and the constraints are just linear inequality constraints.

I am having quite some trouble to implement this function. Below is a minimal example of where I am at now. The error I get is “Cannot perform the operation {convex}*{convex}”. Note that d is strictly positive (and thus ‘t’ will be as well)
EDIT: a,b,c are always stricly positive as well

a = 2; b = 3; c = 4;
n = 10;
d = 1+rand(n,1);
cvx_begin
variable t(n);
minimize(pos(t).' * (a*pow_pos(d.*inv_pos(t),2)+b*(d.*inv_pos(t))+c));
subject to
t*0.1 <= d;
d <= t*10;
cvx_end


Any suggestions on how to improve the code are welcome as well. The object function looks as if it could be written down in a better way, but this was the best I could do so far.

Thanks,

Please let me know if I have misinterpreted what you want to do.

Expand (multiply out) the objective function. The b*d(i) is just a constant, so can be eliminated.
The result, which is accepted by CVX, is

a = 2; c = 4;
n = 10;
d = 1+rand(n,1);
cvx_begin
variable t(n);
minimize(a*sum(d.^2.*inv_pos(t))+c*sum(t))
subject to
t*0.1 <= d <= t*10
cvx_end


Edit: I fixed a thinko from my earlier erroneous reading of the constraints.

Mark’s answer looks good, but this still reflects still a basic failure to read the CVX manual, in particular the DCP ruleset.

It is always easy to blame the user. Are you sure the documentation suffices? For instance: the search function of the user manual does not work properly, i.e., no results are returned. Going through the pdf did not help me to find the answer. Not trying to offend, it’s typically a two way street…

I appreciate the feedback. I would direct you to this section of the documentation, in the introduction. I maintain that attempts to use CVX without understanding this section will inevitably lead to frustration.

And, of course, we have this FAQ) at the top of this forum for those cases where the documentation fails to inform.