ampl/mo-book.ampl.com

Issue on page /notebooks/03/shift-scheduling.html

Mihailby opened this issue · 0 comments

Hi guys!
Thank you very much for the wonderful guide "MO-BOOK: Hands-On Mathematical Optimization with AMPL in Python".

In the AMPL model, it is not entirely clear how the BLOCKS set is formed; I believe that it can be formed using the following expression:

  1. If we declare set SHIFTS as circular:
    set SHIFTS circular = {'Morning','Evening', 'Night'};

set BLOCKS = {d in DAYS, s in SHIFTS, d1 in DAYS, s1 in SHIFTS, d2 in DAYS, s2 in SHIFTS:
if s = first(SHIFTS) then d1 = d and d2 = d and s1= next(s) and s2 = next(s, SHIFTS,2) or
if s = last(SHIFTS) and d!=last(DAYS) then d1 = next(d) and d2 = next(d) and s1= next(s) and s2 = next(s, SHIFTS,2) or
if s = "Evening" and d!=last(DAYS) then d1 = d and d2 = next(d) and s1= next(s) and s2 = next(s, SHIFTS,2)};

Thank you so much again!