Новичок в pyomo: перевести конкретную проблему в абстрактную

#pyomo

#pyomo

Вопрос:

Я сталкиваюсь с некоторыми проблемами, пытаясь перевести конкретную модель в абстрактную.

 Months = RangeSet(6)
RequiredHours = {1: 8000, 2: 9000, 3: 9800, 4: 9900, 5: 10050, 6: 10500}
Notifications = {1: 2, 2: 0, 3: 2, 4: 0, 5: 1, 6: 0}
Costs = {'Attendants': 5100, 'Trainees': 3600}
Hours = {'Attendants': 150, 'Trainees': 25}
TraineeMax = 5

model = ConcreteModel()

model.TraineesNb = Var(Months,domain=NonNegativeIntegers,bounds=(0,TraineeMax))

AvailableAttendants = {}
AvailableTrainees = {}
for m in Months:
    if m == 1: 
        AvailableAttendants[m] = 62
        AvailableTrainees[m] = model.TraineesNb[m]
    if m == 2:
        AvailableAttendants[m] = AvailableAttendants[m-1] - Notifications[m-1]
        AvailableTrainees[m] = model.TraineesNb[m]   model.TraineesNb[m-1]
    if m > 2:
        AvailableAttendants[m] = AvailableAttendants[m-1] - Notifications[m-1]   model.TraineesNb[m-2]
        AvailableTrainees[m] = model.TraineesNb[m]   model.TraineesNb[m-1]
# Objective
model.Costs = Objective(
    expr = sum(AvailableAttendants[m] for m in Months)*Costs["Attendants"]   
           sum(AvailableTrainees[m] for m in Months)*Costs["Trainees"] ,
           sense = minimize)
# declare constraints
model.NeededHours = ConstraintList()
for m in Months:
    model.NeededHours.add(expr = AvailableAttendants[m]*Hours["Attendants"]   
                          AvailableTrainees[m]*Hours["Trainees"] >= RequiredHours[m])
  

Конкретная модель пересылает адекватные результаты (возможно, не самый элегантный код, но он работает). В дискретной версии этой модели в цикле возникает ошибка [для m в модели.Месяцы]
Спасибо за вашу помощь и комментарии
, Наджи