I have a vector with its elements, example five elements. Each element is a sum of ex.(a1+b1+c1)-first element, (a2,b2,c2)-second element,…(a5,b5,c5)-fifth element.
I declare as variables all powers (a1 b1 c1…an so on).

I want to minimize sum a,b,c, or better to say I want to minimize each element of this vector; but in the part of minimize function a get an error mesages, i don’t now how to exspress these elements of vector in minimize funksion?
Can somebody help me please!!

This is the example with no errors, but here I get only one value for optimization variables for only Tmax=10 and it works.

k = 4*10^(-18);
Tmax = 10;
Tmin = 0.1;
alfa = 80;
beta = 0.0125;
S=2;
S_inv = 1./S;
G1 = 2*10^(-15);
G2 = 3*10^(-14);
G3 = 10^(-7);
cvx_begin gp
variables a b c
minimize a + b + c
subject to
(k + b.*(G1))./(c.*(G3)) <= S_inv;
(k + b.*(G1))./(a.*(G2)) <= S_inv;
(k + a.*(G1))./(b.*(G2)) <= S_inv;
((alfa).*(c)) + ((beta).*(a)) <= Tmax;
((alfa).*(c) + (beta).*(a))./Tmin <= 1;
Tmin.*b^(-1) <= 1;
b <= Tmax;
cvx_end

Now I’m trying to solve this for Tmax=[1:1:5], I don’t know how to do this with vectors. Here is the code with errors:

You’re going to have to offer a more complete example, perhaps even the code you’ve tried so far. My guess, however, is that the expression is not convex, or does not obey the DCP ruleset. Please read the manual to understand what expressions are accepted.

Hi, when I write the code just with one iteration (with no vectors), there are no errors, I’m shure that my expression is convex and obeys the DCP ruleset. But the problem comes when I want to calculate optimization in many iterations, and each iteration result to save in a variable of the vector I’ve mentioned earlier—here I’ve stucked!! I dont know how to write objective funksion in case of vector variables??

When I write code with one iteration (with no vectors), there are no errors,I’m shure my expression is convex.The problem comes when I want to calculate optimization in many iterations,and each iteration result to save in a variable of the vector. I dont know how to write objective func. with vector

Edit: I understand English is not your native language, nevertheless, I’ve had trouble understanding what you’re trying to say. Upon re-reading everything, it does appear that mcg is perhaps correctly interpreting what you want to do, and what I wrote further down this post may not be what you want to do. I thought you wanted to solve 5 separate optimization problems, each with a different value of Tmax, and that your difficulty was that you were not retaining the arwgmin (optimal values of optimization variables a, b, c) between invocations, and hence when you looked after the last CVX invocation finished, you had only the argmin corresponding to the last invocation. The rest of my post solved that issue. If you really want to solve a single optimization problem whose objective function is the sum of 15 terms (5 each for a, b, c) with a vector of 5 constraints for each appearance of Tmax, then follow the suggestion in mcg’s comment.

Hopefully this will do what you want. I have placed a % comment at the end of each line I added or changed relative to your “example with no errors”, and commented out the Tmax = 10 statement, and noted that you need to have Tmax array available or define it before the for loop.

k = 4*10^(-18);
% delete this line Tmax = 10;
% Make sure you already have the Tmax array defined before you enter the for loop
Tmin = 0.1;
alfa = 80;
beta = 0.0125;
S=2;
S_inv = 1./S;
G1 = 2*10^(-15);
G2 = 3*10^(-14);
G3 = 10^(-7);
for i=1:length(Tmax) % added this statement
cvx_begin gp
variables a b c
minimize a + b + c
subject to
(k + b.*(G1))./(c.*(G3)) <= S_inv;
(k + b.*(G1))./(a.*(G2)) <= S_inv;
(k + a.*(G1))./(b.*(G2)) <= S_inv;
((alfa).*(c)) + ((beta).*(a)) <= Tmax(i); % changed Tmax to Tmax(i)
((alfa).*(c) + (beta).*(a))./Tmin <= 1;
Tmin.*b^(-1) <= 1;
b <= Tmax(i); % changed Tmax to Tmax(i)
cvx_end
aopt(i)=a; % added this statement
bopt(i)=b; % added this statement
copt(i)=c; % added this statement
end % added this statement, ends for loop

After the for loop end, the vectors aopt, bopt, copt have the optimal values for the corresponding entries in Tmax. You can optionally preallocate the aopt, bopt, and copt arrays before the for loop if you want, but you don’t have to, and they can appear for the first time as shown in the code above.