use solverforge_core::score::SoftScore;
use solverforge_core::PlanningSolution;
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub(super) struct RelShift {
pub(super) id: u32,
pub(super) night: bool,
}
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub(super) struct RelAssignment {
pub(super) shift_id: u32,
pub(super) employee_code: String,
}
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub(super) struct RelEmployee {
pub(super) code: String,
}
#[derive(Clone)]
pub(super) struct RelSchedule {
pub(super) shifts: Vec<RelShift>,
pub(super) assignments: Vec<RelAssignment>,
pub(super) employees: Vec<RelEmployee>,
pub(super) score: Option<SoftScore>,
}
impl PlanningSolution for RelSchedule {
type Score = SoftScore;
fn score(&self) -> Option<Self::Score> {
self.score
}
fn set_score(&mut self, score: Option<Self::Score>) {
self.score = score;
}
}
pub(super) fn rel_shifts(schedule: &RelSchedule) -> &[RelShift] {
schedule.shifts.as_slice()
}
pub(super) fn rel_assignments(schedule: &RelSchedule) -> &[RelAssignment] {
schedule.assignments.as_slice()
}
pub(super) fn rel_employees(schedule: &RelSchedule) -> &[RelEmployee] {
schedule.employees.as_slice()
}
pub(super) fn sample() -> RelSchedule {
RelSchedule {
shifts: vec![
RelShift {
id: 10,
night: true,
},
RelShift {
id: 11,
night: false,
},
],
assignments: vec![
RelAssignment {
shift_id: 10,
employee_code: "e0".to_string(),
},
RelAssignment {
shift_id: 11,
employee_code: "e1".to_string(),
},
RelAssignment {
shift_id: 10,
employee_code: "e0".to_string(),
},
],
employees: vec![
RelEmployee {
code: "e0".to_string(),
},
RelEmployee {
code: "e1".to_string(),
},
],
score: None,
}
}
pub(super) fn coincidence_sample() -> RelSchedule {
RelSchedule {
shifts: vec![RelShift {
id: 10,
night: true,
}],
assignments: vec![RelAssignment {
shift_id: 10,
employee_code: "e0".to_string(),
}],
employees: vec![
RelEmployee {
code: "e0".to_string(),
},
RelEmployee {
code: "10".to_string(),
},
],
score: None,
}
}
pub(super) fn assignment_key(assignment: &RelAssignment) -> u32 {
assignment.shift_id
}
pub(super) fn shift_key(shift: &RelShift) -> u32 {
shift.id
}