Comments (6)
Hi @Kuifje02!
Cheers for another bug.
The tabu algorithm doesn't give optimal paths, just resource feasible ones.
I've just quickly checked, the networkx.astar_path (used in tabu) gives the same solution.
The bidirectional algorithm however, should give the result you've stated. I'll dig into it.
Also, contributions are very welcome!
from cspy.
Hey @Kuifje02, just had another thought about this. It's actually an interesting case.
The label containing the Source-2-1-Sink path, say label_1
, has a total weight of -10 and a total resource usage of [3,2].
The label containing the Source-1-Sink path, say label_2
, has a total weight of 0 and a total resource usage of [1,0].
According to the definition of dominance in
Line 60 in 1c29bff
when these two labels are compared,
label_1
does not dominate label_2
, because even though the weight is lower, label_1.weight
< label_2.weight
, the resource usage is higher, all(label_1.res <= label_2.res)
is not true.The other way around,
label_2
does not dominate label_1
because even though the resource is lower, all(label_2.res <= label_1.res) and any(label_2.res <= label_1.res)
is true, the weight is higher, label_2.weight
<= label_1.weight
is not true.
To overcome this, we can add another condition to the if statement saving the final labels:
cspy/cspy/algorithms/bidirectional.py
Line 285 in 1c29bff
Saying something like neither labels dominate each other then pick the one that has the smallest weight.
from cspy.
Yes that makes sense.
I have checked how it is implemented in the pylgrim library (a python library for the elementary constrained shortest path).
I am not sure I understand as I don't see such a criteria in his domination function :
https://github.com/ToonWeyens/pylgrim/blob/45ac035f38c33cba4e55180480316b1a442b15cd/pylgrim/ESPPRC.py#L321.
Maybe I haven't spend enough time thoroughly reading the code !
ps : I would be happy to contribute if I manage to find some time :)
from cspy.
Yeh, they did the same thing, just more elegantly, it's the standard definition for dominance (from Righini and Salani, 2006):
In pylgrim, a label b
dominates a label a
if and only if not a[0] < b[0]
and not any(a[1] < b[1])
.
I think index 0 is the cost/weight and index 1 contains an array with resource consumptions.
The converse statement would be, label b
dominates a label a
if both b[0] <= a[0]
and all(b[1] <= a[1])
with at least one of the equalities is strict (for any resource in index 1).
This is what I tried to write in my function, however, with the single return it all seems pretty confusing (and probably misses wrong).
Additionally, when you're traversing the graph backwards the inequalities for resources get flipped.
Anyway, will change to make it less confusing.
from cspy.
Changed the definition of dominance one closer to the one in pylgrim (hence more elegant).
This wasn't enough unfortunately, since the definitions were equivalent neither label dominates.
However, if you flip the direction and check the dominance again, this flips the inequality for resources and you get a solution that has a lower cost with a still-feasible but higher resource consumption.
from cspy.
Closing for now, but needs further testing.
from cspy.
Related Issues (20)
- Which dominance rule is used in .bidirectional HOT 1
- Fix Nuget push step in actions
- Generation of more paths with BiDirectional algorithm HOT 5
- cspy.BiDirectional (monodirectional) HOT 9
- Returning all the negative cost path in Elementary shortest path problem HOT 1
- Relax strict monoticity assumption of input resources
- Are these algorithms can be used to find shortest path which travel through a set of specific nodes? HOT 2
- False dominance rule for 2-cycles in non-elementary RCSP HOT 1
- cspy.PSOLGENT example code fails HOT 1
- cspy k path functionality HOT 5
- v1.0.3 unusable on arm64 HOT 2
- Why does min_res impact the output HOT 3
- Ability to select arbitrary source and sink HOT 6
- Ability to disable some checks on the graph. HOT 2
- Multi trip vehicle routing problem
- cspy.GRASP example code fails
- Adding modify accumulated cost in Callback
- Use cspy as a C++ library HOT 1
- Python 3.12 build error HOT 1
- What is an invertible REF? HOT 1
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 cspy.