use super::*;
use crate::{CoefficientError, VariableIDSet};
impl Constraint<Created> {
pub fn reduce_binary_power(
&mut self,
binary_ids: &VariableIDSet,
) -> Result<bool, CoefficientError> {
self.stage.function.reduce_binary_power(binary_ids)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::quadratic;
#[test]
fn test_constraint_reduce_binary_power() {
let binary_ids = crate::variable_ids!(1);
let function = Function::Quadratic((quadratic!(1, 1) + quadratic!(2)).unwrap());
let mut constraint: Constraint<Created> = Constraint {
equality: Equality::LessThanOrEqualToZero,
stage: CreatedData { function },
};
let changed = constraint.reduce_binary_power(&binary_ids).unwrap();
assert!(changed);
let expected_function = Function::Quadratic((quadratic!(1) + quadratic!(2)).unwrap());
assert_eq!(constraint.stage.function, expected_function);
}
}