You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm experiencing random std::bad_alloc when calling pgr_TSP.
My query is
SELECT * FROM pgr_TSP(
$$
SELECT * FROM pgr_withPointsCostMatrix(
'SELECT id, source, target, cost, reverse_cost FROM osm.ways ORDER BY id',
'SELECT pid, edge_id, fraction from osm.TSPpoints',
array[-1, -2, -3, -4], directed := false);
$$,
randomize := false
);
The error that I see on the output is
ERROR: std::bad_alloc
HINT: pgr_eucledianTSP Processing Information
Initializing tsp class ---> tsp.greedyInitial --->
SQL state: XX000
The error doesn't happen every time but only randomly, once every 3-5 tries. When there is no error, the query returns successfully and the output is correct.
I'm using this dataset (the zip file contains an .osm file, downloaded from the OSM site) that I have imported with osm2pgrouting utility (the Windows version, that I found available in my local PostgreSQL installation path) : the osm.ways table contains 2188 rows. Morevoer, the osm.TSPpoints table contains 4 rows: its content can be found in this csv file.
I never get the error when running with the sample data available from the pgrouting documentation (I've tried running the query 20-30 times).
I'm using
PostgreSQL 11.3, compiled by Visual C++ build 1914, 64-bit
The pgr_eucledianTSP function is used to solve the Travelling Salesman Problem (TSP) for a set of points using an Euclidean distance matrix. One possible reason for this error is that the function is trying to allocate too much memory for the distance matrix, either because there are too many points or because the coordinates of the points are very large.
To fix this issue, you may try the following solutions:
Reduce the number of points: If the number of points is large, try reducing it. Depending on the application, you may be able to get away with only visiting a subset of the points.
2.Check the coordinate system: Ensure that the coordinate system is appropriate for the location of the points. If the points are in a large geographic area, consider using a geographic coordinate system rather than a projected one.
3.Optimize the memory usage: Check the memory usage of the system and try to optimize it. You can reduce the memory usage of the program by running it on a machine with more memory or reducing the size of other running programs.
4.Use another algorithm: If the problem persists, try using another algorithm that is better suited for your data. For example, the pgr_TSP function can solve the TSP using a variety of algorithms, and some may be more memory-efficient than others.
I'm experiencing random
std::bad_alloc
when callingpgr_TSP
.My query is
The error that I see on the output is
The error doesn't happen every time but only randomly, once every 3-5 tries. When there is no error, the query returns successfully and the output is correct.
I'm using this dataset (the zip file contains an .osm file, downloaded from the OSM site) that I have imported with
osm2pgrouting
utility (the Windows version, that I found available in my local PostgreSQL installation path) : theosm.ways
table contains 2188 rows. Morevoer, theosm.TSPpoints
table contains 4 rows: its content can be found in this csv file.I never get the error when running with the sample data available from the pgrouting documentation (I've tried running the query 20-30 times).
I'm using
The text was updated successfully, but these errors were encountered: