Skip to main content

Interface: ModelBuilderConfig

Configuration for ModelBuilder.

Example

const config: ModelBuilderConfig = {
  employees: [...],
  shiftPatterns: [...],
  coverage: [...],
  schedulingPeriod: {
    dateRange: { start: '2025-02-03', end: '2025-02-09' },
    daysOfWeek: ['wednesday', 'thursday', 'friday', 'saturday', 'sunday'],
  },
};

Extends

Properties

coverage

coverage: CoverageRequirement[];

coverageBucketMinutes?

optional coverageBucketMinutes: number;
Bucket size used when translating coverage requirements into time-indexed constraints. Smaller buckets are more accurate but increase the number of constraints.

Inherited from

ModelBuilderOptions.coverageBucketMinutes

employees

employees: SchedulingEmployee[];

fairDistribution?

optional fairDistribution: boolean;
Whether to enable fair distribution of shifts across team members. When enabled (default), the solver minimizes the maximum number of shifts any single person works, ensuring work is distributed evenly. Each person works between floor(total/n) and ceil(total/n) shifts. Disable this if you want other rules (like employee-assignment-priority) to have full control over shift distribution.

Default

true;

Inherited from

ModelBuilderOptions.fairDistribution

reporter?

optional reporter: ValidationReporter;
Optional validation reporter for diagnostics.

ruleConfigs?

optional ruleConfigs: CpsatRuleConfigEntry[];
Named rule configurations that will be compiled using the provided rule factories.

ruleFactories?

optional ruleFactories: CpsatRuleFactories;
Rule factories to use when compiling ruleConfigs. Defaults to built-in CP-SAT rules.

rules?

optional rules: CompilationRule[];
Pre-compiled rules; use this for custom rules that are not part of the registry.

schedulingPeriod

schedulingPeriod: SchedulingPeriod;
Defines when scheduling should occur as a date range with optional daysOfWeek and dates filters that compose to narrow which days are included.

shiftPatterns

shiftPatterns: ShiftPattern[];

solverOptions?

optional solverOptions: {
  solutionLimit?: number;
  timeLimitSeconds?: number;
};

solutionLimit?

optional solutionLimit: number;

timeLimitSeconds?

optional timeLimitSeconds: number;

Inherited from

ModelBuilderOptions.solverOptions

weekStartsOn?

optional weekStartsOn: DayOfWeek;

Inherited from

ModelBuilderOptions.weekStartsOn