<div dir="ltr">Hi Dave,<div><br></div><div>Somehow we already discussed this in May:</div><div><a href="http://pgrouting.974090.n3.nabble.com/pgrouting-dev-New-TSP-API-td4025094.html">http://pgrouting.974090.n3.nabble.com/pgrouting-dev-New-TSP-API-td4025094.html</a></div>

<div><br></div><div>I think the current function pgr_tsp function is good as it is, but some alternative with SQL query is a good idea.</div><div>Then there would be two ways how to call TSP, for example</div><div><br></div>

<div><font face="courier new, monospace">pgr_tsp(matrix float[][], start integer)</font></div><div><div><font face="courier new, monospace">pgr_tsp(sql text, start integer)</font></div><div><br></div><div class="gmail_extra">

But instead of rewriting it's better to write a wrapper function that accepts SQL and transforms it into the matrix (and ensures that the matrix is valid).</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>

Daniel</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 14, 2013 at 2:17 PM, Dave Potts <span dir="ltr"><<a href="mailto:dave.potts@pinan.co.uk" target="_blank">dave.potts@pinan.co.uk</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>On 14/06/13 02:59, Daniel Kastl wrote:<br>
      Hi Daniel, List <br>
      <br>
      I must admit I found the entire process of creating a postgress
      array in a suitable form for the pgr_tsp function to be a exercise
      in slow torture! <br>
      <br>
      Would anybody have any major objections if I attempted to rewrite
      the interface so it took a normal sql querry?<br>
      <br>
      Something like <br>
      <pre><span></span><span></span><span></span><span><span>pgr_costResult</span><span>[] </span>pgr_tsp</span><span>(</span><span>'SELECT source,target distance FROM vertex_table'</span><span>,</span><span>2</span><span></span><span></span><span>);

That way the problem with creating a square array in postgres would disappear. 

Dave
</span></pre><span class=""><font color="#888888">
      <br>
          <br>
      <span style="margin-right:0px"><a href="https://www.google.nl/search?client=ubuntu&hs=uQi&channel=fs&gl=uk&q=exercise+in+slow+torture&spell=1&sa=X&ei=BKa6UYnAF5G20QXc_4HQCg&ved=0CCcQvwUoAA" target="_blank"></a></span></font></span></div>

<div><div class="h5">
    <blockquote type="cite">
      <div dir="ltr">Hi Dave,
        <div><br>
        </div>
        <div>Thanks for reporting. Maybe I just mixed up something with
          copy & paste.</div>
        <div>I remember that I needed to add a vertex table to the
          sample data for the new TSP with distance matrix and got the
          ID's a bit wrong first.</div>
        <div>Will take a look.</div>
        <div><br>
        </div>
        <div>Daniel<br>
          <div class="gmail_extra"><br>
            <br>
            <div class="gmail_quote">On Fri, Jun 14, 2013 at 7:40 AM,
              Stephen Woodbridge <span dir="ltr"><<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.com</a>></span>
              wrote:<br>
              <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Dave -
                moving this over to the pgrouting list.
                <div><br>
                  <br>
                  Hi Dave,<br>
                  <br>
                  I'm not sure the Daniel used the example data network
                  for this example. The data looks like one of the
                  matrix I used in my test cases.<br>
                  <br>
                  src/tsp/test/*.test<br>
                  <br>
                  I just made up numbers for a symmetric matrix. It was
                  not taken from an actual network.<br>
                  <br>
                  So the sly part is that its NOT from a graph ;)<br>
                  <br>
                  Daniel - please correct me it you did something else.<br>
                  <br>
                  -Steve<br>
                  <br>
                  On 6/13/2013 6:11 PM, Dave Potts wrote:<br>
                </div>
                <div>
                  <div>
                    <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                      <br>
                      In the travel sales person problem an example is
                      provided,  I having<br>
                      problems understanding it<br>
                      <br>
                      The example route network is posted as<br>
                      <a href="http://docs.pgrouting.org/dev/doc/src/developer/sampledata.html#sampledata" target="_blank">http://docs.pgrouting.org/dev/doc/src/developer/sampledata.html#sampledata</a><br>
                      <br>
                      I have assume the distance between red node 1 and
                      red node 3 is 2, ie<br>
                      the unit distance 1 +1  which I  make to be 2<br>
                      <br>
                      given that<br>
                      <br>
                      I think the route matrix should be<br>
                      <br>
                           1 2 3 4<br>
                      ======<br>
                      1 | 0 1 2 3<br>
                      2 | 1 0 1 2<br>
                      3 | 2 1 0 1<br>
                      4 | 3 2 1 0<br>
                      <br>
                      distance 1 to 4 is 1+1 +1 ==3<br>
                      distance 2 to 4 is 1+1       ==2<br>
                      distance 3 to 4 is 1<br>
                      etc<br>
                      <br>
                      But the give value is (please see<br>
                      <a href="http://docs.pgrouting.org/dev/src/tsp/doc/index.html" target="_blank">http://docs.pgrouting.org/dev/src/tsp/doc/index.html</a>)<br>
                           1 2 3 4<br>
                      <br>
                      1  {0,1,2,3},<br>
                      2  {1,0,3,2},<br>
                      3  {2,3,0,4},<br>
                      4  {3,2,4,0}<br>
                      <br>
                      I just don't understand how the distance between 3
                      and 4 can be the<br>
                      value 4, ditto he values between 2 and 3<br>
                      <br>
                      Have I missed something sly ?<br>
                      <br>
                      Dave.<br>
                      <br>
                      <br>
                      <br>
                      _______________________________________________<br>
                      postgis-devel mailing list<br>
                      <a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
                      <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br>
                    </blockquote>
                    <br>
                    _______________________________________________<br>
                    postgis-devel mailing list<br>
                    <a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
                    <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br>
                  </div>
                </div>
                _______________________________________________<br>
                pgrouting-dev mailing list<br>
                <a href="mailto:pgrouting-dev@lists.osgeo.org" target="_blank">pgrouting-dev@lists.osgeo.org</a><br>
                <a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/pgrouting-dev</a><br>
              </blockquote>
            </div>
            <br>
            <br clear="all">
            <div><br>
            </div>
            -- <br>
            <span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse">Georepublic
              UG & Georepublic Japan<br>
              eMail: <a href="mailto:daniel.kastl@georepublic.de" style="color:rgb(66,99,171)" target="_blank">daniel.kastl@georepublic.de</a><br>
              Web: <a href="http://georepublic.de/" style="color:rgb(66,99,171)" target="_blank">http://georepublic.de</a></span>
          </div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
pgrouting-dev mailing list
<a href="mailto:pgrouting-dev@lists.osgeo.org" target="_blank">pgrouting-dev@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/pgrouting-dev</a>
</pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
pgrouting-dev mailing list<br>
<a href="mailto:pgrouting-dev@lists.osgeo.org">pgrouting-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/pgrouting-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse">Georepublic UG & Georepublic Japan<br>eMail: <a href="mailto:daniel.kastl@georepublic.de" style="color:rgb(66,99,171)" target="_blank">daniel.kastl@georepublic.de</a><br>

Web: <a href="http://georepublic.de/" style="color:rgb(66,99,171)" target="_blank">http://georepublic.de</a></span>
</div></div></div>