<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><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 class="im"><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>
SELECT * FROM pgr_tsp( 'SELECT id, start, end, cost FROM distances,<br>
origin int [, destination int])<br>
</blockquote>
<br></div>
I can do this, so each record is one cell. What are "start" and "end"? are these vertex ids or are they indices? Does the use KNOW that they need to also have a row for (end,start) as well as (start,end)? These things are less obvious and there for have more room for errors.<br>

</blockquote><div><br></div><div style>Well start and end is just "id1" and "id2".</div><div style>You could actually also have two costs there, one for each direction (like cost and reverse_cost).</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>
I suppose we could write an aggregate function that takes your query and returns matrix[][]. But we still need to define how to deal with null values in the matrix.<br></blockquote><div><br></div><div style>I know I said "matrix", but actually I didn't think about matrix ;-)</div>

<div style>I thought about pairs of id's with cost(s). So it wouldn't be an [m][m] matrix but more like a table with m*m/2 records (if there is a cost for each direction for each combination).</div><div style>I don't know how it should be later internally for the algorithm, but I would say, that a query (table) always has a fix number of columns and a variable number of rows.</div>

<div style><br></div><div style>In the end this would look like a graph, where all nodes are connected with all nodes. </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>
select pgr_makematrix(i, j, cost) from<br>
    (select start as i, end as j, cost from distances) as foo;<br>
<br>
Then this could be passed as the SQL to the TSP. We need to keep each function simple and make them chainable or we limit the usefulness of them.<br></blockquote><div><br></div><div style>Exactly ;-)</div><div style> </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>
Any thoughts on how to deal with NULLs in the matrix?<br>
<br>
We could have some default rules like?<br>
1. if the null is on a diagonal set it to zero<br>
2. if the cell(i,j) is null and cell(j,i) is not use cell(j,i)<br>
3. otherwise report an error<br>
<br></blockquote><div><br></div><div><div>If you always have pairs A <-> B then you won't have a diagonal set.</div></div><div style>In case there is no way in one direction (maybe even in both directions), then this could be -1 for example?</div>

<div style>Then it would be same as negative cost for Dijkstra or Astar and it won't be taken into account.</div><div><br></div><div style>Daniel</div><div style><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">


Thoughts?<br>
<br>
-Steve<br>
<br>
<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 class="im">
... which would return the matrix in an optimized order.<br>
I think it would be nice to be able to set origin and destination point.<br>
But destination could be optional.<br>
<br>
Daniel<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
    I'm not interested in computing the distance matrix because I will<br>
    not be able to do it "right" for any given use case and it limits<br>
    how people can use the function.<br>
<br>
    Thoughts?<br>
<br>
    -Steve<br></div>
    ______________________________<u></u>___________________<br>
    pgrouting-dev mailing list<br>
    <a href="mailto:pgrouting-dev@lists.osgeo.org" target="_blank">pgrouting-dev@lists.osgeo.org</a> <mailto:<a href="mailto:pgrouting-dev@lists.osgeo.org" target="_blank">pgrouting-dev@lists.<u></u>osgeo.org</a>><br>


    <a href="http://lists.osgeo.org/__mailman/listinfo/pgrouting-dev" target="_blank">http://lists.osgeo.org/__<u></u>mailman/listinfo/pgrouting-dev</a><div class="im"><br>
    <<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-dev" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-dev</a><u></u>><br>
<br>
<br>
<br>
<br>
--<br>
Georepublic UG & Georepublic Japan<br></div>
eMail: <a href="mailto:daniel.kastl@georepublic.de" target="_blank">daniel.kastl@georepublic.de</a> <mailto:<a href="mailto:daniel.kastl@georepublic.de" target="_blank">daniel.kastl@<u></u>georepublic.de</a>><br>
Web: <a href="http://georepublic.de" target="_blank">http://georepublic.de</a> <<a href="http://georepublic.de/" target="_blank">http://georepublic.de/</a>><div class="im"><br>
<br>
<br>
______________________________<u></u>_________________<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/<u></u>mailman/listinfo/pgrouting-dev</a><br>
<br>
</div></blockquote><div class=""><div class="h5">
<br>
______________________________<u></u>_________________<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/<u></u>mailman/listinfo/pgrouting-dev</a><br>
</div></div></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>