Skip to main content

Type Aliases

TimeInterval

Ƭ TimeInterval: Object

Type declaration


ScheduleWeights

Ƭ ScheduleWeights: Readonly<{ lateness: Readonly<{ per_us: bigint ; weight: bigint }> ; move: Readonly<{ weight: bigint }> ; crewChange: Readonly<{ weight: bigint }> }> Integer soft-rule weights, exact and shared by every consumer.

PlacementCost

Ƭ PlacementCost: Object

Type declaration


IntervalSource

Ƭ IntervalSource: Object One table’s interval rows: an index ending with <interval>.start after the resource field, as interval constraints declare it.

Type declaration


SlotCapacity

Ƭ SlotCapacity: Object The bookings’ cumulative constraint, as scheduling.slots reads it: a fixed capacity or capacity windows whose field holds it, and the declared maxDuration.

Type declaration


Slot

Ƭ Slot: Object

Type declaration


SlotReader

Ƭ SlotReader: Object Not exported: an exported type refers to it.

Type declaration


JobShopProblem

Ƭ JobShopProblem: Infer<typeof problemValidator>

JobShopCandidate

Ƭ JobShopCandidate: Infer<typeof jobShop.candidate>

Properties

candidate

• candidate: VObject<{ bookings: { resource: string; job: string; during: { start: bigint; end: bigint; }; }[] ; objective: bigint }, { bookings: VArray<{ resource: string ; job: string ; during: { start: bigint; end: bigint; } }[], VObject<{ resource: string ; job: string ; during: { start: bigint; end: bigint; } }, { job: VString<string, "required"> ; resource: VString<string, "required"> ; during: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> }, "required", "resource" | "job" | "during" | "during.start" | "during.end">, "required"> ; objective: VInt64<bigint, "required"> }, "required", "bookings" | "objective">

Variables

scheduling

• Const scheduling: Readonly<{ slots: (ctx: SlotReader, options: { job: { _id?: GenericId<string> ; duration_us: bigint ; release_at: bigint ; due_at: bigint ; demand?: bigint } ; resources: readonly GenericId<string>[] ; window: TimeInterval ; bookings: IntervalSource & { job: string ; demand?: string } ; availability: IntervalSource ; weights: ScheduleWeights ; step: string | bigint ; limit: number ; rest?: string | bigint ; current?: { resource: GenericId<string> ; during: TimeInterval } | null ; capacity?: SlotCapacity }) => Promise<{ resources: { resource: GenericId<string> ; slots: Slot[] }[] ; is_complete: boolean }> }>

jobShopJob

• Const jobShopJob: VObject<{ previous: null | { resource: string; during: { start: bigint; end: bigint; }; } ; eligible: string[] ; job: string ; uses: { units: bigint; pool: string; }[] ; due_at: bigint ; duration_us: bigint ; release_at: bigint }, { job: VString<string, "required"> ; duration_us: VInt64<bigint, "required"> ; release_at: VInt64<bigint, "required"> ; due_at: VInt64<bigint, "required"> ; eligible: VArray<string[], VString<string, "required">, "required"> ; uses: VArray<{ units: bigint ; pool: string }[], VObject<{ units: bigint ; pool: string }, { pool: VString<string, "required"> ; units: VInt64<bigint, "required"> }, "required", "units" | "pool">, "required"> ; previous: VUnion<null | { resource: string ; during: { start: bigint; end: bigint; } }, [VObject<{ resource: string ; during: { start: bigint; end: bigint; } }, { resource: VString<string, "required"> ; during: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> }, "required", "resource" | "during" | "during.start" | "during.end">, VNull<null, "required">], "required", "resource" | "during" | "during.start" | "during.end"> }, "required", "previous" | "eligible" | "job" | "uses" | "due_at" | "duration_us" | "release_at" | "previous.resource" | "previous.during" | "previous.during.start" | "previous.during.end"> One job of the job-shop problem: duration, release, due time, eligible resources, the units of shared pools it holds while it runs and its current placement.

jobShop

• Const jobShop: Readonly<{ input: { problemRevision: VLiteral<"job-shop/v2", "required"> ; horizon: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> ; jobs: VArray<{ previous: null | { resource: string; during: { start: bigint; end: bigint; }; } ; eligible: string[] ; job: string ; uses: { units: bigint; pool: string; }[] ; due_at: bigint ; duration_us: bigint ; release_at: bigint }[], VObject<{ previous: null | { resource: string; during: { start: bigint; end: bigint; }; } ; eligible: string[] ; job: string ; uses: { units: bigint; pool: string; }[] ; due_at: bigint ; duration_us: bigint ; release_at: bigint }, { job: VString<string, "required"> ; duration_us: VInt64<bigint, "required"> ; release_at: VInt64<bigint, "required"> ; due_at: VInt64<bigint, "required"> ; eligible: VArray<string[], VString<string, "required">, "required"> ; uses: VArray<{ units: bigint ; pool: string }[], VObject<{ units: bigint ; pool: string }, { pool: VString<string, "required"> ; units: VInt64<bigint, "required"> }, "required", "units" | "pool">, "required"> ; previous: VUnion<null | { resource: string ; during: { start: bigint; end: bigint; } }, [VObject<{ resource: string ; during: { start: bigint; end: bigint; } }, { resource: VString<string, "required"> ; during: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> }, "required", "resource" | "during" | "during.start" | "during.end">, VNull<null, "required">], "required", "resource" | "during" | "during.start" | "during.end"> }, "required", "previous" | "eligible" | "job" | "uses" | "due_at" | "duration_us" | "release_at" | "previous.resource" | "previous.during" | "previous.during.start" | "previous.during.end">, "required"> ; windows: VArray<{ resource: string ; during: { start: bigint; end: bigint; } }[], VObject<{ resource: string ; during: { start: bigint; end: bigint; } }, { resource: VString<string, "required"> ; during: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> }, "required", "resource" | "during" | "during.start" | "during.end">, "required"> ; fixed: VArray<{ resource: string ; uses: { units: bigint; pool: string; }[] ; during: { start: bigint; end: bigint; } }[], VObject<{ resource: string ; uses: { units: bigint; pool: string; }[] ; during: { start: bigint; end: bigint; } }, { resource: VString<string, "required"> ; during: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> ; uses: VArray<{ units: bigint ; pool: string }[], VObject<{ units: bigint ; pool: string }, { pool: VString<string, "required"> ; units: VInt64<bigint, "required"> }, "required", "units" | "pool">, "required"> }, "required", "resource" | "uses" | "during" | "during.start" | "during.end">, "required"> ; pools: VArray<{ units: bigint ; pool: string ; during: { start: bigint; end: bigint; } }[], VObject<{ units: bigint ; pool: string ; during: { start: bigint; end: bigint; } }, { pool: VString<string, "required"> ; during: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> ; units: VInt64<bigint, "required"> }, "required", "units" | "pool" | "during" | "during.start" | "during.end">, "required"> ; weights: VObject<{ move: bigint ; lateness: bigint ; crew_change: bigint ; lateness_per_us: bigint }, { lateness_per_us: VInt64<bigint, "required"> ; lateness: VInt64<bigint, "required"> ; move: VInt64<bigint, "required"> ; crew_change: VInt64<bigint, "required"> }, "required", "move" | "lateness" | "crew_change" | "lateness_per_us"> } ; candidate: VObject<{ bookings: { resource: string; job: string; during: { start: bigint; end: bigint; }; }[] ; objective: bigint }, { bookings: VArray<{ resource: string ; job: string ; during: { start: bigint; end: bigint; } }[], VObject<{ resource: string ; job: string ; during: { start: bigint; end: bigint; } }, { job: VString<string, "required"> ; resource: VString<string, "required"> ; during: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> }, "required", "resource" | "job" | "during" | "during.start" | "during.end">, "required"> ; objective: VInt64<bigint, "required"> }, "required", "bookings" | "objective"> }> The interval-shaped scheduling problem a customer solver receives: jobs; each resource’s working windows; fixed bookings that stay, with the pool units they hold; each shared pool’s capacity windows (a crew or equipment pool holds units at once, none outside its windows), the soft rule weights; and the horizon. Pass jobShop.input and jobShop.candidate to the compute component’s defineProblem; a problem that reads its jobs from a pinned dataset declares jobShopJob rows instead.

problemValidator

• Const problemValidator: VObject<{ fixed: { resource: string; uses: { units: bigint; pool: string; }[]; during: { start: bigint; end: bigint; }; }[] ; horizon: { start: bigint; end: bigint; } ; windows: { resource: string; during: { start: bigint; end: bigint; }; }[] ; problemRevision: "job-shop/v2" ; jobs: { previous: { resource: string; during: { start: bigint; end: bigint; }; } | null; eligible: string[]; job: string; uses: { units: bigint; pool: string; }[]; due_at: bigint; duration_us: bigint; release_at: bigint; }[] ; pools: { units: bigint; pool: string; during: { start: bigint; end: bigint; }; }[] ; weights: { move: bigint; lateness: bigint; crew_change: bigint; lateness_per_us: bigint; } }, { problemRevision: VLiteral<"job-shop/v2", "required"> ; horizon: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> ; jobs: VArray<{ previous: null | { resource: string; during: { start: bigint; end: bigint; }; } ; eligible: string[] ; job: string ; uses: { units: bigint; pool: string; }[] ; due_at: bigint ; duration_us: bigint ; release_at: bigint }[], VObject<{ previous: null | { resource: string; during: { start: bigint; end: bigint; }; } ; eligible: string[] ; job: string ; uses: { units: bigint; pool: string; }[] ; due_at: bigint ; duration_us: bigint ; release_at: bigint }, { job: VString<string, "required"> ; duration_us: VInt64<bigint, "required"> ; release_at: VInt64<bigint, "required"> ; due_at: VInt64<bigint, "required"> ; eligible: VArray<string[], VString<string, "required">, "required"> ; uses: VArray<{ units: bigint ; pool: string }[], VObject<{ units: bigint ; pool: string }, { pool: VString<string, "required"> ; units: VInt64<bigint, "required"> }, "required", "units" | "pool">, "required"> ; previous: VUnion<null | { resource: string ; during: { start: bigint; end: bigint; } }, [VObject<{ resource: string ; during: { start: bigint; end: bigint; } }, { resource: VString<string, "required"> ; during: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> }, "required", "resource" | "during" | "during.start" | "during.end">, VNull<null, "required">], "required", "resource" | "during" | "during.start" | "during.end"> }, "required", "previous" | "eligible" | "job" | "uses" | "due_at" | "duration_us" | "release_at" | "previous.resource" | "previous.during" | "previous.during.start" | "previous.during.end">, "required"> ; windows: VArray<{ resource: string ; during: { start: bigint; end: bigint; } }[], VObject<{ resource: string ; during: { start: bigint; end: bigint; } }, { resource: VString<string, "required"> ; during: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> }, "required", "resource" | "during" | "during.start" | "during.end">, "required"> ; fixed: VArray<{ resource: string ; uses: { units: bigint; pool: string; }[] ; during: { start: bigint; end: bigint; } }[], VObject<{ resource: string ; uses: { units: bigint; pool: string; }[] ; during: { start: bigint; end: bigint; } }, { resource: VString<string, "required"> ; during: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> ; uses: VArray<{ units: bigint ; pool: string }[], VObject<{ units: bigint ; pool: string }, { pool: VString<string, "required"> ; units: VInt64<bigint, "required"> }, "required", "units" | "pool">, "required"> }, "required", "resource" | "uses" | "during" | "during.start" | "during.end">, "required"> ; pools: VArray<{ units: bigint ; pool: string ; during: { start: bigint; end: bigint; } }[], VObject<{ units: bigint ; pool: string ; during: { start: bigint; end: bigint; } }, { pool: VString<string, "required"> ; during: VObject<{ start: bigint ; end: bigint }, { start: VInt64<bigint, "required"> ; end: VInt64<bigint, "required"> }, "required", "start" | "end"> ; units: VInt64<bigint, "required"> }, "required", "units" | "pool" | "during" | "during.start" | "during.end">, "required"> ; weights: VObject<{ move: bigint ; lateness: bigint ; crew_change: bigint ; lateness_per_us: bigint }, { lateness_per_us: VInt64<bigint, "required"> ; lateness: VInt64<bigint, "required"> ; move: VInt64<bigint, "required"> ; crew_change: VInt64<bigint, "required"> }, "required", "move" | "lateness" | "crew_change" | "lateness_per_us"> }, "required", "fixed" | "horizon" | "windows" | "problemRevision" | "jobs" | "pools" | "weights" | "horizon.start" | "horizon.end" | "weights.move" | "weights.lateness" | "weights.crew_change" | "weights.lateness_per_us"> Not exported: an exported type refers to it.

Functions

scheduleWeights

▸ scheduleWeights(rules): ScheduleWeights Declare the soft rules: scheduleWeights(\{ lateness: \{ per: "1h", weight: 10n \}, move: \{ weight: 3n \}, crewChange: \{ weight: 1n \} \}). Omitted rules weigh zero.

Parameters

Returns

ScheduleWeights

placementCost

▸ placementCost(weights, job, placement, current): PlacementCost The weighted cost of placing a job on resource during during, given its current booking if any.

Parameters

Returns

PlacementCost

mergeIntervals

▸ mergeIntervals(intervals): TimeInterval[] Disjoint, sorted intervals: adjacent and overlapping inputs merge.

Parameters

Returns

TimeInterval[]

freeIntervals

▸ freeIntervals(windows, busy, rest?): TimeInterval[] windows minus busy, each busy interval padded by rest on both sides.

Parameters

Returns

TimeInterval[]

slotStarts

▸ slotStarts(free, options): Object Every start aligned to step (from the epoch) where duration fits in one free interval within window and after release.

Parameters

Returns

Object

jobShopWeights

▸ jobShopWeights(problem): ScheduleWeights The problem’s weights as scheduleWeights.

Parameters

Returns

ScheduleWeights

capacityExceeded

▸ capacityExceeded(holds, windows): bigint | null The first instant at which the summed units of holds exceed the capacity of the window containing it (zero where none does), or null. Intervals are half-open, so a hold ending when another starts never stacks with it: the same rule the cumulative constraint enforces.

Parameters

Returns

bigint | null

verifySchedule

▸ verifySchedule(problem, candidate): Object Recheck a solver’s candidate independently of the model that produced it: every job placed once on an eligible resource for exactly its duration, no earlier than its release and inside the horizon, within the union of that resource’s windows, overlapping neither another placement nor a fixed booking, every pool within its capacity at every instant, and an objective equal to the recomputed cost.

Parameters

Returns

Object

partitionJobShop

▸ partitionJobShop(problem): JobShopProblem[] Split a problem into independent partitions: jobs that can share a resource or a pool stay together, and each partition carries only its resources’ windows, its pools’ capacity windows and the fixed bookings on either. The cost is a sum over jobs, so the partitions’ optimal objectives add up to the whole problem’s, and each partition can be solved, verified and applied in its own transaction. A job no resource admits is its own partition, which no solver can place. Partitions are ordered by their smallest job identity.

Parameters

Returns

JobShopProblem[]