English
Resources and plan analysis
How to compare demand with capacity (including capacity that changes over time and assignments for part of a task), level resources, show a plan by resource with unplanned tasks, explain why a task starts when it does, and compare a candidate plan with the current one. Calculating the plan itself is covered in the Scheduling guide.
Compare demand with capacity
Resources have integer capacity and optional half-open availability periods. Omit periods for continuous availability, or use an empty array to close the resource throughout the horizon. Capacity is constant while available, unless the resource has capacityPeriods (see Capacity that changes over time). Each assignment requests positive integer units and applies to every work segment of the task, unless it covers only part of the work (see Assignments for part of a task). Duplicate assignments for the same task and resource are rejected. To use fractions, choose a shared unit such as percentage points for both capacity and demand.
The sweep reports load, available capacity, excess units and active task IDs for every event interval. Work that falls outside the equipment calendar appears as demand against zero capacity. Conflicts are diagnostic. levelResources provides a baseline leveling heuristic, described in Level resources. Optimization, setup sequencing and other leveling policies remain the planning application's concern.
Capacity that changes over time
capacityPeriods on a resource gives it a different capacity over fixed elapsed intervals, for example a second crew in a peak week, a reduced shift or a maintenance stop:
ts
const resources = [{
id: 'press', capacity: 2, periods: workingTime,
capacityPeriods: [
{ start: monday6, end: monday14, capacity: 3 }, // extra operator
{ start: tuesday10, end: tuesday12, capacity: 0 }, // maintenance
],
}]- Each period is half-open
[start, end)in absolute time, with integer endpoints,end > startand a nonnegative integercapacity. Periods of one resource must not overlap; adjacent periods are fine. A violation throws a RangeError that names the resource.levelResourcesalso requires the endpoints to align with the quantum, as it does forperiods. - Inside a capacity period its
capacityapplies; outside every capacity period the resource'scapacityapplies. Outside the availabilityperiodsthe capacity stays 0, whatever the capacity periods say: a capacity period does not make a closed resource available. calculateResourceLoadsplits its segments wherever the capacity changes, so each segment'scapacityandoverloadhold for its whole interval. A task that needs 3 units from 13:00 to 15:00 on a resource with capacity 2 until 14:00 and 3 after is overloaded by exactly 1 unit from 13:00 to 14:00 and not after. A capacity of 0 during downtime overloads only the work that falls into it; idle time needs nothing. A capacity period with the same capacity as its surroundings does not split a segment.- GanttChart draws the capacity line of each load segment at that segment's
capacity, so the line steps with the capacity when you pass the output ofcalculateResourceLoadasloadSegments.renderTimelineSvgdraws the same line. levelResourcesreserves capacity against the same step function, so leveling and the load calculation agree at every instant: a plan withoutunresolvedTaskIdshas no overload.
Assignments for part of a task
An assignment with workOffset or workDuration needs its resource only for part of the task's work, such as "the machine for the whole operation, one operator only for the first 30 minutes":
ts
const assignments = [
{ resourceId: 'machine', taskId: 'turn' },
{ resourceId: 'operator', taskId: 'turn', workDuration: 30 * minute },
{ resourceId: 'inspector', taskId: 'turn', workOffset: 90 * minute, workDuration: 15 * minute },
]- Both values are working time of the task, measured along its scheduled
worksegments in the units of the plan's times:workOffsetfrom the start of the task's work (default 0, a nonnegative integer) andworkDurationfrom there (a positive integer, default the rest of the work). Calendar breaks, pauses and leveling splits are skipped, so a 30-minute part that reaches lunch continues after lunch.assignmentWorkPeriods(work, assignment)returns the elapsed periods of the part. - The part is relative to the task, so it moves with the task. Capacity periods, in contrast, are fixed in absolute time: use them for what the resource can supply when, and partial assignments for what a task needs during its work.
- A part that reaches beyond the task's work is clipped to it. A part that starts at or after the end of the work takes no capacity. This keeps an assignment valid when the task gets shorter. Negative or fractional values, or a
workDurationof 0, throw a RangeError.levelResourcesalso requires both values to be multiples of the quantum. calculateResourceLoadadds the assignment's units only during its part, and lists the task in a segment'staskIdsonly there. Offsets count from the start of the whole work even whenrangestarts later.levelResourceschecks and reserves each resource only during its part of the work at each candidate placement. Two tasks that each need the single operator for their first hour can overlap after that hour. Asplittabletask pauses only where a resource it needs at that point of its work is short. A manual task is checked only over each part.projectResourceTimelineshows the whole task on the row of a partially assigned resource: a bar is the task, not the part. The load is computed from the scheduled tasks and the assignments, so nothing is counted twice. UseassignmentWorkPeriodsto draw the part yourself, for example assegmentsof that projection. A replacement withproposeResourceAssignmentkeeps the part.
Leveling remains the heuristic described in Level resources: with time-varying capacity and partial assignments it still places one task at a time at its earliest feasible start, and does not search for an optimal plan.
Other functions that read resources and assignments
| Function | Capacity periods and partial assignments |
|---|---|
calculateResourceLoad, levelResources | Use both, as described above |
toPlanningDiagnostics | Reads the overload of each load segment, which already reflects both |
buildPlacementInput | Copies resources and the assignments of placed tasks unchanged |
projectResourceTimeline, proposeResourceAssignment | Accept partial assignments; one bar per assignment for the whole task; a replacement keeps the part |
parseWeaveSnapshot, restoreWeaveSnapshot | A planning snapshot keeps both and reports invalid values as structure diagnostics |
resourceLoadFromMsProject, timelineFromMsProject | Never produce them: the Microsoft Project import does not read resource availability tables or assignment contours |
Level resources
levelResources({ ...scheduleInput, resources, assignments }) returns a schedule in which assigned load stays within capacity wherever a permitted delay allows. It uses the same resource and assignment rules as calculateResourceLoad, and resource periods must also align with the quantum. It is a deterministic serial heuristic, not an optimizer:
- It schedules the input with every task as soon as possible. A cycle or infeasible input returns that failure unchanged.
- It calculates latest dates for every task without the project finish, so a task can move later only while all of its successors stay feasible.
- It places tasks one at a time. The next task is the highest-ranked task whose predecessors are all placed. The rank uses the higher
priorityfirst (default 0), then the smaller unleveledtotalFloat, then the earlier unleveled start, then the task ID in code-unit order. - Each task gets the earliest start that its placed predecessors, own bounds and calendar allow and at which its assigned resources have enough remaining capacity for all of its work. A
splittabletask instead takes the earliest working units that have capacity and can pause in between. Milestones and tasks without assignments do not wait for capacity. - A task with no capacity-feasible placement before its latest dates stays at its earliest dates. It is listed in
unresolvedTaskIds, and its overload remains.
Manual tasks are placed before every other task, at their manual dates, and never move; a manual task whose dates lack capacity is listed in unresolvedTaskIds. Inactive tasks and their assignments are ignored.
The result has the fields of a successful scheduleTasks result for the leveled plan, plus:
leveledTasks: the input tasks with astartNoEarlierThanat the leveled start for delayed and split tasks, and addedpausesfor split tasks. Split tasks are pinned even when they start at their earliest date, so an end bound cannot pull their work away from the reserved capacity.scheduleTasksreproduces the same dates from them. Persist these when you accept the plan.delays: each task whose dates or work changed, in input order, withbeforeandafterintervals,delay(after.start - before.start, in elapsed units), the addedpauses, andcause. The cause iscapacitywhen leveling constrained the task itself, andpredecessorwhen only a dependency moved it.overloads: the overloaded segments ofcalculateResourceLoadfor the leveled plan. The list is empty when every task was resolved.unresolvedTaskIds: tasks that kept an overload, in input order.
Capacity periods and partial assignments take part in steps 4 and 5: a task needs each resource only during its part of the work, against the capacity valid at each time. See Compare demand with capacity.
Leveling ignores mode and omits it from leveledTasks, because placing a task later after capacity is reserved would reintroduce conflicts. The deadline, the horizon and every task bound remain hard limits. The unleveled project finish is not a limit, so the leveled finish can be later. calculateResourceLoad remains the diagnostic for any plan.
Try the demo
Open Scheduling and focus Cut order A. Press Right Arrow once to move its requested start from 08:00 to 09:00. Inspection moves to 13:00, projected finish moves from 16:00 to 17:00, and the CNC overlap grows from one to two resource-hours. Press Right Arrow again to see packing finish on 11 November after the 10 November closure. Further moves beyond the horizon leave the accepted plan on screen. Reset schedule restores the original dates.
Check Summary task links to add a small plan with a summary task. Its links end at the Build phase rollup bar; drag Frame to move the rollup bar and its links, select a link with Enter and remove it with Delete, or drag from a rollup handle to add one. FF and SF links into the summary are rejected with a message.
The status date slider (09 Nov 12:00 by default) draws the status-date line, and Show progress line draws the progress line from the reported progress: cutting order A is done, B is half done and inspection a quarter done. Reschedule from status date applies rescheduleFromStatusDate: B keeps its first hour and finishes after lunch, inspection keeps its first half hour and continues at 13:00, and packing moves to 14:30–16:30. At 09 Nov 08:00 the done hour of cutting order B cannot fit before the status date, so the demo catches the RangeError and reports it instead of changing the plan. The next edit recalculates the plan from the requested starts. Export MS Project XML, Export iCalendar and Export CSV save the current plan with toMsProjectXml, toICalendar and toCsv, and Network diagram shows it as a NetworkGraph built with scheduleToGraph.
Drag Cut order A two hours to the right with the pointer: while it is held, dashed outlines show inspection and packing at the dates propagateEdit computes for the new start, and the bars stay where they are. Release to accept the move and the cascaded operations as one batch; Escape discards the preview. A requested start inside the lunch break or on the closed day is previewed from the next working time, as the scheduler places it.
The link from Cut order B to packing has a two-hour lead (lag: -2 * hour), labelled −2 h: packing may overlap the last two hours of cutting order B. It does not bind in the original plan. Drag Cut order B five hours later, to 15:00–17:00: the preview moves packing to 15:00, two hours before B finishes, and releasing it applies the same dates. Without the lead packing would wait for 17:00 and move past the closure.
The demo shades breaks, nights and the closed date with invertWorkPeriods and builds its bars with scheduledBarFields. Inspection crosses the lunch break, so it is drawn as two work pieces. Critical tasks have a red outline, Cut order B shows its float as a thin line, and packing has a dispatch deadline at 17:00 on 9 November. After the second move, packing is split by the closure and marked late. Clear Shade non-working time or Show critical path and float to hide these layers, and use Export schedule SVG to save the chart with them.
Check Show scheduling constraints (off by default) to give packing a hard finishNoLaterThan at the 17:00 cut-off, which the scheduler applies, unlike the display-only deadline, and to show the requested start of each cutting order as a startNoEarlierThan handle. Drag the handle of Cut order B from 10:00 to 13:00: the demo applies the constraint-edit proposal to its tasks and reschedules. Drag it three hours further: packing can no longer finish by 17:00, so the demo shows the scheduler's diagnostic, "Infeasible: Pack order A cannot meet its finish no later than with the link Cut order B → Pack order A", and keeps the plan. Focus the handle to move it with the arrow keys or remove it with Delete. With the option on, Export MS Project XML writes packing's constraint as ConstraintType 7.
Check Schedule inspection manually to give inspection manual dates at its current plan. Its bar turns violet, shows no float and is never critical, and the Float column reads "manual". Move Cut order A later: inspection stays where it is, and the Manual date conflicts list names the link it now breaks (manualConflicts). Drag or resize the inspection bar instead: propagateEdit moves its manual dates, packing follows, and the conflict clears once the link is met again. A manual task keeps its elapsed length when moved, so moving it across the lunch break changes its work hours. Check Cancel order B (inactive) to make cutting order B inactive: its bar stays as a pale placeholder at its last dates, its links leave the chart and the network diagram, its CNC load leaves the load view (calculateResourceLoad with inactiveTaskIds), Export MS Project XML writes it with Active 0, and iCalendar leaves it out. Reset schedule turns both options off.
Terminology references include Microsoft Project dependency types and critical-path guidance.
Resource rows and unplanned tasks
A resource view shows each resource as a GanttChart row and each assignment as a bar. Build it with projectResourceTimeline from the placed tasks, the resources and the assignments, and keep the tasks and assignments as the data you edit and save. A task on two resources has two bars but is still one task: compute the load with calculateResourceLoad from the scheduled tasks and the original assignments, never from the projected bars.
ts
import { createResourceTimelineProjector, resolveResourceTimelineEdit, scheduledBarFields } from '@eightkk/vue-weave/core'
const project = createResourceTimelineProjector()
const projection = project({
resources: [{ id: 'cnc', label: 'CNC' }, { id: 'press', label: 'Press' }],
tasks: schedule.tasks.map(task => ({ id: task.id, label: names[task.id], ...scheduledBarFields(task) })),
assignments,
dependencies: links,
})
// <GanttChart :rows="projection.rows" :bars="projection.bars" :dependencies="projection.dependencies"
// :lane-count="projection.laneCount" row-draggable @edit="onEdit" />Keep the arrays you pass to the projector unchanged between renders: a new bars array cancels a drag in progress, and the projector returns the previous projection while its inputs are the same objects.
Edits arrive as ordinary edit events. resolveResourceTimelineEdit turns a horizontal move or resize into a task date change, which applies to every projection of the task, and a move to another row into an assignment replacement; a diagonal move gives both, which you accept or refuse together as one history step. A move to a resource the task already has is rejected. Removing a bar from a row is a choice between removing the assignment (proposeResourceAssignment with kind: 'remove') and removing the task. After a replacement the bar ID changes to resourceTimelineBarId(taskId, newResourceId). For cascade previews, pass resourceTimelineCascade(projection, input) as cascade: it runs propagateEdit on task IDs and maps the result back to every projection.
Chart links and scheduler links
ScheduleLink and TimelineDependency share a shape, so a task chart can use one array for both. A resource view cannot: chart links connect bar IDs and scheduler links connect task IDs. Pass the task links to the projection and the scheduler, and the projection's dependencies to the chart. Each task link is drawn once, between representative projections (the preferred bars you pass, else the first row of each task); dependencyOrigins maps it back and omittedDependencyIds lists the links whose other projection pairs are not drawn.
Unplanned tasks
An unplanned task is a task without dates, not a missing task. Do not give it invented dates. Pass its ID in unplannedTaskIds, where its assignments and links are accepted but not drawn, and leave it out of the scheduler with buildPlacementInput(input, placedTaskIds). (A task that has dates but should not count is an inactive task instead; see Manual and inactive tasks.) The scheduler and calculateResourceLoad throw for links and assignments to tasks they do not have; buildPlacementInput removes the unplaced tasks, their links and their assignments, so unplanned work does not count towards the load. A placed task whose predecessor is unplaced is reported as an unplaced-predecessor diagnostic and the result is not ok: refuse the placement, or place the predecessor too, instead of showing a plan that ignores the link.
Leveling previews
levelResources ignores mode, so an ALAP task is previewed at its earliest leveled dates. When a placement or edit preview shows a plan, say whether it came from scheduleTasks, which does not resolve capacity, or from levelResources, and decide explicitly whether an overload is allowed, a warning or a reason to refuse.
Explain a plan
Pass { explain: true } as the second argument of scheduleTasks or levelResources to get a trace with the reasons for each task's dates. The calculation is the same: the reasons are recorded where the normal passes place each task, and without the option no reason is created and the result is unchanged.
ts
import { collectScheduleReasons, scheduleTasks, toPlanningDiagnostics } from '@eightkk/vue-weave/core'
const plan = scheduleTasks(input, { explain: true })
if (plan.ok) {
const why = collectScheduleReasons(plan.trace, 'B', { phases: ['earliest'] })
}
const problems = toPlanningDiagnostics(plan)A task with manual dates has a manual reason in each phase instead of bounds, because nothing else places it. Each reason belongs to a phase. earliest is the forward pass and records the lower limits that set each task's earliest start or finish. latest is the backward pass and records the upper limits from successors, the project finish and the task's own bounds. placement records why an ALAP task was placed where it is. leveling records the limits and the capacity shortages met while levelResources reserved capacity; its latest reasons are those of the leveling horizon, which ignores the project finish.
For example, with A and B of duration 2, an FS link with lag 1 and a calendar with working time [0, 3) and [5, 12), B's candidate start is 3. Time 3 is not working time, because [0, 3) is half-open, so B starts at 5. The trace holds a dependency reason (candidate 3, placed 5, parent: A's reason) and a calendar reason (3 to 5). A pause that moves the task further is a separate pause reason, so calendar time off and the task's own pauses can be told apart. Lag is elapsed time, so the candidate is the predecessor's end plus the lag before any calendar applies.
When several limits are equal, all are reported, for example two FS predecessors that finish together. range is reported only when no other bound has the same value, as in failures.
Leveling records why it delayed or split a task as capacity reasons with the resource, the interval, the units needed, the capacity there and the tasks that already held it. They are recorded in the reservation loop, not taken from the replayed scheduleTasks run, so the startNoEarlierThan that leveling adds to leveledTasks is never reported as the cause. Adjacent shortages of one resource with the same capacity form one reason whose range covers them all and whose relatedTaskIds name every task holding the resource in it, in the order leveling placed them. A task that waits behind many short reservations therefore gets one reason per resource and run of equal capacity, not one per reservation; a change of capacity, a stretch with enough capacity left, or time outside the task's working time starts a new reason. A delay with cause: 'capacity' can also have dependency reasons when a predecessor moved too. A task that is listed in unresolvedTaskIds is not resolved even though the result is ok: true: do not show such a result as free of capacity conflicts. toPlanningDiagnostics lists it as leveling-unresolved next to its resource-overload segments.
Keep the three kinds of deadline apart:
ScheduleInput.deadlineis a hard limit on the whole project. It is reported as thedeadlineconstraint and aproject-boundreason.ScheduleTask.finishNoLaterThanis a hard limit on one task, reported as aconstraintreason.TimelineBar.deadlineis only drawn by GanttChart and never takes part in scheduling.
toPlanningDiagnostics(result, load?) lists cycles and infeasible tasks of a failure, or unresolved tasks and overloaded segments of a success. Each entry of manualConflicts becomes a manual-conflict warning (the task, then the link), listed before the unresolved tasks and overloads; the plan is still valid, so it is not an error. Its reasonIds hold the task's manual reason of the earliest phase when the result was calculated with explain. A failure lists only its own problems, so an earlier successful plan is never shown as current. propagateEdit and rescheduleFromStatusDate do not take the option.
Compare plan scenarios
comparePlans(current, candidate) compares a candidate plan with the current plan, for example after equipment maintenance is planned and the planner tries to push work later on the same equipment or to move it to other equipment. Keep three layers apart:
- Input: each plan is a
PlanScenariowhoseinputis thescheduleTasksinput with optionalresourcesandassignments. The candidate is a separate draft of the input; the current plan stays where it is (inuseEditHistoryoruseEditTransaction) and does not change while comparing. - Computed result: each side's schedule and load. Pass a precomputed
result(for example fromlevelResources) andload, or letcomparePlanscalculatescheduleTasks(input, { explain: true })andcalculateResourceLoad. The comparison itself is computed too: recalculate it whenever either plan changes, never store it. - View projection:
planComparisonTargetsturns compared tasks into the targets of the existing highlight props through your view bindings, andplanBaselinesturns the current plan into a baseline set for the candidate's bars.
ts
import { comparePlans, planBaselines, planComparisonTargets, scheduleTasks } from '@eightkk/vue-weave/core'
const comparison = comparePlans(
{ input: currentInput, revision: acceptedVersion },
{ input: candidateInput, baseRevision: candidateBaseVersion },
)
comparison.input.tasks.changed // [{ id: 'cutA', fields: ['startNoEarlierThan'] }]
comparison.input.resources.changed // [{ id: 'cnc', fields: ['periods'] }]
comparison.result.editedTaskIds // tasks the planner changed (fields or assignments)
comparison.result.consequenceTaskIds // tasks with unchanged input whose dates, critical flag or state moved
comparison.result.finish // { current, candidate, shift }
comparison.result.overload // cumulative overload per resource, both sides
// Draw the current plan under the candidate bars with the existing baseline sets.
const before = planBaselines(scheduleTasks(currentInput), 'current')
const bars = candidateTasks.map(task => ({ ...barOf(task), baselines: [before.get(task.id)!] }))
// <GanttChart :bars="bars" :baseline-ids="['current']" ... />What the comparison means:
- A task is edited when its own fields or its assignments differ (or it was added or removed). A task whose input is unchanged but whose result differs is a consequence. A changed dependency, calendar or resource is reported in
inputbut does not make a task edited. - When one side has no schedule (a cycle, or an infeasible plan such as a missed project
deadline),result.statesays so,result.comparableis false and the input differences are still returned; nothing throws. Its finish is undefined. - Invalid input throws the scheduler's own error (or that of the shared resource and assignment checks) with the side appended, for example
Duplicate task ID: a (candidate plan), so one message text covers bothscheduleTasksandcomparePlans. A side with a precomputedresultis validated the same way, and a successfulresultmust contain each active task of its input exactly once and list exactly its inactive tasks ininactiveTaskIds; otherwisecomparePlansthrows, for exampleThe result has no entry for task b, an active task of its input; recalculate it from this input (candidate plan). This catches a result calculated before a task was added, removed or (de)activated. It cannot catch a result for an older version of the same tasks, such as one calculated before a duration changed: recalculate the result whenever its input changes (or omitresultand letcomparePlanscalculate it), and keep your own revision with both if they are stored apart. A failed result is checked only for its shape, and apartialside's result must come from the loaded input passed with it. - Summary tasks are compared by their rolled-up dates, so a summary usually appears as a consequence of its subtasks. Manual tasks keep their dates; a link they now violate appears as a gained
manual-conflictviolation. Inactive tasks have the side stateinactive. deadlineviolations come fromPlanComparisonTask.deadline, a due time likeTimelineBar.deadlinethat the scheduler ignores. The hardScheduleInput.deadlineandfinishNoLaterThanmake a plan infeasible instead.- Cumulative overload is the sum of
overload * (end - start)over one resource's load segments, in your capacity units times your time units. It is never summed across resources. A task assigned to two resources counts once in each resource and never twice in one; overlapping segments of one resource in a suppliedloadthrow a RangeError. reasonsare each side's own trace reasons of a task. They explain that plan's dates; they are not a claim that one change caused the difference.
Adopting or discarding a candidate
The library leaves the decision to the application. The contract the demo follows:
- Creating a candidate records the revision of the current plan it was derived from (
baseRevision), and remembers the selection of the moment. - Comparing never changes the current plan. If the current plan advances (another planner's save, a server refresh), recalculate
comparePlansagainst the new current plan;comparison.revision.staleis then true, and the candidate must not be adopted as it is. - Adopting is one bulk change: commit the whole candidate input with one
history.commit(...), or oneuseEditTransaction.submit(changes)with all changes, so that one Undo reverts the adoption. - Discarding drops the draft. The current plan was never touched; restore the remembered selection.
- When a plan is only partly loaded (for example a windowed load of a large plan), set
partial: trueon that side.comparison.completeis then false; show the comparison as incomplete and do not adopt from it.
Try it in the demo: open Linked views and check Compare plan scenarios.
To compare other revisions that are not scheduler input, such as two versions of a bill of materials, a WBS or a product hierarchy, use diffStructure(before, after, { key, parentKey?, fields?, equals? }). It reports added and removed keys, the changed fields with their values in both versions and, with parentKey, the items that moved to another parent. Resolve effective dates first and diff the two resolved snapshots. See Structure comparison.