Beispiel #1
0
def get_deadline_area(task_deadline):
    f_ = CpoStepFunction()
    f_.set_value(0, DAYS_IN_SPRINT * HOURS_IN_DAY, 100)
    f_.set_value(task_deadline * HOURS_IN_DAY + 1,
                 DAYS_IN_SPRINT * HOURS_IN_DAY, 0)
    return f_
Beispiel #2
0
JIM_HOLYDAYS = ((26, 40), (201, 225), (306, 313), (397, 411), (565, 579))

#-----------------------------------------------------------------------------
# Prepare the data for modeling
#-----------------------------------------------------------------------------

# Assign an index to tasks
ALL_TASKS = (MASONRY, CARPENTRY, PLUMBING, CEILING, ROOFING, PAINTING, WINDOWS,
             FACADE, GARDEN, MOVING)
for i in range(len(ALL_TASKS)):
    ALL_TASKS[i].id = i

# Initialize availability calendar for workers
joe_calendar = CpoStepFunction()
jim_calendar = CpoStepFunction()
joe_calendar.set_value(0, MAX_YEARS * 365, 100)
jim_calendar.set_value(0, MAX_YEARS * 365, 100)

# Remove week ends
for w in range(MAX_YEARS * 52):
    joe_calendar.set_value(5 + (7 * w), 7 + (7 * w), 0)
    jim_calendar.set_value(5 + (7 * w), 7 + (7 * w), 0)

# Remove holidays
for b, e in JOE_HOLYDAYS:
    joe_calendar.set_value(b, e, 0)
for b, e in JIM_HOLYDAYS:
    jim_calendar.set_value(b, e, 0)

#-----------------------------------------------------------------------------
# Build the model
Beispiel #3
0
DURATIONS = [TASKS[t]["duration"] for t in range(NB_TASKS)]

# Требования задач к ресурсам - тут всё просто - 1 разраб = 1 задача
DEMANDS = [
    make_resource_row(TASKS[t]["rnd"], NB_RESOURCES, DURATIONS[t])
    for t in range(NB_TASKS)
]

# построим список функций "присутсвия на работе"
RND_CALENDAR = []
for i in range(NB_RESOURCES):
    print("Calendar function for rnd {}".format(i))
    cnst_pr = [0, 0]
    last_val = sign(MM_DEV_ACTIVE_HOURS[i][0][0])
    fs = CpoStepFunction()
    fs.set_value(0, DAYS_IN_SPRINT * HOURS_IN_DAY, 100)
    for fdays, farrhr in enumerate(MM_DEV_ACTIVE_HOURS[i]):
        for fhours, fval in enumerate(farrhr):
            if fval == last_val == 0:
                cnst_pr[1] = fdays * HOURS_IN_DAY + fhours
            elif fval == 1 and last_val == 0:
                fs.set_value(cnst_pr[0], cnst_pr[1], 0)
                print("find interval from {} to {}".format(
                    cnst_pr[0], cnst_pr[1]))
                cnst_pr[0] = cnst_pr[1] = fdays * HOURS_IN_DAY + fhours
            elif fval == 0 and last_val == 1:
                cnst_pr[0] = cnst_pr[1] = fdays * HOURS_IN_DAY + fhours
            last_val = fval
    RND_CALENDAR.append(fs)

# -----------------------------------------------------------------------------
Beispiel #4
0
def get_allowable_area(shls, ax_attr, temperature):
    f_ = CpoStepFunction()
    if ax_attr == 'x':
        f_.set_value(0, SIZE_SHELF["x"] * SHELF_COUNT, 100)
        for ih in range(len(shls)):
            f_.set_value(shls[ih].x_start, shls[ih].x_start + 1, 0)
            f_.set_value(shls[ih].x_stop - 1, shls[ih].x_stop, 0)
            if not shls[ih].t_min <= temperature <= shls[ih].t_max:
                f_.set_value(shls[ih].x_start, shls[ih].x_stop, 0)
    elif ax_attr == 'y':
        f_.set_value(0, SIZE_SHELF["y"] * SHELF_COUNT, 100)
        for ih in range(len(shls)):
            f_.set_value(shls[ih].y_start, shls[ih].y_start + 1, 0)
            f_.set_value(shls[ih].y_stop - 1, shls[ih].y_stop, 0)
            if not shls[ih].t_min <= temperature <= shls[ih].t_max:
                f_.set_value(shls[ih].y_start, shls[ih].y_stop, 0)
    return f_