Open woodbri opened 8 years ago
I like the term "turn-penalties". Describing "restrictions" as a special case for "penalties" reminds me a bit how one-way restrictions are handled. While in the beginning we said, that you just need to make the cost "very high" to apply one-way restrictions, it still means, that the route might violate the rule, if there is no other way.
I prefer to use -1
however rather than using high costs, so I would also like to handle turn-restrictions/penalties in a similar way.
Family of functions:
pgr_TRSP(one to one, one to many, many to one, many to many) pgr_TRSPCost(one to one, one to many, many to one, many to many) pgr_TRSPCostMatrix pgr_TRSPDD(single start point, multiple start point) pgr_TRSPKSP() pgr_TRSPVIA()
pgr_TRSPWithPoints(one to one, one to many, many to one, many to many) pgr_TRSPWithPointsCost(one to one, one to many, many to one, many to many) pgr_TRSPWithPointsCostMatrix() pgr_TRSPWithPointsDD(single start point, multiple start point) pgr_TRSPWithPointsKSP() pgr_TRSPWithPointsVIA()
pgr_turnRestricted(one to one, one to many, many to one, many to many) pgr_turnRestrictedCost(one to one, one to many, many to one, many to many) pgr_turnRestrictedCostMatrix pgr_turnRestrictedDD(single start point, multiple start point) pgr_turnRestrictedKSP() pgr_turnRestrictedVIA()
pgr_turnRestrictedWithPoints(one to one, one to many, many to one, many to many) pgr_turnRestrictedWithPointsCost(one to one, one to many, many to one, many to many) pgr_turnRestrictedWithPointsCostMatrix() pgr_turnRestrictedWithPointsDD(single start point, multiple start point) pgr_turnRestrictedWithPointsKSP() pgr_turnRestrictedWithPointsVIA()
On 7/8/2016 9:38 PM, Daniel Kastl wrote:
I like the term "turn-penalties". Describing "restrictions" as a special case for "penalties" reminds me a bit how one-way restrictions are handled. While in the beginning we said, that you just need to make the cost "very high" to apply one-way restrictions, it still means, that the route might violate the rule, if there is no other way.
I prefer to use |-1| however rather than using high costs, so I would also like to handle turn-restrictions/penalties in a similar way.
The issue here has more to do with how the code is implemented. We use -1 to remove the edge but with turn restrictions it is potentially much more complicated because the same edges need to be there for some paths through the intersection and not for restricted paths.
So until we understand how we want to build the graph and process it and what constraints that puts on the code it is hard to determine what is possible. Anyway, I hear what you are asking for and tend to agree that that should be the plan if we can make it work that way.
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
-1 on the internal sql query cost & reverse_cost the corresponding (source, target), (target, source) edge is not inserted. (for one way) Internally: if the algorithm needs to remove it, it can be done. if the algorithm needs to recover it, it can be done. if the algorithm needs to change the value, it can be done.
Don't take my comment as how you should implement it ;-)
I'm speaking from the user perspective and I find it better to assign -1
to apply a restriction than a very high cost. That's all. How this is applied internally is a different problem.
"no u-turn" "no right turn" "no left turn"
currently there is this way of representing "saving restrictions" in sample data
CREATE TABLE restrictions (
rid BIGINT NOT NULL,
to_cost FLOAT,
target_id BIGINT,
from_edge BIGINT,
via_path TEXT
);
COPY restrictions (rid, to_cost, target_id, from_edge, via_path) FROM stdin WITH NULL '__NULL__' DELIMITER ',';
1,100,7,4,__NULL__
1,100,11,8,__NULL__
1,100,10,7,__NULL__
2,4,8,3,5
3,100,9,16,__NULL__
\.
and when passed as a parameter to pgr_TRSP
'SELECT to_cost, target_id,
from_edge || coalesce('','' || via_path, '''') AS via_path
FROM restrictions'
What would be the wish list for storing the restrictions so its easy to understand/use? (I am asking for a wish list, so we can have options for analysis of pro & con)
I would say:
0
means no restriction and no penalty>0
would be a turn penalty-1
would be a turn restriction (prohibited)Thoughts?
(rid, to_cost, target_id, from_edge, via_path) (1, 0,7,4,NULL) (1,100,7,4,NULL) (1,-1,7,4,NULL)
(1, 0,7,4, {1,2,3}) <--- (1,100,7,4, {1,2,3}) (1,-1,7,4, {1,2,3})
this 7,4, {1,2,3} without looking at the documentation can you explain what it means?
The definition of a restriction is:
For simple restrictions, via_path is NULL as the whole restriction can be defined using target_id and from_edge. For more complex restrictions, you need to define a path of multiple edges that represent the restriction.
We have the following pages in the wiki related to turn restrictions:
Also the sample data was originally designed for test various simple and complex restrictions.
Basically, our restriction model is identical to the OSM model: http://wiki.openstreetmap.org/wiki/Relation:restriction
Here are some references to various papers discussing turn restriction implementation:
Here is the link of the current user's documentation: http://docs.pgrouting.org/2.2/en/src/trsp/doc/pgr_trsp.html
@sankepallyrohithreddy (rid, to_cost, target_id, from_edge, via_path) (1, 0,7,4, {1,2,3}) <--- This: 7,4, {1,2,3} With the detailed information given above, what do you think it means?
I will leave the explaination to @sankepallyrohithreddy but will note that for this restriction:
(1, 0,7,4, {1,2,3}) <---
that regardless of the meaning, that the "effect" will be nothing because even if the restriction is triggered, the 0 cost would be the same as if it were not triggered.
Upon reading through, what I understand is
please correct me if I am wrong.
@sankepallyrohithreddy so what is the path that is being restricted? ie: what is the sequence of edge ids in the path that is the restriction?
I'll rephrase the question. for the current implementation what is the meaning of all of this: (rid, to_cost, target_id, from_edge, via_path) (1, 100,7,4, {1,2,3})
@sankepallyrohithreddy can you draw, how the restricted path looks?
I think I misunderstood the definiton of via_edges. I think it is a sequence of edges which connects the from_edge and the target_edge. I would like to explain the following restriction (rid, to_cost, target_id, from_edge, via_path) (2, 4, 8, 3, {5} ) which is one of the restrictions mentioned in the documentation.
from_edge: v4-----e3------>v3 target_id: v6------e8------>v5, v5------e8------>v6 via_path: v3------e5----->v6
So now when we want to reach from v4 to v5 through the via_path the to_cost applied would be 4.
please correct me if I am wrong.
(rid, to_cost, target_id, from_edge, via_path) (2, 4, 8, 3, {5} ) id of the restriction is: 2 cost is: 4 target_id is: 8 <<-- documentation is not clear if its a node or an edge This table has to be used with: 'SELECT to_cost, target_id, from_edge || coalesce('',''||via_path,'''') AS via_path FROM restrictions'); so 3, 5 and 5 are edges ids
so the restriction is you want to go to 8 via 3 and 5. I would understand that e3->e5->8 where 8 is not clear if its a vertex or and edge
(rid, to_cost, target_id, from_edge, via_path) (1, 100,7,4, {1,2,3}) I understand that e4->e1->e2->e3->7
Here is an interesting ticket from OSRM regarding restrictions and CH. https://github.com/Project-OSRM/osrm-backend/issues/2681
The current pgr_trsp function does not use Boost in its underlying implementation, in part because Boost Graph does not support it natively. There has been some discussion about re-implementing the pgr_trsp like functionality using Boost Graph. I'm opening this issue to collect ideas and references regarding this.
There are also two terms that I have come across in this research "turn-penalties" and "turn-restrictions". An infinite penalty can be considered a restriction. From an implementation point of view having penalties is probably preferable because applying a penalty allows you more flexibility like applying a cost to making a turn or applying a greater cost to make a turn across traffic, or at traffic lights ot stop signs, etc.
In my mind "turn-restrictions" could be viewed as dynamic modification to the graph, based on the first link above this might be problematic, while changing the costs to a particular node based on the path to get there might be less problematic.
Please add additional useful comments and research.