Solver Multi Selection Constraint

hoosier02

New Member
Joined
Aug 10, 2015
Messages
8
I have a problem that I am trying to use a solver with a Simplex Linear solving method for. The problem is simple until the last part. See an example of the basic table below, mine is much larger but this example should show the major constraints. I want to create a basket of fruit and want to choose one fruit from each of the different groups.

The problem I am trying to maximize is income and my first constraint is cost. The second constraint is that I can only choose each fruit once. You can see in this example if I just tried to maximize income I could choose apple every time. However apple can’t be chosen every time. The solver works by changing column 1 between 0 and 1. If it is chosen a 1 is selected and if not then a zero. Maximizing income and staying under budget are two easy constraints however I am having a hard time when it comes to making sure that each item can only be selected once. Any ideas on how to best set this solver constraint up?

Here is a basic example of the table. Sorry for the formatting I am slow to understand the table builder.

Pick Group 1 Cost Income
0/1 Apple 10 1000
0/1 Pear 50 60
0/1 Banana 40 60
Group 2
0/1 Apple 10 1000
0/1 Plum 25 30
0/1 Strawberry 30 50
Group 3
0/1 Apple 10 1000
0/1 Raspberry 20 25
0/1 Kiwi 30 40
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
To clarify a couple of things that I tried that didn't work as options.
1) I tried creating a sumif on the fruit for each row. And make the sumif equal to 1. This worked. However, my list is long and the maximum constraints is 100 so it wasn't a feasible solution to implement.
2) I tried to use the sumif again on each rown and then use the max function on all the sumif rows. However, solver says that the "max" function causes non-linearity. Not sure why since sum doesn't cause the issue.
3) Tried using the sum function on all the sumifs and set the sum to the total number of fruit I need. However, in this case it will never select apple because the sumif on apple is 3 which in the example above is the total allowable.
I also tried multiple other options with both countif and match but haven't had much luck. I am sure the solution is something simple but running out of good ideas. Any assistance is appreciated and if any more information would be helpful please let me know. Thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top