Comments (9)
Maybe just a hash will do inside the matrix-wrapper class:
- hash-function made out of the combination of the column and row, that should be altered.
- for retriving: checking if combination "number-row/number-column" exist in hash,
=> then take the edited value,
=> else take the value from the original matrix.
At least thats, what has been on my mind for quite some time ...
from vroom.
Thanks for the input, I guess choosing the way to do it will mostly come down to efficiency. Maybe a simpler filtering might also be sufficient as we "only" want zeros on whole line/columns (https://github.com/VROOM-Project/vroom/blob/master/src/problems/tsp/tsp.cpp#L32-L49).
from vroom.
If it is only about the zeroes in the diagonal, then yes thats easy to achive: Simply look, if column equal row.
But there were also some other alterations made in the matrix to force the solver to determined start-endpoints. Thats why I was there maybe thinking to general, that it should be able to "overwrite" any value from the Matrix inside the wrapper.
from vroom.
Now this comes down to not creating a new matrix using get_sub_matrix
at
vroom/src/problems/tsp/tsp.cpp
Line 19 in 897ba57
Costs could be retrieved from the original matrix without a copy by using the indexes matching in _tsp_index_to_global
to add a level of indirection.
Potential concern: I wonder what would be the impact of accessing the original matrix from different threads solving TSP sub-problems in parallel.
from vroom.
Since the algorithm do not care how the matrix is accessed in the background, i come up with the idea to make matrix
a virtual class, which got only the virtual methods size()
and operator[]
for the access.
The original matrix
class becomes the content_matrix
and inherits from matrix
.
The sub_matrix_wrapper
inherits from matrix
also, and gets the address to the rows/entries of a content_matrix
.
The content_matrix
then can create those wrappers with the get_sub_matrix()
method.
I'm currently implementing the described structure on this branch.
from vroom.
@PattyDePuh Using get_sub_matrix
to populate the content will leave the same amount of copying around.
I was thinking of just having an object holding a const ref to the original matrix and the list of indices for the sub-problem, as transmitted in the tsp
constructor here:
vroom/src/problems/tsp/tsp.cpp
Lines 18 to 19 in 87c3091
Then wrapper[i][j]
would just return original_matrix[indices[i]][indices[j]]
.
On second though this would not be enough to cover the matrix modifications in the workaround for fixed start/end.
After all, I actually wonder if this is worth the trouble for now as it would only impact the TSP code. And we are far from hitting memory/computing times bounds right now, even with big instances.
from vroom.
The wrapper solution could be implemented easily, if we would abonden the idea to access the matrix with double operator[]
and instead using a normal 'two arguments between parantheses' call:
wrapper::get(i,j)
Your concern about the modification: Here we could also have a variety of wrappers, which all inherit from the basic wrapper and alter the output according to the demand.
And i think they will become useful in the future.
Right after we decided which attribute of the verhicle routing problem we are going to handle next.
from vroom.
Now that the object model is in place, job
and vehicle
descriptions hold all relevant information to remove the need for hacky workarounds when handling other variants.
The TSP code situation is a bit special as it was written in the first place, therefore not using the current model, but only relying on a matrix for problem description.
from vroom.
Closing here as I don't think this is worth the trouble for now, especially in the light of the recent code changes introduced by the CVRP approach.
from vroom.
Related Issues (20)
- Ensure request interpretation as TSP HOT 3
- Error with inconsistent vehicle capacity arrays HOT 1
- Seeking Advice: Implementing User-Defined Routes with Invisible Points to Guide Optimization Algorithm HOT 4
- Design of Matrix class HOT 7
- Refactor functions to accept a range instead of a pair of iterators HOT 2
- Compiler warning in gcc-12 build HOT 5
- Update GitHub Actions HOT 1
- Speed up OSRM CI build HOT 2
- Mismatch in compilers used for OSRM and VROOM in CI HOT 1
- VROOM schedules next-day deliveries despite sufficient time windows HOT 5
- Can i solve this user case with VROOM? HOT 2
- More unassigned when using 1 vehicles instead of 2, while creating always 1 route only HOT 10
- Function template names forward iterator while in fact it requires a random access iterator HOT 4
- position job by time HOT 11
- Evaluating dropping rapidjson HOT 5
- vroom-docker with osrm HOT 1
- high loading time when using 1000 points or more HOT 2
- Vehicles to arrive at the same job at the same time HOT 1
- Some questions about time windows, duration and... HOT 2
- Second trip pickup duration HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vroom.