Kuifje02 / vrpy

A python framework for solving the VRP and its variants with column generation.
MIT License
179 stars 43 forks source link

How to handle cspy.res_cost object if it has variable length ? #3

Closed Kuifje02 closed 4 years ago

Kuifje02 commented 4 years ago

When considering the following constraints :

resources extension functions are additive, so it is not necessary to define a custom REF.

But when considering time windows, a custom REF is necessary with the cspy.REF_custom method :

image

How can we handle the fact that the cumulative_res object has a variable length, as it depends on which constraints are activated (load, duration, etc.) ?

For example, we know that the monotone resource is alway first (new_res[0}+=1), but not sure how to handle the other ones.

torressa commented 4 years ago

@Kuifje02 Just seen this. I'll have a look through the new stuff and see

torressa commented 4 years ago

I think I fixed it? Couldn't come up with an actual solution. Was mostly trying to get the resource functions working Please check the time windows resources are correct.

Kuifje02 commented 4 years ago

Yes looks good to me for now! Still need to perform more thorough checks.

I thought of an alternative solution. Would it work if we always worked with all the resources (monotone,stops, capacity, time, time_windows, ...) and changed res_max according to the constraints that are activated ? When solving the big instances we will run into negative cycles and will have to add another resource to enforce path elementarity.

An obvious down side is that if you only have one constraint, for example, capacity, you have to handle all the other "dummy" resources in the algorithm. I assume this affects the computational complexity of the bidirectional algorithm (exponentially ?) ?

torressa commented 4 years ago

Yeh that's a much neater solution. The number of resources should not really affect the algorithms performance.

Kuifje02 commented 4 years ago

Partially implemented. Partially because two tests fail and I cannot figure out why for the moment. Still looking. For some reason the maximum number of stops resource fails.

torressa commented 4 years ago

It turned out pretty neat! Fixed on error, got a new one. It seems pretty tricky to get the REFs right, not easy to debug either...

torressa commented 4 years ago

Not sure, seems to work without the REFs. The total resource consumption is not correct. So I think it might be a problem with cspy not dealing with custom REFs very well.

torressa commented 4 years ago

New commit in cspy fixes all errors except time windows. I'll have another look into it tomorrow.

torressa commented 4 years ago

Works with the the version in cspy-master!!

Kuifje02 commented 4 years ago

Nice I'll take a look !