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>;
37 [[nodiscard]]
static size_t completed()
noexcept;
42 [[nodiscard]]
static size_t count()
noexcept;
74 DurationSize start_time,
76 const shared_ptr<topo::Perimeter>& perimeter,
96 DurationSize start_time,
97 const shared_ptr<topo::Cell>& start_cell,
142 void cancel(
bool show_warning)
noexcept;
172 [[nodiscard]]
constexpr Idx
rows()
const
220 [[nodiscard]]
constexpr size_t id()
const
237 [[nodiscard]]
constexpr DurationSize
dayStart(
const size_t for_day)
const
246 [[nodiscard]]
constexpr DurationSize
dayEnd(
const size_t for_day)
const
259 [[nodiscard]]
const wx::FwiWeather* weather_daily(
const DurationSize time)
const
268 [[nodiscard]]
constexpr int nd(
const DurationSize time)
const
295 [[nodiscard]]
constexpr bool isAtNight(
const DurationSize time)
const
297 const auto day =
static_cast<Day
>(time);
298 const auto hour_part = 24 * (time - day);
326 [[nodiscard]] topo::Cell
cell(
const InnerPos& p)
const noexcept;
332 Scenario* run(map<DurationSize, ProbabilityMap*>* probabilities);
348 [[nodiscard]]
bool canBurn(
const topo::Cell& location)
const;
403 [[nodiscard]]
bool ran() const noexcept;
411 [[nodiscard]]
bool survives(const DurationSize time,
413 const DurationSize time_at_location)
const
421 const auto wx = fire_wx->
at(time);
425 || (109 >= mc && 5 > time_at_location)
426 || (119 >= mc && 4 > time_at_location)
427 || (131 >= mc && 3 > time_at_location)
428 || (145 >= mc && 2 > time_at_location)
429 || (218 >= mc && 1 > time_at_location))
438 catch (
const std::out_of_range& e)
451 [[nodiscard]] vector<DurationSize>
savePoints()
const;
465 void clear() noexcept;
467 string add_log(const
char* format) const noexcept override;
482 wx::FireWeather* weather_daily,
483 DurationSize start_time,
485 const shared_ptr<topo::
Perimeter>& perimeter,
486 const shared_ptr<topo::
Cell>& start_cell,
606 shared_ptr<LogPoints> log_points_;
Definition CellPoints.h:164
A specific Event scheduled in a specific Scenario.
Definition Event.h:19
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:290
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:31
Model * model_
Model this Scenario is being run in.
Definition Scenario.h:557
constexpr DurationSize dayStart(const size_t for_day) const
Sunrise time for given day.
Definition Scenario.h:237
wx::FireWeather * weather_
Hourly weather to use for this Scenario.
Definition Scenario.h:549
size_t oob_spread_
How many times this scenario tried to spread out of bounds.
Definition Scenario.h:614
constexpr Idx rows() const
Number of rows.
Definition Scenario.h:172
map< topo::Cell, DurationSize > arrival_
Map of when Cell had first Point arrive in it.
Definition Scenario.h:537
size_t id_
Identifier.
Definition Scenario.h:573
MathSize max_ros_
Maximum rate of spread for current time.
Definition Scenario.h:541
static size_t total_steps() noexcept
Total number of spread events for all Scenarios.
Definition Scenario.cpp:87
const wx::FwiWeather * weather(const DurationSize time) const
FwiWeather for given time.
Definition Scenario.h:255
topo::StartPoint start_point_
Origin of fire.
Definition Scenario.h:569
ThresholdSize spreadThresholdByRos(const DurationSize time) const
Get spread threshold for given time.
Definition Scenario.h:286
CellPointsMap points_
Map of Cells to the PointSets within them.
Definition Scenario.h:509
MathSize minimumFfmcForSpread(const DurationSize time) const noexcept
Minimum Fine Fuel Moisture Code for spread to be possible.
Definition Scenario.h:306
void addSaveByOffset(int offset)
Add a save point for simulation data at the given offset.
Definition Scenario.cpp:989
constexpr MathSize cellSize() const
Cell width and height (m)
Definition Scenario.h:188
shared_ptr< topo::Cell > start_cell_
Cell that the Scenario starts from if no Perimeter.
Definition Scenario.h:545
bool canBurn(const topo::Cell &location) const
Whether or not a Cell can burn.
Definition Scenario.cpp:967
int64_t simulation_
Simulation number.
Definition Scenario.h:589
static size_t count() noexcept
Number of Scenarios that have been initialized.
Definition Scenario.cpp:83
bool ran() const noexcept
Whether or not this Scenario has run already.
Definition Scenario.cpp:423
bool ran_
Whether or not this Scenario has completed running.
Definition Scenario.h:601
constexpr int nd(const DurationSize time) const
Difference between date and the date of minimum foliar moisture content.
Definition Scenario.h:268
util::SafeVector * final_sizes_
Where to append the final size of this Scenario when run is complete.
Definition Scenario.h:565
topo::Cell cell(const Idx row, const Idx column) const
Get Cell for given row and column.
Definition Scenario.h:154
vector< DurationSize > savePoints() const
List of what times the simulation will save.
Definition Scenario.cpp:995
static size_t completed() noexcept
Number of Scenarios that have completed running.
Definition Scenario.cpp:79
DurationSize start_time_
Start time (decimal days)
Definition Scenario.h:577
vector< ThresholdSize > extinction_thresholds_
Thresholds used to determine if extinction occurs.
Definition Scenario.h:497
constexpr topo::Cell cell(const Position< P > &position) const
Get Cell for given Location.
Definition Scenario.h:164
map< topo::SpreadKey, SpreadInfo > spread_info_
Calculated SpreadInfo for SpreadKey for current time.
Definition Scenario.h:533
map< DurationSize, ProbabilityMap * > * probabilities_
Map of ProbabilityMaps by time snapshot for them was taken.
Definition Scenario.h:561
BurnedData * unburnable_
Contains information on cells that are not burnable.
Definition Scenario.h:513
void evaluateNextEvent()
Evaluate next Event in the queue.
Definition Scenario.cpp:1010
void endSimulation() noexcept
End the simulation.
Definition Scenario.cpp:983
shared_ptr< topo::Perimeter > perimeter_
Initial intensity map based off perimeter.
Definition Scenario.h:529
void addEvent(Event &&event)
Whether or not Location with given hash has burned already.
Definition Scenario.cpp:1005
wx::FireWeather * weather_daily_
Weather stream to use for spread and extinction probability.
Definition Scenario.h:553
constexpr const Model & model() const
Model this Scenario is running in.
Definition Scenario.h:228
MathSize currentFireSize() const
Current fire size (ha)
Definition Scenario.cpp:963
Scenario & operator=(Scenario &&rhs) noexcept
Move assignment.
Definition Scenario.cpp:457
constexpr size_t weightedDsr() const noexcept
Weighted Danger Severity Rating.
Definition Scenario.h:52
void clear() noexcept
Clear the Event list and all other data.
Definition Scenario.cpp:59
constexpr size_t id() const
Identifier.
Definition Scenario.h:220
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:411
constexpr DurationSize dayEnd(const size_t for_day) const
Sunset time for given day.
Definition Scenario.h:246
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:157
bool isSurrounded(const Location &location) const
Whether or not the given Location is surrounded by cells that are burnt.
Definition Scenario.cpp:514
vector< ThresholdSize > spread_thresholds_by_ros_
Thresholds used to determine if spread occurs.
Definition Scenario.h:501
DurationSize last_save_
Which save point is the last one.
Definition Scenario.h:581
Scenario * reset(mt19937 *mt_extinction, mt19937 *mt_spread, util::SafeVector *final_sizes)
Reset thresholds and set SafeVector to output results to.
Definition Scenario.cpp:239
Day last_date_
Last day of simulation.
Definition Scenario.h:597
void addSave(V time)
Add a save point for simulation data at given time.
Definition Scenario.cpp:1000
constexpr const topo::StartPoint & startPoint() const
StartPoint that provides sunrise/sunset times.
Definition Scenario.h:204
void saveStats(DurationSize time) const
Save state of Scenario at given time.
Definition Scenario.cpp:415
size_t current_time_index_
Time index for current time.
Definition Scenario.h:585
size_t step_
How many times point spread event has happened.
Definition Scenario.h:610
unique_ptr< IntensityMap > intensity_
Map of what intensity each cell has burned at.
Definition Scenario.h:521
bool hasBurned(const Location &location) const
Whether or not Cell with the given hash can burn.
Definition Scenario.cpp:975
constexpr Idx columns() const
Number of columns.
Definition Scenario.h:180
bool cancelled_
Whether this has been cancelled.
Definition Scenario.h:605
void scheduleFireSpread(const Event &event)
Schedule a fire spread Event.
Definition Scenario.cpp:760
void cancel(bool show_warning) noexcept
Definition Scenario.cpp:1022
Day start_day_
First day of simulation.
Definition Scenario.h:593
void burn(const Event &event)
Burn cell that Event takes place in.
Definition Scenario.cpp:488
DurationSize current_time_
Current time for this Scenario.
Definition Scenario.h:505
void evaluate(const Event &event)
Take whatever steps are necessary to process the given Event.
Definition Scenario.cpp:304
vector< DurationSize > save_points_
List of times to save simulation.
Definition Scenario.h:493
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:203
ThresholdSize extinctionThreshold(const DurationSize time) const
Get extinction threshold for given time.
Definition Scenario.h:277
set< Event, EventCompare > scheduler_
Event scheduler used for ordering events.
Definition Scenario.h:517
constexpr int64_t simulation() const
Simulation number.
Definition Scenario.h:196
constexpr DurationSize startTime() const
Simulation start time.
Definition Scenario.h:212
constexpr bool isAtNight(const DurationSize time) const
Whether or not time is after sunrise and before sunset.
Definition Scenario.h:295
static MathSize minimumFfmcAtNight() noexcept
Minimum Fine Fuel Moisture Code required for spread during the night.
Definition Settings.cpp:611
static MathSize minimumFfmc() noexcept
Minimum Fine Fuel Moisture Code required for spread during the day.
Definition Settings.cpp:607
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