|
@ -25,13 +25,23 @@ fn main() { |
|
|
let city = City::read_from_file("01.in", city::INPUT_CITY_WIDTH, city::INPUT_CITY_HEIGHT); |
|
|
let city = City::read_from_file("01.in", city::INPUT_CITY_WIDTH, city::INPUT_CITY_HEIGHT); |
|
|
eprintln!("Loaded the city file, {} houses", city.get_house_count()); |
|
|
eprintln!("Loaded the city file, {} houses", city.get_house_count()); |
|
|
|
|
|
|
|
|
const MIN_WEIGHT_SCORE: f64 = 540000.; |
|
|
const MIN_WEIGHT_SCORE: f64 = 530000.; |
|
|
const MAX_WEIGHT_SCORE: f64 = 570000.; |
|
|
const MAX_WEIGHT_SCORE: f64 = 540000.; |
|
|
const DB_CHOICE_PROBABILITY: f64 = 0.99; |
|
|
const DB_CHOICE_PROBABILITY: f64 = 0.99; |
|
|
|
|
|
const START_WITH_MERGE: bool = false; |
|
|
|
|
|
|
|
|
//let best_layouts = db.layouts().iter()
|
|
|
//let best_layouts: Vec<_> = db.layouts().iter()
|
|
|
// .sorted_by(|x, y| city::get_price(&city, x.houses()).cmp(&city::get_price(&city, y.houses())))
|
|
|
// .sorted_by(|x, y| city::get_price(&city, x.houses()).cmp(&city::get_price(&city, y.houses())))
|
|
|
// .take_while(|x| city::get_price(&city, x.houses()) < 550000);
|
|
|
// .take_while(|x| city::get_price(&city, x.houses()) < 535000)
|
|
|
|
|
|
// .map(|x| x.clone())
|
|
|
|
|
|
// .collect();
|
|
|
|
|
|
|
|
|
|
|
|
//if let Some(best_layout) = db.layouts().iter()
|
|
|
|
|
|
// .sorted_by(|x, y| city::get_price(&city, x.houses()).cmp(&city::get_price(&city, y.houses())))
|
|
|
|
|
|
// .next() {
|
|
|
|
|
|
// eprintln!("Printing best layout, ID {}, price {}", best_layout.id(), city::get_price(&city, best_layout.houses()));
|
|
|
|
|
|
// print_houses(best_layout.houses());
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
let mut best_price: Option<u32> = None; |
|
|
let mut best_price: Option<u32> = None; |
|
|
|
|
|
|
|
@ -52,9 +62,11 @@ fn main() { |
|
|
//populate_from_saved_layout(&mut layout, &best_layout);
|
|
|
//populate_from_saved_layout(&mut layout, &best_layout);
|
|
|
//eprintln!("Finished loading DB layout ID {}, price: {}, houses: {}", best_layout.id(), layout.price(), layout.houses().len());
|
|
|
//eprintln!("Finished loading DB layout ID {}, price: {}, houses: {}", best_layout.id(), layout.price(), layout.houses().len());
|
|
|
|
|
|
|
|
|
optimization::iterate_improvements(&mut layout, &mut rng, true, START_WITH_MERGE); |
|
|
let improved = optimization::iterate_improvements(&mut layout, &mut rng, true, START_WITH_MERGE); |
|
|
dump_layout(&layout, &mut best_price, seed); |
|
|
dump_layout(&layout, &mut best_price, seed); |
|
|
|
|
|
//if improved {
|
|
|
db.add_layout(&layout.houses(), true).expect("Failed to insert into DB"); |
|
|
db.add_layout(&layout.houses(), true).expect("Failed to insert into DB"); |
|
|
|
|
|
//}
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|