Skip to content

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

@pchtsp

Description

@pchtsp

Describe the bug

Followed this guide:

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

  • Installed everything
  • Created a virtual environment
  • Started the web server in the command line.
  • Clicked on the solve button in the web UI.

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:

  • I followed the instructions, that clone from master.
  • python 3.10

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 [email protected]
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.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions