schedulrv0.14.0

API overview

The entry points of the crate at a glance. Item-level documentation for the released version is on docs.rs.

Full generated documentation for the latest release: docs.rs/schedulr. Everything below is exported from the crate root (use schedulr::…).

Batch planning

fncompilesince 0.1
pub fn compile(problem: &SchedulingProblem) -> Result<CompiledProblem, CompileError>

Validates the problem and builds the constraint model. All validation errors are collected into one CompileError.

structCompiledProblem
impl CompiledProblem {
  pub fn solve(&self) -> SolveResult
  pub fn solve_with(&self, options: &SolveOptions) -> SolveResult
  pub fn explain(&self, result: &SolveResult) -> Vec<Conflict>
  pub fn check(&self, solution: &Solution) -> SolutionCheck
  pub fn analyze(&self) -> Analysis
  pub fn evaluate_move(&self, solution: &Solution, activity: ActivityId, proposed: TimeWindow) -> MoveEvaluation
  pub fn suggest(&self, solution: &Solution, proposed: TimeWindow) -> Vec<Suggestion>
  pub fn evaluate_changes(&self, solution: &Solution, changes: &[ChangeRequest]) -> ChangeEvaluation
  pub fn repair(&self, baseline: &Solution, options: &RepairOptions) -> SolveResult
  pub fn repair_with_outcome(&self, baseline: &Solution, options: &RepairOptions) -> RepairResult
}

The compiled model. See Analysis and repair.

fnchecksince 0.9
pub fn check(&self, solution: &Solution) -> SolutionCheck

Evaluates every constraint against a complete or partial solution without changing it. A missing assignment is a blocking Unassigned conflict, an unknown activity a blocking ActivityDomain conflict. Equivalent to the union of the per-assignment no-op probes, in one call.

fncompare
pub fn compare(before: &Solution, after: &Solution) -> SolutionComparison

Lists added, removed and changed assignments and the score delta between two solutions.

Buckets

fnbucket_windows
pub fn bucket_windows(
  template: Option<&ScheduleTemplate>,
  min_value: i64,
  max_value: i64,
) -> Vec<BucketWindow>

The period buckets the day and bucket rules are measured in: one per day of the template, repeated every cycle, or the whole range without a template. See Day and bucket rules.

fnbucket_load_pattern
pub fn bucket_load_blocks(assignments: &[(ActivityId, TimeWindow)], buckets: &[TimeWindow]) -> Vec<Vec<i64>>
pub fn bucket_load_pattern(assignments: &[(ActivityId, TimeWindow)], buckets: &[TimeWindow]) -> Vec<i64>
pub fn matches_bucket_load_pattern(
  pattern: &BucketLoadPattern,
  assignments: &[(ActivityId, TimeWindow)],
  buckets: &[TimeWindow],
) -> bool

Block lengths per bucket, all block lengths largest first, and whether they match a BucketLoadPattern — the same measurement the solver uses, for plans outside it.

Single-activity checks

structSchedulingStatesince 0.1
impl SchedulingState {
  pub fn new(
      resources: impl IntoIterator<Item = Resource>,
      participants: impl IntoIterator<Item = Participant>,
      resource_pools: impl IntoIterator<Item = ResourcePool>,
  ) -> Self
  pub fn check_feasibility(&self, proposal: &ProposedActivity) -> Vec<Conflict>
  pub fn commit(&mut self, proposal: ProposedActivity) -> Result<ActivityId, Vec<Conflict>>
  pub fn cancel(&mut self, activity: ActivityId) -> Option<(Activity, Assignment)>
  pub fn proposal_for(&self, activity: ActivityId) -> Option<ProposedActivity>
}

In-memory booking state. See Booking single activities.

Model types

Type Role
SchedulingProblem Everything the batch path needs, built with with_* methods
TimeWindow Half-open integer interval [start, end)
Resource, ResourcePool Capacity-constrained entities and named sets of them
Participant, ParticipantPool, ParticipantGroup, GroupMembership People, interchangeable sets, attending groups
Activity, ProposedActivity Batch demand, and one exact change for SchedulingState
ResourceRequirement, ParticipantRequirement Exact or solver-chosen resources and people
ParticipantConflictPolicy Whether a participant conflict blocks or is only reported
ScheduleTemplate, DayTemplate, SlotTemplate, BreakTemplate, AcademicPeriod Calendars
ParticipantChoiceGroup Activities that must choose the same participant
Recurrence Instances of a recurring activity, for with_recurring_activity
ScoreRule, ScoreRuleKind, ScoreLevel Preferences for one activity
ActivityRelation, ActivityRelationConstraint Relations between activities, hard or soft
SoftPenalty Makes a hard rule or relation a preference (.soft(...))
MaximumDailyLoad, MinimumBreak, MaximumActiveBuckets Load, breaks and active days of one entity, see Day and bucket rules
DayRule, DayRuleKind The shape of one entity’s day
MaximumBucketStarts, MaximumDistinctPerBucket, ConsecutiveRunLimit Starts, distinct groups and back-to-back runs of activities per bucket
BucketLoadPattern, BucketWindow Allowed block shapes of a group of activities, and the buckets they are measured in
TimePreference, IdleBounds Preferred times and free-time band of one entity, see Goals and preferences
SoftGoal, SoftGoalKind Global preferences: idle time, room stability, spreading over days
ActivityGoal, ActivityGoalKind, ProximityMode Distribution of a set of activities over the buckets
ResourceCostGoal, RoomChangeGoal Resource ranking, room changes and travel
IsolatedBlockGoal, JointPresenceGoal, ConcurrentFreeGoal Lone blocks, joint presence, simultaneous free time
SolveOptions, SolveStrategy, CancellationToken Time limit, strategy and cancellation for solve_with
RepairOptions Settings for repair: start and assignment penalties, frozen activities, cancellation, time limit
RepairOutcome, RepairResult Whether repair_with_outcome repaired or fell back to solve

Result types

Type Role
SolveResult, SolveStatus, SolveStatistics Outcome of solve and repair
Solution, Assignment Placed activities with resources and participants
SolutionCheck Full verdict on one solution: feasibility, conflicts, score
Score, ScoreComponent Aggregated score and per-rule contributions
Conflict, ConflictSeverity, EntityRef Structured conflicts, see Conflicts and errors
CompileError All validation messages of a failed compile
Analysis, Bottleneck, MoveEvaluation, Suggestion, SolutionComparison, AssignmentChange Results of the analysis functions
ChangeRequest, ChangeEvaluation A batch of edits for evaluate_changes, and its verdict
ChangeAspects Which parts of an AssignmentChange differ
AbortReason Why a search stopped early

Edit this page on GitHub · Docs for v0.14.0