8#include "EventCompare.h"
9#include "FireWeather.h"
10#include "IntensityMap.h"
13#include "StartPoint.h"
15#include "FireSpread.h"
16#include "CellPoints.h"
25using PointSet = vector<InnerPos>;
44 [[nodiscard]]
static size_t completed()
noexcept;
49 [[nodiscard]]
static size_t count()
noexcept;
81 DurationSize start_time,
83 const shared_ptr<topo::Perimeter>& perimeter,
103 DurationSize start_time,
104 const shared_ptr<topo::Cell>& start_cell,
149 void cancel(
bool show_warning)
noexcept;
179 [[nodiscard]]
constexpr Idx
rows()
const
227 [[nodiscard]]
constexpr size_t id()
const
244 [[nodiscard]]
constexpr DurationSize
dayStart(
const size_t for_day)
const
253 [[nodiscard]]
constexpr DurationSize
dayEnd(
const size_t for_day)
const
266 [[nodiscard]]
const wx::FwiWeather* weather_daily(
const DurationSize time)
const
275 [[nodiscard]]
constexpr int nd(
const DurationSize time)
const
302 [[nodiscard]]
constexpr bool isAtNight(
const DurationSize time)
const
304 const auto day =
static_cast<Day
>(time);
305 const auto hour_part = 24 * (time - day);
333 [[nodiscard]] topo::Cell
cell(
const InnerPos& p)
const noexcept;
339 Scenario* run(map<DurationSize, ProbabilityMap*>* probabilities);
355 [[nodiscard]]
bool canBurn(
const topo::Cell& location)
const;
421 void saveIntensity(const
string& dir, const
string& base_name) const;
426 [[nodiscard]]
bool ran() const noexcept;
434 [[nodiscard]]
bool survives(const DurationSize time,
436 const DurationSize time_at_location)
const
449 const auto wx = fire_wx->
at(time);
453 || (109 >= mc && 5 > time_at_location)
454 || (119 >= mc && 4 > time_at_location)
455 || (131 >= mc && 3 > time_at_location)
456 || (145 >= mc && 2 > time_at_location)
457 || (218 >= mc && 1 > time_at_location))
466 catch (
const std::out_of_range& e)
479 [[nodiscard]] vector<DurationSize>
savePoints()
const;
503 void clear() noexcept;
505 string add_log(const
char* format) const noexcept override;
520 wx::FireWeather* weather_daily,
521 DurationSize start_time,
523 const shared_ptr<topo::
Perimeter>& perimeter,
524 const shared_ptr<topo::
Cell>& start_cell,
648 shared_ptr<LogPoints> log_points_;
Definition CellPoints.h:206
A specific Event scheduled in a specific Scenario.
Definition Event.h:19
Interface for observers that get notified when cells burn so they can track things.
Definition Observer.h:20
Contains all the immutable information regarding a simulation that is common between Scenarios.
Definition Model.h:134
topo::Cell cell(const Idx row, const Idx column) const
Cell at the given row and column.
Definition Model.h:167
constexpr Idx columns() const
Number of columns in extent.
Definition Model.h:202
constexpr int nd(const DurationSize time) const
Difference between date and the date of minimum foliar moisture content.
Definition Model.h:282
constexpr Idx rows() const
Cell at the Location represented by the given hash.
Definition Model.h:194
constexpr MathSize cellSize() const
Cell width and height (m)
Definition Model.h:210
A single Scenario in an Iteration using a specific FireWeather stream.
Definition Scenario.h:38
Model * model_
Model this Scenario is being run in.
Definition Scenario.h:599
constexpr DurationSize dayStart(const size_t for_day) const
Sunrise time for given day.
Definition Scenario.h:244
wx::FireWeather * weather_
Hourly weather to use for this Scenario.
Definition Scenario.h:591
size_t oob_spread_
How many times this scenario tried to spread out of bounds.
Definition Scenario.h:656
constexpr Idx rows() const
Number of rows.
Definition Scenario.h:179
map< topo::Cell, DurationSize > arrival_
Map of when Cell had first Point arrive in it.
Definition Scenario.h:579
size_t id_
Identifier.
Definition Scenario.h:615
MathSize max_ros_
Maximum rate of spread for current time.
Definition Scenario.h:583
static size_t total_steps() noexcept
Total number of spread events for all Scenarios.
Definition Scenario.cpp:94
const wx::FwiWeather * weather(const DurationSize time) const
FwiWeather for given time.
Definition Scenario.h:262
topo::StartPoint start_point_
Origin of fire.
Definition Scenario.h:611
ThresholdSize spreadThresholdByRos(const DurationSize time) const
Get spread threshold for given time.
Definition Scenario.h:293
CellPointsMap points_
Map of Cells to the PointSets within them.
Definition Scenario.h:551
MathSize minimumFfmcForSpread(const DurationSize time) const noexcept
Minimum Fine Fuel Moisture Code for spread to be possible.
Definition Scenario.h:313
void addSaveByOffset(int offset)
Add a save point for simulation data at the given offset.
Definition Scenario.cpp:1158
constexpr MathSize cellSize() const
Cell width and height (m)
Definition Scenario.h:195
shared_ptr< topo::Cell > start_cell_
Cell that the Scenario starts from if no Perimeter.
Definition Scenario.h:587
bool canBurn(const topo::Cell &location) const
Whether or not a Cell can burn.
Definition Scenario.cpp:1136
int64_t simulation_
Simulation number.
Definition Scenario.h:631
static size_t count() noexcept
Number of Scenarios that have been initialized.
Definition Scenario.cpp:90
bool ran() const noexcept
Whether or not this Scenario has run already.
Definition Scenario.cpp:483
bool ran_
Whether or not this Scenario has completed running.
Definition Scenario.h:643
list< unique_ptr< IObserver, IObserver_deleter > > observers_
Observers to be notified when cells burn.
Definition Scenario.h:531
constexpr int nd(const DurationSize time) const
Difference between date and the date of minimum foliar moisture content.
Definition Scenario.h:275
util::SafeVector * final_sizes_
Where to append the final size of this Scenario when run is complete.
Definition Scenario.h:607
topo::Cell cell(const Idx row, const Idx column) const
Get Cell for given row and column.
Definition Scenario.h:161
vector< DurationSize > savePoints() const
List of what times the simulation will save.
Definition Scenario.cpp:1164
static size_t completed() noexcept
Number of Scenarios that have completed running.
Definition Scenario.cpp:86
DurationSize start_time_
Start time (decimal days)
Definition Scenario.h:619
vector< ThresholdSize > extinction_thresholds_
Thresholds used to determine if extinction occurs.
Definition Scenario.h:539
constexpr topo::Cell cell(const Position< P > &position) const
Get Cell for given Location.
Definition Scenario.h:171
map< topo::SpreadKey, SpreadInfo > spread_info_
Calculated SpreadInfo for SpreadKey for current time.
Definition Scenario.h:575
map< DurationSize, ProbabilityMap * > * probabilities_
Map of ProbabilityMaps by time snapshot for them was taken.
Definition Scenario.h:603
BurnedData * unburnable_
Contains information on cells that are not burnable.
Definition Scenario.h:555
void evaluateNextEvent()
Evaluate next Event in the queue.
Definition Scenario.cpp:1179
void registerObserver(IObserver *observer)
Register an IObserver that will be notified when Cells burn.
Definition Scenario.cpp:451
void endSimulation() noexcept
End the simulation.
Definition Scenario.cpp:1152
shared_ptr< topo::Perimeter > perimeter_
Initial intensity map based off perimeter.
Definition Scenario.h:571
void addEvent(Event &&event)
Whether or not Location with given hash has burned already.
Definition Scenario.cpp:1174
wx::FireWeather * weather_daily_
Weather stream to use for spread and extinction probability.
Definition Scenario.h:595
constexpr const Model & model() const
Model this Scenario is running in.
Definition Scenario.h:235
MathSize currentFireSize() const
Current fire size (ha)
Definition Scenario.cpp:1132
Scenario & operator=(Scenario &&rhs) noexcept
Move assignment.
Definition Scenario.cpp:518
constexpr size_t weightedDsr() const noexcept
Weighted Danger Severity Rating.
Definition Scenario.h:59
void clear() noexcept
Clear the Event list and all other data.
Definition Scenario.cpp:63
constexpr size_t id() const
Identifier.
Definition Scenario.h:227
bool survives(const DurationSize time, const topo::Cell &cell, const DurationSize time_at_location) const
Whether or not the fire survives the conditions.
Definition Scenario.h:434
constexpr DurationSize dayEnd(const size_t for_day) const
Sunset time for given day.
Definition Scenario.h:253
void saveObservers(const string &base_name) const
Tell Observers to save their data with base file name.
Definition Scenario.cpp:462
Scenario(Model *model, size_t id, wx::FireWeather *weather, wx::FireWeather *weather_daily, DurationSize start_time, const shared_ptr< topo::Perimeter > &perimeter, const topo::StartPoint &start_point, Day start_day, Day last_date)
Constructor.
Definition Scenario.cpp:164
bool isSurrounded(const Location &location) const
Whether or not the given Location is surrounded by cells that are burnt.
Definition Scenario.cpp:577
vector< ThresholdSize > spread_thresholds_by_ros_
Thresholds used to determine if spread occurs.
Definition Scenario.h:543
void notify(const Event &event) const
Notify IObservers that a Cell has burned.
Definition Scenario.cpp:455
DurationSize last_save_
Which save point is the last one.
Definition Scenario.h:623
Scenario * reset(mt19937 *mt_extinction, mt19937 *mt_spread, util::SafeVector *final_sizes)
Reset thresholds and set SafeVector to output results to.
Definition Scenario.cpp:250
Day last_date_
Last day of simulation.
Definition Scenario.h:639
void addSave(V time)
Add a save point for simulation data at given time.
Definition Scenario.cpp:1169
constexpr const topo::StartPoint & startPoint() const
StartPoint that provides sunrise/sunset times.
Definition Scenario.h:211
void saveStats(DurationSize time) const
Save state of Scenario at given time.
Definition Scenario.cpp:443
size_t current_time_index_
Time index for current time.
Definition Scenario.h:627
void saveIntensity(const string &dir, const string &base_name) const
Save burn intensity information.
Definition Scenario.cpp:479
size_t step_
How many times point spread event has happened.
Definition Scenario.h:652
unique_ptr< IntensityMap > intensity_
Map of what intensity each cell has burned at.
Definition Scenario.h:563
bool hasBurned(const Location &location) const
Whether or not Cell with the given hash can burn.
Definition Scenario.cpp:1144
constexpr Idx columns() const
Number of columns.
Definition Scenario.h:187
bool cancelled_
Whether this has been cancelled.
Definition Scenario.h:647
void scheduleFireSpread(const Event &event)
Schedule a fire spread Event.
Definition Scenario.cpp:923
void cancel(bool show_warning) noexcept
Definition Scenario.cpp:1191
Day start_day_
First day of simulation.
Definition Scenario.h:635
void burn(const Event &event)
Burn cell that Event takes place in.
Definition Scenario.cpp:550
DurationSize current_time_
Current time for this Scenario.
Definition Scenario.h:547
void evaluate(const Event &event)
Take whatever steps are necessary to process the given Event.
Definition Scenario.cpp:319
vector< DurationSize > save_points_
List of times to save simulation.
Definition Scenario.h:535
Scenario * reset_with_new_start(const shared_ptr< topo::Cell > &start_cell, util::SafeVector *final_sizes)
Assign start Cell, reset thresholds and set SafeVector to output results to.
Definition Scenario.cpp:210
ThresholdSize extinctionThreshold(const DurationSize time) const
Get extinction threshold for given time.
Definition Scenario.h:284
set< Event, EventCompare > scheduler_
Event scheduler used for ordering events.
Definition Scenario.h:559
constexpr int64_t simulation() const
Simulation number.
Definition Scenario.h:203
constexpr DurationSize startTime() const
Simulation start time.
Definition Scenario.h:219
constexpr bool isAtNight(const DurationSize time) const
Whether or not time is after sunrise and before sunset.
Definition Scenario.h:302
static MathSize minimumFfmcAtNight() noexcept
Minimum Fine Fuel Moisture Code required for spread during the night.
Definition Settings.cpp:724
static bool deterministic() noexcept
Whether or not to run deterministically (100% chance of spread & survival)
Definition Settings.cpp:616
static MathSize minimumFfmc() noexcept
Minimum Fine Fuel Moisture Code required for spread during the day.
Definition Settings.cpp:720
A Position with a Slope, Aspect, and Fuel.
Definition Cell.h:20
static constexpr FuelCodeSize fuelCode(const SpreadKey value) noexcept
Fuel.
Definition Cell.h:136
Definition Location.h:229
Perimeter for an existing fire to initialize a simulation with.
Definition Perimeter.h:24
A Position with a row and column.
Definition Location.h:57
constexpr HashSize hash() const noexcept
Hash derived from row and column.
Definition Location.h:80
A Point that has sunrise and sunset times for each day.
Definition StartPoint.h:17
constexpr DurationSize dayStart(const size_t day) const
Sunrise time.
Definition StartPoint.h:57
constexpr DurationSize dayEnd(const size_t day) const
Sunset time.
Definition StartPoint.h:66
A vector with added thread safety.
Definition SafeVector.h:15
A stream of weather that gets used by a Scenario every Iteration.
Definition FireWeather.h:29
constexpr size_t weightedDsr() const noexcept
Weighted Danger Severity Rating for the stream.
Definition FireWeather.h:91
const FwiWeather * at(const DurationSize time) const
Get FwiWeather for given time.
Definition FireWeather.h:53
A Weather value with calculated FWI indices.
Definition FWI.h:209
constexpr MathSize mcDmcPct() const
Moisture content (%) based on Dmc.
Definition FWI.h:398
Deleter for IObserver to get around incomplete class with unique_ptr.
Definition Scenario.h:30