Gurobi / gurobi-optimods

Data-driven APIs for common optimization tasks
https://gurobi-optimods.readthedocs.io/en/stable
Apache License 2.0
139 stars 31 forks source link

(Elementary) shortest path problem with resource constraints #50

Open ruthmair opened 1 year ago

ruthmair commented 1 year ago

Why this Mod?

What will the API be?

node_data = pd.DataFrame([
    {"node": 0, "cost": -3, "time": 4, "distance": 3},
    {"node": 1, "cost": 5, "time": 3, "distance": 7},
    {"node": 2, "cost": 6, "time": 1, "distance": 2},
    {"node": 3, "cost": -4, "time": 5, "distance": 3}
])

arc_data = pd.DataFrame([
    {"source": 0, "target": 1, "cost": 16, "distance": 1},
    {"source": 0, "target": 2, "cost": -13, "distance": 3},
    {"source": 1, "target": 2, "cost": 10, "distance": 2},
    {"source": 2, "target": 1, "cost": -4, "distance": 6},
    {"source": 1, "target": 3, "cost": 12, "distance": 3},
    {"source": 3, "target": 2, "cost": -9, "distance": 2}
])

limits = {
  "time": 10,
  "distance": 18
}

path, objective = solve_espprc(node_data=node_data, arc_data=arc_data, source=0, target=3, limits=limits, elementary=True)

Additional context

simonbowly commented 1 year ago

@torressa @ruthmair could we extend the existing shortest path mod with this version to avoid too much duplication? A simple shortest path problem would still be solvable by imposing no limits.

torressa commented 1 year ago

Indeed a simple shortest path can be used but only for some bounds. This problem has the following additional constraints (as well as others to enforce elementary paths): $$\sum{ij} a^r{ij} x_{ij} \leq A^r,~~\forall r$$ Where $r$ is a resource (in Mario's example: limits.keys()). So this would need a change to the underlying min-cost flow formulation (the one in src/gurobi_optimods/network_util.py)

simonbowly commented 1 year ago

Yep, I mean we could do away with the min-cost-flow based implementation and only implement the more complex resource-constrained model. If re-using the network_util stuff over-complicates things, we can just have some duplication.

ruthmair commented 1 year ago

Ok, then I will take it from here.

simonbowly commented 1 year ago

@ruthmair @torressa FYI I removed the current shortest path implementation & docs from the main repo, and re-instated it on the branch simonbowly/rcsp, so you can use it as a starting point for docs and tests of a resource-constrained version.

ruthmair commented 1 year ago

I guess the public/private issue also made the rcsp fork unusable? This is no issue at all, I can just start with a new fork.

simonbowly commented 1 year ago

Yeah, new fork required I'm afraid, sorry about that.

torressa commented 11 months ago

@ruthmair Are you still working on this? Simon has given us the OK on writing a VRP mod! 😈

ruthmair commented 11 months ago

I still need to start working on this, but it is on my list. Would you do a VRP mod based on column generation?

torressa commented 11 months ago

Yeah, why not? Would you say the formulation is better? We could have mod based on the formulation(s), or even better formulation(s) + heuristic to insert solutions via callback