Effacer les filtres
Effacer les filtres

Optimization problem with array input

1 vue (au cours des 30 derniers jours)
Mehmet
Mehmet le 25 Déc 2023
Modifié(e) : Torsten le 26 Déc 2023
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 commentaires
MEHMET SAHIN
MEHMET SAHIN le 25 Déc 2023
Modifié(e) : MEHMET SAHIN le 25 Déc 2023
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 le 25 Déc 2023
Modifié(e) : Torsten le 25 Déc 2023
Try my suggestion below - I guess that for bigger problems, your attempt will lead nowhere.

Connectez-vous pour commenter.

Réponse acceptée

Torsten
Torsten le 25 Déc 2023
Modifié(e) : Torsten le 25 Déc 2023
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 commentaires
MEHMET SAHIN
MEHMET SAHIN le 26 Déc 2023
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 le 26 Déc 2023
Modifié(e) : Torsten le 26 Déc 2023
Didn't know that Excel has such a solver. But glad to hear you succeeded in MATLAB.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Elementary Math dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by