Skip to content

Commit

Permalink
Remove lint and add VRPy to PyProject.TOML
Browse files Browse the repository at this point in the history
Signed-off-by: Risbud, Sumedh <[email protected]>
  • Loading branch information
srrisbud committed Apr 7, 2023
1 parent 20839e7 commit d7925ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ scikit-optimize = "^0.9.0"
scipy = "^1.9.1"
nbformat = "^5.7.1"


[tool.poetry.dev-dependencies]
bandit = "1.7.4"
coverage = "^6.3.2"
Expand Down
16 changes: 13 additions & 3 deletions src/lava/lib/optimization/apps/vrp/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
import networkx as ntx
from pprint import pprint
from dataclasses import dataclass
from vrpy import VehicleRoutingProblem
try:
from vrpy import VehicleRoutingProblem
except ImportError:
class VehicleRoutingProblem:
def __init__(self, graph):
self.graph = graph
self.vrpy_not_installed = True

from lava.lib.optimization.problems.problems import QUBO
from lava.lib.optimization.solvers.generic.solver import OptimizationSolver, \
SolverReport
Expand Down Expand Up @@ -120,7 +127,9 @@ def _prepare_graph_for_vrpy(g):
g.add_edge("Source", n, cost=cost_src_to_nod)
g.add_edge(n, "Sink", cost=cost_nod_to_snk)
return g
if scfg.core_solver == CoreSolver.VRPY_CPU:
vrp = VehicleRoutingProblem(self.problem.problem_graph)
vrpy_is_installed = not hasattr(vrp, "vrpy_not_installed")
if scfg.core_solver == CoreSolver.VRPY_CPU and vrpy_is_installed:
# 1. Prepare problem for VRPy
graph_to_solve = self.problem.problem_graph.copy()
graph_to_solve = _prepare_graph_for_vrpy(graph_to_solve)
Expand Down Expand Up @@ -230,4 +239,5 @@ def _prepare_graph_for_vrpy(g):
tsp_routes.update(route)
return clustering_solution, tsp_routes
else:
raise ValueError("Incorrect core solver specified.")
raise ValueError("Incorrect core solver specified or VRPy is not "
"installed.")
3 changes: 2 additions & 1 deletion src/lava/lib/optimization/solvers/generic/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ def _get_run_config(
elif backend in NEUROCORES:
# from lava.lib.optimization.solvers.generic.read_gate.ncmodels \
# import get_read_gate_c_model_class
# ReadGateCModel = get_read_gate_c_model_class(num_in_ports, backend)
# ReadGateCModel = \
# get_read_gate_c_model_class(num_in_ports, backend)
pdict = {
self.solver_process: self.solver_model,
ReadGate: ReadGateCModel,
Expand Down

0 comments on commit d7925ec

Please sign in to comment.