Network Model - Shortest Path

Hi all,
I have created spatial network containing non lrs sdo_geometry objects in Oracle 10g (Release 2). In this network model there are 33208 nodes and 42406 links.
Now I need to write a java program to find shortest route between two selected nodes. Here is snippet of my source code.
Connection connection = DriverManager.getConnection(dbUrl, databaseUser,   databasePassword);
boolean readForUpdate = false;
Network net= NetworkManager.readNetwork(connection, "SDO_ROAD_NETWORK", readForUpdate);
Path path = NetworkManager.shortestPath(net, startNodeId ,endNodeId);
System.out.println ("total distance " path.getCost() );+
Link[] linkArray = path.getLinkArray();
But this will throws an exception - Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
It was working fine for 1000 nodes and 1000 links. I tried by changing java options like -Xms and Xmx parameters but same result.
Then I tried to find shortest route using pl/sql using following.
DECLARE
testNet VARCHAR2(30) := 'SDO_ROAD_NETWORK';
startNode NUMBER := 120150;
endNode NUMBER :=1740034;
path NUMBER;
linkArray SDO_NUMBER_ARRAY;
BEGIN
sdo_net_mem.network_manager.read_network('SDO_ROAD_NETWORK', 'FALSE');
dbms_output.put_line('Loading finished');
path := SDO_NET_MEM.NETWORK_MANAGER.SHORTEST_PATH_DIJKSTRA('SDO_ROAD_NETWORK', startNode, endNode);
IF path IS NULL THEN
dbms_output.put_line('route not found');
return;
END IF;
linkArray := SDO_NET_MEM.PATH.GET_LINK_IDS(testNet, path);
FOR i IN linkArray.first..linkArray.last
LOOP
dbms_output.put_line('Link -- ' || linkArray(i) || ' ' ||
SDO_NET_MEM.LINK.GET_NAME (testNet, linkArray(i)) || ' ' ||
SDO_NET_MEM.LINK.GET_COST (testNet, linkArray(i)));
END LOOP;
END;
+/+
But this takes nearly 4 minutes to just read the nework (sdo_net_mem.network_manager.read_network).
Finally I dowloaded standalone java client application NDM Network Editor from OTN. This application loads entire network within 25 seconds and finds shortest route within 5 seconds.
Please guide me how can I write improved code reading network. My requirement is to get shortest path between two nodes
Thanks,
Sujnan

Hi Sujnan
In the past there have been some performance issue for the Oracle JVM. Not sure if this addressed in the latest releases (10.r2 or 11).
Performance Status OJVM used for SDO Network data Model 10R2.0.2
Maybe the oracle guys can give an update.
Luc

Similar Messages

  • Q: Using Path tables with Network Model (api)

    Hello
    Just a quick question to get on track.
    In order to use the Path tables from a network model and to fill the geometry field, is this the right way to start working?
    1. use the sdonm api to load network and analyse it (like the demo java file LoadAndAnlayze.java)
    2. get the link array from the path object
    3. itterate through the link array and use the
    NetworkUtility.concatenateGeometry in order to end up with one sdo_geometry line object
    4. Insert the appropriate path attributes into the Path table of the network via an SQL INSERT.
    Is this the right way or is there an othaer/better way?
    tx
    Luc

    A path by default does not have its geometry computed when it's created.
    You can use method to compute its geometry (from link geometry).
    If you have computed a path using NDM API(for example, shortestPath), you can
    1. compute path geometry by using path.computeGeometry(double tolerance)
    2. add the path to the network (network.addPath(path)
    3. use NetworkManager.writeNetwork(conn, network) to populate path and path-link tables (assuming they have been created and registered in the network metadata already!)

  • Shortest path calculation in huge spatial network

    Looks like I have to load the whole network in order to perform shortest path calculation.
    such as NetworkManager.shortestPathAStar, NetworkManager.shortestPath
    Suppose the network is too big to be loaded at one time, what is the possible solution in Oracle spatial to solve this issue???

    I can’t think of a way of analysing the network in chunks as it would increase the complexity of the calculation and may miss routes. If you know the start and end point have you considered drawing a connecting line between the two, buffering it and just loading the network inside the area.
    You would need to check the route by increasing the buffer size and finding the shortest route again.
    Another option could be to divide the network into primary and secondary routes. Find the route from the start to the nearest primary node and from the end point to the nearest primary point then connect the primary nodes. Based in a quick Google this is sounds a bit like the algorithms Garmin and Tom Tom use.
    Message was edited by:
    grahamallan

  • Shortest path between two arbitrary point in the network

    Hi All,
    In oracle NDM, it's possible to find shortest path between two nodes (e.g. using SDO_NET_MEM.NETWORK_MANAGER.SHORTEST_PATH), but I need to find shortest path between 2 points which are on the network edges. I suppose I should use (Interface SubPath) in network java apis. However I want to do it via PLSQL api. Should I code it myself or there exists a function?
    Any help is appreciated.
    Edited by: Fa on Dec 15, 2011 2:51 AM

    pritamg wrote:
    I have to build an application in which the user will draw the graph by creating nodes and edges.and then the start node will be marked.Then the shortest paths to other nodes will be displayed.Give me any possible clue how to start.I am in deep deep trouble.I have to use Dijkstra's Algorithm.
    please help some one...pleaseDo you know Dijkstra's Algorithm for shortest path? I believe that one was also called the traveling salesman problem. You can easily Google to find out what it is.
    Did you listen to your instructor when he/she did his/her lectures on recursion and halting contitions? If not, then please go talk to him/her and read your book, the forum is not a place to try to learn a basic concept that you should have paid attention in class for the first time.
    If you have code and you have specific questions post them and we will be glad to help, but we are not here to develop your homework solutions for you, no matter how that may affect your future.

  • LRS and network analysis like shortest path

    Does Spatial support/has function for network analysis, like fe. Shortest path?
    Maybe via the LRS?
    tx
    Luc VAN LINDEN

    Hi,
    This feature is not supported using any Oracle Spatial primitives. It is possible to manipulate geometries and get this information, but you would need to write your own functions.

  • Dispay shortest path in MapViewer

    Hello,
    I had sucsessfully installed MapViewer 9.0.4 and Oracle Spatial 10g.
    here I would like to know how to make a shortest path query between two point in Oracle MapViewer and display it.
    Any help will be appreciated.
    regards
    aziz

    Hi Aziz,
    the next release of MapViewer will support the Network Model including requests ro render shortest paths.

  • Computing of the shortest path using a custom cost function in Oracle NDM

    Hi to all,
    I have Oracle 10g R2, I'm working on Oracle Network Data Model. I created a Network (named ITALIA_NET) based on links table (named ITALIA_LINK$) and nodes table (named ITALIA_NODE$).
    Until now I computed the shortest path between two nodes using the 10gR2 NDM Java API, in particular I used the shortestPath() method.
    I know that this method computes the shortest path between two nodes on the base of the values of a field that can be the lenght OR the travel time of the links.
    What I wish to do is compute the shortest path between two nodes with a function that considers ( at the same time ) more parameters and on the base of them returns a path. For example, I want compute the shortest path taking into account these parameters for the links:
    travel times of links
    gradient links
    tortuosity links
    Infact, I have for each link the costs of: travel time (for example 3 minuts for cross the link), gradient (for example, the link has 2% of gradient) and tortuosity (for example, the link has two curves of 60° of angle).
    Do you have any idea how I can implement this?
    Are there other ways for reach this objective?
    I hope I explained well my objective.
    Thank you very much to all in advance.

    _1) If I convert the values of the other cost columns into the values of the primary cost column (time is ok), what is the formulation for do this conversion?_
    The modeling part is the most difficult part. I am not sure if there is a universal conversion formula between two different costs.
    One recommendation is to use time as your primary cost.
    For any other secondary costs, collect some data (or from some published statistics) on how these costs affect the travel time (based on the actual speeds wrt to gradients and tortuosity).
    I am not an expert on this. Maybe asking questions like,
    Q. how will a road of gradient = 10 deg affect the speed, uphill and downhill compared to the speed limit?
    Once you have a good estimates on the speeds, you can compute the travel times as the distance/length of the link is known. The same applies to tortuosity,
    Q. how will roads with 30/60/90 deg angles affect the travel speeds compared to the speed limit?
    Assuming you are using something like the speed limit as you normal travel speed to compute your travel time.
    _2) After conversion, how can I combine these columns?_
    Say if you have done the conversion part in Step 1, you have 3 costs,
    cost1, cost2, and cost3
    You can create a view on the link table with the combined link cost as (cost1+cost2+cost4) or
    you can create a new column that sums up the costs you want and use it as the link cost.
    hope it helps!
    jack

  • Question re: MapViewer and Network Model functions

    Hi all,
    Quick question re: MapViewer and it's support for the Network Model and the shortest-path functions. If I create a base map with a network theme based on my (large) network, and then use a jdbc_network_query on the same network to do some shortest path analysis will MapViewer use the (hopefully) cached copy of the Network to calculate the shortest path? i.e can I expect good response times once the cache is warmed up?
    Thanks,
    Steve

    Hi Steve,
    MapViewer uses the Network Java library to run the shortest path algorithm. This library is independent of the MapViewer cache, and also not thread safe. So for now the network is always loaded. The load time may be reduced if the request has a MBR, but it is not the ideal solution. There is a working going on, and we hope to avoid this load in future versions.
    Thanks.

  • Network Model - AStar dies, Dijkstra is OK

    Hi all,
    I'm using the Network Model to model a road network. I have a problem when a "complicated path" can't be found. By this I mean two nodes that aren't connected (one of them is an island with no connectivity in the nertwork) but the intervening network "space" is complicated and extensive. When the intervening "space" is smaller then there isn't a problem.
    When I use shortestPathAStar() then my Java app just eats up memory and CPU and eventually runs out of Java heap space. When I use shortestPathDijkstra() then the code correctly works out there is not a path between the two.
    The problem for me is that i'd really like to use AStar. I'm calculating many paths through the network and A* is just so much faster....
    Are there any bugs or known issues in this area, or has anyone else seen anything? I can't find anything on Metalink.
    Thanks
    Steve

    AStart algorithm uses more memory compared to Dijkstra Algorithm in NDM API.
    If the network is not fully connected, you could use isReachable(network,startNodeID,endNodeID) method first to find out if there exists at least one path before computing the shortest path.
    The overhead for this method is small compared to the shortest path algorithms.
    You could also try to increase the heap size (using Java -Xmx heapSize) when running your application.
    By the way, what is the size of the network and what is the java heap size you use?
    What version are you using?

  • Cost Factor in Shortest Path

    Hi,
    I need a little help.
    I am performing routing on geodatic data (i.e., locations with Lat/Long).
    I think the AStar shortest path algorithms are finding the shortest path on the basis of distance betwwen two nodes.
    I am not quite sure whether they are taking care of the cost column in the link table.
    for eg., say A-B-C and A-D-C are two alternative routes from A to C .
    such that A-B-C is the shortest path on the basis of geodatic distance between the locations A an C.
    But may be the cost-wise A-D-C would have been a shorter path.
    So, which path will the algo return?
    Also I do not want to implement AStarCostFunction class and provide a distance function.
    Please help me out.
    Regards.

    Hi,
    Any/all cost-based analysis in the network data model is done using the cost column. If the cost column contains geodetic distances then that is what will be used.
    Hope this helps,
    Dan

  • Questions on the LRS network model.

    On page 6-26 of the "Oracle Spatial Topology and Network Data Models" documentation, the example shows that measures are recorded in the 'roads' table (i.e. the one with the geometry of the feature).
    1. Why in this example is 'null' used for Node 5 ('...automatically calculated and filled...') but not the others?
    2. Why in this example is measure even necessary? There is no link to the underlying route from this table (i.e. measures should only be recorded in the context of a given route).
    3. It seems like this measure is merely the offset from the starting vertex (not true LRS); do we have the wrong interpretation?
    On Page 6-30, the example shows that measures are recorded for each Node and each Link. We had envisioned nodes and links being separate from the route they play a role upon. For example, if the same node was part of two distinct routes, does this mean storing two rows in "road_nodes"? But they're the exact same location and the same node in our network. The same question applies to the 'road_links' table. If the answer is 'duplicate the rows' in nodes and links (once per route), why doesn't 10g Spatial record 'measure' in the "road_paths" table? Note that, on page 6-31, it says that it is '...for possible future use...'...
    This example also implies the rows in the roads table are replicated as the (m)easure of the geometry column would change based on the route involved? If this is not the case why store the measure in the geometry column at all?

    Hi,
    My name is Gary Wong, and the original poster was asking these questions on my behalf. I'd like to continue the thread below in-line....
    A: This is a basic LRS concept. You can have some NULL
    measure values, and LRS can compute the actual measure
    corresponding to a NULL value. This has nothing to do
    with Network modeling, so you can assume a valid
    measure value here for this example.So this was just an example showing both 'manually calculated and entered' and 'let Spatial figure it out'? As this is merely the offset from the starting point, wouldn't a user always use NULL to let Spatial figure it out? It seems like this model will always use whole links in a contiguous fashion, so when would the measure not be the cumulative total?
    2. Why in this example is measure even necessary? There
    is no link to the underlying route from this table
    (i.e. measures should only be recorded in the context
    of a given route).So in this model (and example), the entry in roads is the route itself? Other LRS models allow the re-use of a common route, so multiple entries in the roads table would reference the same route (in another table). A real-life example is a single straight road that has different names, or has different road surface, or road classifications.
    Folowing this example, if I wanted to spatially reference some other business attribution on an existing route, say R1, would I have to create another entry in roads and duplicate the data? Even if it has the same start/end locations and path?
    A: Measure is always an offset from the start vertex
    and this is true for any LRS system. I am not sure what
    you mean by "not true LRS".My mistake in using these words; there is no true LRS, just different models/implementations of it =8^). Other LRS systems can have a measure beginning, say 2.5 metres after the starting node (node, not vertex; I define a vertex as as one of co-ordinates defining the link, and node as a topologically significant vertex such as the start and end vertices).
    Hmmm, does this answer my first question above? If you wished to start a road (as per the example) slightly off of a node, would you enter a non-zero measure as the initial co-ordinate?
    Assuming I'm on the right track (i.e. cannot re-use a route), does anyone know if Oracle plans to implement this kind of LRS in 10g Spatial?
    I see a cryptic ".. for possible future use..." reference on page 6-31 regarding the create_path_table() and create_path_link_table() methods.
    Is this future use to allow multiple uses and references of a route?
    Thanks and sorry for the loooong email..
    gary

  • Query for finding shortest path

    I know nothing about Oracle Spatial. Just want to know if this query is possible using Spatial.
    Given the following data for undirected weighted graph,
    v1: vertex 1
    v2: vertex 2
    w: weight between vertices v1 and v2(or, distance of edge)
    table name : wgraph
    v1  v2  w
    k   a    2
    m  a    3
    k   c    1
    k   d    4
    c   b    2
    h   d    3
    c   h    3
    h   e    4
    e   b    4
    m  b    6Can I make a query which gives the shortest path from vertex 'a' to vertext 'e' using Spatial?
    If this possible, that query gives the following result. (row-spanning form)
    I think this is almost impossible using just a hierachical query.
    Any method for this in Oracle Spatial?
    spath
    a
    k
    c
    b
    e
    This is not a sort of homework or exam, just my interest.
    Thx in advance.
    Query Your Dream & Future at
    http://www.soqool.com

    yes why not! in your case just create a logical network- called LRS Network and insert your vertices in node- table and additional information plus cost in the link table.
    you can find ways using by dijkstra and A*

  • Designing a network model

    Hi,
    Let me start saying that im pretty newbie still considering networking. I have studied CCNA and CCNP in my school and am now working on my final work which is to design a basic network model that can be applied into small to medium sized companies.
    The network core devices are a Cisco Catalyst 3550 Switch and a Cisco PIX 515E (7.0) The C3550 will handle the traffic inside the network and connection outwards will go trough PIX Firewall.
    In the work im going to divide the ports in the switch to 3 different VLANs that will be for the assumed different departments of the company. (production,offices,administration/servers etc more added if needed)
    Im making Access-lists for every VLAN and I am wondering should I only use these ACLs to set what kind of traffic goes between the VLANs in the companys inside network and let PIX handle the traffic that enters and leaves the network? Should i have an ACL in the switch already preventing somekind of traffic going forward to the PIX?
    I have found it abit hard building access-lists for both inbound and outbound VLAN traffic as i feel i have to open alot of ports to get the most basic traffic flowing without problem in the inside network.(Programs using ports > 1024 in the return traffic getting blocked in the return packets, unless i open alot of those larger port numbers)
    Should i just limit what traffic can exit a VLAN and leave the rest of traffic flow inspection for PIX to handle? Will this provide enough security to the network provided the end stations have proper software protection and the switch is secured to prevent adding of unwanted networking devices. Im kind of unsure of the PIX device itself as my studies never crossed path with it so never got to use it before this point.
    Any views on how to handle the security in different points of the network would be greatly appriciated.
    - Jouni Forss

    Thanks for the fast reply,
    As we havent gone indepth with securing a network in our studies I feel the need to find as much info on the best practices to secure a network. All our studies have given a pretty narrow look into the ways to do that.
    Im pretty sure i will go with applying outbound traffic ACLs to each VLAN and after the switch has been secured will move onto configuring the PIX.
    Basicly the main idea is to have all the different departments connect to the server
    VLAN for resources. Only the office and admin/server VLAN will have connection to outside world. This is ofcourse just a basic idea to start building the configuration on and the ACLs would probably change depending on the real life application situation.
    Also one point was to build a possibility for VPN connections to the server VLAN from outside world which is another thing i need to get into after the switch. These connection would be coming from perhaps home office or such places with DSL connection to perform some remote management on the servers and such.
    The customers using this type of network model would be mostly behind slow connections and there wouldnt be any high load traffic going out or inside the network. (DSL etc connections)
    By reading info on the PIX i presume that in this situation it would be best to use it in Transparent mode between the C3550 and the DSL modem in question. Or maybe use PIX in routed mode and configure the outside interface to get its IP address with DHCP from the DSL modem? Or maybe some static configuration would be better there.
    One thing i would like to know about the PIX is that does it have some basic settings that would make it possible to basicly insert it to the network and it would provide some basic protection already? I guess if theres some good base that i could start building the configuration suited for the network in question.
    I find myself lacking alot of basic information concerning Firewalls/PIX even though it should be really essential in my studies. Thats why i would like to know how much does PIX ability to keep the network secured depend on the the right type of configuration or does it perform most of its measures to intercept harmfull traffic automatically with some built in methods? (Not really sure on my choice of words)
    I guess at this point i would really appriciate any tips that any of you expirienced PIX users could give me to set me on way configuring my firewall to provide sufficient protection for the network.
    - Jouni Forss

  • Network Model writeNetwork

    Whilst using the sdonm API I have been calculating the shortest path between two nodes. This all works very well. However when I come to write this path to the path and path_link tables the NetworkManager.writeNetwork method does nothing. More precisely I do:
    Network nw=NetworkManager.readNetwork(connection,name,true);
    Path shortPath=NetworkManager.shortestPath(nw,node1,node2);
    shortPath.computeGeometry(0.05);
    nw.addPath(shortPath);
    NetworkManager.writeNetwork(connection,name);
    connection.commit;
    From reading around the forums I am unsure as to whether the above should work, as a workaround I am inserting the data into the table manually but it is less elegant and a lot more hassle than the above.
    Help?

    Hi,
    I can write the path data out to the path table by using the JNDI datasource and a preparedstatement, so I don't think there is a config issue. I had a read on the internet for some hours today and from what I understand sometimes Oracle doesn't like being written to by anything other than the Oracle driver? What I mean is that the connection given by using the drivermanager method is of a different type to the JNDI method. I did read that if I used an OracleDataSource rather than a javax.sql.DataSource then this might make it work, however I have been unable to cast the JNDI connection to an OracleDataSource. i.e.
    <pre>
    Context ctx = new InitialContext();
    OracleDataSource ds = (OracleDataSource)ctx.lookup(JNDIName);
    </pre>
    However this gives me a classcastexception. This seemed a little strange as in the oc4j admin pages the JNDIName is actually formed from the oracle.jdc.pool.OracleDataSource. Does this sound reasonable?

  • Network Model  - Arcs create unexpected results

    Hello Spatial Users,
    I have created a road network using the "Automatic" Network Definition, loaded all the nodes and links, and everything seems to be OK. It all validates, links and nodes have the correct values. It is an undirected network.
    I can create shortest paths, but the issue I'm having is arcs within the links are returning unexpected results. It is as though the start of the arc is used and then it follows the arc and jumps back to the end of the line - so the shortest path is not the shortest with all this jumping from start to finish of the arcs within the line string.
    Do I need to convert the arcs to lines or am I missing something else? I was hoping that because it was 'undirected' this would resolve this issue.
    We are using 11.1.0.6.0.
    Thanks for your help,
    Kerryne

    Hi, Kerryne,
    NDM doesn't support arcs in its spatial path representation. For arcs it will only use start and end pt of the arc. You need to approximate arcs as linear segments for link geometry to get a more accurate path geometry.
    Regards,
    Jack

Maybe you are looking for