<?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: Simulating all the possible routes starting on one position and returning to that position in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Simulating-all-the-possible-routes-starting-on-one-position-and/m-p/225422#M8172</link>
    <description>&lt;P&gt;This is an enumeration of the possible paths in the Traveling Salesman problem.&amp;nbsp; As the number of points grows, brute-force enumeration becomes prohibitive, but you can use various optimization schemes to obtain optimal or nearly optimal paths.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do an internet search for +SAS "Traveling salesman" to see many solutions in SAS for the TSP.&lt;/P&gt;</description>
    <pubDate>Mon, 14 Sep 2015 18:39:06 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2015-09-14T18:39:06Z</dc:date>
    <item>
      <title>Simulating all the possible routes starting on one position and returning to that position</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Simulating-all-the-possible-routes-starting-on-one-position-and/m-p/204005#M7557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to simulate combinations based on 5 coordinates (datset below):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data coord;&lt;/P&gt;&lt;P&gt;input x 1. y 1.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;11&lt;/P&gt;&lt;P&gt;32&lt;/P&gt;&lt;P&gt;55&lt;/P&gt;&lt;P&gt;91&lt;/P&gt;&lt;P&gt;14&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Every combination must begin with (1,1) and end with (1,1) i.e.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(1,1) -&amp;gt; (3,2)-&amp;gt; (5,5)-&amp;gt; (9,1)-&amp;gt; (1,4)-&amp;gt; (1,1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and all combinations must be unique and finally that there can't be the above route and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(1,1) -&amp;gt;(1,4)-&amp;gt; (9,1)-&amp;gt; (5,5)-&amp;gt; (3,2)-&amp;gt; (1,1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as both routes are the same but in opposite directions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to do this in sas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2015 20:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Simulating-all-the-possible-routes-starting-on-one-position-and/m-p/204005#M7557</guid>
      <dc:creator>Hugo123</dc:creator>
      <dc:date>2015-08-20T20:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating all the possible routes starting on one position and returning to that position</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Simulating-all-the-possible-routes-starting-on-one-position-and/m-p/224768#M8165</link>
      <description>&lt;P&gt;The code below should do what you require.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just a few notes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) I've stuck the x and the y coordinate together as it's easier to deal with them in this way.&lt;/P&gt;
&lt;P&gt;2) I've hard coded the 1,1 coordinate as it does not change. This can however be incorporated into the data if you require.&lt;/P&gt;
&lt;P&gt;3) The data set outds2 also contains a list of the routes you require and outds3 contains the reverse of these routes.&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;P&gt;/*Set up the initial table*/&lt;BR /&gt;data coord;&lt;BR /&gt;input xy 8.;&lt;BR /&gt;datalines;&lt;BR /&gt;32&lt;BR /&gt;55&lt;BR /&gt;91&lt;BR /&gt;14&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*Find all unique routes*/&lt;BR /&gt;proc sql noprint ;&lt;BR /&gt;create table outds as&lt;BR /&gt;select 11 as c1,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; a.xy as c2,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; b.xy as c3,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; c.xy as c4,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; d.xy as c5,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 11 as c6&lt;BR /&gt;from coord as a,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; coord as b,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; coord as c,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; coord as d&lt;BR /&gt;where a.xy ne b.xy and a.xy ne c.xy and a.xy ne d.xy and b.xy ne c.xy and b.xy ne d.xy and c.xy ne d.xy ;&lt;BR /&gt;&lt;BR /&gt;select count(*) into :nobserv from outds ;&lt;BR /&gt;&lt;BR /&gt;quit ;&lt;BR /&gt;&lt;BR /&gt;/*Find the routes which are the reverse of already known routes*/&lt;BR /&gt;data outds2 (drop=c2_2 c3_2 c4_2 c5_2);&lt;BR /&gt;do i = 1 to &amp;amp;nobserv-1 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;do j = i+1 to &amp;amp;nobserv ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;set outds point=i ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;set outds (rename=(c2=c2_2 c3=c3_2 c4=c4_2 c5=c5_2)) point=j ;&lt;BR /&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;if c2=c5_2 and c3=c4_2 and c4=c3_2 and c5=c2_2 then output ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;end ;&lt;BR /&gt;end ;&lt;BR /&gt;stop ;&lt;BR /&gt;run ;&lt;BR /&gt;&lt;BR /&gt;/*Remove the reverse routes from the main data set*/&lt;BR /&gt;proc sql ;&lt;BR /&gt;create table outds3 as&lt;BR /&gt;select *&lt;BR /&gt;from&amp;nbsp;&amp;nbsp; outds&lt;BR /&gt;except all&lt;BR /&gt;select *&lt;BR /&gt;from&amp;nbsp;&amp;nbsp; outds2 ;&lt;BR /&gt;quit ;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2015 15:38:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Simulating-all-the-possible-routes-starting-on-one-position-and/m-p/224768#M8165</guid>
      <dc:creator>FatCaptain</dc:creator>
      <dc:date>2015-09-09T15:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating all the possible routes starting on one position and returning to that position</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Simulating-all-the-possible-routes-starting-on-one-position-and/m-p/225152#M8169</link>
      <description>&lt;P&gt;Hi, here's another approach that uses LEXPERM to generate the permutations of nodes&amp;nbsp;(same answer as the other posted solution with some paths shown in the reverse order) ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;* generate permutations of four nodes;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;data perm;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;array x(4) $2 ('32' '14' '55' '91');&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;do j=1 to fact(4);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;rc=lexperm(j, of x(*));&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;output;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;keep x:;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;* identify duplicates (left-2-right = right-2-left, output only one of the pair);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;data check;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;retain x0 x5 '11';&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;set perm nobs=howmany;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;s1 = catt(of x1-x4);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;do j=_n_ to howmany;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;set perm point=j;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;s2 = catt(of x4-x1);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;if s1 eq s2 then leave;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;if s1 eq s2 then output;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;keep x:;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data set CHECK ...&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;Obs x0 x1 x2 x3 x4 x5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;1 &amp;nbsp;11 91 55 32 14 11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;2 &amp;nbsp;11 55 91 32 14 11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;3 &amp;nbsp;11 91 32 55 14 11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;4&amp;nbsp;&amp;nbsp;11 32 91 55 14 11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;5 &amp;nbsp;11 55 32 91 14 11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;6 &amp;nbsp;11 32 55 91 14 11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;7 &amp;nbsp;11 91 55 14 32 11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;8 &amp;nbsp;11 55 91 14 32 11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;9 &amp;nbsp;11 91 14 55 32 11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;10 &amp;nbsp;11 55 14 91 32 11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;11 &amp;nbsp;11 91 32 14 55 11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;12 &amp;nbsp;11 91 14 32 55 11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 13:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Simulating-all-the-possible-routes-starting-on-one-position-and/m-p/225152#M8169</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2015-09-11T13:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating all the possible routes starting on one position and returning to that position</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Simulating-all-the-possible-routes-starting-on-one-position-and/m-p/225422#M8172</link>
      <description>&lt;P&gt;This is an enumeration of the possible paths in the Traveling Salesman problem.&amp;nbsp; As the number of points grows, brute-force enumeration becomes prohibitive, but you can use various optimization schemes to obtain optimal or nearly optimal paths.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do an internet search for +SAS "Traveling salesman" to see many solutions in SAS for the TSP.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2015 18:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Simulating-all-the-possible-routes-starting-on-one-position-and/m-p/225422#M8172</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-09-14T18:39:06Z</dc:date>
    </item>
  </channel>
</rss>

