Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vehicle Routing Meta Solvers added #70

Closed

Conversation

LucasBerger
Copy link
Contributor

@LucasBerger LucasBerger commented Mar 21, 2024

This PR adds a few solvers in regards to a newly added vehicle routing optimization problem (VRP). The corresponding PR on web is: ProvideQ/toolbox-web#46

It adds the following Solvers:

VRP:

  • ClusterAndSolveVrpSolver (This Solver is the root for all VrpSolvers that first cluster and then solve the clusters individually. It creates subproblems of type CLUSTERABLE_VRP and sends it to the Cluster Solvers)
  • LkhVrpSolver (This solver directly solves a VRP with the LKH solver. !To be able to use this solver the lkh folder on the root has to be installed and a LKH binary compiled from source http://webhotel4.ruc.dk/~keld/research/LKH-3/ has to be put into lkh/vrp/bin/)
  • QuboTspSolver (This solver transforms a TSP (shorter form of VRP) into a QUBO as a LP File which then gets solved by a chosen QUBO Solver)
  • NEW: QrispVrpSolver (This solver uses grover on a classical quantum computer to solve VRPs directly. You will have to install the 'qrisp' folder to make this work (python =3.10 needed otherwise it won't work))

CLUSTERABLE_VRP:

  • TwoPhaseClusterer (This method of clustering VRPs outputs a bunch of TSP clusters which can be solve by both LKH and the QUBO transformer)
  • KmeansClusterer (This method of clustering VRPs outputs a defined number of VRPs. The number of clusters can be changed by setting the cluster option. by default this option is 3)
  • NoClusteringClusterer (This method is a dummy and just directly invokes a VRP Subroutine)

QUBO:

  • DwaveQuboSolver (This Qubo Solver uses the Dwave Quantum Annealer script in the dwave folder. To make this script work, one has to install the python packages in the dwave folder (Note: It seams the python version for installing has to be 3.10 or !lower!). There are 4 different Quantum Anealling functions in the script that can be choosen from with a settings option on the DwaveQuboSolver, though for any function other than sim, an API Token for Dwave's Leap is needed https://cloud.dwavesys.com/leap/login)
  • NEW: QrispQuboSolver (This solver uses qaoa on a classical quantum computer to solve QUBOs directly. The algorithm is designed to work only with QUBOs which were transformed with the TspQuboSolver. You will have to install the 'qrisp' folder to make this work (!python =3.10 needed or otherwise it won't work))

!For all the clusterers and the QuboTspSolver there needs to be a current version of the binary compiled from: https://github.com/LucasBerger/quantum-vrp
copy this binary into the bin folder

For the python solver: All the new python folders in JAVA are referred to as if there is a virtual environment in the folder /venv (e.g. lkh/venv). This is needed as some python packages need lower versions of python (e.g. qrisp, dwave)

In addition to those solvers these are further features:

  • tests and example problems for VRP Problems are correctly added.
  • added support for solver specific settings (formerly only settings regarding the meta solver could be added)
  • added support for more advanced CLI binary executions (custom solution retrieval, better support for adding arguments, support for environment variables)

!THIS PR is based on the refactor/solve-get-request-to-solution branch. this branch should be added first and then this branch should be rebased with develop afterwards.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@koalamitice
Copy link
Member

koalamitice commented May 2, 2024

TODOs:

  • Extend the server build pipeline so that it includes building the binaries (lkh/vrp/bin and vrp/bin/pipeline)
  • Extend the Readme of the server: it should include steps that explain how the solvers can be installed locally

How to install Rust:
(1) curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
(2) rustup install nightly-2023-07-01
(3) grab specific version name on machine...
(4) rustup default nightly-2023-07-01 (... specific version name on machine)
(5) cargo build

pipeline will be installed in target/.. directory

Questions:
We could either let the user compile the pipeline & lkh solver for themselves, or we could add default binaries that work on standard windows, linux, and mac.
(1) We have to differentiate the used binary during runtime. Currently all paths are handled over the applications.properties file. We would have to implement some kind of OS-checker there.
For instance, by adding multiple application.properties files. Or multiple paths to the existing files.

@koalamitice koalamitice self-requested a review May 15, 2024 14:13
@koalamitice koalamitice force-pushed the feature/vrp-meta-solver branch 2 times, most recently from 48c5c9d to f65f729 Compare May 28, 2024 10:39
@koalamitice koalamitice force-pushed the feature/vrp-meta-solver branch from 5f63835 to 37f8d36 Compare August 12, 2024 11:30
@koalamitice koalamitice requested a review from Elscrux August 12, 2024 11:44
@koalamitice koalamitice force-pushed the feature/vrp-meta-solver branch from 914516c to 0be2a1a Compare August 13, 2024 11:28
Dockerfile Outdated Show resolved Hide resolved
@Elscrux
Copy link
Member

Elscrux commented Aug 20, 2024

Overall the checkstyle plugin should be run in the IDE. Because this branch is on Lucas's repository, it doesn't run those workflows but once we merged this into dev it would complain at the check stage.

Copy link
Member

@Elscrux Elscrux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far! Just some changes needed.

// write solutions of the clusters into files:
for (var entry : clusterSolutionMap.entrySet()) {
String fileName = entry.getKey().getFileName().toString().replace(".vrp", ".sol");
Path solutionFilePath = Path.of(problemDirectoryPath, ".vrp", fileName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding a comment so it's clear what's done here, I don't quite understand tbh :D

@Elscrux
Copy link
Member

Elscrux commented Aug 21, 2024

@koalamitice Thanks for the changes! I found some minor things and resolved pretty much all threads but one. Btw, my Checkstyle currently still reports Checkstyle violations in QuboSolverTest.java and VrpSolverTest.java. Could you check those out? Once all that is done this is ready to be merged!

Copy link

@koalamitice
Copy link
Member

This pull Request was Merged with #78 -> will be closed and continued there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants