Git Product home page Git Product logo

Comments (6)

torressa avatar torressa commented on September 14, 2024 1

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.

torressa avatar torressa commented on September 14, 2024

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

def dominates(self, other, direction):

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:

if self.currentLabel[direc].dominates(self.finalLabel[direc],

Saying something like neither labels dominate each other then pick the one that has the smallest weight.

from cspy.

Kuifje02 avatar Kuifje02 commented on September 14, 2024

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.

torressa avatar torressa commented on September 14, 2024

Yeh, they did the same thing, just more elegantly, it's the standard definition for dominance (from Righini and Salani, 2006):

dominance

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.

torressa avatar torressa commented on September 14, 2024

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.

torressa avatar torressa commented on September 14, 2024

Closing for now, but needs further testing.

from cspy.

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.