Excel Solver Using Strings - excel

I'm going to try to explain this the best that I can.
Right now I have a spreadsheet with a list of football players, each of which has an assigned salary and projected point total for the week.
My goal is to use Solver or some other method to determine the best combination of players to maximize the projected point total while staying under a salary cap.
In this example I have 4 separate player lists, like this:
QB: Player A, Player B, Player C...Player N
RB: Player a, Player b, Player c...Player N
WR: Player X, Player Y, Player Z...Player N
TE: Player x, Player y, Player z...Player N
I need the best combination that includes 2 QBs, 2 RBs, 2 WRs, 1 TE, and 2 "Flex", which means any of RB/WR/TE.
I have tried using Solver to maximize the projected point total, but the variable fields in this case would be the Player's Names and it seems like the variable field needs to be a number, not a list of strings.
Any ideas?

My favorite kind of question :)
Here is the model setup:
Top table shows the decision variables: = 1 if player i = A, B, ..., N of list L = QB, .., TE is selected, =0 otherwise.
Entries in column R, (next to the top table) are the sums of each row. These must be constrained with the numbers in column T. Cell R7 is the total sum of players, which should be 9: 2 flexible and 7 as per the individual list requirements.
Middle table shows the salaries (randomly generated between 50,000 and 150,000). The Sum of Salaries formula is =SUMPRODUCT(C11:P14,C3:P6). The idea here is that only the salaries of players that are selected are taken into account. This SUMPRODUCT should be constrained with the budget, which is in cell T14. For my experiment, I put it equal to 80% of the total sum of all salaries.
Objective: Bottom table shows the projected points for each player. The formula in cell R22 is =SUMPRODUCT(C19:P22,C3:P6) (same logic as with salaries above). This is the value to be maximized.
Solver Model shown below:
I suggest selecting Simplex LP and going to Options and setting the Integer Optimality to zero (0).
Result:
Solver manages to find an optimal solution. The problem is really small and it is very quick. Solver works with up to 200 variables and 100 constraints, for large problems you will need the (commercial) extended version:
Of course, you can just order the real player names so that they fit this setting. For example, if you sort the players of each list alphabetically, then (Player A, QB) = first player of team QB, etc.
I hope this helps! Let me know if you would like me to upload the file for you.
Best,
Ioannis

Excel's solver is built on numerical methods. Applying to a domain that consists of discrete values, like strings or football players is probably going to fail. You should consider writing a brute force solver in a "real" programming language, like c#, java, python, ruby, or javascript. If there are performance problems, then optimize from there.

Solver won't work here because it's not a numeric solution you're after.
Make a spreadsheet that has every possible combination of position players (that meet your criteria) on each row. Then make an Excel formula that calculates projected point total based on the players in that row. Sort the spreadsheet by your projected point column.

Related

Evenly Distribute Players between 2 teams in Excel

I have a group of players, 915 in total, each with different engagement scores that I am trying to break out into two evenly distributed groups based on their engagement scores. I tried using Solver in excel to set contstraints, indices etc, but unfortunately Solver can only handle 200 variables, and I have 915. Another approach I researched is to give the first group with the best player also the worst player, give the second group the second best player and the second worst player, and so on. Problem is I am not an excel wiz and need some help writing out this formula in excel so both columns A and B show "1's" for the agents that should be selected for both groups in the group A and group B columns in the below screenshot (the screenshot is a small sample of the entire data set, FYI),
Screenshot Here
As you mentioned combination of best and worst player.
Your data is already sorted on descending index. Say, the data is in A,B and C Columns. Just put A in D2 and B in D3.
Select D2 and D3 and once you get + cursor on the bottom right of the selection, double click.
Filter A for group A and B for group B.

Calculating poker preflop equity efficient

I've read many articles about the Monte Carlo algorithm for approximating the preflop equity in NL holdem poker.
Unfortunately, it iterates over only a few possible boards to see what happens. The good thing about this is that you can put in exact hand ranges.
Well, I don't need exact ranges. It's good enough to say "Top 20% vs Top 35%".
Is there a simple formula to tell (or approximate) the likelihood of winning or losing? We can ignore splits here.
I can imagine that the way to calculate the odds will become much simpler if we just using two (percentile) numbers instead of all possible card combinations.
The thing is, I don't know if for example the case "Top 5% vs Top 10%" is equal to "Top 10% vs Top 20%".
Does anyone know of a usable relation or a formula for these inputs?
Thanks
Okay, I've made a bit analytical work and I came up wit the following.
The Formula
eq_a(a, b) := 1/2 - 1/(6*ln(10)) * ln(a/b)
Or if you like:
eq_a(a, b) := 0.5 - 0.072382 * ln(a/b)
Where a is the range in percent (0 to 1) for player a. Same for b.
The function outputs the equity for player a. To get the equity for player b just swap the two ranges.
When we plot the function it will look like this: (Where a = x and b = y)
As you can see it's very hard to get an equity greater than 80% preflop (as even AA isn't that good mostly).
How I came up with this
After I've done some analysis I became aware of the fact that the probability of winning is dependent on just the ratio of the two ranges (same for multiway pots).
So:
eq_a(a, b) = eq(a * h, b * h)
And yes, Top 5% vs Top 10% has the same equities as Top 50% vs Top 100%.
The way I've got the formula is I've done some regressions on sample data I've calculated with an app and picked the best fit (the logarithmic one). Then I optimised it using special cases like eq_a(0.1, 1)=2/3 and eq_a(a, a)=1/2.
It would be great if someone will do the work for multiway preflop all-ins.

Grab next same value in Excel/Google Sheets for RANK/MATCH formula

I have a list of players in Google Sheets that assigns them a rank based on wins, followed by some more match variables — standard stuff.
I then use the rank to order the players in a league table format.
However, when I have two more players with the same rank, I hit a problem. The easiest way to illustrate it is with a link to the spreadsheet. Left side is the data, right side is the outputted table:
https://docs.google.com/spreadsheets/d/1n05ETFfF01uCwp1Q88Z0Zi8XkH-dNm29Ocb6yVP84rU/edit?usp=sharing
My aim is:
To allow drawing players, and thus output:
1= Player 1
1= Player 2
3 Player 3
4 Player 4
But also to add players with a rank of 0 (already calculated) to the bottom of the list, in no particular order, but below those who have played.
May serve for ColumnM, but seems would require adjustments elsewhere:
=if(countif(I$2:I$8,I2)>1,IF((B2=0), 0, RANK(H2,$H$1:$H$531,0))&"=",IF((B2=0), 0, RANK(H2,$H$1:$H$531,0)))
You could reproduce your table (excluding the ranking) with this in N1:
=QUERY(A:G,"select * order by B desc, G desc",1)
and then in M2:
=ArrayFormula(IF(LEN(N2:N),(COUNTIF(S2:S,">"&S2:S)+1)&IF(COUNTIF(S2:S,S2:S)>1,"=",),))
Any kind of algorithm is going to hate ties. They will produce unpredictable results, logic errors.
So you might set up your ranking system to remove the ties. Possibly use the date they joined the league for tiebreaker, which would allow you to rank the players with no stats as well.
Make the rules known to all players. E.g. 3 points for a win, 1 point for a tie, 0 for a loss, tie goes to the player with highest total points scored. If still tied, it goes to player in the league longer. The likelihood of established players getting to the join-date tiebreaker should be as remote as you can make it, so your first tiebreaker should be one that produces a lot of diverse answers.
Also, I am not sure, but I think the reason your question got downvoted was because a) it's a bit vague, and b) in this day and age, you really don't want to be opening data files from unknown people. A snapshot of data from your spreadsheet might have been a better illustration than a link to it. I know I will not open your sheet...I don't know you.

Show on PivotChart... sum of two fields

OK, let's say I have this PivotChart:
I have a excel sheet of football matches and I watch to see the highest scoring team but it only does either home or away and I want to combine the two... how can I do that on my PivotChart fields?
I suggest inserting a column immediately to the right of B say labelled GSum with:
=SUMIF(F:F,B2,E:E)+SUMIF(B:B,B2,D:D)
in C2 and copied down to suit. In the PT add a Calculated Field, say Goals with =SUM(GSum)/2 and Sum of Goals at the bottom of Σ Values.
With luck on refresh the results might be similar to shown in this simplified example:
Note that, for example, C has not scored at home (so no blue) but has had three goals scored against it at home (brown). You might prefer the latter to indicate how many goals C has scored away (ie 4 - the same as it has scored in total) instead.

Picking top 5 scores from a range

I run a small golf eclectic with excel. One of the things we have is a points system. I would like to get the 5 highest points scored over the season and have them ranked from 1 (being the highest points scored) to 5.
My knowledge of excel "sums" goes only a wee bit further than add and subtract.
Thanks!
If you don't want to change the order that they are presently in you can use the LARGE function. It returns the kth largest value.
Below is a great formula, if you drag it down it will automatically get the second, third and nth largest value from a table of data (in this example the data is between A1 to A10).
=LARGE(A1:A10,ROW(A1)-ROW($A$1)+1)
You can then match the values with names or corresponding data from the tables using the MATCH and INDEX functions. The example below would fetch the name for each value from the second column.
=INDEX($A$1:$B$10,MATCH(cell reference with score or value,$A$1:$B$10,2))
Play around with these formulas, they are very convenient for data m
If you have a column containing the scores, you could add a filter (Data->Filter I think) and sort descending.
Though, if you just have rows that are something like [Date][Person][Score] you'll need to go to another sheet and SUM the scores for each person then sort that... Unfortunately my Excel skills aren't up to par to pull a score for each person like that.
Given a list of numbers in A1 to A10, you can work out their 'Rank' relative to each other by using 'RANK'.
e.g.
RANK(A1,A1:A6,0)
RANK(cell, list of cells to check against, order)
For order, 0 = descending.
From there you can work out which one is first pragmatically.
If you have Excel 2007,
Check that your data is continuous, with no blank rows or columns. Click on your scores and then select 'Data - Filter'
Using the dropdown that the filter creates at the top of your scores column and select 'Number filters - Top ten'
A 'Top ten Autofilter' dialog will be displayed, reduce the show 10 to 5 and then click on OK.
For earlier versions of Excel add a RANK formula in a new column. Be careful as the scores need to be sorted, usually into descending order. If there are any ties, they will be given the same ranking number and the subsequent rank number will be incremented by the number of ties. (E.g. If there are two scores of 2, ranked as 5. The next score will be ranked as 7, not 6)
If you want to use the LARGE Function as described above, make sure you put the same range in the list for each of the LARGE functions. That is, change =LARGE(A1:A10,ROW(A1)-ROW($A$1)+1) to =LARGE(A$1:A$10,ROW(A1)-ROW($A$1)+1) or you will get some strange incorrect results

Resources