A collection of algorithms for the (Resource) Constrained Shortest Path problem in Python / C++ / C#
https://github.com/torressa/cspy/compare/v1.0.2...v1.0.3
i->j->i
are not allowed).sdplog
.Coauthored with @dvbuntu! :rocket:
Fix minimum number of nodes on path condition for PSOLGENT
.
Force node sorting to start with "Source" and end with "Sink" in PSOLGENT
.
Force inclusion of Source and Sink nodes in PSOLGENT
paths.
Clean up:
BiDirectional
to use search objects again.labelling.*
remove LabelExtension
unified with Params
.Record rand
value used to generate PSOLGENT
paths from positions.
Make upper and lower bound of PSOLGENT
initial positions optional arguments.
2opt in PSOLGENT
for better evaluation of solutions.
Critical resource as a parameter to BiDirectional
[EXPERIMENTAL] Add critical resource preprocessing attempt using longest paths
benchmarks/README.md
.Rewrite of the bidirectional algorithm in C++ interfaced with Python using SWIG.
I compared the performance on a solomon instance using vrpy
. The exact=True/False
are attributes of vrpy
that uses the threshold
option.
The algorithm improvements include:
direction="both"
) with lower bounding and sorted labelsREFCallback
. and then pass them to the algorithm using the REF_callback
parameter. This change applies to all algorithms.
Note that:
REF_fwd
, REF_bwd
and REF_join
)direction="forward"
, then only REF_fwd
would suffice. In the case of the callback being passed and only part of the functions implemented, the default implementation will used for the missing ones.e.g.
from cspy import BiDirectional, REFCallback
class MyCallback(REFCallback):
def __init__(self, arg1, arg2):
# You can use custom arguments and save for later use
REFCallback.__init__(self) # Init parent
self._arg1: int = arg1
self._arg2: bool = arg2
def REF_fwd(self, cumul_res, tail, head, edge_res, partial_path,
cumul_cost):
res_new = list(cumul_res) # local copy
# do some operations on `res_new` maybe using `self._arg1/2`
return res_new
def REF_bwd(self, cumul_res, tail, head, edge_res, partial_path,
cumul_cost):
res_new = list(cumul_res) # local copy
# do some operations on `res_new` maybe using `self._arg1/2`
return res_new
def REF_join(self, fwd_resources, bwd_resources, tail, head, edge_res):
fwd_res = list(fwd_resources) # local copy
# do some operations on `res_new` maybe using `self._arg1/2`
return fwd_res
# Load G, max_res, min_res
alg = BiDirectional(G, max_res, min_res, REF_callback=MyCallback(1, True))
method="random"
see issues (hopefully only temporary).New Parameters and changes to the custom REF inputs
Release for JOSS paper.
Code changes include:
BiDirectional:
_propagate_label
.Rework of path and algorithm attributes to avoid duplication
Replaced networkx.astar
algorithm with a procedure that finds a short simple
path using networkx.shortest_simple_paths
.
Some bug fixes have led to the following changes in the BiDirectional