필터 지우기
필터 지우기

Optimization problem with array input

조회 수: 1 (최근 30일)
Mehmet
Mehmet 2023년 12월 25일
편집: Torsten 2023년 12월 26일
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
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
Torsten 2023년 12월 25일
편집: Torsten 2023년 12월 25일
Try my suggestion below - I guess that for bigger problems, your attempt will lead nowhere.

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
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
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.
Torsten
Torsten 2023년 12월 26일
편집: Torsten 2023년 12월 26일
Didn't know that Excel has such a solver. But glad to hear you succeeded in MATLAB.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Elementary Math에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by