Skip to content

Commit

Permalink
style: cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Shi-Raida committed Oct 31, 2024
1 parent 3617a6b commit 18404ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
8 changes: 4 additions & 4 deletions examples/sat/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ fn solve_multi_threads(model: Model, opt: &Opt, deadline: Option<Instant>) -> Re
let choices: Vec<_> = model.state.variables().map(|v| Lit::geq(v, 1)).collect();
let solver = Box::new(Solver::new(model));

let search_params: Vec<_> = opt.search.split(",").collect();
let search_params: Vec<_> = opt.search.split(',').collect();
let num_threads = search_params.len();

let conflict_params = |conf: &str| {
let mut params = Params::default();
for opt in conf.split(":") {
for opt in conf.split(':') {
let handled = params.configure(opt);
if !handled {
panic!("UNSUPPORTED OPTION: {opt}")
Expand All @@ -119,8 +119,8 @@ fn solve_multi_threads(model: Model, opt: &Opt, deadline: Option<Instant>) -> Re
};

let mut par_solver = ParSolver::new(solver, num_threads, |id, solver| {
let search_params: Vec<_> = search_params[id].split("/").collect();
let stable_params = if search_params.len() > 0 {
let search_params: Vec<_> = search_params[id].split('/').collect();
let stable_params = if !search_params.is_empty() {
search_params[0]
} else {
"+lrb:+p+l:-neg"
Expand Down
19 changes: 10 additions & 9 deletions examples/scheduling/src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ struct Strat {
pub fn get_solver(base: Solver, strategy: &SearchStrategy, pb: &Encoding, num_threads: usize) -> ParSolver {
let mut base_solver = Box::new(base);

let mut load_conf = |conf: &str| -> Strat {
let load_conf = |conf: &str| -> Strat {
let mut mode = Mode::Stable;
let mut params = conflicts::Params::default();
params.heuristic = conflicts::Heuristic::LearningRate;
params.active = conflicts::ActiveLiterals::Reasoned;
params.impact_measure = ImpactMeasure::LBD;
let mut params = conflicts::Params {
heuristic: conflicts::Heuristic::LearningRate,
active: conflicts::ActiveLiterals::Reasoned,
impact_measure: ImpactMeasure::LBD,
..Default::default()
};
for opt in conf.split(':') {
if params.configure(opt) {
// handled
Expand All @@ -111,7 +113,7 @@ pub fn get_solver(base: Solver, strategy: &SearchStrategy, pb: &Encoding, num_th
SearchStrategy::Default => "stable:+sol",
SearchStrategy::Custom(conf) => conf.as_str(),
};
let all_strats = conf.split("/").map(|s| load_conf(s)).collect_vec();
let all_strats = conf.split('/').map(load_conf).collect_vec();

let decision_lits: Vec<Lit> = base_solver
.model
Expand All @@ -131,8 +133,7 @@ pub fn get_solver(base: Solver, strategy: &SearchStrategy, pb: &Encoding, num_th
Mode::Stable => (2000, 1.2), // stable: few restarts
Mode::Focused => (800, 1.0), // focused: always aggressive restarts
};
let brancher = brancher.with_restarts(restart_period, restart_update);
brancher
brancher.with_restarts(restart_period, restart_update)
};

// build a brancher that alternates between the proposed strategies
Expand Down Expand Up @@ -160,7 +161,7 @@ pub fn get_solver(base: Solver, strategy: &SearchStrategy, pb: &Encoding, num_th
.collect_vec();

// conflict based search, possibly alternating between several strategies
let branchers = strats.into_iter().map(|strat| build_brancher(strat)).collect_vec();
let branchers = strats.into_iter().map(build_brancher).collect_vec();
let brancher = round_robin(branchers);

// search strategy. For the first one simply add a greedy EST strategy to bootstrap the search
Expand Down

0 comments on commit 18404ea

Please sign in to comment.