Giter Site home page Giter Site logo

Matrix wrapper about vroom HOT 9 CLOSED

vroom-project avatar vroom-project commented on July 21, 2024
Matrix wrapper

from vroom.

Comments (9)

PattyDePuh avatar PattyDePuh commented on July 21, 2024

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.

jcoupey avatar jcoupey commented on July 21, 2024

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.

PattyDePuh avatar PattyDePuh commented on July 21, 2024

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.

jcoupey avatar jcoupey commented on July 21, 2024

Now this comes down to not creating a new matrix using get_sub_matrix at

_matrix(_input._matrix.get_sub_matrix(_tsp_index_to_global)),

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.

PattyDePuh avatar PattyDePuh commented on July 21, 2024

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.

jcoupey avatar jcoupey commented on July 21, 2024

@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:

_tsp_index_to_global(std::move(problem_indices)),
_matrix(_input._matrix.get_sub_matrix(_tsp_index_to_global)),

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.

PattyDePuh avatar PattyDePuh commented on July 21, 2024

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.

jcoupey avatar jcoupey commented on July 21, 2024

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.

jcoupey avatar jcoupey commented on July 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.