mobook / MO-book

Hands-On Optimization with Python
MIT License
153 stars 40 forks source link

Issue on page /notebooks/04/01-dinner-seat-allocation.html #77

Closed jon-nowacki closed 3 months ago

jon-nowacki commented 8 months ago

This block:

%time flow_value, flow_dict = nx.maximum_flow(G, 'door', 'seat')

%time results, seatplan = seating_allocation_maximize_flow_to_tables(members=[6, 8, 2, 9, 13, 1], capacity=[8, 8, 10, 4, 9], kmax=3, domain=pyo.NonNegativeIntegers)

Errors out, then everything below it does as well:

CPU times: user 2.21 ms, sys: 883 µs, total: 3.09 ms
Wall time: 10.1 ms
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<timed exec> in <module>

ValueError: not enough values to unpack (expected 2, got 1)
alessandrozocca commented 3 months ago

Thanks for spotting the error. The model was built but never solved. The latest commit fixes this issue by adding the following lines of code in a separate cell to get a meaningful time comparison with the networkx function.

%%time 
m = seating_allocation_maximize_flow_to_tables(members=[6, 8, 2, 9, 13, 1], capacity=[8, 8, 10, 4, 9], kmax=3, domain=pyo.NonNegativeIntegers)
_ = SOLVER.solve(m)