TimefoldAI / timefold-quickstarts

Get started with Timefold quickstarts here. Optimize the vehicle routing problem, employee rostering, task assignment, maintenance scheduling and other planning problems.
https://timefold.ai
Apache License 2.0
245 stars 76 forks source link

Bug: 'Vehicle routing with capacity and time windows' python demo sometimes raises run-time Exception when retrieving the solution #574

Open pchtsp opened 2 months ago

pchtsp commented 2 months ago

Describe the bug

Followed this guide:

https://github.com/TimefoldAI/timefold-quickstarts/tree/stable/python/vehicle-routing

Expected behavior

The solution is loaded without errors in the console.

Actual behavior

IMPORTANT: this does not happen everytime, it seems the first time after starting the web server it always fails.

The results partially load. But I got an exception in the console:

  File "timefold/python/timefold-quickstarts/python/vehicle-routing/src/vehicle_routing/domain.py", line 131, in arrival_time
    return (self.visits[-1].departure_time +
TypeError: unsupported operand type(s) for +: 'NoneType' and 'datetime.timedelta'

and the UI shows:

Getting route plan has failed.

500: Internal Server Error

Code: unknown
Error id: ----

To Reproduce

Follow the quickstart README.

Environment

Timefold Solver Version or Git ref:

As per the pyproject.toml:

[project]
name = "vehicle_routing"
version = "1.0.0"
requires-python = ">=3.10"
dependencies = [
    'timefold == 1.13.0b0',
    'fastapi == 0.111.0',
    'pydantic == 2.7.3',
    'uvicorn == 0.30.1',
    'pytest == 8.2.2',
]

Output of java -version:

openjdk version "17.0.12" 2024-07-16 OpenJDK Runtime Environment (build 17.0.12+7-Ubuntu-1ubuntu222.04) OpenJDK 64-Bit Server VM (build 17.0.12+7-Ubuntu-1ubuntu222.04, mixed mode, sharing)

Output of uname -a or ver:

(uname -a)

Linux system76-pc 6.9.3-76060903-generic #202405300957~1721174657~22.04~abb7c06~dev-Ubuntu SMP PREEMPT_DY x86_64 x86_64 x86_64 GNU/Linux

Additional information

I also tried running the solver through the REST API using the commands provided in the "GUIDE" section:

curl -X GET -H 'Accept:application/json' http://localhost:8080/demo-data/FIRENZE -o sample.json
curl -X POST -H 'Content-Type:application/json' http://localhost:8080/route-plans -d@sample.json
curl -X GET -H 'Accept:application/json' http://localhost:8080/route-plans/ID

If I keep runing the third command during solving, I get solutions most of the times, but it also raises errors often.

triceo commented 2 months ago

Hello @pchtsp and thanks for reporting! We'll take a look when time permits.