level_resources

Level the renewable resources (only those that have been included by the P2Schedule:include_in_leveling function).

This function requires four input parameters, as follows:

  • FixedDW: The general formula used during leveling of resources is equal to work = activity duration x resource demand. This relation allows to level resources in two ways, as follows
    • Fixed duration: The duration and resource demand of each activity will never change. 
    • Fixed work: P2Engine will search for a schedule without over-allocations with a fixed work content for each activity. Using this option means that the activity duration and resource demand for each activity can change, such that the work content remains fixed. As an example, an activity with a duration of 2 days and a resource demand of 2 people (i.e. a work content of 4 man-days) can change to an activity with a duration of 4 days only demanding 1 person per day.
  • ScheduleMethodID: The method to schedule activities without over-allocations is based on priority based scheduling techniques, where the priorities are set based on calculations, as follows:
    • Random (0): Randomly rank the activities.
    • SPT (1): Rank the activities according to their shortest processing time.
    • LPT (2): Rank the activities according to their longest processing time.
    • MIS (3): Rank the activities according to their most immediate successors.
    • MTS (4): Rank the activities according to their most total successors.
    • LNJ (5): Rank the activities according to their least non-related jobs.
    • GRPW (6): Rank the activities according to their greatest rank positional weight.
    • ESS (7): Rank the activities according to their earliest start time.
    • LSS (8): Rank the activities according to their latest start time.
    • MSLK (9): Rank the activities according to their minimum slack value.
    • GRWC (10): Rank the activities according to their greatest work content.
    • GCRWC (11): Rank the activities according to their greatest cumulative work content.
    • AC (12): Rank the activities in such a way to avoid conflicts with activity constraints.
    • Special case: Intensive search (-1): Keep searching for a resource feasible schedule until the search is truncated by the user using the Callbackfunction.
  • ModeAssignID: When the fixedDW parameter is set to “fixed work”, the activity durations and resource demand can change according to various approaches. P2Engine currently uses default search options and this parameter must be set to 1 (will be extended in future P2Engine releases).
  • Callbackfunction: Name of a LUA function that should be called during the leveling search (more information below, only relevant when ScheduleMethodID = -1).

This level_resources function returns 1 if a schedule has been found without resource over-allocations, and 0 otherwise. In case of a successful leveling run, the function P2Schedule:get_all_resource_start_times must be used to copy the new schedule into the current P2Schedule object. 

The Callbackfunction parameter contains the name of a LUA function that should be called during the leveling search. This user defined LUA function can be used to conditionally stop the search to a leveled schedule, and can have the three following arguments

    • Argument1: The current best solution found without over-allocations (if already found)
    • Argument2: The number of trails done during the level_resources search
    • Argument3: The number of solutions found without over-allocations

The function should return a 0 (continue the search) or 1 (stop the search). When no such a LUA function exists with the define name, a message will be shown to report this lack of function.

Parameters: 
I/O Type Name Description
input integer fixedDW 0 (fixed work) or 1 (fixed duration)
input integer scheduleMethodID scheduling method to solve over-allocations (0 to 12)
input integer modeAssignID 1 (default)
input string callbackfunction LUA function name (argument1,argument2,argument3)
output integer result 99999999 (failure) or new project duration (successful)
Learn More: 

Step inside PMKC.

Example: 
function ()
        io.write('\n')
end
Class: 
P2Schedule