pumpkin_solver/propagators/cumulative/time_table/explanations/
mod.rspub(crate) mod big_step;
pub(crate) mod naive;
pub(crate) mod pointwise;
use std::fmt::Display;
use std::rc::Rc;
use big_step::create_big_step_predicate_propagating_task_lower_bound_propagation;
use big_step::create_big_step_predicate_propagating_task_upper_bound_propagation;
use naive::create_naive_predicate_propagating_task_lower_bound_propagation;
use naive::create_naive_predicate_propagating_task_upper_bound_propagation;
use pointwise::create_pointwise_predicate_propagating_task_lower_bound_propagation;
use pointwise::create_pointwise_predicate_propagating_task_upper_bound_propagation;
use super::time_table_util::ResourceProfile;
use crate::engine::propagation::PropagationContext;
use crate::predicates::Predicate;
use crate::predicates::PropositionalConjunction;
use crate::propagators::Task;
use crate::variables::IntegerVariable;
#[derive(Debug, Clone, Copy, Default)]
pub enum CumulativeExplanationType {
Naive,
#[default]
BigStep,
PointWise,
}
impl Display for CumulativeExplanationType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
CumulativeExplanationType::Naive => write!(f, "naive"),
CumulativeExplanationType::BigStep => write!(f, "big-step"),
CumulativeExplanationType::PointWise => write!(f, "pointwise"),
}
}
}
pub(crate) fn create_predicate_propagating_task_lower_bound_propagation<
Var: IntegerVariable + 'static,
>(
explanation_type: CumulativeExplanationType,
context: &PropagationContext,
task: &Rc<Task<Var>>,
profile: &ResourceProfile<Var>,
time_point: Option<i32>,
) -> Predicate {
match explanation_type {
CumulativeExplanationType::Naive => {
create_naive_predicate_propagating_task_lower_bound_propagation(context, task)
}
CumulativeExplanationType::BigStep => {
create_big_step_predicate_propagating_task_lower_bound_propagation(task, profile)
}
CumulativeExplanationType::PointWise => {
create_pointwise_predicate_propagating_task_lower_bound_propagation(task, time_point)
}
}
}
pub(crate) fn add_propagating_task_predicate_lower_bound<Var: IntegerVariable + 'static>(
mut explanation: PropositionalConjunction,
explanation_type: CumulativeExplanationType,
context: &PropagationContext,
task: &Rc<Task<Var>>,
profile: &ResourceProfile<Var>,
time_point: Option<i32>,
) -> PropositionalConjunction {
explanation.add(create_predicate_propagating_task_lower_bound_propagation(
explanation_type,
context,
task,
profile,
time_point,
));
explanation
}
pub(crate) fn create_predicate_propagating_task_upper_bound_propagation<
Var: IntegerVariable + 'static,
>(
explanation_type: CumulativeExplanationType,
context: &PropagationContext,
task: &Rc<Task<Var>>,
profile: &ResourceProfile<Var>,
time_point: Option<i32>,
) -> Predicate {
match explanation_type {
CumulativeExplanationType::Naive => {
create_naive_predicate_propagating_task_upper_bound_propagation(context, task)
}
CumulativeExplanationType::BigStep => {
create_big_step_predicate_propagating_task_upper_bound_propagation(
task, profile, context,
)
}
CumulativeExplanationType::PointWise => {
create_pointwise_predicate_propagating_task_upper_bound_propagation(task, time_point)
}
}
}
pub(crate) fn add_propagating_task_predicate_upper_bound<Var: IntegerVariable + 'static>(
mut explanation: PropositionalConjunction,
explanation_type: CumulativeExplanationType,
context: &PropagationContext,
task: &Rc<Task<Var>>,
profile: &ResourceProfile<Var>,
time_point: Option<i32>,
) -> PropositionalConjunction {
explanation.add(create_predicate_propagating_task_upper_bound_propagation(
explanation_type,
context,
task,
profile,
time_point,
));
explanation
}