# I want to solve minimize max problem using cvx

\$C_max \$is the max processing time of all machines,i want to make every machine as average as possiable

Have you read the CVX Users’ Guide? That is a fairly straightforward Binary Linear Programming problem to enter in CVX.

cvx_begin
expression T(5,1);
variable x(5,10) binary;
expression x_tmp(10,1);

minimize(max(T))
subject to
for i=1:5
for j=1:10
T(i)=T(i)+x(i,j)*charging_time(j);
end
end
T_max=max(T);
T>=0;
for i=1:5

end
for i=1:10
x_tmp(i)=0;
for j=1:5
x_tmp(i)=x_tmp(i)+x(j,i);
end
end
x_tmp==1;

cvx_end

this is my code,but result is terriable

Expressions have the value that hey have when they are used in the code. Expressions have value zero by default before anything is assigned to them. So your objective is always zero, and CVX/;solver can choose any feasible values they “want” for the variables. So you should move the minimize statement to after T as been assigned.

Much of your code can be vectorized. For instance, sum(x,2) == 1 can be used instead of the double for loop with x_tmp, which is unnecessary. From the image, it looks like you can have code such as x.*P <= Cmax, with P having the same dimensions as x, and not use any for loops.

Thank you !!! I have soloved it .WOW