Skip to content

Commit

Permalink
chore(jsp): Improve debug formatting of operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
arbimo committed Nov 9, 2024
1 parent c07b983 commit 82a2ddb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion examples/scheduling/src/problem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use aries::model::lang::linear::LinearSum;
use aries::model::lang::max::{EqMax, EqMin};
use aries::model::lang::{IAtom, IVar};
use itertools::Itertools;
use std::fmt::{Debug, Formatter};

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[allow(clippy::enum_variant_names)]
Expand Down Expand Up @@ -137,7 +138,7 @@ pub struct Operation {
end: IAtom,
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub struct OperationId {
pub job: u32,
pub op: u32,
Expand All @@ -146,6 +147,17 @@ pub struct OperationId {
pub alt: Option<u32>,
}

impl Debug for OperationId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "({}, {}, ", self.job, self.op)?;
if let Some(alt) = self.alt {
write!(f, "{alt})")
} else {
write!(f, ")")
}
}
}

/// Represents one alternative to an operation
#[derive(Clone)]
pub struct OperationAlternative {
Expand Down

0 comments on commit 82a2ddb

Please sign in to comment.