VROOM-Project / pyvroom

Vehicle Routing Open-source Optimization Machine
BSD 2-Clause "Simplified" License
69 stars 14 forks source link

Issue running pyvroom #85

Open murali731 opened 1 year ago

murali731 commented 1 year ago

Hi, I tried running the example code given in the documentation but encountered errors. Please let me know how to resolve this.

Find below the Python code I have used.


import vroom

problem_instance = vroom.Input()

problem_instance.set_durations_matrix( profile="car", matrix_input = [[0, 2104, 197, 1299], [2103, 0, 2255, 3152], [197, 2256, 0, 1102], [1299, 3153, 1102, 0]], )

problem_instance.add_vehicle([vroom.Vehicle(47, start=0, end=0), vroom.Vehicle(48, start=2, end=2)])

problem_instance.add_job([vroom.Job(1414, location=0), vroom.Job(1515, location=1), vroom.Job(1616, location=2), vroom.Job(1717, location=3)])

solution = problem_instance.solve(exploration_level=5, nb_threads=4)

print('Done')


I tried running the same code with different versions of Python.

Error with Python version 3.7.1

C:\Project\venvs\work_1\Scripts\python.exe C:\Project\practice_work\vrp_vroom\test.py Traceback (most recent call last): File "C:\Project\practice_work\vrp_vroom\test.py", line 1, in import vroom File "C:\Project\venvs\work_1\lib\site-packages\vroom__init__.py", line 14, in from .input.input import Input File "C:\Project\venvs\work_1\lib\site-packages\vroom\input\input.py", line 6, in from numpy.typing import ArrayLike ModuleNotFoundError: No module named 'numpy.typing'

Error with Python version 3.8.10:

C:\Project\venvs\work_2\Scripts\python.exe C:\Project\practice_work\vrp_vroom\test.py Traceback (most recent call last): File "C:\Project\practice_work\vrp_vroom\test.py", line 5, in problem_instance.set_durations_matrix( File "C:\Project\venvs\work_2\lib\site-packages\vroom\input\input.py", line 283, in set_durations_matrix matrix_input = _vroom.Matrix(numpy.asarray(matrix_input, dtype="uint32")) RuntimeError: Incompatible buffer format!

Operating system: Windows 10, 64-bit

jonathf commented 1 year ago

Do you mind updating and reporting the version of Numpy? I suspect it is out of date?

jfulem commented 1 year ago

I have the same issue. Numpy version 1.26.0, pyvroom 1.13.3. Win 11, 64-bit. I'm using python 3.10.11.

jfulem commented 1 year ago

@jcoupey, please, can you help me with this issue specific to Win OS?

jonathf commented 1 year ago

There are two different errors here. Are you saying that you are getting the error equal to 3.7 or 3.8?

jfulem commented 1 year ago

Yes

set_durations_matrix matrix_input = _vroom.Matrix(numpy.asarray(matrix_input, dtype="uint32")) RuntimeError: Incompatible buffer format!

jonathf commented 1 year ago

I can't reproduce so I'm not completly sure, but I suspect that the underlying data types are mismatching.

I've made a experimental release for 1.13.4-dev1 which you can try out where I replace uint32 with generic unsigned integer.

Let me know if that solves the issue.

jfulem commented 1 year ago

Can I install via pip?

jonathf commented 1 year ago

yes. pip install pyvroom==1.13.4.dev1.

jfulem commented 1 year ago

Hmm, I'm getting still this: matrix_input = _vroom.Matrix(numpy.asarray(matrix_input, dtype="u4")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: Incompatible buffer format!

jfulem commented 1 year ago

And @jonathf you can't reproduce on windows 11? Which python? I tried Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]

jonathf commented 1 year ago

That is unfortunate. I don't have a windows machine.

@nilsnolde, any chance you have time to try diagnose this issue?

jfulem commented 1 year ago

@jonathf on Ubuntu 20.04 or 22.04 it works with no issues. But we want to support Windows as well :-(.

nilsnolde commented 1 year ago

I’m currently taking a bit of distance to unpaid work for the rest of the year tbh. That is to say, you can contact me on enquiry@gis-ops.com @jfulem if you want commercial support on this. At some point we’ll deal with this too, but that’s well into next year.

nilsnolde commented 1 year ago

Fwiw, the tests should probably run on windows as well. For FOSS it’s not counting towards GitHub limits @jonathf. OSX should mostly be fine when Linux is ok since the tool chains are so similar, but win is a very different STL.

jfulem commented 1 year ago

@nilsnolde OK, fair enough. I don't need commercial support.

jonathf commented 1 year ago

@nilsnolde, very understandable.

Yeah, activating the tests for windows should be done. We chose against it when we started as I didn't want to use up vrooms entired budget, but that isn't as much of an issue anymore as the activity is now much lower. I'll get to that one of these days.