Skip to content

Commit

Permalink
Merge pull request #31 from regexident/fix-api-typos
Browse files Browse the repository at this point in the history
Fix API typos
  • Loading branch information
xgillard committed Jul 7, 2023
2 parents 87ae459 + 7ee1f1d commit adb714b
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 68 deletions.
2 changes: 1 addition & 1 deletion ddo/examples/alp/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn max_width<P: Problem>(p: &P, w: Option<usize>) -> Box<dyn WidthHeuristic<P::S
if let Some(w) = w {
Box::new(FixedWidth(w))
} else {
Box::new(NbUnassignedWitdh(p.nb_variables()))
Box::new(NbUnassignedWidth(p.nb_variables()))
}
}
/// An utility function to return a cutoff heuristic that can either be a time budget policy
Expand Down
2 changes: 1 addition & 1 deletion ddo/examples/alp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn solve_id(id: &str) -> isize {
let relaxation = AlpRelax::new(problem.clone());
let ranking = AlpRanking;

let width = NbUnassignedWitdh(problem.nb_variables());
let width = NbUnassignedWidth(problem.nb_variables());
let dominance = SimpleDominanceChecker::new(AlpDominance);
let cutoff = NoCutoff;
let mut fringe = NoDupFringe::new(MaxUB::new(&ranking));
Expand Down
8 changes: 4 additions & 4 deletions ddo/examples/golomb/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ impl Relaxation for GolombRelax<'_> {
/// solver is a `StateRanking`. This is an heuristic which is used to select the most
/// and least promising nodes as a means to only delete/merge the *least* promising nodes
/// when compiling restricted and relaxed DDs.
pub struct Golombranking;
impl StateRanking for Golombranking {
pub struct GolombRanking;
impl StateRanking for GolombRanking {
type State = GolombState;

fn compare(&self, a: &Self::State, b: &Self::State) -> std::cmp::Ordering {
Expand Down Expand Up @@ -219,7 +219,7 @@ fn max_width<T>(nb_vars: usize, w: Option<usize>) -> Box<dyn WidthHeuristic<T> +
if let Some(w) = w {
Box::new(FixedWidth(w))
} else {
Box::new(NbUnassignedWitdh(nb_vars))
Box::new(NbUnassignedWidth(nb_vars))
}
}

Expand All @@ -229,7 +229,7 @@ fn main() {
let args = Args::parse();
let problem = Golomb::new(args.size);
let relaxation = GolombRelax{pb: &problem};
let heuristic = Golombranking;
let heuristic = GolombRanking;
let width = max_width(problem.nb_variables(), args.width);
let dominance = EmptyDominanceChecker::default();
let cutoff = TimeBudget::new(Duration::from_secs(args.timeout));//NoCutoff;
Expand Down
6 changes: 3 additions & 3 deletions ddo/examples/golomb/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
//! This module is meant to tests the correctness of our golomb example
use ddo::*;

use crate::{Golomb, Golombranking, GolombRelax};
use crate::{Golomb, GolombRanking, GolombRelax};

pub fn solve_golomb(n: usize) -> isize {

let problem = Golomb::new(n);
let relaxation = GolombRelax{pb: &problem};
let heuristic = Golombranking;
let width = NbUnassignedWitdh(problem.nb_variables());
let heuristic = GolombRanking;
let width = NbUnassignedWidth(problem.nb_variables());
let dominance = EmptyDominanceChecker::default();
let cutoff = NoCutoff;
let mut fringe = SimpleFringe::new(MaxUB::new(&heuristic));
Expand Down
2 changes: 1 addition & 1 deletion ddo/examples/knapsack/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ fn max_width<T>(nb_vars: usize, w: Option<usize>) -> Box<dyn WidthHeuristic<T> +
if let Some(w) = w {
Box::new(FixedWidth(w))
} else {
Box::new(NbUnassignedWitdh(nb_vars))
Box::new(NbUnassignedWidth(nb_vars))
}
}

Expand Down
2 changes: 1 addition & 1 deletion ddo/examples/knapsack/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn solve_id(id: &str) -> isize {
let relaxation = KPRelax{pb: &problem};
let ranking = KPRanking;

let width = NbUnassignedWitdh(problem.nb_variables());
let width = NbUnassignedWidth(problem.nb_variables());
let dominance = SimpleDominanceChecker::new(KPDominance);
let cutoff = NoCutoff;
let mut fringe = NoDupFringe::new(MaxUB::new(&ranking));
Expand Down
2 changes: 1 addition & 1 deletion ddo/examples/lcs/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn max_width<P: Problem>(p: &P, w: Option<usize>) -> Box<dyn WidthHeuristic<P::S
if let Some(w) = w {
Box::new(FixedWidth(w))
} else {
Box::new(NbUnassignedWitdh(p.nb_variables()))
Box::new(NbUnassignedWidth(p.nb_variables()))
}
}
/// An utility function to return a cutoff heuristic that can either be a time budget policy
Expand Down
2 changes: 1 addition & 1 deletion ddo/examples/max2sat/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn max_width<P: Problem>(p: &P, w: Option<usize>) -> Box<dyn WidthHeuristic<P::S
if let Some(w) = w {
Box::new(FixedWidth(w))
} else {
Box::new(NbUnassignedWitdh(p.nb_variables()))
Box::new(NbUnassignedWidth(p.nb_variables()))
}
}

Expand Down
2 changes: 1 addition & 1 deletion ddo/examples/max2sat/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn solve_id(id: &str) -> isize {
let relaxation = Max2SatRelax(&problem);
let ranking = Max2SatRanking;

let width = NbUnassignedWitdh(problem.nb_variables());
let width = NbUnassignedWidth(problem.nb_variables());
let dominance = EmptyDominanceChecker::default();
let cutoff = NoCutoff;
let mut fringe = NoDupFringe::new(MaxUB::new(&ranking));
Expand Down
2 changes: 1 addition & 1 deletion ddo/examples/mcp/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ fn max_width<P: Problem>(p: &P, w: Option<usize>) -> Box<dyn WidthHeuristic<P::S
if let Some(w) = w {
Box::new(FixedWidth(w))
} else {
Box::new(NbUnassignedWitdh(p.nb_variables()))
Box::new(NbUnassignedWidth(p.nb_variables()))
}
}
2 changes: 1 addition & 1 deletion ddo/examples/mcp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn solve_id(id: &str) -> isize {
let relaxation = McpRelax::new(&problem);
let ranking = McpRanking;

let width = NbUnassignedWitdh(problem.nb_variables());
let width = NbUnassignedWidth(problem.nb_variables());
let dominance = EmptyDominanceChecker::default();
let cutoff = NoCutoff;
let mut fringe = NoDupFringe::new(MaxUB::new(&ranking));
Expand Down
2 changes: 1 addition & 1 deletion ddo/examples/misp/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ fn max_width<P: Problem>(p: &P, w: Option<usize>) -> Box<dyn WidthHeuristic<P::S
if let Some(w) = w {
Box::new(FixedWidth(w))
} else {
Box::new(NbUnassignedWitdh(p.nb_variables()))
Box::new(NbUnassignedWidth(p.nb_variables()))
}
}
/// An utility function to return a cutoff heuristic that can either be a time budget policy
Expand Down
2 changes: 1 addition & 1 deletion ddo/examples/misp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn solve_id(id: &str) -> isize {
let relaxation = MispRelax {pb: &&problem};
let ranking = MispRanking;

let width = NbUnassignedWitdh(problem.nb_variables());
let width = NbUnassignedWidth(problem.nb_variables());
let dominance = EmptyDominanceChecker::default();
let cutoff = NoCutoff;
let mut fringe = NoDupFringe::new(MaxUB::new(&ranking));
Expand Down
2 changes: 1 addition & 1 deletion ddo/examples/psp/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn max_width<P: Problem>(p: &P, w: Option<usize>) -> Box<dyn WidthHeuristic<P::S
if let Some(w) = w {
Box::new(FixedWidth(w))
} else {
Box::new(NbUnassignedWitdh(p.nb_variables()))
Box::new(NbUnassignedWidth(p.nb_variables()))
}
}
/// An utility function to return a cutoff heuristic that can either be a time budget policy
Expand Down
2 changes: 1 addition & 1 deletion ddo/examples/srflp/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn max_width<P: Problem>(p: &P, w: Option<usize>) -> Box<dyn WidthHeuristic<Srfl
if let Some(w) = w {
Box::new(SrflpWidth::new(p.nb_variables(), w))
} else {
Box::new(NbUnassignedWitdh(p.nb_variables()))
Box::new(NbUnassignedWidth(p.nb_variables()))
}
}
/// An utility function to return a cutoff heuristic that can either be a time budget policy
Expand Down
2 changes: 1 addition & 1 deletion ddo/examples/talentsched/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn max_width<P: Problem>(p: &P, w: Option<usize>) -> Box<dyn WidthHeuristic<P::S
if let Some(w) = w {
Box::new(FixedWidth(w))
} else {
Box::new(NbUnassignedWitdh(p.nb_variables()))
Box::new(NbUnassignedWidth(p.nb_variables()))
}
}
/// An utility function to return a cutoff heuristic that can either be a time budget policy
Expand Down
24 changes: 12 additions & 12 deletions ddo/src/implementation/heuristics/width.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl <X> WidthHeuristic<X> for FixedWidth {
/// # profit : vec![60, 100, 120],
/// # weight : vec![10, 20, 30]
/// };
/// let heuristic = NbUnassignedWitdh(problem.nb_variables());
/// let heuristic = NbUnassignedWidth(problem.nb_variables());
/// let subproblem= SubProblem {
/// # state: Arc::new(KnapsackState{depth: 3, capacity: 2}),
/// # value: 5,
Expand All @@ -267,7 +267,7 @@ impl <X> WidthHeuristic<X> for FixedWidth {
/// ```
///
/// # Typical usage example
/// Typically, you will only ever create a NbUnassignedWitdh policy when instanciating
/// Typically, you will only ever create a NbUnassignedWidth policy when instanciating
/// your solver. The following example shows how you create a solver that imposes
/// a maximum layer width of one node per unassigned variable.
///
Expand Down Expand Up @@ -388,14 +388,14 @@ impl <X> WidthHeuristic<X> for FixedWidth {
/// &problem,
/// &relaxation,
/// &heuristic,
/// &NbUnassignedWitdh(problem.nb_variables()),
/// &NbUnassignedWidth(problem.nb_variables()),
/// &dominance,
/// &cutoff,
/// &mut fringe);
/// ```
#[derive(Default, Debug, Copy, Clone)]
pub struct NbUnassignedWitdh(pub usize);
impl <X> WidthHeuristic<X> for NbUnassignedWitdh {
pub struct NbUnassignedWidth(pub usize);
impl <X> WidthHeuristic<X> for NbUnassignedWidth {
fn max_width(&self, x: &SubProblem<X>) -> usize {
self.0 - x.path.len()
}
Expand Down Expand Up @@ -489,7 +489,7 @@ impl <X> WidthHeuristic<X> for NbUnassignedWitdh {
/// # profit : vec![60, 100, 120],
/// # weight : vec![10, 20, 30]
/// };
/// let heuristic = Times(5, NbUnassignedWitdh(problem.nb_variables()));
/// let heuristic = Times(5, NbUnassignedWidth(problem.nb_variables()));
/// let subproblem= SubProblem {
/// # state: Arc::new(KnapsackState{depth: 3, capacity: 2}),
/// # value: 5,
Expand Down Expand Up @@ -627,7 +627,7 @@ impl <X> WidthHeuristic<X> for NbUnassignedWitdh {
/// &problem,
/// &relaxation,
/// &heuristic,
/// &Times(5, NbUnassignedWitdh(problem.nb_variables())),
/// &Times(5, NbUnassignedWidth(problem.nb_variables())),
/// &dominance,
/// &cutoff,
/// &mut fringe);
Expand Down Expand Up @@ -729,7 +729,7 @@ impl <S, X: WidthHeuristic<S>> WidthHeuristic<S> for Times<X> {
/// # profit : vec![60, 100, 120],
/// # weight : vec![10, 20, 30]
/// };
/// let heuristic = DivBy(2, NbUnassignedWitdh(problem.nb_variables()));
/// let heuristic = DivBy(2, NbUnassignedWidth(problem.nb_variables()));
/// let subproblem= SubProblem {
/// # state: Arc::new(KnapsackState{depth: 3, capacity: 2}),
/// # value: 5,
Expand Down Expand Up @@ -866,7 +866,7 @@ impl <S, X: WidthHeuristic<S>> WidthHeuristic<S> for Times<X> {
/// &problem,
/// &relaxation,
/// &heuristic,
/// &DivBy(2, NbUnassignedWitdh(problem.nb_variables())),
/// &DivBy(2, NbUnassignedWidth(problem.nb_variables())),
/// &dominance,
/// &cutoff,
/// &mut fringe);
Expand All @@ -890,7 +890,7 @@ mod test_nbunassigned {
#[test]
fn non_empty() {
// assume a problem with 5 variables
let heu = NbUnassignedWitdh(5);
let heu = NbUnassignedWidth(5);
let sub = SubProblem {
state: Arc::new('a'),
value: 10,
Expand All @@ -902,7 +902,7 @@ mod test_nbunassigned {
}
#[test]
fn all() {
let heu = NbUnassignedWitdh(5);
let heu = NbUnassignedWidth(5);
let sub = SubProblem {
state: Arc::new('a'),
value: 10,
Expand All @@ -915,7 +915,7 @@ mod test_nbunassigned {
#[test]
fn empty() {
// assume a problem with 5 variables
let heu = NbUnassignedWitdh(5);
let heu = NbUnassignedWidth(5);
let sub = SubProblem {
state: Arc::new('a'),
value: 10,
Expand Down
Loading

0 comments on commit adb714b

Please sign in to comment.