Optimization problem with array input
2 ビュー (過去 30 日間)
古いコメントを表示
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 日
編集済み: 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
採用された回答
Torsten
2023 年 12 月 25 日
編集済み: Torsten
2023 年 12 月 25 日
You might want to try "intlinprog" with x being a binary vector with x(i) = 1 meaning: ball i is picked and x(i)= 0 meaning: ball i is not picked.
Then set up the problem as
minimize/maximize sum_i x(i)*spike(i)
under the constraints
sum_i x(i)*holes(i) = 100
sum_i x(i) = 30
sum_{i=1}^{i=5} x(i) >= 1
sum_{i=5+1}^{i=5+150} x(i) > = 1
sum_{i=5+150+1}^{i=5+150+58} x(i) >= 1
...
5 件のコメント
MEHMET SAHIN
2023 年 12 月 26 日
Thanks!! I tried this way in Excel solver and it tooks 1 day to get the solution. But intlinprog is more powerful and gave me the answer in 3 secs.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Quadratic Programming and Cone Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!