Maximization/Optimization

agutts6

New Member
Joined
Jun 19, 2011
Messages
19
Baseball question!

But if that's not your thing, feel free to think of it in terms of your favorite sport.

Let's say I have a typical roster of players. The cell values are their unit values, if they play each position (it's different for each player--if they play one position, they'll have more or less value than they do if they play another).

[TABLE="width: 500"]
<tbody>[TR]
[TD]Name[/TD]
[TD]First Base[/TD]
[TD]Second Base[/TD]
[TD]Third Base[/TD]
[TD]Shortstop[/TD]
[/TR]
[TR]
[TD]Sam
[/TD]
[TD]5[/TD]
[TD]4[/TD]
[TD]2[/TD]
[TD]1
[/TD]
[/TR]
[TR]
[TD]Tom[/TD]
[TD]5[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]Will[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]Brian[/TD]
[TD]4[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]Tod
[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]2
[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]Matt[/TD]
[TD]6[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]Ahmed[/TD]
[TD]2[/TD]
[TD]7[/TD]
[TD]1[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]Billy[/TD]
[TD]3[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]Steve[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]6[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]Paul[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]1[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]Benjamin Netanyahu[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
</tbody>[/TABLE]

How would I write an equation that solves for the optimal value of this configuration (who to put at which four positions, to maximize total value)?

It seems more complex to me than a standard optimization problem, because it involves things like "if you use Steve here, then he can't play there" or "if you use Ahmed at his second-best position, it allows Steve to play his best position" (and then of course those combinations compound with further iterations).

So it may be that it just requires higher optimization logic than I can easily conceive. Or maybe this is an iterative solve? I really don't know where to start, and would appreciate the help.

Thanks!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I don't recall having much luck with solver the last time someone asked about this type of problem, but I only have the basic version included with Excel. It's not difficult to print every possible combination of the 11 names, and they'll be plenty of repeats because of impossible combinations where multiple instances of the same name occur on a line:


Excel 2010
ABCDEFGHIJKLMNOPQR
11111542112NameFirst BaseSecond BaseThird BaseShortstop
21112542314Sam5421
31113542314Tom5333
41114542415Will2333
51115542617Brian4344
61116542314Tod5626
71117542415Matt6333
81118542314Ahmed2714
91119542617Billy3133
1011110542415Steve2366
1111111542314Paul1414
121121543113Benjamin3333
Sheet2
Cell Formulas
RangeFormula
A1=MOD(ROUNDUP(ROW(A1)/1331,0)-1,11)+1
B1=MOD(ROUNDUP(ROW(A1)/121,0)-1,11)+1
C1=MOD(ROUNDUP(ROW(A1)/11,0)-1,11)+1
D1=MOD(ROW(A1)-1,11)+1
F1=INDEX($O$2:$R$12,A1,COLUMN(A1))
G1=INDEX($O$2:$R$12,B1,COLUMN(B1))
H1=INDEX($O$2:$R$12,C1,COLUMN(C1))
I1=INDEX($O$2:$R$12,D1,COLUMN(D1))
K1=SUM(F1:I1)


Copy down to row 14641 (11^4) and then paste as values, sort the sums to get:


Excel 2010
ABCDEFGHIJK
146406795676625
Sheet2 (2)


which your map tells us is:


Excel 2010
NOPQR
1NameFirst BaseSecond BaseThird BaseShortstop
2Sam5421
3Tom5333
4Will2333
5Brian4344
6Tod5626
7Matt6333
8Ahmed2714
9Billy3133
10Steve2366
11Paul1414
12Benjamin3333
13
146795
15MattAhmedSteveTod
166766
Sheet2 (2)
Cell Formulas
RangeFormula
O15=INDEX($N$2:$N$12,O14)
P15=INDEX($N$2:$N$12,P14)
Q15=INDEX($N$2:$N$12,Q14)
R15=INDEX($N$2:$N$12,R14)


This is much better to do in C++ or any OOP/scripting language where you print to the command prompt rather than a much slower graphics heavy worksheet like Excel's. Especially as the number of names and positions increases for instance. Excel's row count is limited so you might also write a macro that deletes the unneeded lines as they appear.
 
Last edited:
Upvote 0
Thanks, this is wonderful.

My fear here is I don't entirely follow the logic; the logic is sort of the operative value here for me, as I presented an abridged version.... in reality I'll have up to 20 names and 9 positions (depending on the instance) and I'm wondering if this is too customized to the problem--as in, if I want to expand from how it's set up here.

Do you know what the solver hangups would be, and/or how to overcome?

I found a similar set of issues here; I wonder about adapting this to my question: Excel Solver Using Strings - Stack Overflow
 
Upvote 0
The logic is very simple, you're looking at every possible combination of numbers 1-11 arranged in groups of 4. It's an easy way to do it, but not the most efficient. An algorithm would be better. Or perhaps solver combined with VBA like Tushar Mehta's method to find numbers in a group whose total is known: Combination of numbers that sum or match a target value

I tried solver again on this problem, with no success:


Excel 2010
ABCDEFGHIJKLMN
1NameFirst BaseSecond BaseThird BaseShortstop# unique
2Sam54211.100031.100031.100031.100030
3Tom5333First BaseSecond BaseThird BaseShortstopsum
4Will2333542112
5Brian4344
6Tod5626
7Matt6333
8Ahmed2714
9Billy3133
10Steve2366
11Paul1414
12Benjamin3333
Sheet3
Cell Formulas
RangeFormula
N2=SUMPRODUCT(--(COUNTIF($H$2:$K$2,$H$2:$K$2)=1))
H4=INDEX(B$2:B$12,H2)
I4=INDEX(C$2:C$12,I2)
J4=INDEX(D$2:D$12,J2)
K4=INDEX(E$2:E$12,K2)
L4=SUM(H4:K4)


I'll try to post the screenshot of the constraints
 
Last edited:
Upvote 0
xsLfu1l.png
 
Upvote 0

Forum statistics

Threads
1,225,662
Messages
6,186,290
Members
453,348
Latest member
newbieBA

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