|
@ -5,6 +5,7 @@ use std::fmt::Formatter; |
|
|
use std::collections::{HashMap, HashSet}; |
|
|
use std::collections::{HashMap, HashSet}; |
|
|
use city::{HouseLayout, City, House}; |
|
|
use city::{HouseLayout, City, House}; |
|
|
use crate::db::LayoutDB; |
|
|
use crate::db::LayoutDB; |
|
|
|
|
|
use crate::population::build_house_probabilities; |
|
|
|
|
|
|
|
|
mod optimization; |
|
|
mod optimization; |
|
|
mod population; |
|
|
mod population; |
|
@ -16,6 +17,12 @@ fn main() { |
|
|
eprintln!("Loaded the DB, {} stored layouts", db.layouts().len()); |
|
|
eprintln!("Loaded the DB, {} stored layouts", db.layouts().len()); |
|
|
|
|
|
|
|
|
let city = City::read_from_file("01.in"); |
|
|
let city = City::read_from_file("01.in"); |
|
|
|
|
|
eprintln!("Loaded the city file, {} houses", city.get_house_count()); |
|
|
|
|
|
|
|
|
|
|
|
const MIN_WEIGHT_SCORE: f64 = 600000.; |
|
|
|
|
|
const MAX_WEIGHT_SCORE: f64 = 700000.; |
|
|
|
|
|
const DB_CHOICE_PROBABILITY: f64 = 0.9; |
|
|
|
|
|
|
|
|
let mut best_price: Option<u32> = None; |
|
|
let mut best_price: Option<u32> = None; |
|
|
|
|
|
|
|
|
loop { |
|
|
loop { |
|
@ -23,8 +30,11 @@ fn main() { |
|
|
eprintln!("Starting seed {}", seed); |
|
|
eprintln!("Starting seed {}", seed); |
|
|
let mut rng = StdRng::seed_from_u64(seed); |
|
|
let mut rng = StdRng::seed_from_u64(seed); |
|
|
let mut layout = HouseLayout::new(&city); |
|
|
let mut layout = HouseLayout::new(&city); |
|
|
eprintln!("Starting random population..."); |
|
|
//eprintln!("Starting random population...");
|
|
|
population::populate_random(&mut layout, &mut rng); |
|
|
//population::populate_random(&mut layout, &mut rng);
|
|
|
|
|
|
eprintln!("Starting random population, using DB ({}-{} {})...", |
|
|
|
|
|
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: {}", layout.price()); |
|
|
eprintln!("Finished random init, price: {}", layout.price()); |
|
|
loop { |
|
|
loop { |
|
|
let mut improved = false; |
|
|
let mut improved = false; |
|
|