OpenBI Docs Buy

SCHEDULE OpenBI

A job shop's schedule, solved with OR-Tools' CP-SAT: each task's start and end on its machine, and all of them done as early as possible.

Group: Operations research. OpenBI’s own: DAX has no function of this name.

Syntax

SCHEDULE ( <tasks>, <job>, <machine>, <duration> [, <order>] [, <seconds>] )
ParameterTypeDescription
tasksTableThe tasks: a row each, such as the Brewing table.
jobExpression
evaluated for each row
The row's job, such as a batch: its tasks run one after another.
machineExpression
evaluated for each row
The row's machine, such as a kettle, which handles a single task at once.
durationExpression
evaluated for each row
How long the task takes, 0 or more, in whole units such as hours (rounded).
orderExpression
optional, evaluated for each row
The task's place in its job, such as a step number. Left out, the tasks of a job run in the order of the rows.
secondsNumber
optional
How long the solver may search: 5 when left out, at most 120.

Returns

Table. A row for each task, the tasks of a job together: Job, Order (1 for the job's first task), Machine, Start, End and Duration in the durations' units from 0, then Makespan (when the last task ends) and Optimal (TRUE when no schedule can be shorter).

Remarks

  • Each job's tasks run in their order, no machine handles two tasks at once, and the makespan, the time when everything is done, is made as short as the solver can within the seconds given.
  • Start and End are numbers of units from the start of the schedule, not dates. Add them to a start date in the units the durations are in (hours / 24 for days) to place them on a calendar.
  • Optimal is TRUE when the solver proved that no shorter schedule exists; FALSE means the schedule is the best it found in time.
  • When several schedules are equally short, which one comes back may change from one session to the next; the makespan does not. The same question asked again while the engine runs gets the same schedule.
  • Rows with a blank job, machine or duration are left out; a table with no task left, a negative duration or more than 5,000 tasks is an error.

Compared with DAX

An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.

Examples

Next week's brewing

Six batches of the Brewing table on one mash tun, one kettle, three fermenters, a press and a bottling line, in hours. Both IPA batches need fermenter B for 36 hours, after 9 hours of mashing and boiling and before 4 of bottling: no schedule takes less than 85 hours.

EVALUATE
SELECTCOLUMNS (
    SCHEDULE ( Brewing, Brewing[Batch], Brewing[Equipment], Brewing[Hours], Brewing[Step] ),
    "Batch", [Job],
    "Step", [Order],
    "Equipment", [Machine],
    "From hour", [Start],
    "To hour", [End]
)
BatchStepEquipmentFrom hourTo hour
Pils 411Mash tun1014
Pils 412Kettle1417
Pils 413Fermenter A3060
Pils 414Bottling line6066
IPA 171Mash tun05
IPA 172Kettle59
IPA 173Fermenter B945
IPA 174Bottling line4549
Cider 91Press06
Cider 92Fermenter A630
Cider 93Bottling line3035
Lettøl 121Mash tun1821
Lettøl 122Kettle2124
Lettøl 123Fermenter C5171
Lettøl 124Bottling line7176
Pils 421Mash tun1418
Pils 422Kettle1821
Pils 423Fermenter C2151
Pils 424Bottling line5157
IPA 181Mash tun510
IPA 182Kettle1014
IPA 183Fermenter B4581
IPA 184Bottling line8185

Only the makespan is certain

EVALUATE
VAR Plan = SCHEDULE ( Brewing, Brewing[Batch], Brewing[Equipment], Brewing[Hours], Brewing[Step] )
RETURN
    ROW ( "Hours in all", MAXX ( Plan, [Makespan] ), "Optimal", MAXX ( Plan, IF ( [Optimal], 1, 0 ) ) = 1 )
Hours in allOptimal
85TRUE

Two jobs, two machines

Job A needs the cutter, then the welder; job B the other way round. Each machine serves one job while the other waits: 5 hours, and only one way to do it in 5.

EVALUATE
VAR Tasks =
    DATATABLE (
        "Job", STRING, "Step", INTEGER, "Machine", STRING, "Hours", INTEGER,
        {
            { "A", 1, "Cutter", 3 },
            { "A", 2, "Welder", 2 },
            { "B", 1, "Welder", 3 },
            { "B", 2, "Cutter", 2 }
        }
    )
RETURN
    SELECTCOLUMNS (
        SCHEDULE ( Tasks, [Job], [Machine], [Hours], [Step] ),
        "Job", [Job],
        "Machine", [Machine],
        "Start", [Start],
        "End", [End],
        "Makespan", [Makespan]
    )
JobMachineStartEndMakespan
ACutter035
AWelder355
BWelder035
BCutter355

ROUTES, OPTIMIZE, MAXX.

Last updated · OpenBI Studio 0.3.74