Back to examples

Shift planning by the hour

A week on a small production line. Three orders go through a press, a CNC mill and a paint booth; each job takes 30 to 180 minutes and runs on the early (06:00–14:00) or the late (14:00–22:00) shift. Parts cool for an hour after pressing and paint cures for two. Level the plan by the hour, take the press down on Tuesday afternoon, or move a shift end, and the plan is scheduled again.

Minutes, hours and shifts

The engine counts every amount in working minutes: duration_unit: "minute" for jobs, lag_unit: "hour" for cooling and curing. Shifts are calendars with their hours, and the axis above the chart shows only 06:00–22:00, the hours the machines run. See Working time and calendars.

The plan
project.solve({
  config: {
    calendar_mode: "resource",
    duration_unit: "minute",
    apply_constraints: true,
  },
  calendars: [
    { id: "early",
      worktime: { hours: ["06:00-14:00"], days: [0, 1, 1, 1, 1, 1, 0] } },
    { id: "late",
      worktime: { hours: ["14:00-22:00"], days: [0, 1, 1, 1, 1, 1, 0] } },
    { id: "press",
      worktime: { hours: ["06:00-22:00"], days: [0, 1, 1, 1, 1, 1, 0] } },
    // one calendar per machine and shift:
    // the shift, minus the machine's downtime
    { id: "press-late", base: "late" },
    // …
  ],
  tasks: [
    { id: 8, start_date: "2026-08-10 00:00", duration: 150,
      calendar_id: "press-late" },
    // …
  ],
  links: [
    // cooling
    { id: 6, source: 8, target: 9, type: "fs", lag: 1, lag_unit: "hour" },
  ],
  resources: [
    { id: "press", calendar_id: "press" },
    { id: "late-crew", capacity: 2, calendar_id: "late" },
  ],
  assignments: [
    { task: 8, resource: "press", value: 1 },
    { task: 8, resource: "late-crew", value: 1 },
  ],
});

Machine and crew work the same hours

Every job is assigned to its machine and to its shift’s crew. When the two resources have different calendars, the engine lets each assignment run the job’s duration on its own calendar, so the press and the crew could book different hours. The demo avoids that with one calendar per machine and shift (press-late), set on the job. Both assignments then work exactly the job’s hours, and the load rows of a machine and its crew show the same booked hours.

The press goes down

The button adds the downtime to the press calendar and to every press job calendar it touches. A date rule lists the hours that remain, so the late press calendar keeps 18:00–22:00 on Tuesday. Order C’s die change and pressing wait for 18:00, and its milling and painting move after it. Jobs on other machines stay where they are.

A downtime
// "Press down Tue 14:00–18:00": a date rule lists the hours that remain.
{ id: "press", worktime: {
  /* … */
  dates: { "2026-08-11": ["06:00-14:00", "18:00-22:00"] },
} }
{ id: "press-late", base: "late", worktime: {
  dates: { "2026-08-11": ["18:00-22:00"] },
} }

Level by the hour

Orders A and B arrive together on Monday and both want the press. Level by hour runs the forward leveler on hour buckets: jobs are placed in dependency order at the first hour their machine and crew are free. The load rows under the chart are an hour loadProfile, in percent of each resource’s capacity. Read more in Leveling resources, or see a day-scale version in the leveling demo.

Load and leveling by the hour
const profile = project.loadProfile({
  from: "2026-08-10 00:00", to: "2026-08-15 00:00", basis: "hour", tasks: "all",
});
const result = project.level({ strategy: "forward", basis: "hour" });
// result.rounds, result.passes, result.converged, result.overallocations