pumpkin_solver/propagators/cumulative/
options.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use std::fmt::Display;

use super::CumulativeExplanationType;

#[derive(Debug, Default, Clone, Copy)]
pub(crate) struct CumulativePropagatorOptions {
    /// Specifies whether it is allowed to create holes in the domain; if this parameter is set to
    /// false then it will only adjust the bounds when appropriate rather than removing values from
    /// the domain
    pub(crate) allow_holes_in_domain: bool,
    /// The type of explanation which is used by the cumulative to explain propagations and
    /// conflicts.
    pub(crate) explanation_type: CumulativeExplanationType,
    /// Determines whether a sequence of profiles is generated when explaining a propagation.
    pub(crate) generate_sequence: bool,
}

#[derive(Debug, Copy, Clone, Default)]
pub struct CumulativeOptions {
    /// The propagation method which is used for the cumulative constraints; currently all of them
    /// are variations of time-tabling. The default is incremental time-tabling reasoning over
    /// intervals.
    pub(crate) propagation_method: CumulativePropagationMethod,
    /// The options which are passed to the propagator itself
    pub(crate) propagator_options: CumulativePropagatorOptions,
}

impl CumulativeOptions {
    pub fn new(
        allow_holes_in_domain: bool,
        explanation_type: CumulativeExplanationType,
        generate_sequence: bool,
        propagation_method: CumulativePropagationMethod,
    ) -> Self {
        Self {
            propagation_method,
            propagator_options: CumulativePropagatorOptions {
                allow_holes_in_domain,
                explanation_type,
                generate_sequence,
            },
        }
    }
}

#[derive(Debug, Default, Clone, Copy)]
pub enum CumulativePropagationMethod {
    TimeTablePerPoint,
    TimeTablePerPointIncremental,
    TimeTableOverInterval,
    #[default]
    TimeTableOverIntervalIncremental,
}

impl Display for CumulativePropagationMethod {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            CumulativePropagationMethod::TimeTablePerPoint => write!(f, "time-table-per-point"),
            CumulativePropagationMethod::TimeTablePerPointIncremental => {
                write!(f, "time-table-per-point-incremental")
            }
            CumulativePropagationMethod::TimeTableOverInterval => {
                write!(f, "time-table-over-interval")
            }
            CumulativePropagationMethod::TimeTableOverIntervalIncremental => {
                write!(f, "time-table-over-interval-incremental")
            }
        }
    }
}