how can I compare two optimization variables before running the model?
Afficher commentaires plus anciens
Hi guys I am using matlab 2018B with optimization toolbox. Can any one help me with this error "Error using max Invalid data type. First argument must be numeric or logical.
Error in int_TCT (line 38)" C_k_2{j,k} = max(C_1_k(1,k),C_k_2(j,k-1)) + (x(j,k) * P(2,j));" on the following code and how to overcome:
P = [24 6 7 9 24 12 11; 8,8,21,16,9,6,17];
n = size(P,2);
prob = optimproblem('ObjectiveSense','min'); %to define the maximization function
x = optimvar('x',[n,n],'LowerBound',0,'UpperBound',1,'Type','integer');
SumToOne_row = sum(x,2) == 1; % Eqation(18): sum(z_jk=1, for all k
prob.Constraints.row = SumToOne_row;
SumToOne_col = sum(x,1) == 1; % Eqation(18): sum(z_jk=1, for all j
prob.Constraints.col = SumToOne_col;
for j = 1:n
for k = 1:n
W(j,k) = P(1,j) * x(j,k) ;% processing time of the job in position k
end
end
W1 = sum(W);
C_1_k(1,1) = W1(1,1); % completion time of position 1 on machine 1
for k = 2:n
C_1_k(1,k) = W1(1,k) + (C_1_k(1,k-1)); % completion time of position k > 1 on machine 1
end
for j = 1:n
C_k_2(j,1) = (P(1,j) + P(2,j)) * x(j,1); % completion time of the first position on machine 2 %k=1
end
for k = 2:n
for j = 1:n
C_k_2{j,k} = max(C_1_k(1,k),C_k_2(j,k-1)) + (x(j,k) * P(2,j));
end
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Nonlinear Optimization dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!