Optimization problem with array input
이전 댓글 표시
Guys i need to figure out the algorithm to model a question. Question is here: I have to pickup 30 balls that are in 10 different colors. Number of the balls are in the first column of the input matrice. Only requirement here is i have to pick at least one for each color.Every balls have different numbers of holes and spike on them. These are column 2 and 3 input. The sum of the holes must be 100. I want to solve for min and max spike conditions. What is the algorithm here? I tried to assign coefficients but that doesn't seem like it works. I could solve with 10 for loops but the sizes of arrays differ from 5 to 150. It takes about 3 days to execute. I kinda search for fmincon for discrete array inputs. Thanks!
댓글 수: 6
MEHMET SAHIN
2023년 12월 25일
I have 10 separate matrices in .xlsx format for each color.Like c1(5,3) & c2(150,3) & c3(58,3) etc.
John D'Errico
2023년 12월 25일
편집: John D'Errico
2023년 12월 25일
You CANNOT use fmincon. fmincon does not apply to discrete problems, Period. You might decide to try GA, but your question is still to vague to understand it. No matter what, this problem is never going to be solvable using brute force loops.
An example matrix with your data in it might help. For example, do all red balls have the same number of holes and spikes?
MEHMET SAHIN
2023년 12월 25일
편집: MEHMET SAHIN
2023년 12월 25일
% for yellow balls
% Number of balls as package, number of holes on each,number of spikes on
% each
a = [3 5 36;1 5 25;2 8 2;4 7 23;8 22 8;8 2 7;5 12 98;6 15 5];
% for black balls
% Number of balls as package, number of holes on each,number of spikes on
% each
b = [3 3 3;1 6 6;2 8 2;3 5 2;3 11 5;8 5 31;7 6 7;9 3 8;8 4 9;2 20 3;3 4 51];...
%constraints
for aa=1:height(a)
for bb=1:height(b)...
tot_num_balls=a(aa,1)+b(bb+1);... % must be equal to 30
tot_holes=a(aa,1).*a(aa,2)+b(bb,1).*b(bb,2);... % must be equal to 100
tot_spikes=a(aa,1).*a(aa,3)+b(bb,1).*b(bb,3);... % search for min and max values
end
end
MEHMET SAHIN
2023년 12월 25일
편집: MEHMET SAHIN
2023년 12월 25일
i pick balls as packages like trio,duo, single etc. For example, as indicated in the first row of a, I have 3 balls that have 5 holes and 36 spikes on each and i cannot divide them. So i have 2 choices here:
(0) Do not pick -- 0 balls 0 hole 0 spike
(1) Pick -- 3 balls 15 holes 108 spikes
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!