FireSTARR
Loading...
Searching...
No Matches
fs::sim::Scenario Class Reference

A single Scenario in an Iteration using a specific FireWeather stream. More...

#include <Scenario.h>

Inheritance diagram for fs::sim::Scenario:
Collaboration diagram for fs::sim::Scenario:

Public Member Functions

constexpr size_t weightedDsr () const noexcept
 Weighted Danger Severity Rating.
 
 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.
 
 Scenario (Model *model, size_t id, wx::FireWeather *weather, wx::FireWeather *weather_daily, DurationSize start_time, const shared_ptr< topo::Cell > &start_cell, const topo::StartPoint &start_point, Day start_day, Day last_date)
 Constructor.
 
 Scenario (Scenario &&rhs) noexcept
 Move constructor.
 
 Scenario (const Scenario &rhs)=delete
 
Scenariooperator= (Scenario &&rhs) noexcept
 Move assignment.
 
Scenariooperator= (const Scenario &rhs) const =delete
 
Scenarioreset_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.
 
Scenarioreset (mt19937 *mt_extinction, mt19937 *mt_spread, util::SafeVector *final_sizes)
 Reset thresholds and set SafeVector to output results to.
 
void burn (const Event &event)
 Burn cell that Event takes place in.
 
void cancel (bool show_warning) noexcept
 
topo::Cell cell (const Idx row, const Idx column) const
 Get Cell for given row and column.
 
template<class P >
constexpr topo::Cell cell (const Position< P > &position) const
 Get Cell for given Location.
 
constexpr Idx rows () const
 Number of rows.
 
constexpr Idx columns () const
 Number of columns.
 
constexpr MathSize cellSize () const
 Cell width and height (m)
 
constexpr int64_t simulation () const
 Simulation number.
 
constexpr const topo::StartPointstartPoint () const
 StartPoint that provides sunrise/sunset times.
 
constexpr DurationSize startTime () const
 Simulation start time.
 
constexpr size_t id () const
 Identifier.
 
constexpr const Modelmodel () const
 Model this Scenario is running in.
 
constexpr DurationSize dayStart (const size_t for_day) const
 Sunrise time for given day.
 
constexpr DurationSize dayEnd (const size_t for_day) const
 Sunset time for given day.
 
const wx::FwiWeatherweather (const DurationSize time) const
 FwiWeather for given time.
 
const wx::FwiWeatherweather_daily (const DurationSize time) const
 
constexpr int nd (const DurationSize time) const
 Difference between date and the date of minimum foliar moisture content.
 
ThresholdSize extinctionThreshold (const DurationSize time) const
 Get extinction threshold for given time.
 
ThresholdSize spreadThresholdByRos (const DurationSize time) const
 Get spread threshold for given time.
 
constexpr bool isAtNight (const DurationSize time) const
 Whether or not time is after sunrise and before sunset.
 
MathSize minimumFfmcForSpread (const DurationSize time) const noexcept
 Minimum Fine Fuel Moisture Code for spread to be possible.
 
bool isSurrounded (const Location &location) const
 Whether or not the given Location is surrounded by cells that are burnt.
 
template<class P >
bool isSurrounded (const Position< P > &position) const
 
topo::Cell cell (const InnerPos &p) const noexcept
 Cell that InnerPos falls within.
 
Scenariorun (map< DurationSize, ProbabilityMap * > *probabilities)
 Run the Scenario.
 
void scheduleFireSpread (const Event &event)
 Schedule a fire spread Event.
 
MathSize currentFireSize () const
 Current fire size (ha)
 
bool canBurn (const topo::Cell &location) const
 Whether or not a Cell can burn.
 
bool hasBurned (const Location &location) const
 Whether or not Cell with the given hash can burn.
 
template<class P >
bool hasBurned (const Position< P > &position) const
 
void addEvent (Event &&event)
 Whether or not Location with given hash has burned already.
 
void evaluateNextEvent ()
 Evaluate next Event in the queue.
 
void endSimulation () noexcept
 End the simulation.
 
void addSaveByOffset (int offset)
 Add a save point for simulation data at the given offset.
 
template<class V >
void addSave (V time)
 Add a save point for simulation data at given time.
 
void saveObservers (const string &base_name) const
 Tell Observers to save their data with base file name.
 
void saveObservers (DurationSize time) const
 Tell Observers to save their data for the given time.
 
void saveIntensity (const string &dir, const string &base_name) const
 Save burn intensity information.
 
bool ran () const noexcept
 Whether or not this Scenario has run already.
 
bool survives (const DurationSize time, const topo::Cell &cell, const DurationSize time_at_location) const
 Whether or not the fire survives the conditions.
 
vector< DurationSize > savePoints () const
 List of what times the simulation will save.
 
void saveStats (DurationSize time) const
 Save state of Scenario at given time.
 
void registerObserver (IObserver *observer)
 Register an IObserver that will be notified when Cells burn.
 
void notify (const Event &event) const
 Notify IObservers that a Cell has burned.
 
void evaluate (const Event &event)
 Take whatever steps are necessary to process the given Event.
 
void clear () noexcept
 Clear the Event list and all other data.
 

Static Public Member Functions

static size_t completed () noexcept
 Number of Scenarios that have completed running.
 
static size_t count () noexcept
 Number of Scenarios that have been initialized.
 
static size_t total_steps () noexcept
 Total number of spread events for all Scenarios.
 

Protected Member Functions

string add_log (const char *format) const noexcept override
 
 Scenario (Model *model, size_t id, wx::FireWeather *weather, wx::FireWeather *weather_daily, DurationSize start_time, const shared_ptr< topo::Perimeter > &perimeter, const shared_ptr< topo::Cell > &start_cell, topo::StartPoint start_point, Day start_day, Day last_date)
 Constructor.
 
- Protected Member Functions inherited from fs::logging::SelfLogger
void log_output (const int level, const char *format,...) const noexcept
 
void log_extensive (const char *format,...) const noexcept
 
void log_verbose (const char *format,...) const noexcept
 
void log_debug (const char *format,...) const noexcept
 
void log_info (const char *format,...) const noexcept
 
void log_note (const char *format,...) const noexcept
 
void log_warning (const char *format,...) const noexcept
 
void log_error (const char *format,...) const noexcept
 
void log_check_fatal (bool condition, const char *format,...) const
 
void log_fatal (const char *format,...) const
 

Protected Attributes

list< unique_ptr< IObserver, IObserver_deleter > > observers_ {}
 Observers to be notified when cells burn.
 
vector< DurationSize > save_points_
 List of times to save simulation.
 
vector< ThresholdSize > extinction_thresholds_ {}
 Thresholds used to determine if extinction occurs.
 
vector< ThresholdSize > spread_thresholds_by_ros_ {}
 Thresholds used to determine if spread occurs.
 
DurationSize current_time_
 Current time for this Scenario.
 
CellPointsMap points_
 Map of Cells to the PointSets within them.
 
BurnedData * unburnable_
 Contains information on cells that are not burnable.
 
set< Event, EventComparescheduler_
 Event scheduler used for ordering events.
 
unique_ptr< IntensityMapintensity_
 Map of what intensity each cell has burned at.
 
shared_ptr< topo::Perimeterperimeter_
 Initial intensity map based off perimeter.
 
map< topo::SpreadKey, SpreadInfospread_info_ {}
 Calculated SpreadInfo for SpreadKey for current time.
 
map< topo::Cell, DurationSize > arrival_ {}
 Map of when Cell had first Point arrive in it.
 
MathSize max_ros_
 Maximum rate of spread for current time.
 
shared_ptr< topo::Cellstart_cell_
 Cell that the Scenario starts from if no Perimeter.
 
wx::FireWeatherweather_
 Hourly weather to use for this Scenario.
 
wx::FireWeatherweather_daily_
 Weather stream to use for spread and extinction probability.
 
Modelmodel_
 Model this Scenario is being run in.
 
map< DurationSize, ProbabilityMap * > * probabilities_
 Map of ProbabilityMaps by time snapshot for them was taken.
 
util::SafeVectorfinal_sizes_
 Where to append the final size of this Scenario when run is complete.
 
topo::StartPoint start_point_
 Origin of fire.
 
size_t id_
 Identifier.
 
DurationSize start_time_
 Start time (decimal days)
 
DurationSize last_save_
 Which save point is the last one.
 
size_t current_time_index_ = numeric_limits<size_t>::max()
 Time index for current time.
 
int64_t simulation_
 Simulation number.
 
Day start_day_
 First day of simulation.
 
Day last_date_
 Last day of simulation.
 
bool ran_
 Whether or not this Scenario has completed running.
 
bool cancelled_ = false
 Whether this has been cancelled.
 
shared_ptr< LogPointslog_points_
 
size_t step_
 How many times point spread event has happened.
 
size_t oob_spread_
 How many times this scenario tried to spread out of bounds.
 

Detailed Description

A single Scenario in an Iteration using a specific FireWeather stream.

Constructor & Destructor Documentation

◆ Scenario() [1/4]

fs::sim::Scenario::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.

Parameters
modelModel running this Scenario
idIdentifier
weatherHourly weather stream to use
weatherWeather stream to use for spread and extinction probability
start_timeStart time for simulation
initial_intensityIntensity grid to start from
perimeterPerimeter to initialize with
start_pointStartPoint to use sunrise/sunset times from
start_dayFirst day of simulation
last_dateLast day of simulation

◆ Scenario() [2/4]

fs::sim::Scenario::Scenario ( Model * model,
size_t id,
wx::FireWeather * weather,
wx::FireWeather * weather_daily,
DurationSize start_time,
const shared_ptr< topo::Cell > & start_cell,
const topo::StartPoint & start_point,
Day start_day,
Day last_date )

Constructor.

Parameters
modelModel running this Scenario
idIdentifier
weatherHourly weather stream to use
weatherWeather stream to use for spread and extinction probability
start_timeStart time for simulation
start_cellCell to start ignition in
start_pointStartPoint to use sunrise/sunset times from
start_dayFirst day of simulation
last_dateLast day of simulation

◆ Scenario() [3/4]

fs::sim::Scenario::Scenario ( Scenario && rhs)
noexcept

Move constructor.

Parameters
rhsScenario to move from

◆ Scenario() [4/4]

fs::sim::Scenario::Scenario ( Model * model,
size_t id,
wx::FireWeather * weather,
wx::FireWeather * weather_daily,
DurationSize start_time,
const shared_ptr< topo::Perimeter > & perimeter,
const shared_ptr< topo::Cell > & start_cell,
topo::StartPoint start_point,
Day start_day,
Day last_date )
protected

Constructor.

Parameters
modelModel running this Scenario
idIdentifier
weatherHourly weather stream to use
weatherWeather stream to use for spread and extinction probability
start_timeStart time for simulation
start_pointStartPoint to use sunrise/sunset times from
start_dayFirst day of simulation
last_dateLast day of simulation
Here is the call graph for this function:

Member Function Documentation

◆ add_log()

string fs::sim::Scenario::add_log ( const char * format) const
overrideprotectedvirtualnoexcept

◆ addEvent()

void fs::sim::Scenario::addEvent ( Event && event)

Whether or not Location with given hash has burned already.

Parameters
hashHash of Location to check
Returns
Whether or not Location with given hash has burned already

Add an Event to the queue

Parameters
eventEvent to add
Here is the caller graph for this function:

◆ addSave()

template<class V >
void fs::sim::Scenario::addSave ( V time)

Add a save point for simulation data at given time.

Template Parameters
VType to use for time
Parameters
timeTime to add save point at

◆ addSaveByOffset()

void fs::sim::Scenario::addSaveByOffset ( int offset)

Add a save point for simulation data at the given offset.

Parameters
offsetOffset from start of simulation (days)

◆ burn()

void fs::sim::Scenario::burn ( const Event & event)

Burn cell that Event takes place in.

Parameters
eventEvent with cell location
Here is the call graph for this function:
Here is the caller graph for this function:

◆ canBurn()

bool fs::sim::Scenario::canBurn ( const topo::Cell & location) const
nodiscard

Whether or not a Cell can burn.

Parameters
locationCell
Returns
Whether or not a Cell can burn
Here is the caller graph for this function:

◆ cancel()

void fs::sim::Scenario::cancel ( bool show_warning)
noexcept

Mark as cancelled so it stops computing on next event.

Parameters
Whetherto log a warning about this being cancelled

◆ cell() [1/3]

topo::Cell fs::sim::Scenario::cell ( const Idx row,
const Idx column ) const
inlinenodiscard

Get Cell for given row and column.

Parameters
rowRow
columnColumn
Returns
Cell for given row and column
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cell() [2/3]

Cell fs::sim::Scenario::cell ( const InnerPos & p) const
nodiscardnoexcept

Cell that InnerPos falls within.

Parameters
pInnerPos
Returns
Cell that InnerPos falls within

◆ cell() [3/3]

template<class P >
topo::Cell fs::sim::Scenario::cell ( const Position< P > & position) const
inlinenodiscardconstexpr

Get Cell for given Location.

Parameters
locationLocation
Returns
Cell for given Location
Here is the call graph for this function:

◆ cellSize()

MathSize fs::sim::Scenario::cellSize ( ) const
inlinenodiscardconstexpr

Cell width and height (m)

Returns
Cell width and height (m)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ columns()

Idx fs::sim::Scenario::columns ( ) const
inlinenodiscardconstexpr

Number of columns.

Returns
Number of columns
Here is the call graph for this function:

◆ completed()

size_t fs::sim::Scenario::completed ( )
staticnodiscardnoexcept

Number of Scenarios that have completed running.

Returns
Number of Scenarios that have completed running
Here is the caller graph for this function:

◆ count()

size_t fs::sim::Scenario::count ( )
staticnodiscardnoexcept

Number of Scenarios that have been initialized.

Returns
Number of Scenarios that have been initialized
Here is the caller graph for this function:

◆ currentFireSize()

MathSize fs::sim::Scenario::currentFireSize ( ) const
nodiscard

Current fire size (ha)

Returns
Current fire size (ha)
Here is the caller graph for this function:

◆ dayEnd()

DurationSize fs::sim::Scenario::dayEnd ( const size_t for_day) const
inlinenodiscardconstexpr

Sunset time for given day.

Parameters
for_dayDay to get sunset time for
Returns
Sunset time for given day
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dayStart()

DurationSize fs::sim::Scenario::dayStart ( const size_t for_day) const
inlinenodiscardconstexpr

Sunrise time for given day.

Parameters
for_dayDay to get sunrise time for
Returns
Sunrise time for given day
Here is the call graph for this function:
Here is the caller graph for this function:

◆ evaluate()

void fs::sim::Scenario::evaluate ( const Event & event)

Take whatever steps are necessary to process the given Event.

Parameters
eventEvent to process
Here is the call graph for this function:

◆ evaluateNextEvent()

void fs::sim::Scenario::evaluateNextEvent ( )

Evaluate next Event in the queue.

Returns
Whether to continue simulation
Here is the caller graph for this function:

◆ extinctionThreshold()

ThresholdSize fs::sim::Scenario::extinctionThreshold ( const DurationSize time) const
inlinenodiscard

Get extinction threshold for given time.

Parameters
timeTime to get value for
Returns
Extinction threshold for given time
Here is the caller graph for this function:

◆ hasBurned()

bool fs::sim::Scenario::hasBurned ( const Location & location) const
nodiscard

Whether or not Cell with the given hash can burn.

Parameters
hashHash for Cell to check
Returns
Whether or not Cell with the given hash can burn

Whether or not Location has burned already

Parameters
locationLocation to check
Returns
Whether or not Location has burned already

◆ id()

size_t fs::sim::Scenario::id ( ) const
inlinenodiscardconstexpr

Identifier.

Returns
Identifier

◆ isAtNight()

bool fs::sim::Scenario::isAtNight ( const DurationSize time) const
inlinenodiscardconstexpr

Whether or not time is after sunrise and before sunset.

Parameters
timeTime to determine for
Returns
Whether or not time is after sunrise and before sunset
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSurrounded()

bool fs::sim::Scenario::isSurrounded ( const Location & location) const
nodiscard

Whether or not the given Location is surrounded by cells that are burnt.

Parameters
locationLocation to check if is surrounded
Returns
Whether or not the given Location is surrounded by cells that are burnt
Here is the caller graph for this function:

◆ minimumFfmcForSpread()

MathSize fs::sim::Scenario::minimumFfmcForSpread ( const DurationSize time) const
inlinenodiscardnoexcept

Minimum Fine Fuel Moisture Code for spread to be possible.

Parameters
timeTime to determine for
Returns
Minimum Fine Fuel Moisture Code for spread to be possible
Here is the call graph for this function:
Here is the caller graph for this function:

◆ model()

const Model & fs::sim::Scenario::model ( ) const
inlinenodiscardconstexpr

Model this Scenario is running in.

Returns
Model this Scenario is running in
Here is the caller graph for this function:

◆ nd()

int fs::sim::Scenario::nd ( const DurationSize time) const
inlinenodiscardconstexpr

Difference between date and the date of minimum foliar moisture content.

Parameters
timeTime to get value for
Returns
Difference between date and the date of minimum foliar moisture content
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify()

void fs::sim::Scenario::notify ( const Event & event) const

Notify IObservers that a Cell has burned.

Parameters
eventEvent to notify IObservers of
Here is the caller graph for this function:

◆ operator=()

Scenario & fs::sim::Scenario::operator= ( Scenario && rhs)
noexcept

Move assignment.

Parameters
rhsScenario to move from
Returns
This, after assignment

◆ ran()

bool fs::sim::Scenario::ran ( ) const
nodiscardnoexcept

Whether or not this Scenario has run already.

Returns
Whether or not this Scenario has run already
Here is the caller graph for this function:

◆ registerObserver()

void fs::sim::Scenario::registerObserver ( IObserver * observer)

Register an IObserver that will be notified when Cells burn.

Parameters
observerObserver to add to notification list
Here is the caller graph for this function:

◆ reset()

Scenario * fs::sim::Scenario::reset ( mt19937 * mt_extinction,
mt19937 * mt_spread,
util::SafeVector * final_sizes )
nodiscard

Reset thresholds and set SafeVector to output results to.

Parameters
mt_extinctionUsed for extinction random numbers
mt_spreadUsed for spread random numbers
final_sizesSafeVector to output results to
Returns
This
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_with_new_start()

Scenario * fs::sim::Scenario::reset_with_new_start ( const shared_ptr< topo::Cell > & start_cell,
util::SafeVector * final_sizes )
nodiscard

Assign start Cell, reset thresholds and set SafeVector to output results to.

Parameters
start_cellCell to start ignition in
final_sizesSafeVector to output results to
Returns
This
Here is the call graph for this function:

◆ rows()

Idx fs::sim::Scenario::rows ( ) const
inlinenodiscardconstexpr

Number of rows.

Returns
Number of rows
Here is the call graph for this function:

◆ run()

Scenario * fs::sim::Scenario::run ( map< DurationSize, ProbabilityMap * > * probabilities)

Run the Scenario.

Parameters
probabilitiesmap to update ProbabilityMap for times base on Scenario results
Returns
This
Here is the call graph for this function:

◆ saveIntensity()

void fs::sim::Scenario::saveIntensity ( const string & dir,
const string & base_name ) const

Save burn intensity information.

Parameters
dirDirectory to save to
base_nameBase file name
Here is the caller graph for this function:

◆ saveObservers() [1/2]

void fs::sim::Scenario::saveObservers ( const string & base_name) const

Tell Observers to save their data with base file name.

Parameters
base_nameBase file name
Here is the caller graph for this function:

◆ saveObservers() [2/2]

void fs::sim::Scenario::saveObservers ( DurationSize time) const

Tell Observers to save their data for the given time.

Parameters
timeTime to save data for
Here is the call graph for this function:

◆ savePoints()

vector< DurationSize > fs::sim::Scenario::savePoints ( ) const
nodiscard

List of what times the simulation will save.

Returns
List of what times the simulation will save

◆ saveStats()

void fs::sim::Scenario::saveStats ( DurationSize time) const

Save state of Scenario at given time.

Parameters
time
Here is the call graph for this function:
Here is the caller graph for this function:

◆ scheduleFireSpread()

void fs::sim::Scenario::scheduleFireSpread ( const Event & event)

Schedule a fire spread Event.

Parameters
eventEvent to schedule
Here is the call graph for this function:
Here is the caller graph for this function:

◆ simulation()

int64_t fs::sim::Scenario::simulation ( ) const
inlinenodiscardconstexpr

Simulation number.

Returns
Simulation number
Here is the caller graph for this function:

◆ spreadThresholdByRos()

ThresholdSize fs::sim::Scenario::spreadThresholdByRos ( const DurationSize time) const
inlinenodiscard

Get spread threshold for given time.

Parameters
timeTime to get value for
Returns
Spread threshold for given time

◆ startPoint()

const topo::StartPoint & fs::sim::Scenario::startPoint ( ) const
inlinenodiscardconstexpr

StartPoint that provides sunrise/sunset times.

Returns
StartPoint

◆ startTime()

DurationSize fs::sim::Scenario::startTime ( ) const
inlinenodiscardconstexpr

Simulation start time.

Returns
Simulation start time

◆ survives()

bool fs::sim::Scenario::survives ( const DurationSize time,
const topo::Cell & cell,
const DurationSize time_at_location ) const
inlinenodiscard

Whether or not the fire survives the conditions.

Parameters
timeTime to use weather from
cellCell to use
time_at_locationHow long the fire has been in that Cell
Returns
Whether or not the fire survives the conditions
Here is the call graph for this function:
Here is the caller graph for this function:

◆ total_steps()

size_t fs::sim::Scenario::total_steps ( )
staticnodiscardnoexcept

Total number of spread events for all Scenarios.

Returns
Total number of spread events for all Scenarios
Here is the caller graph for this function:

◆ weather()

const wx::FwiWeather * fs::sim::Scenario::weather ( const DurationSize time) const
inlinenodiscard

FwiWeather for given time.

Parameters
timeTime to get weather for (decimal days)
Returns
FwiWeather for given time
Here is the call graph for this function:
Here is the caller graph for this function:

◆ weightedDsr()

size_t fs::sim::Scenario::weightedDsr ( ) const
inlinenodiscardconstexprnoexcept

Weighted Danger Severity Rating.

Returns
Weighted Danger Severity Rating
Here is the call graph for this function:

Member Data Documentation

◆ perimeter_

shared_ptr<topo::Perimeter> fs::sim::Scenario::perimeter_
protected

Initial intensity map based off perimeter.

Perimeter used to start Scenario from


The documentation for this class was generated from the following files: