Skip to main content

dpm_schedule/
projection.rs

1use dpm_model::WorkItemId;
2use serde::{Deserialize, Serialize};
3use std::collections::BTreeMap;
4#[derive(Debug, Clone, Serialize, Deserialize)]
5/// Earliest/latest times and float for one activity, in elapsed hours after the origin.
6pub struct ActivitySchedule {
7    /// Minimum feasible start relative to the projection origin.
8    pub earliest_start_hours: f64,
9    /// Earliest start plus activity duration.
10    pub earliest_finish_hours: f64,
11    /// Latest start that does not delay project completion.
12    pub latest_start_hours: f64,
13    /// Latest start plus activity duration.
14    pub latest_finish_hours: f64,
15    /// Delay available without postponing project completion.
16    pub total_float_hours: f64,
17    /// Delay available without moving any direct successor's earliest start or project completion.
18    pub free_float_hours: f64,
19    /// Whether total float is within numerical tolerance of zero.
20    pub critical: bool,
21    /// Calendar the task follows and how long its verification waits for the verifier, when the
22    /// plan has calendars.
23    #[serde(default, skip_serializing_if = "Option::is_none")]
24    pub calendar: Option<ActivityCalendar>,
25}
26
27#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
28/// How calendars place one task in a remaining projection.
29pub struct ActivityCalendar {
30    /// Calendar, executor kind and the rule that chose them.
31    #[serde(flatten)]
32    pub resolved: dpm_model::ResolvedCalendar,
33    /// Hours between the end of execution and verification at the earliest times, waiting for
34    /// the verifier's calendar.
35    pub review_wait_hours: f64,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
39/// Derived critical-path projection for the entire graph.
40pub struct Schedule {
41    /// Earliest possible completion of every activity.
42    pub project_finish_hours: f64,
43    /// Activity projections indexed by work identity.
44    pub activities: BTreeMap<WorkItemId, ActivitySchedule>,
45    /// Work identities with zero total float.
46    pub critical_activities: Vec<WorkItemId>,
47    /// Every constraint between scheduled activities, with its slack at the earliest times.
48    #[serde(default)]
49    pub relations: BTreeMap<dpm_model::DependencyId, RelationSchedule>,
50}
51
52#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
53/// How tightly one constraint binds its successor in the projection.
54pub struct RelationSchedule {
55    /// How far the successor's constrained event lies past the bound this constraint puts on it.
56    pub slack_hours: f64,
57    /// The constraint sets its successor's earliest start, or on calendars holds its finish: its
58    /// slack is within tolerance of zero.
59    pub driving: bool,
60    /// A driving constraint between two critical activities, so it lies on a critical path.
61    pub critical: bool,
62}