Browse Source

Do not redo steps that would not improve the solution

master
Jirka Sejkora 4 years ago
parent
commit
b3cf776618
  1. 16
      src/main.rs

16
src/main.rs

@ -36,18 +36,25 @@ fn main() {
MIN_WEIGHT_SCORE, MAX_WEIGHT_SCORE, DB_CHOICE_PROBABILITY);
population::populate_using_db(&mut layout, &mut rng, &db, MIN_WEIGHT_SCORE, MAX_WEIGHT_SCORE, DB_CHOICE_PROBABILITY);
eprintln!("Finished random init, price: {}, houses: {}", layout.price(), layout.houses().len());
let mut last_improved_step = -1;
loop {
let mut improved = false;
if last_improved_step == 1 {
break;
}
eprintln!("Starting moving individual houses...");
if optimization::improve_move_individual_houses(&mut layout, &mut rng) {
dump_layout(&layout, &mut best_price, seed);
improved = true;
last_improved_step = 1;
}
eprintln!("Finished moving individual houses...");
if last_improved_step == 2 {
break;
}
eprintln!("Starting pairwise house merge...");
if optimization::improve_merge_pairwise(&mut layout) {
dump_layout(&layout, &mut best_price, seed);
improved = true;
last_improved_step = 2;
}
eprintln!("Finished pairwise house merge");
//eprintln!("Starting pairwise house move...");
@ -56,9 +63,6 @@ fn main() {
// improved = true;
//}
//eprintln!("Finished pairwise house move");
if !improved {
break;
}
}
db.add_layout(&layout.houses(), true).expect("Failed to insert into DB");
}

Loading…
Cancel
Save