1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use abstio::MapName;
use abstutil::Timer;
use sim::prebake::prebake;
use sim::{ScenarioGenerator, SimFlags};
use synthpop::Scenario;

use crate::sandbox::TutorialState;

pub fn prebake_all() {
    let mut timer = Timer::new("prebake all challenge results");

    {
        let map =
            map_model::Map::load_synchronously(MapName::seattle("montlake").path(), &mut timer);
        for generator in TutorialState::scenarios_to_prebake(&map) {
            let scenario = generator.generate(
                &map,
                &mut SimFlags::for_test("prebaked").make_rng(),
                &mut timer,
            );
            // Don't record a summary for this
            prebake(&map, scenario, &mut timer);
        }
    }

    let mut summaries = Vec::new();
    for name in vec![
        //MapName::seattle("arboretum"),
        MapName::seattle("montlake"),
        //MapName::seattle("lakeslice"),
        //MapName::seattle("phinney"),
        //MapName::seattle("qa"),
        //MapName::seattle("wallingford"),
    ] {
        let map = map_model::Map::load_synchronously(name.path(), &mut timer);
        let scenario: Scenario =
            abstio::read_binary(abstio::path_scenario(map.get_name(), "weekday"), &mut timer);
        summaries.push(prebake(&map, scenario, &mut timer));
    }

    // Since adding off-map traffic, these all gridlock now
    if false {
        let pbury_map = map_model::Map::load_synchronously(
            MapName::new("gb", "poundbury", "center").path(),
            &mut timer,
        );
        for scenario_name in ["base", "go_active", "base_with_bg", "go_active_with_bg"] {
            let scenario: Scenario = abstio::read_binary(
                abstio::path_scenario(pbury_map.get_name(), scenario_name),
                &mut timer,
            );
            summaries.push(prebake(&pbury_map, scenario, &mut timer));
        }
    }

    // Started gridlocking with more realistic pedestrian crossing behavior
    if false {
        let tehran_map = map_model::Map::load_synchronously(
            MapName::new("ir", "tehran", "parliament").path(),
            &mut timer,
        );
        let scenario = ScenarioGenerator::proletariat_robot(
            &tehran_map,
            &mut SimFlags::for_test("prebaked").make_rng(),
            &mut timer,
        );
        summaries.push(prebake(&tehran_map, scenario, &mut timer));
    }

    {
        let map = map_model::Map::load_synchronously(
            MapName::new("br", "sao_paulo", "sao_miguel_paulista").path(),
            &mut timer,
        );
        let scenario: Scenario =
            abstio::read_binary(abstio::path_scenario(map.get_name(), "Full"), &mut timer);
        summaries.push(prebake(&map, scenario, &mut timer));
    }

    // Assume this is being run from the root directory (via import.sh). This other tests directory
    // is the most appropriate place to keep this.
    abstio::write_json(
        "tests/goldenfiles/prebaked_summaries.json".to_string(),
        &summaries,
    );
}