<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fantasy Football Optimal Model in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171194#M871</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How exactly would you solve this with a simple data step?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Jan 2015 21:47:00 GMT</pubDate>
    <dc:creator>Matthew_Galati</dc:creator>
    <dc:date>2015-01-09T21:47:00Z</dc:date>
    <item>
      <title>Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171189#M866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good evening,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a dataset that contains the predicted points for each player in a fantasy football competition. The fields in the dataset are:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Player&lt;/P&gt;&lt;P&gt;Team&lt;/P&gt;&lt;P&gt;Position (G, D, M or A)&lt;/P&gt;&lt;P&gt;Points&lt;/P&gt;&lt;P&gt;Price&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to use a procedure that would enable me to pick the combination of players that would score maximum points while satisfying following conditions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Number of G selected = 1&lt;/P&gt;&lt;P&gt;Number of D selected = 4&lt;/P&gt;&lt;P&gt;Number of M selected = 4&lt;/P&gt;&lt;P&gt;Number of A selected = 2&lt;/P&gt;&lt;P&gt;Total price of of players selected &amp;lt;= £75,000,000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks for any help you can give,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cxkev&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 20:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171189#M866</guid>
      <dc:creator>cxkev182</dc:creator>
      <dc:date>2014-10-02T20:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171190#M867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sure there is a mathematical formula for this (that I am not aware of so take this with a grain of salt), but you could break it into a logic problem and avoid any 'formulas' all together.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;By definition, if you had no price cap, you would simply pick the 1 G, 4 D, 4 M, and 2 A that scored the most amount of points.&amp;nbsp; however you have a price cap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what I would do is create a new variable that is the players Points / Cost.&amp;nbsp;&amp;nbsp; Then I would select the Best players in every group (defined by points scored, regardless of price),&amp;nbsp; then figure out how much you are OVER in your spending budget.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then rank your players by your "points / cost" variable. Replace the player with the worst points / cost from your seiection&amp;nbsp; with the next available player, and see if you are then under-budget.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Continue this process in a loop and once you are under budget you are "very close" to maximized in your points scored. There's a little more work from here however.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets say you are only 1 million over budget, and you replace your 3rd best D with the 5th best D, however their salaries are very far apart. Maybe now you are 8 million under-budget... Well you might be able to get a better "G" player, so you'd have to loop over all available players to see if the difference in salaries are small enough for you to add them back.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again once this logic check fails you are maximized on points scored.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 21:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171190#M867</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2014-10-02T21:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171191#M868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use PROC OPTMODEL to formulate the problem and solve it with the mixed integer linear programming (MILP) solver.&amp;nbsp; You need to introduce one binary variable per player, with the interpretation that the variable equals 1 if and only if that player is selected.&amp;nbsp; Each of the four conditions corresponds to a linear constraint over these variables.&amp;nbsp; And the objective function to be maximized is also a linear function of these variables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Oct 2014 02:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171191#M868</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2014-10-03T02:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171192#M869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi cxkev,&lt;/P&gt;&lt;P&gt;I have a blog post, that is exactly about this problem. Unfortunately it is in Hungarian. Formulas are in English.&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://blogs.sas.com/content/analitika/2012/09/03/kell-egy-csapat-a-feladat-megoldasa/" title="http://blogs.sas.com/content/analitika/2012/09/03/kell-egy-csapat-a-feladat-megoldasa/"&gt;Kell egy csapat! – a feladat megoldása - Analitika anyanyelven&lt;/A&gt;&lt;/P&gt;&lt;P&gt;But you can download sample data and code (OPTMODEL) from here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://blogs.sas.com/content/analitika/files/2012/09/generate_data_sas.txt" title="http://blogs.sas.com/content/analitika/files/2012/09/generate_data_sas.txt"&gt;http://blogs.sas.com/content/analitika/files/2012/09/generate_data_sas.txt&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://blogs.sas.com/content/analitika/files/2012/09/solve_team_sas.txt" title="http://blogs.sas.com/content/analitika/files/2012/09/solve_team_sas.txt"&gt;http://blogs.sas.com/content/analitika/files/2012/09/solve_team_sas.txt&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Oct 2014 06:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171192#M869</guid>
      <dc:creator>gergely_batho</dc:creator>
      <dc:date>2014-10-03T06:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171193#M870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You also don't need SAS/OR , just a simple data step is enough.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Oct 2014 12:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171193#M870</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-10-03T12:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171194#M871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How exactly would you solve this with a simple data step?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jan 2015 21:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171194#M871</guid>
      <dc:creator>Matthew_Galati</dc:creator>
      <dc:date>2015-01-09T21:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171195#M872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure . The condition is set &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Total price of of players selected &amp;lt;= £75,000&amp;nbsp; .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
input Player Position $&amp;nbsp; Points Price&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;;
cards;
1 G 2 8000
2 D 4 7000
3 M 6 12000
4 A 8 10000
5 G 4 9000
6 A 9 14000
8 D 4 8000
9 M 6 4000
10 A 8 10000
12 A 9 14000
13 D 4 7000
14 M 6 12000
17 A 9 14000
18 G 2 8000
19 D 4 7000
20 M 6 12000
24 D 4 7000
25 M 6 12000
29 D 4 7000
30 M 6 7000
32 M 6 1000
36 D 4 7000
37 M 6 12000
42 D 4 7000
43 M 6 12000
45 G 4 9000
46 A 9 14000
47 D 4 7000
48 M 6 12000
55 D 4 7000
56 M 6 12000
60 D 4 6000
61 M 6 9000
63 M 6 2000
67 D 4 5000
68 M 6 9000
70 M 8 6000
;
run;

%let dsid=%sysfunc(open(have));
%let nobs=%sysfunc(attrn(&amp;amp;dsid,nlobs));
%let dsid=%sysfunc(close(&amp;amp;dsid));
proc sort data=have ;by position;run;
data _null_;
 set have;
 by position;
 if last.position then call symputx(position,_n_);
run;
data _null_;
 set have end=last;
 length list $ 100 point_sum point_max cost _cost 8 ;
 array pla{&amp;amp;nobs}&amp;nbsp; _temporary_ ;
 array pos{&amp;amp;nobs} $&amp;nbsp; _temporary_ ;
 array poi{&amp;amp;nobs}&amp;nbsp; _temporary_ ;
 array pri{&amp;amp;nobs}&amp;nbsp; _temporary_ ;
 pla{_n_}=Player;
 pos{_n_}=Position;
 poi{_n_}=Points;
 pri{_n_}=Price;

if last then do; 
do i1=1 to &amp;amp;A ;
do i2=i1+1 to &amp;amp;A ;
&amp;nbsp; do j1=%eval(&amp;amp;A+1) to &amp;amp;D ;
&amp;nbsp; do j2=j1+1 to &amp;amp;D ;
&amp;nbsp; do j3=j2+1 to &amp;amp;D ;
&amp;nbsp; do j4=j3+1 to &amp;amp;D ;
&amp;nbsp;&amp;nbsp;&amp;nbsp; do m=%eval(&amp;amp;D+1) to &amp;amp;G ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do n1=%eval(&amp;amp;G+1) to &amp;amp;M ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do n2=n1+1 to &amp;amp;M ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do n3=n2+1 to &amp;amp;M ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do n4=n3+1 to &amp;amp;M ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point_sum=sum(poi{i1},poi{i2},poi{j1},poi{j2},poi{j3},poi{j4},poi{m},poi{n1},poi{n2},poi{n3},poi{n4});
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cost=sum(pri{i1},pri{i2},pri{j1},pri{j2},pri{j3},pri{j4},pri{m},pri{n1},pri{n2},pri{n3},pri{n4});

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; point_sum gt point_max and cost le 75000 then do;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point_max=point_sum; _cost=cost;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list=catx('|',pla{i1},pla{i2},pla{j1},pla{j2},pla{j3},pla{j4},pla{m},pla{n1},pla{n2},pla{n3},pla{n4});
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp; end;
&amp;nbsp; end;
&amp;nbsp; end;
&amp;nbsp; end;
&amp;nbsp; end;
end;
end;


putlog 'Players : ' list 'Max Points : ' point_max 'Cost : ' _cost;
end;
run;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Players : 6|12|2|13|60|67|5|9|32|63|70 Max Points : 64 Cost : 75000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: xia keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Jan 2015 11:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171195#M872</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-01-10T11:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171196#M873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="645292" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;, This is hardly can be called a 'simple data step', maybe only for you though &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;.&amp;nbsp;&amp;nbsp; nonetheless, you have the job done nicely. However, you probably need additional step to obtain all of the qualified combinations, or you sure can go extra miles within single data step by setting up Hash or multi-dim array to retain all of the qualified combinations, and in your mock data there are 432 combinations meeting the same criteria.&lt;/P&gt;&lt;P&gt;Here is my dumber approach,&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;noprint&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; player &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; :gp separated by &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;' '&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; Position=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'G'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; count(player) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; :gc separated by &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;' '&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; Position=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'G'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; player &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; :dp separated by &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;' '&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; Position=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'D'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; count(player) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; :dc separated by &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;' '&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; Position=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'D'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; player &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; :mp separated by &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;' '&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; Position=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'M'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; count(player) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; :mc separated by &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;' '&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; Position=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'M'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; player &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; :ap separated by &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;' '&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; Position=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'A'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; count(player) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; :ac separated by &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;' '&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; Position=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'A'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _gp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; gp[&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;gc.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;]&amp;nbsp; (&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;gp.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; n=dim(gp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; k=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ncomb=comb(n, k);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; j=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ncomb;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; allcomb(j, k, of gp&lt;LI&gt;);&lt;/LI&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;keep&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; gp1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _dp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; dp[&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;dc.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;]&amp;nbsp; (&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;dp.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; n=dim(dp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; k=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ncomb=comb(n, k);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; j=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ncomb;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; allcomb(j, k, of dp&lt;LI&gt;);&lt;/LI&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;keep&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; dp1-dp4;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _mp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; mp[&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;mc.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;]&amp;nbsp; (&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;mp.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; n=dim(mp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; k=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ncomb=comb(n, k);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; j=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ncomb;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; allcomb(j, k, of mp&lt;LI&gt;);&lt;/LI&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;keep&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; mp1-mp4;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _ap;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ap[&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;ac.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;]&amp;nbsp; (&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;ap.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; n=dim(ap);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; k=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ncomb=comb(n, k);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; j=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ncomb;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; allcomb(j, k, of ap&lt;LI&gt;);&lt;/LI&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;keep&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ap1-ap2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; comall &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; * &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _gp, _dp, _mp, _ap;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; h1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _n_=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt; &lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;declare&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; hash h(dataset:&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'have'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; h.definekey(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'player'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; h.definedata(all:&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'y'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; h.definedone();&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; comall;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; p gp1--ap2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; missing (_price, _points);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;over&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; p;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; rc=h.find(key:p);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _price+price;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _points+points;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _price &amp;lt;=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;75000&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; want(keep = gp1 dp1-dp4 mp1-mp4 ap1 ap2) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; * &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; h1&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;having&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _points=max(_points);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2015 14:48:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171196#M873</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-01-12T14:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171197#M874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Both data step / sql approaches are using brute force enumeration and hard coded sizes for the player positions (number of players needed). What happens if the number of players needed would change? What if you tried to scale this up? How long does the data step take to run if you had a field of 500 players - which is quite common in Fantasy sports applications?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For this tiny example, on my machine,&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Xia's code ran in: 7 seconds&lt;/LI&gt;&lt;LI&gt;Haikuo's code ran in: ~2 minutes&lt;/LI&gt;&lt;LI&gt;My code below (adapted from previous post) ran in: 0.03 seconds&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data rules;&lt;/P&gt;&lt;P&gt; input position $ numPlayersPerPos;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;G 1&lt;/P&gt;&lt;P&gt;D 4&lt;/P&gt;&lt;P&gt;M 4&lt;/P&gt;&lt;P&gt;A 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;/P&gt;&lt;P&gt; set PLAYERS;&lt;/P&gt;&lt;P&gt; num price{PLAYERS};&lt;/P&gt;&lt;P&gt; num points{PLAYERS};&lt;/P&gt;&lt;P&gt; str position{PLAYERS};&lt;/P&gt;&lt;P&gt; set&amp;lt;str&amp;gt; POSITIONS;&lt;/P&gt;&lt;P&gt; num numPlayersPerPos{POSITIONS}; &lt;/P&gt;&lt;P&gt; var assign{PLAYERS} binary;&lt;/P&gt;&lt;P&gt; max sumPoints=sum{p in PLAYERS}points&lt;/P&gt;&lt;P&gt;*assign&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt; con Budget: sum{p in PLAYERS}price&lt;/P&gt;&lt;P&gt;*assign&lt;/P&gt;&lt;P&gt;&amp;lt;=75000;&lt;/P&gt;&lt;P&gt; con NumPos{po in POSITIONS}:sum{p in PLAYERS:position&lt;/P&gt;&lt;P&gt;=po}assign&lt;/P&gt;&lt;P&gt;=numPlayersPerPos[po];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; read data have into PLAYERS=[Player] position price points;&lt;/P&gt;&lt;P&gt; read data rules into POSITIONS=[position] numPlayersPerPos;&lt;/P&gt;&lt;P&gt; solve; &lt;/P&gt;&lt;P&gt; create data team from [player=p]={p in PLAYERS:assign&lt;/P&gt;&lt;P&gt;&amp;gt;0.9};&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2015 15:24:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171197#M874</guid>
      <dc:creator>Matthew_Galati</dc:creator>
      <dc:date>2015-01-12T15:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171198#M875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Point taken and there is no surprise that specialized SAS Proc will win &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;.&amp;nbsp; But what if you don't have SAS/OR? SAS/OR is not something like SAS/STAT which most of the customers would want to have for just being on the safe side. For those only need this kind of functionality sparsely, data step or proc sql will still stand as a viable solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2015 16:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171198#M875</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-01-12T16:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171199#M876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Everyone I know wants to have SAS/OR. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2015 16:56:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171199#M876</guid>
      <dc:creator>Matthew_Galati</dc:creator>
      <dc:date>2015-01-12T16:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171200#M877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;True. I want it, but sadly we don't have it, even as a company with more than 400 SAS users.&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2015 17:02:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171200#M877</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-01-12T17:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171201#M878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"&lt;SPAN style="color: #575757; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;What happens if the number of players needed would change? What if you tried to scale this up?"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #575757; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;I can make a macro like SAS/OR did , that is not a big deal .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;What happens if the number of players needed would change? What if you tried to scale this up?"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;That is depended on which &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;algorithm&amp;nbsp; you are using .&lt;/SPAN&gt; I would like to know a better and faster algorithm for this question. It would be generous if you could display what exact algorithm SAS/OR is using by SAS data step or just explain it in English .&amp;nbsp; Maybe I could end up a better and faster algorithm in near future.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As Bian said , SAS/OR need money to get it , and I also believe SAS/OR have the best algorithm in the world to process such PROGRAMMING . But not every company would like to pay for it . So data step or some other kind skill is an alternative way , although it would cost lots of time more than SAS/OR &lt;STRONG&gt;.But that is algorithm problem&lt;/STRONG&gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 05:15:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171201#M878</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-01-13T05:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171202#M879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;(Disclaimer: I write models for SAS/OR customers.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd venture to say that for any sufficiently complex business, the cost of not having SAS/OR is greater than the cost of the license, and that the difference between those two costs only increases as advances in predictive analytics and data management increase analytical maturity. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Beyond computing time, think of analyst time. That is what is most expensive. Compare the complexity of the solutions on this page. If the opportunity to automate a decision process is ignored because implementing a solution using imperative languages is too complicated, or is too difficult to adapt to changing underlying circumstances, then that business process remains manual, errors and inefficiencies in that business process remain undetected, and all the interactions between that process and the other processes in the firm suffer. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In contrast, when it is easy to describe a decision process using declarative constructs that are close to the business rules themselves, and easy to use an optimization engine to automate the computation of the solution, then more processes are automated, and the automation of each process enables gains that start from that very specific operation but then emanate throughout the firm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Those network effects are benefits beyond the traditional, more immediate benefit of running the process itself in a more efficient manner.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 09:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171202#M879</guid>
      <dc:creator>LeoLopes</dc:creator>
      <dc:date>2015-01-13T09:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171203#M880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Xia - The solver code in SAS/OR is not a data step. It is written in C.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The algorithm used in SAS/OR is a variant of the branch-and-cut algorithm for integer programming. You can see some high level information about the algorithm here: &lt;A href="http://support.sas.com/documentation/cdl/en/ormpug/67517/HTML/default/viewer.htm#ormpug_milpsolver_details.htm" title="http://support.sas.com/documentation/cdl/en/ormpug/67517/HTML/default/viewer.htm#ormpug_milpsolver_details.htm"&gt;SAS/OR(R) 13.2 User's Guide: Mathematical Programming&lt;/A&gt;. Or, there are many textbooks on the topic - see, for example: &lt;A href="http://www.amazon.com/gp/product/0471359432/ref=pd_lpo_sbs_dp_ss_1?pf_rd_p=1944687462&amp;amp;pf_rd_s=lpo-top-stripe-1&amp;amp;pf_rd_t=201&amp;amp;pf_rd_i=0471283665&amp;amp;pf_rd_m=ATVPDKIKX0DER&amp;amp;pf_rd_r=0E9B963GJYX4927NAQ18" title="http://www.amazon.com/gp/product/0471359432/ref=pd_lpo_sbs_dp_ss_1?pf_rd_p=1944687462&amp;amp;pf_rd_s=lpo-top-stripe-1&amp;amp;pf_rd_t=201&amp;amp;pf_rd_i=0471283665&amp;amp;pf_rd_m=ATVPDKIKX0DER&amp;amp;pf_rd_r=0E9B963GJYX4927NAQ18"&gt;Integer and Combinatorial Optimization: Laurence A. Wolsey, George L. Nemhauser: 9780471359432: Amazon.com: Books&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 13:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171203#M880</guid>
      <dc:creator>Matthew_Galati</dc:creator>
      <dc:date>2015-01-13T13:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171204#M881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;While I am heartily embracing your sentiment, your general comments can also apply to SAS/IML, SAS/ETS, SAS/QC, and even SAS/AF. And if you want to go beyond that, they can also apply to E-miner, and on top of that, Text-miner, and one step further,&amp;nbsp; SAS Sentiment Analysis, and we haven't touched many other great SAS solution servers. By the end of the day, it is all about cost of ownership vs potential risks, and where to set the line most time it is hard to calculate therefore rather subjective. While I am no where close to the pay grade to decide which product to buy, I can still see how it goes. When business feel confused/undecided, that is when they step on the brakes, and sadly to say, that is also when they resort to third party solutions, such as R.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 14:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171204#M881</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-01-13T14:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171205#M882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matt,&lt;/P&gt;&lt;P&gt;Thanks for sharing that book . Hope one day I could buy one and have time to read about it .&lt;/P&gt;&lt;P&gt;I ended up with a better and faster BACKWARDS algorithm (although it is not best algorithm).&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;For this tiny example, on my machine,&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;original code ran in: 9 seconds&lt;/LI&gt;&lt;LI&gt;this one ran in 0.03 seconds&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt; 
 
data have;
input Player Position $&amp;nbsp; Points Price&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;
cards;
1 G 2 8000
2 D 4 7000
3 M 6 12000
4 A 8 10000
5 G 4 9000
6 A 9 14000
8 D 4 8000
9 M 6 4000
10 A 8 10000
12 A 9 14000
13 D 4 7000
14 M 6 12000
17 A 9 14000
18 G 2 8000
19 D 4 7000
20 M 6 12000
24 D 4 7000
25 M 6 12000
29 D 4 7000
30 M 6 7000
32 M 6 1000
36 D 4 7000
37 M 6 12000
42 D 4 7000
43 M 6 12000
45 G 4 9000
46 A 9 14000
47 D 4 7000
48 M 6 12000
55 D 4 7000
56 M 6 12000
60 D 4 6000
61 M 6 9000
63 M 6 2000
67 D 4 5000
68 M 6 9000
70 M 8 6000
;
run;


proc sort data=have ;by position descending Points Price;run;
data _null_;
 set have;
 by position ;
 if last.position then call symputx(position,_n_);
run;
data _null_;
 set have end=last;
 length list $ 100 point_sum point_max cost _cost 8 ;
 array pla{&amp;amp;M}&amp;nbsp; _temporary_ ;
 array pos{&amp;amp;M} $&amp;nbsp; _temporary_ ;
 array poi{&amp;amp;M}&amp;nbsp; _temporary_ ;
 array pri{&amp;amp;M}&amp;nbsp; _temporary_ ;
 pla{_n_}=Player;
 pos{_n_}=Position;
 poi{_n_}=Points;
 pri{_n_}=Price;

if last then do; 
offset=-1;
do until(offset=max(&amp;amp;A-2,&amp;amp;D-&amp;amp;A-4,&amp;amp;G-&amp;amp;D-1,&amp;amp;M-&amp;amp;G-4));
offset+1;
do i1=1 to min(2+offset,&amp;amp;A) ;
do i2=i1+1 to&amp;nbsp; min(2+offset,&amp;amp;A) ;
&amp;nbsp; do j1=%eval(&amp;amp;A+1) to&amp;nbsp; min(&amp;amp;A+4+offset,&amp;amp;D) ;
&amp;nbsp; do j2=j1+1 to min(&amp;amp;A+4+offset,&amp;amp;D);
&amp;nbsp; do j3=j2+1 to min(&amp;amp;A+4+offset,&amp;amp;D) ;
&amp;nbsp; do j4=j3+1 to min(&amp;amp;A+4+offset,&amp;amp;D) ;
&amp;nbsp;&amp;nbsp;&amp;nbsp; do m=%eval(&amp;amp;D+1) to min(&amp;amp;D+1+offset,&amp;amp;G) ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do n1=%eval(&amp;amp;G+1) to min(&amp;amp;G+4+offset,&amp;amp;M) ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do n2=n1+1 to min(&amp;amp;G+4+offset,&amp;amp;M) ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do n3=n2+1 to min(&amp;amp;G+4+offset,&amp;amp;M) ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do n4=n3+1 to min(&amp;amp;G+4+offset,&amp;amp;M) ;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if i1=min(2+offset,&amp;amp;A) or i2=min(2+offset,&amp;amp;A)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j1=min(&amp;amp;A+4+offset,&amp;amp;D) or j2=min(&amp;amp;A+4+offset,&amp;amp;D) or&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j3=min(&amp;amp;A+4+offset,&amp;amp;D) or j4=min(&amp;amp;A+4+offset,&amp;amp;D) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m=min(&amp;amp;D+1+offset,&amp;amp;G) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n1=min(&amp;amp;G+4+offset,&amp;amp;M) or n2=min(&amp;amp;G+4+offset,&amp;amp;M) or n3=min(&amp;amp;G+4+offset,&amp;amp;M) or n4=min(&amp;amp;G+4+offset,&amp;amp;M) then do;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point_sum=sum(poi{i1},poi{i2},poi{j1},poi{j2},poi{j3},poi{j4},poi{m},poi{n1},poi{n2},poi{n3},poi{n4});
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cost=sum(pri{i1},pri{i2},pri{j1},pri{j2},pri{j3},pri{j4},pri{m},pri{n1},pri{n2},pri{n3},pri{n4});

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; point_sum gt point_max and cost le 75000 then do;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point_max=point_sum; _cost=cost;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list=catx('|',pla{i1},pla{i2},pla{j1},pla{j2},pla{j3},pla{j4},pla{m},pla{n1},pla{n2},pla{n3},pla{n4});
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not missing(list) then do;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; putlog 'Players : ' list 'Max Points : ' point_max 'Cost : ' _cost; stop;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;

&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp; end;
&amp;nbsp; end;
&amp;nbsp; end;
&amp;nbsp; end;
&amp;nbsp; end;
end;
end;
end;
putlog 'Not found solution.'; 
end;
run;








Players : 6|12|67|60|2|13|5|70|32|63|9 Max Points : 64 Cost : 75000

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: xia keshan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: xia keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2015 13:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171205#M882</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-01-16T13:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171206#M883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good job.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, I think your approach might start to struggle if you change any of the rules associated with the model (for example, try to apply that to a different sport for Fantasy, or change a rule), or if you scale the problem up to more realistic sizes (since you are using "brute force").&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As an example, let's consider a larger field of players (more realistic for Fantasy Sports applications). We can simulate that as such:&lt;/P&gt;&lt;P&gt;%macro createData(n=15);&lt;/P&gt;&lt;P&gt;data have(drop=i rename=(count=player));&lt;/P&gt;&lt;P&gt; retain count 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt; do i = 1 to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp; count+1; &lt;/P&gt;&lt;P&gt;&amp;nbsp; playerNumber = player;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend createData;&lt;/P&gt;&lt;P&gt;%createData();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running your code took 49 minutes.&lt;/P&gt;&lt;P&gt;Players : 76|77|511|512|513|514|61|541|542|301|302 Max Points : 66 Cost : 71000&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49:02.72&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 49:02.69&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And running my code took: 0.08s&lt;/P&gt;&lt;P&gt;NOTE: Optimal.&lt;/P&gt;&lt;P&gt;NOTE: Objective = 68.&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE OPTMODEL used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.08 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.07 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also,&amp;nbsp; are you sure your code is exact? The OR solver found a better solution (68).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2015 20:17:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171206#M883</guid>
      <dc:creator>Matthew_Galati</dc:creator>
      <dc:date>2015-01-16T20:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171207#M884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;169&amp;nbsp; %macro createData(n=15);&lt;/P&gt;&lt;P&gt;170&amp;nbsp; data have(drop=i rename=(count=player));&lt;/P&gt;&lt;P&gt;171&amp;nbsp; retain count 0;&lt;/P&gt;&lt;P&gt;172&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;173&amp;nbsp; do i = 1 to &amp;amp;n;&lt;/P&gt;&lt;P&gt;174&amp;nbsp;&amp;nbsp;&amp;nbsp; count+1;&lt;/P&gt;&lt;P&gt;175&amp;nbsp;&amp;nbsp;&amp;nbsp; playerNumber = player;&lt;/P&gt;&lt;P&gt;176&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;177&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;178&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;179&amp;nbsp; %mend createData;&lt;/P&gt;&lt;P&gt;180&amp;nbsp; %createData()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WARNING: Variable Player already exists on file WORK.HAVE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why I would got this message.&lt;/P&gt;&lt;P&gt;As I said . My algorithm is &lt;STRONG&gt;Backward&lt;/STRONG&gt; , so if the solution is at high level , my code would be very fast, whereas if it is at low level ,mine would cost lots of time. But that is the start point problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;"brute force" , I don't agree with that,&amp;nbsp; I am partially brute force . first four member then five member .....six ....&amp;nbsp;&amp;nbsp; .If the solution is at the top ,that would be very fast.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Of courese. I have a long way to walk.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Yeah. You are right. I need to reconsider it for a while .&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: xia keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Jan 2015 06:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171207#M884</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-01-17T06:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Fantasy Football Optimal Model</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171208#M885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Haha Matt,&lt;/P&gt;&lt;P&gt;I ended up with Genetic Algorithm . It is so sharp and powerful and almost be able to solve all kind of optimum problem.&lt;/P&gt;&lt;P&gt;Which means You can solve all the optimum problems &lt;STRONG&gt;without any money&lt;/STRONG&gt; if you have SAS University Edition.Code is written in IML.&lt;/P&gt;&lt;P&gt;It is so amazing and so fast (0.4 sec). I love it too much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input Player Position $&amp;nbsp; Points Price ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 G 2 8000&lt;/P&gt;&lt;P&gt;2 D 4 7000&lt;/P&gt;&lt;P&gt;3 M 6 12000&lt;/P&gt;&lt;P&gt;4 A 8 10000&lt;/P&gt;&lt;P&gt;5 G 4 9000&lt;/P&gt;&lt;P&gt;6 A 9 14000&lt;/P&gt;&lt;P&gt;8 D 4 8000&lt;/P&gt;&lt;P&gt;9 M 6 4000&lt;/P&gt;&lt;P&gt;10 A 8 10000&lt;/P&gt;&lt;P&gt;12 A 9 14000&lt;/P&gt;&lt;P&gt;13 D 4 7000&lt;/P&gt;&lt;P&gt;14 M 6 12000&lt;/P&gt;&lt;P&gt;17 A 9 14000&lt;/P&gt;&lt;P&gt;18 G 2 8000&lt;/P&gt;&lt;P&gt;19 D 4 7000&lt;/P&gt;&lt;P&gt;20 M 6 12000&lt;/P&gt;&lt;P&gt;24 D 4 7000&lt;/P&gt;&lt;P&gt;25 M 6 12000&lt;/P&gt;&lt;P&gt;29 D 4 7000&lt;/P&gt;&lt;P&gt;30 M 6 7000&lt;/P&gt;&lt;P&gt;32 M 6 1000&lt;/P&gt;&lt;P&gt;36 D 4 7000&lt;/P&gt;&lt;P&gt;37 M 6 12000&lt;/P&gt;&lt;P&gt;42 D 4 7000&lt;/P&gt;&lt;P&gt;43 M 6 12000&lt;/P&gt;&lt;P&gt;45 G 4 9000&lt;/P&gt;&lt;P&gt;46 A 9 14000&lt;/P&gt;&lt;P&gt;47 D 4 7000&lt;/P&gt;&lt;P&gt;48 M 6 12000&lt;/P&gt;&lt;P&gt;55 D 4 7000&lt;/P&gt;&lt;P&gt;56 M 6 12000&lt;/P&gt;&lt;P&gt;60 D 4 6000&lt;/P&gt;&lt;P&gt;61 M 6 9000&lt;/P&gt;&lt;P&gt;63 M 6 2000&lt;/P&gt;&lt;P&gt;67 D 4 5000&lt;/P&gt;&lt;P&gt;68 M 6 9000&lt;/P&gt;&lt;P&gt;70 M 8 6000&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro createData(n=15);&lt;/P&gt;&lt;P&gt;data have(drop=i rename=(count=player));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have(drop=player);&lt;/P&gt;&lt;P&gt;do i = 1 to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp; count+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend createData;&lt;/P&gt;&lt;P&gt;%createData()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options fullstimer;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt; select count(*) into : A from have where Position='A';&lt;/P&gt;&lt;P&gt; select count(*) into : D from have where Position='D';&lt;/P&gt;&lt;P&gt; select count(*) into : G from have where Position='G';&lt;/P&gt;&lt;P&gt; select count(*) into : M from have where Position='M';&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;use have;&lt;/P&gt;&lt;P&gt;read all var _all_ where(Position='A');&lt;/P&gt;&lt;P&gt;Player_A=Player;Point_A=Points;Pice_A=Price;&lt;/P&gt;&lt;P&gt;read all var _all_ where(Position='D');&lt;/P&gt;&lt;P&gt;Player_D=Player;Point_D=Points;Pice_D=Price;&lt;/P&gt;&lt;P&gt;read all var _all_ where(Position='G');&lt;/P&gt;&lt;P&gt;Player_G=Player;Point_G=Points;Pice_G=Price;&lt;/P&gt;&lt;P&gt;read all var _all_ where(Position='M');&lt;/P&gt;&lt;P&gt;Player_M=Player;Point_M=Points;Pice_M=Price;&lt;/P&gt;&lt;P&gt;close have;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start football(x) global(Point_A,Pice_A,Point_D,Pice_D,Point_G,Pice_G,Point_M,Pice_M);&lt;/P&gt;&lt;P&gt; points=sum(Point_A[x[1:2]],Point_D[x[3:6]],Point_G[x[7]],Point_M[x[8:11]]);&lt;/P&gt;&lt;P&gt; sum_cost=sum(Pice_A[x[1:2]],Pice_D[x[3:6]],Pice_G[x[7]],Pice_M[x[8:11]]);&lt;/P&gt;&lt;P&gt; if sum_cost&amp;gt;75000 then points=1;&lt;/P&gt;&lt;P&gt; return (points);&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start uniform_cross(child1, child2, parent1, parent2);&lt;/P&gt;&lt;P&gt; child1 = parent1;&lt;/P&gt;&lt;P&gt; child2 = parent2;&lt;/P&gt;&lt;P&gt; do i = 1 to ncol(parent1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; r = uniform(1234);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if r&amp;lt;=0.5 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; child1&lt;I&gt; = parent2&lt;I&gt;;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; child2&lt;I&gt; = parent1&lt;I&gt;;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id=gasetup(2,11,123);&lt;/P&gt;&lt;P&gt;call gasetobj(id,1,"football");&lt;/P&gt;&lt;P&gt;call gasetcro(id,1.0,0,"uniform_cross");&lt;/P&gt;&lt;P&gt;call gasetmut(id,0.2,1);&lt;/P&gt;&lt;P&gt;call gasetsel(id,3,1,0.95);&lt;/P&gt;&lt;P&gt;call gainit(id,2000,{1&amp;nbsp; 1&amp;nbsp; 1&amp;nbsp; 1&amp;nbsp; 1&amp;nbsp; 1&amp;nbsp; 1&amp;nbsp; 1&amp;nbsp; 1&amp;nbsp; 1&amp;nbsp; 1 ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;A &amp;amp;A &amp;amp;D &amp;amp;D &amp;amp;D &amp;amp;D &amp;amp;G &amp;amp;M &amp;amp;M &amp;amp;M &amp;amp;M });&lt;/P&gt;&lt;P&gt;niter = 100;&lt;/P&gt;&lt;P&gt;summary = j(niter,2);&lt;/P&gt;&lt;P&gt;mattrib summary [c = {"Max Points", "Avg Points"} l=""];&lt;/P&gt;&lt;P&gt;do i = 1 to niter;&lt;/P&gt;&lt;P&gt; call garegen(id);&lt;/P&gt;&lt;P&gt; call gagetval(value, id);&lt;/P&gt;&lt;P&gt; summary[i,1] = value[1];&lt;/P&gt;&lt;P&gt; summary[i,2] = value[:];&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;call gagetmem(mem, value, id, 1);&lt;/P&gt;&lt;P&gt;Players=Player_A[mem[1:2]]//Player_D[mem[3:6]]//Player_G[mem[7]]//Player_M[mem[8:11]];&lt;/P&gt;&lt;P&gt;sum_cost=sum(Pice_A[mem[1:2]],Pice_D[mem[3:6]],Pice_G[mem[7]],Pice_M[mem[8:11]]);&lt;/P&gt;&lt;P&gt;print Players[ l="best member:"],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Max Points: " value[l = ""],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Total Cost:&amp;nbsp; " sum_cost[l = ""] ;&lt;/P&gt;&lt;P&gt;iteration = t(1:niter);&lt;/P&gt;&lt;P&gt;print iteration summary;&lt;/P&gt;&lt;P&gt;call gaend(id);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Feb 2015 08:21:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Fantasy-Football-Optimal-Model/m-p/171208#M885</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-02-15T08:21:00Z</dc:date>
    </item>
  </channel>
</rss>

