<?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: An interesting OR problem in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256349#M1264</link>
    <description>&lt;P&gt;Hi Team&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I will be posting more detail on the SAS-L list, But it has 15 lines in a single data step(after removing checking arrays)?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There appear to be 4 solutions, kind of a lark so be suspecious. I learn more from my errors then my solutions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;see below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is one of them&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3=c&lt;BR /&gt;4=d&lt;BR /&gt;6=f&lt;BR /&gt;11=k&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Others are below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution may not scale &amp;nbsp;over 54 codes without using extended precision, no limit of number of vectors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only change from a previous post on SAS-L was to substitute 'bor' for 'sum'&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Obs TOT E1 E2 E3 E4 D1 D2 D3 D4&lt;/P&gt;&lt;P&gt;1 2097150 136522 1155104 52246 1966992 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 4 6 11&lt;BR /&gt;2 2097150 136522 1155104 84172 1966992 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 4 9 11&lt;BR /&gt;3 2097150 136522 1090160 952320 84172 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 7 8 9&lt;BR /&gt;4 2097150 136522 1090160 84172 1966992 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 7 9 11&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data x;&lt;BR /&gt;cost= 2**1+2**3+2**5+2**7+2**9+2**19+2**12 ; output;&lt;BR /&gt;cost= 2**2+2**4+2**6+2**8+2**10+2**16 ; output;&lt;BR /&gt;cost= 2**3+2**6+2**8+2**12+2**17+2**1+2**10 ; output;&lt;BR /&gt;cost= 2**5+2**13+2**20+2**15+2**16 ; output;&lt;BR /&gt;cost= 2**4+2**9+2**15+2**19+2**5+2**14 ; output;&lt;BR /&gt;cost= 2**11+2**2+2**4+2**15+2**1+2**14+2**10 ; output;&lt;BR /&gt;cost= 2**20+2**13+2**15+2**4+2**5+2**6+2**9 ; output;&lt;BR /&gt;cost= 2**19+2**18+2**17+2**11+2**15 ; output;&lt;BR /&gt;cost= 2**2+2**14+2**6+2**16+2**3+2**11+2**7 ; output;&lt;BR /&gt;cost= 2**1+2**12+2**3+2**13+2**4+2**14+2**18 ; output;&lt;BR /&gt;cost= 2**7+2**17+2**8+2**18+2**9+2**19+2**20+2**4; output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;all = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20} ;&lt;/P&gt;&lt;P&gt;%macro ngetk(n=11);&lt;BR /&gt;/* generate combinations of n items taken k at a time */&lt;BR /&gt;data Comb(keep=tot res d: e: where=(tot=2097150));&lt;BR /&gt;retain tot 0 res e1-e11 d1-d11;&lt;BR /&gt;array chksum[11] _temporary_ (529066,66900,136522,1155104,574000,52246,1090160,952320,84172,290842,1966992);&lt;BR /&gt;array d[11] d1-d11 (11*0);&lt;BR /&gt;array e[11] e1-e11 (11*0);&lt;BR /&gt;%do k=1 %to 11;&lt;BR /&gt;array c&amp;amp;k.f[&amp;amp;k] (&amp;amp;k.*0); /* initialize array to 0 */&lt;BR /&gt;ncomb = comb(&amp;amp;n, &amp;amp;k); /* number of combinations */&lt;BR /&gt;do j = 1 to ncomb;&lt;BR /&gt;rc = lexcombi(&amp;amp;n, &amp;amp;k, of c&amp;amp;k.f[*]);&lt;BR /&gt;do l=1 to &amp;amp;k;&lt;BR /&gt;tot=bor(tot, chksum[c&amp;amp;k.f[l]]);&lt;BR /&gt;d[l]=c&amp;amp;k.f[l];&lt;BR /&gt;e[l]=chksum[c&amp;amp;k.f[l]];&lt;BR /&gt;end;&lt;BR /&gt;res=put(tot,hex8.);&lt;BR /&gt;output;&lt;BR /&gt;tot=0;&lt;BR /&gt;end;&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend ngetk;&lt;/P&gt;&lt;P&gt;%ngetk;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 13 Mar 2016 00:06:11 GMT</pubDate>
    <dc:creator>rogerjdeangelis</dc:creator>
    <dc:date>2016-03-13T00:06:11Z</dc:date>
    <item>
      <title>An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256267#M1259</link>
      <description>&lt;P&gt;Here is an very interesting operation research problem .&lt;/P&gt;
&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/35863766/find-the-minimal-list-from-a-many-to-many-mapping" target="_blank"&gt;http://stackoverflow.com/questions/35863766/find-the-minimal-list-from-a-many-to-many-mapping&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want know how to use SAS/OR to solve this.&lt;/P&gt;
&lt;P&gt;I make it a little bit more complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;all = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20} ;&lt;/P&gt;
&lt;P&gt;A 1,3,5,7,9,19,12&lt;BR /&gt;B 2,4,6,8,10,16&lt;BR /&gt;C 3,6,8,12,17,1,10&lt;BR /&gt;D 5,13,20,15,16&lt;BR /&gt;E 4,9,15,19,5,14&lt;BR /&gt;F 11,2,4,15,1,14,10&lt;BR /&gt;G 20,13,15,4,5,6,9&lt;BR /&gt;H 19,18,17,11,15,11&lt;BR /&gt;I 2,14,6,16,3,11,7&lt;BR /&gt;J 1,12,3,13,4,14,18&lt;BR /&gt;K 7,17,8,18,9,19,20,4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my GA solution.Don't cheat .&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
input name $ v  $40.;
cards;
A 1,3,5,7,9,19,12
B 2,4,6,8,10,16
C 3,6,8,12,17,1,10
D 5,13,20,15,16
E 4,9,15,19,5,14
F 11,2,4,15,1,14,10
G 20,13,15,4,5,6,9
H 19,18,17,11,15,11
I 2,14,6,16,3,11,7
J 1,12,3,13,4,14,18
K 7,17,8,18,9,19,20,4
;
run;
data have;
 set x;
 do i=1 to countw(v,',');
  value=input(scan(v,i,','),best32.);
  output;
 end;
 drop i v;
run;
data key;
 set x(keep=name rename=(name=l));
run;

proc iml;

all = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20} ;


use have nobs nobs;
read all var {name value};
close have;
use key;
read all var {l};
close key;

group_n=t(loc(name^=t(remove(name,1)||{' '})))-
        t(loc(name^=t({' '}||remove(name,nobs)))) +1;
all_n=countunique(all);
n=countunique(name);
encoding=repeat({0,1},1,n);

start func(x) global(value,group_n,all_n); 
 temp=setdif(t(repeat(x,group_n))#value,{0});
 if countunique(temp)=all_n then sum=sum(x);
  else sum=99999;
 return (sum);
finish;

id=gasetup(2,n,1234);
call gasetobj(id,0,"func");
call gasetcro(id,0.95,2);
call gasetmut(id,0.95,3);
call gasetsel(id,100,1,1);
call gainit(id,1000,encoding); 
niter = 100000;
summary = j(niter,2);
mattrib summary [c = {"MinCount", "Avg Count"} l=""];
do i = 1 to niter;
 call garegen(id);
 call gagetval(v, id);
 summary[i,1] = v[1];
 summary[i,2] = v[:];
end;
call gagetmem(mem, v, id, 1);

Memebers=l[loc(mem)];
print "Best Members:" Memebers[l=""],
      "Min Count:   " v[l = ""] ;
call gaend(id);
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OUTPUT:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#FFFFFF"&gt;Best Members: C G I K&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FFFFFF"&gt;Min Count: 4&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2016 05:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256267#M1259</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-12T05:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256305#M1260</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
   set &amp;lt;str,num&amp;gt; NAMES_VALUES;
   read data have into NAMES_VALUES=[name value];
   set NAMES  = setof {&amp;lt;i,v&amp;gt; in NAMES_VALUES} i;
   set VALUES = setof {&amp;lt;i,v&amp;gt; in NAMES_VALUES} v;

   var Select {NAMES} binary;
   min NumSelected = sum {i in NAMES} Select[i];
   con Cover {v in VALUES}:
      sum {&amp;lt;i,(v)&amp;gt; in NAMES_VALUES} Select[i] &amp;gt;= 1;

   solve;
   print {i in NAMES: Select[i].sol &amp;gt; 0.5} Select;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;[1] Select &lt;BR /&gt;C 1 &lt;BR /&gt;D 1 &lt;BR /&gt;F 1 &lt;BR /&gt;K 1 &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is known as a "set covering problem" in the literature.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2016 17:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256305#M1260</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2016-03-12T17:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256326#M1261</link>
      <description>&lt;P&gt;Did you modify&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;'s input (to correct the anomaly in set H) ? I get C-G-H-I with SAS/STAT 13.1 .&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2016 19:52:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256326#M1261</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-03-12T19:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256334#M1262</link>
      <description>&lt;P&gt;No, I just used the "have" data set as is. &amp;nbsp;The READ DATA statement automatically removed the duplicate:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;WARNING: Duplicate key &amp;lt;H,11&amp;gt; was read at observation 51.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, you can use the CLP solver to find all optimal solutions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   solve with CLP / findallsolns;
   for {s in 1.._NSOL_} put ({i in NAMES: Select[i].sol[s] &amp;gt; 0.5});
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It turns out that there are four in this case:&lt;/P&gt;
&lt;P&gt;{'C','G','H','I'}&lt;BR /&gt;{'C','D','I','K'}&lt;BR /&gt;{'C','G','I','K'}&lt;BR /&gt;{'C','D','F','K'}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How did you solve it with SAS/STAT?&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2016 20:42:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256334#M1262</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2016-03-12T20:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256337#M1263</link>
      <description>&lt;P&gt;I used SAS/OR 9.1, sorry. Yet, it didn't pick the same answer as yours. Is there something non-deterninistic in the algorithm?&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2016 20:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256337#M1263</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-03-12T20:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256349#M1264</link>
      <description>&lt;P&gt;Hi Team&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I will be posting more detail on the SAS-L list, But it has 15 lines in a single data step(after removing checking arrays)?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There appear to be 4 solutions, kind of a lark so be suspecious. I learn more from my errors then my solutions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;see below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is one of them&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3=c&lt;BR /&gt;4=d&lt;BR /&gt;6=f&lt;BR /&gt;11=k&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Others are below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution may not scale &amp;nbsp;over 54 codes without using extended precision, no limit of number of vectors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only change from a previous post on SAS-L was to substitute 'bor' for 'sum'&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Obs TOT E1 E2 E3 E4 D1 D2 D3 D4&lt;/P&gt;&lt;P&gt;1 2097150 136522 1155104 52246 1966992 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 4 6 11&lt;BR /&gt;2 2097150 136522 1155104 84172 1966992 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 4 9 11&lt;BR /&gt;3 2097150 136522 1090160 952320 84172 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 7 8 9&lt;BR /&gt;4 2097150 136522 1090160 84172 1966992 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 7 9 11&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data x;&lt;BR /&gt;cost= 2**1+2**3+2**5+2**7+2**9+2**19+2**12 ; output;&lt;BR /&gt;cost= 2**2+2**4+2**6+2**8+2**10+2**16 ; output;&lt;BR /&gt;cost= 2**3+2**6+2**8+2**12+2**17+2**1+2**10 ; output;&lt;BR /&gt;cost= 2**5+2**13+2**20+2**15+2**16 ; output;&lt;BR /&gt;cost= 2**4+2**9+2**15+2**19+2**5+2**14 ; output;&lt;BR /&gt;cost= 2**11+2**2+2**4+2**15+2**1+2**14+2**10 ; output;&lt;BR /&gt;cost= 2**20+2**13+2**15+2**4+2**5+2**6+2**9 ; output;&lt;BR /&gt;cost= 2**19+2**18+2**17+2**11+2**15 ; output;&lt;BR /&gt;cost= 2**2+2**14+2**6+2**16+2**3+2**11+2**7 ; output;&lt;BR /&gt;cost= 2**1+2**12+2**3+2**13+2**4+2**14+2**18 ; output;&lt;BR /&gt;cost= 2**7+2**17+2**8+2**18+2**9+2**19+2**20+2**4; output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;all = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20} ;&lt;/P&gt;&lt;P&gt;%macro ngetk(n=11);&lt;BR /&gt;/* generate combinations of n items taken k at a time */&lt;BR /&gt;data Comb(keep=tot res d: e: where=(tot=2097150));&lt;BR /&gt;retain tot 0 res e1-e11 d1-d11;&lt;BR /&gt;array chksum[11] _temporary_ (529066,66900,136522,1155104,574000,52246,1090160,952320,84172,290842,1966992);&lt;BR /&gt;array d[11] d1-d11 (11*0);&lt;BR /&gt;array e[11] e1-e11 (11*0);&lt;BR /&gt;%do k=1 %to 11;&lt;BR /&gt;array c&amp;amp;k.f[&amp;amp;k] (&amp;amp;k.*0); /* initialize array to 0 */&lt;BR /&gt;ncomb = comb(&amp;amp;n, &amp;amp;k); /* number of combinations */&lt;BR /&gt;do j = 1 to ncomb;&lt;BR /&gt;rc = lexcombi(&amp;amp;n, &amp;amp;k, of c&amp;amp;k.f[*]);&lt;BR /&gt;do l=1 to &amp;amp;k;&lt;BR /&gt;tot=bor(tot, chksum[c&amp;amp;k.f[l]]);&lt;BR /&gt;d[l]=c&amp;amp;k.f[l];&lt;BR /&gt;e[l]=chksum[c&amp;amp;k.f[l]];&lt;BR /&gt;end;&lt;BR /&gt;res=put(tot,hex8.);&lt;BR /&gt;output;&lt;BR /&gt;tot=0;&lt;BR /&gt;end;&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend ngetk;&lt;/P&gt;&lt;P&gt;%ngetk;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2016 00:06:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256349#M1264</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2016-03-13T00:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256359#M1265</link>
      <description>&lt;P&gt;The algorithm is deterministic in the sense that if you run it twice with the same settings on the same machine, you will get the same solution. &amp;nbsp;But, in each new release of SAS/OR, changes in the underlying simplex algorithm, presolver, heuristics, cutting planes, branching strategies, etc.&amp;nbsp;can alter which solution gets returned.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2016 01:22:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256359#M1265</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2016-03-13T01:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256360#M1266</link>
      <description>&lt;P&gt;Impressed. I want know how many students OR can handle ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PG,&lt;/P&gt;
&lt;P&gt;Yes. H is a typo . Sorry.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2016 01:23:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256360#M1266</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-13T01:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256362#M1269</link>
      <description>&lt;P&gt;Roger,&lt;/P&gt;
&lt;P&gt;I noticed you used&amp;nbsp;&lt;SPAN&gt;lexcombi(). That means you can't handle large scale problem(i.e. have lots and lots of student) .&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2016 01:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256362#M1269</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-13T01:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256364#M1270</link>
      <description>&lt;P&gt;The number of students it can handle depends on the number of courses, how much memory you have, how long you're willing to wait, and how close to optimal you want to get. &amp;nbsp;Set covering is NP-hard, but in practice the MILP approach should definitely scale much better than brute-force.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2016 01:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256364#M1270</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2016-03-13T01:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256375#M1272</link>
      <description>&lt;P&gt;I guess this means that the solution returned might depend on the number of threads involved in the search.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2016 03:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256375#M1272</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-03-13T03:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256376#M1273</link>
      <description>&lt;P&gt;Yes, the solution can depend on the number of threads used.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2016 04:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/256376#M1273</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2016-03-13T04:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/405197#M2013</link>
      <description>&lt;P&gt;&lt;FONT color="#0000FF"&gt;Fantastic kskarp. Thanks a lot.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;You make me dive deeply into the GA subject as I am having a hard time to understand your code.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;But finally I've come behind it and I would like to share my insights for others who might be struggling to understand this code.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;As the link to the problem description is broken, I start with my auto-explanation of what is the task here.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Find a minimum set of persons (variable:names) so that their attributes (here numbers from 1 to 20, vector:value) represent the range of the population (vector:all).&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;your code in &lt;FONT color="#000000"&gt;black&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;group_n=t(loc(name^=t(remove(name,1)||{' '})))-&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt; t(loc(name^=t({' '}||remove(name,nobs)))) +1;&lt;/FONT&gt;&amp;nbsp; &lt;FONT color="#008000"&gt;/*Create a count of values for each person. The "data have" step earlier ensures that it gets sorted by person. It cost me a hell to figure out what it does. It's a nice trick but for me it's easier to understand to get this via this loop:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;u = unique(name); /* 2. Unique values (levels) of categorical variable. */&lt;BR /&gt;s = j(ncol(u),1); /* 3. Allocate vector to hold results */&lt;BR /&gt;do i = 1 to ncol(u); /* 4. For each level... */&lt;BR /&gt; idx = (name=u[i]); /* 5. indicator matrix */&lt;BR /&gt; s[i] = t(idx)*idx;/* 6. count */&lt;BR /&gt;end;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;encoding=repeat({0,1},1,n);&lt;/FONT&gt; &lt;FONT color="#339966"&gt;/*The encoding has ones and zeros and its size is equal to number of unique persons.&amp;nbsp;One selects that person meanwhile 0 leaves it out from the selection.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;For the sake of understanding I created an random selection vector and played around:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;call randseed(&lt;STRONG&gt;123&lt;/STRONG&gt;);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* set random number seed */&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;u = j(&lt;STRONG&gt;1&lt;/STRONG&gt;,nrow(group_n),&lt;STRONG&gt;1&lt;/STRONG&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; /* allocate */&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;call randgen(u, "BERNOULLI",&lt;STRONG&gt;0.1&lt;/STRONG&gt;);&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;repeat(u,group_n);&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#339966"&gt; /* Create ones and zeros as of the size of the vector of attributes. First element A=1 second element A=3...&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;This puts zeros (or ones) to all person's elements.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;t(repeat(x,group_n))#value&lt;/FONT&gt; &lt;FONT color="#339966"&gt;/*&amp;nbsp;The 1/0 vector gets multiplied elementwise with the attributes values vector prior transpose.&lt;/FONT&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;temp=setdif(t(repeat(x,group_n))#value,{0});&lt;/FONT&gt; &lt;FONT color="#339966"&gt;/*The setdif function cancels out zeros and leaves only unique entries. If 10 as value appears several times, then the setdif resulting vector has only 1 times 10.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt; if countunique(temp)=all_n then sum=sum(x); &lt;FONT color="#339966"&gt;/*If and only if all values are present in the current selection then count the sum of persons chosen.&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt; else sum=99999;&lt;/FONT&gt;&amp;nbsp; &lt;FONT color="#339966"&gt;/*As it's a minimization problem, else set sum to a very high value to penalize. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 13:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/405197#M2013</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2017-10-18T13:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: An interesting OR problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/405206#M2014</link>
      <description>&lt;P&gt;Congratulations!&lt;/P&gt;
&lt;P&gt;Glad you could understand my GA code.&lt;/P&gt;
&lt;P&gt;Enjoy Genetic Algorithm, you can concur any of optimal problem via it.&lt;/P&gt;
&lt;P&gt;I know&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;might don't think so . But I love GA .&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 13:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/An-interesting-OR-problem/m-p/405206#M2014</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-10-18T13:49:13Z</dc:date>
    </item>
  </channel>
</rss>

