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

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

#include <Scenario.h>

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

Public Member Functions

 Scenario (Scenario &&rhs) noexcept
 
 Scenario (const Scenario &rhs)=delete
 
Scenario & operator= (Scenario &&rhs) noexcept
 
Scenario & operator= (const Scenario &rhs) const =delete
 
Scenario * reset_with_new_start (const XYIdx &start_cell, ptr< SafeVector > final_sizes)
 Assign start Cell, reset thresholds and set SafeVector to output results to.
 
Scenario * reset (mt19937_64 *mt_extinction, mt19937_64 *mt_spread, ptr< 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
 
Cell cell (const XYIdx xy) const
 
constexpr Idx height () const
 
constexpr Idx width () const
 
constexpr MathSize cellSize () const
 Cell width and height (m)
 
constexpr int64_t simulation () const
 Simulation number.
 
constexpr DurationSize current_time () const
 
constexpr const StartPoint & startPoint () const
 StartPoint that provides sunrise/sunset times.
 
constexpr DurationSize startTime () const
 Simulation start time.
 
constexpr size_t id () const
 Identifier.
 
constexpr const Model & model () 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.
 
ptr< const FwiWeather > weather (const DurationSize time) const
 FwiWeather for given time.
 
ptr< const FwiWeather > weather_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 XYIdx &location) const
 Whether or not the given Location is surrounded by cells that are burnt.
 
Scenario * run (map< DurationSize, shared_ptr< 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 XYIdx &location) const
 Whether or not a Cell can burn.
 
bool hasBurned (const XYIdx &location) const
 Whether or not Location has burned already.
 
void addEvent (Event &&event)
 Add an Event to the queue.
 
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.
 
void addSave (const DurationSize time)
 Add a save point for simulation data at given time.
 
FileList saveObservers (const string_view output_directory, const string_view base_name) const
 Tell Observers to save their data with base file name.
 
FileList saveObservers (const string_view output_directory, DurationSize time) const
 Tell Observers to save their data for the given time.
 
FileList saveIntensity (const string_view output_directory, const string_view 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 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.
 
 Scenario (Model *model, size_t id, const ptr< const FireWeather > weather, const ptr< const FireWeather > weather_daily, DurationSize start_time, const shared_ptr< Perimeter > &perimeter, const XYIdx &start_xy, StartPoint start_point, Day start_day, Day last_date)
 Constructor.
 

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 Attributes

string log_prefix_ {}
 
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_
 
BurnedData unburnable_ {}
 Contains information on cells that are not burnable.
 
set< Event > scheduler_
 Event scheduler used for ordering events.
 
unique_ptr< IntensityMap > intensity_ {nullptr}
 Map of what intensity each cell has burned at.
 
shared_ptr< Perimeter > perimeter_ {nullptr}
 Perimeter used to start Scenario from.
 
map< SpreadKey, SpreadInfo > spread_info_ {}
 Calculated SpreadInfo for SpreadKey for current time.
 
map< XYIdx, DurationSize > arrival_ {}
 Map of when Cell had first Point arrive in it.
 
MathSize max_ros_
 Maximum rate of spread for current time.
 
XYIdx start_xy_ {}
 Cell that the Scenario starts from if no Perimeter.
 
ptr< const FireWeather > weather_ {nullptr}
 Hourly weather to use for this Scenario.
 
ptr< const FireWeather > weather_daily_ {nullptr}
 Weather stream to use for spread and extinction probability.
 
Model * model_ {nullptr}
 Model this Scenario is being run in.
 
map< DurationSize, shared_ptr< ProbabilityMap > > * probabilities_ {nullptr}
 Map of ProbabilityMaps by time snapshot for them was taken.
 
ptr< SafeVector > final_sizes_ {nullptr}
 Where to append the final size of this Scenario when run is complete.
 
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.
 
size_t step_
 How many times point spread event has happened.
 
LogPoints points_log_ {}
 Point logging.
 
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()

fs::Scenario::Scenario ( Model * model,
size_t id,
const ptr< const FireWeather > weather,
const ptr< const FireWeather > weather_daily,
DurationSize start_time,
const shared_ptr< Perimeter > & perimeter,
const XYIdx & start_xy,
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_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

◆ addEvent()

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

Add an Event to the queue.

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

◆ addSave()

void fs::Scenario::addSave ( const DurationSize time)

Add a save point for simulation data at given time.

Parameters
timeTime to add save point at

◆ addSaveByOffset()

void fs::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::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::Scenario::canBurn ( const XYIdx & 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::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

◆ cellSize()

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

Cell width and height (m)

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

◆ completed()

size_t fs::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::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::Scenario::currentFireSize ( ) const
nodiscard

Current fire size (ha)

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

◆ dayEnd()

DurationSize fs::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::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::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::Scenario::evaluateNextEvent ( )

Evaluate next Event in the queue.

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

◆ extinctionThreshold()

ThresholdSize fs::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::Scenario::hasBurned ( const XYIdx & location) const
nodiscard

Whether or not Location has burned already.

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

◆ id()

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

Identifier.

Returns
Identifier

◆ isAtNight()

bool fs::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::Scenario::isSurrounded ( const XYIdx & 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

◆ minimumFfmcForSpread()

MathSize fs::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:

◆ model()

const Model & fs::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::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:

◆ notify()

void fs::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:

◆ ran()

bool fs::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::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::Scenario::reset ( mt19937_64 * mt_extinction,
mt19937_64 * mt_spread,
ptr< 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::Scenario::reset_with_new_start ( const XYIdx & start_cell,
ptr< 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:

◆ run()

Scenario * fs::Scenario::run ( map< DurationSize, shared_ptr< 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:
Here is the caller graph for this function:

◆ saveIntensity()

FileList fs::Scenario::saveIntensity ( const string_view output_directory,
const string_view base_name ) const
nodiscard

Save burn intensity information.

Parameters
output_directoryDirectory to save to
base_nameBase file name
Returns
FileList of file names saved to
Here is the caller graph for this function:

◆ saveObservers() [1/2]

FileList fs::Scenario::saveObservers ( const string_view output_directory,
const string_view base_name ) const
nodiscard

Tell Observers to save their data with base file name.

Parameters
output_directoryDirectory to save to
base_nameBase file name
Returns
FileList of file names saved to
Here is the caller graph for this function:

◆ saveObservers() [2/2]

FileList fs::Scenario::saveObservers ( const string_view output_directory,
DurationSize time ) const
nodiscard

Tell Observers to save their data for the given time.

Parameters
output_directoryDirectory to save to
timeTime to save data for
Returns
FileList of file names saved to
Here is the call graph for this function:

◆ savePoints()

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

List of what times the simulation will save.

Returns
List of what times the simulation will save

◆ saveStats()

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

Save state of Scenario at given time.

Parameters
time
Here is the caller graph for this function:

◆ scheduleFireSpread()

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

Schedule a fire spread Event.

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

◆ simulation()

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

Simulation number.

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

◆ spreadThresholdByRos()

ThresholdSize fs::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 StartPoint & fs::Scenario::startPoint ( ) const
inlinenodiscardconstexpr

StartPoint that provides sunrise/sunset times.

Returns
StartPoint

◆ startTime()

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

Simulation start time.

Returns
Simulation start time

◆ survives()

bool fs::Scenario::survives ( const DurationSize time,
const 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::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()

ptr< const FwiWeather > fs::Scenario::weather ( const DurationSize time) const
inlinenodiscard

FwiWeather for given time.

Parameters
timeTime to get weather for (decimal days)
Returns
FwiWeather for given time

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