torressa / cspy

A collection of algorithms for the (Resource) Constrained Shortest Path problem in Python / C++ / C#
https://torressa.github.io/cspy/
MIT License
78 stars 24 forks source link

Update REF Callback Docs #68

Closed tomatoes-prog closed 3 years ago

tomatoes-prog commented 3 years ago

Describe the bug The is simply, I am trying to create my own REF_callback for a CG problem, so I need to use the REFCallback class, to create de forward, backward and join functions, but I cannot import the Class and apparently it doent exist. The docs seems outdated, I would like to know how to implement this in the 0.1.2 version thanks.

To Reproduce Steps to reproduce the behavior:

  1. pip install cspy
  2. from cspy import REFCallback
torressa commented 3 years ago

Hey! The docs are the most recent version v1.0 which is still in alpha stage (but it is orders of magnitude faster, see here).

pip uninstall cspy
pip install cspy==1.0.0a0

I'd strongly recommend you upgrade to this version, for which (other than what's in the docs) you can see a good example of custom REFs for the VRP here (note that the backward and joining functions have been commented but they work! I was having some issues with the direction="both").

If your code heavily relies on v0.1.2, you can still see the old documentation by browsing the repo under the 0.1.2 tag (docs, BiDirectional). But again, since you already have the REF in the new format, I would recommend you work with v1.0, the parameter changes are minimal.

I'll leave this issue open, as there are still parts of the documentation that need updating (e.g. the Jane example).

tomatoes-prog commented 3 years ago

Thank you, I really appreciate your fast answer!

I have tried to run this new version but I think the C++ gave me some unexpected issues: it always broke the console with no Errors or Traceback. Does it need some kind of specific python version to work? I am working in this machine:

Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

torressa commented 3 years ago

I haven't tested it on windows, but in theory it should also work (works on python3.6 to 3.9).

With your custom REFs, you have to really careful with the arguments (e.g. make copies as shown in the example) but also that the REFs are correct. I've had all sorts of errors with both the code being wrong and the REF being incorrect (not doing what you intended). I'd suggest to get a simple example working (maybe with some print outs), then work your way up. Also If you can give me a reproducible example, I can give it a try Worst comes to worst you can revert to v0.1.2 and pass the different functions separately.

Let me know how you get on!

torressa commented 3 years ago

REFs page: