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

Contains all the immutable information regarding a simulation that is common between Scenarios. More...

#include <Model.h>

Collaboration diagram for fs::sim::Model:

Public Member Functions

topo::Cell cell (const Idx row, const Idx column) const
 Cell at the given row and column.
 
template<class P >
constexpr topo::Cell cell (const Position< P > &position) const
 Cell at the given Location.
 
constexpr Idx rows () const
 Cell at the Location represented by the given hash.
 
constexpr Idx columns () const
 Number of columns in extent.
 
constexpr MathSize cellSize () const
 Cell width and height (m)
 
constexpr const topo::Environmentenvironment () const
 Environment simulation is occurring in.
 
constexpr Clock::time_point runningSince () const
 Time that execution started.
 
constexpr Clock::duration timeLimit () const
 Maximum amount of time simulation can run for before being stopped.
 
bool shouldStop () const noexcept
 Whether or not simulation has exceeded any limits that mean it should stop.
 
bool isOutOfTime () const noexcept
 Whether or not simulation has been running longer than maximum duration.
 
bool isOverSimulationCountLimit () const noexcept
 Whether or not simulation is over max simulation count.
 
int year () const noexcept
 What year the weather is for.
 
int ignitionScenarios () const noexcept
 How many ignition scenarios are being used.
 
int scenarioCount () const noexcept
 How many Scenarios are in each Iteration.
 
constexpr int nd (const DurationSize time) const
 Difference between date and the date of minimum foliar moisture content.
 
const char * outputDirectory () const
 
std::chrono::seconds runTime () const
 Duration that model has run for.
 
ProbabilityMapmakeProbabilityMap (DurationSize time, DurationSize start_time, int min_value, int low_max, int med_max, int max_value) const
 Create a ProbabilityMap with the same extent as this.
 
 Model (const string dir_out, const topo::StartPoint &start_point, topo::Environment *env)
 Constructor.
 
 Model (Model &&rhs) noexcept=delete
 
 Model (const Model &rhs)=delete
 
Modeloperator= (Model &&rhs) noexcept=delete
 
Modeloperator= (const Model &rhs)=delete
 
void setWeather (const wx::FwiWeather &weather, const Day start_day)
 Set constant weather.
 
void readWeather (const wx::FwiWeather &yesterday, const MathSize latitude, const string &filename)
 Read weather used for Scenarios.
 
void makeStarts (Coordinates coordinates, const topo::Point &point, string perim, size_t size)
 Make starts based on desired point and where nearest combustible cells are.
 
Iteration readScenarios (const topo::StartPoint &start_point, DurationSize start, Day start_day, Day last_date)
 Create an Iteration by initializing Scenarios.
 
BurnedData * getBurnedVector () const noexcept
 Acquire a BurnedData that has already burnt cells set.
 
void releaseBurnedVector (BurnedData *has_burned) const noexcept
 Return a BurnedData so it can be used in the future.
 
const wx::FwiWeatheryesterday () const noexcept
 

Static Public Member Functions

static int runScenarios (const string dir_out, const char *weather_input, const wx::FwiWeather &yesterday, const char *raster_root, const topo::StartPoint &start_point, const tm &start_time, const string &perimeter, size_t size)
 Run Scenarios initialized from given inputs.
 

Static Public Attributes

static Semaphore task_limiter {static_cast<int>(std::thread::hardware_concurrency())}
 Semaphore used to limit how many things run at once.
 

Private Member Functions

bool add_statistics (vector< MathSize > *all_sizes, vector< MathSize > *means, vector< MathSize > *pct, const util::SafeVector &sizes)
 Add statistics for completed iterations.
 
map< DurationSize, ProbabilityMap * > runIterations (const topo::StartPoint &start_point, DurationSize start, Day start_day)
 Run Iterations until confidence is reached.
 
void findAllStarts ()
 Find all Cell(s) that can burn in entire Environment.
 
DurationSize saveProbabilities (map< DurationSize, ProbabilityMap * > &probabilities, const Day start_day, const bool is_interim)
 
void findStarts (Location location)
 Find Cell(s) that can burn closest to Location.
 

Private Attributes

const string dir_out_
 
mutex vector_mutex_
 Mutex for parallel access.
 
tm start_time_
 Start time of simulation.
 
vector< unique_ptr< BurnedData > > vectors_ {}
 Pool of BurnedData that can be reused.
 
array< int, MAX_DAYS > nd_ {}
 Differences between date and the date of minimum foliar moisture content.
 
map< size_t, shared_ptr< wx::FireWeather > > wx_ {}
 Map of scenario number to weather stream.
 
map< size_t, shared_ptr< wx::FireWeather > > wx_daily_ {}
 Map of scenario number to weather stream.
 
vector< shared_ptr< topo::Cell > > starts_ {}
 Cell(s) that can burn closest to start Location.
 
Clock::time_point running_since_
 Time to use for simulation start.
 
Clock::duration time_limit_
 Maximum amount of time simulation can run for before being stopped.
 
shared_ptr< topo::Perimeterperimeter_ = nullptr
 Initial intensity map based off perimeter.
 
topo::Environmentenv_
 Environment to use for Model.
 
int year_
 What year the weather is for.
 
bool is_out_of_time_ = false
 If simulation is out of time and should stop.
 
bool is_over_simulation_count_ = false
 If simulation is over max simulation count.
 
wx::FwiWeather yesterday_
 
std::chrono::steady_clock::time_point last_checked_
 Time when we last checked if simulation should end.
 
MathSize latitude_
 Latitude to use for any calcualtions.
 
MathSize longitude_
 Longitude to use for any calcualtions.
 

Detailed Description

Contains all the immutable information regarding a simulation that is common between Scenarios.

Constructor & Destructor Documentation

◆ Model()

fs::sim::Model::Model ( const string dir_out,
const topo::StartPoint & start_point,
topo::Environment * env )

Constructor.

Parameters
start_pointStartPoint to use for sunrise/sunset times
envEnvironment to run simulations in
Here is the call graph for this function:

Member Function Documentation

◆ add_statistics()

bool fs::sim::Model::add_statistics ( vector< MathSize > * all_sizes,
vector< MathSize > * means,
vector< MathSize > * pct,
const util::SafeVector & sizes )
nodiscardprivate

Add statistics for completed iterations.

Parameters
all_sizesAll sizes that have simulations have produced
meansMean sizes per iteration
pct95th percentile sizes per iteration
cur_sizesSizes to add to statistics
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cell() [1/2]

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

Cell at the given row and column.

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

◆ cell() [2/2]

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

Cell at the given Location.

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

◆ cellSize()

MathSize fs::sim::Model::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::Model::columns ( ) const
inlinenodiscardconstexpr

Number of columns in extent.

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

◆ environment()

const topo::Environment & fs::sim::Model::environment ( ) const
inlinenodiscardconstexpr

Environment simulation is occurring in.

Returns
Environment simulation is occurring in
Here is the caller graph for this function:

◆ findStarts()

void fs::sim::Model::findStarts ( Location location)
private

Find Cell(s) that can burn closest to Location.

Parameters
locationLocation to look for start Cells
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBurnedVector()

BurnedData * fs::sim::Model::getBurnedVector ( ) const
nodiscardnoexcept

Acquire a BurnedData that has already burnt cells set.

Returns
A BurnedData that has already burnt cells set
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ignitionScenarios()

int fs::sim::Model::ignitionScenarios ( ) const
inlinenodiscardnoexcept

How many ignition scenarios are being used.

Returns
How many ignition scenarios are being used
Here is the caller graph for this function:

◆ isOutOfTime()

bool fs::sim::Model::isOutOfTime ( ) const
nodiscardnoexcept

Whether or not simulation has been running longer than maximum duration.

Returns
Whether or not simulation has been running longer than maximum duration
Here is the caller graph for this function:

◆ isOverSimulationCountLimit()

bool fs::sim::Model::isOverSimulationCountLimit ( ) const
nodiscardnoexcept

Whether or not simulation is over max simulation count.

Returns
Whether or not simulation is over max simulation count
Here is the caller graph for this function:

◆ makeProbabilityMap()

ProbabilityMap * fs::sim::Model::makeProbabilityMap ( DurationSize time,
DurationSize start_time,
int min_value,
int low_max,
int med_max,
int max_value ) const
nodiscard

Create a ProbabilityMap with the same extent as this.

Parameters
timeTime in simulation this ProbabilityMap represents
start_timeStart time of simulation
min_valueLower bound of 'low' intensity range
low_maxUpper bound of 'low' intensity range
med_maxUpper bound of 'moderate' intensity range
max_valueUpper bound of 'high' intensity range
Returns
ProbabilityMap with the same extent as this
Here is the call graph for this function:

◆ makeStarts()

void fs::sim::Model::makeStarts ( Coordinates coordinates,
const topo::Point & point,
string perim,
size_t size )

Make starts based on desired point and where nearest combustible cells are.

Parameters
coordinatesCoordinates in the Environment to try starting at
pointPoint Coordinates represent
perimPerimeter to start from, if there is one
sizeSize of fire to create if no input Perimeter
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nd()

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

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

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

◆ readScenarios()

Iteration fs::sim::Model::readScenarios ( const topo::StartPoint & start_point,
DurationSize start,
Day start_day,
Day last_date )
nodiscard

Create an Iteration by initializing Scenarios.

Parameters
start_pointStartPoint to use for sunrise/sunset
startStart time for simulation
start_dayStart date for simulation
last_dateEnd date for simulation
Returns
Iteration containing initialized Scenarios
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readWeather()

void fs::sim::Model::readWeather ( const wx::FwiWeather & yesterday,
const MathSize latitude,
const string & filename )

Read weather used for Scenarios.

Parameters
yesterdayFwiWeather for yesterday
latitudeLatitude to calculate for
filenameWeather file to read
Here is the call graph for this function:
Here is the caller graph for this function:

◆ releaseBurnedVector()

void fs::sim::Model::releaseBurnedVector ( BurnedData * has_burned) const
noexcept

Return a BurnedData so it can be used in the future.

Parameters
has_burnedBurnedData to return to pool
Here is the caller graph for this function:

◆ rows()

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

Cell at the Location represented by the given hash.

Parameters
hash_sizeHash size for Location to get Cell for
Returns
Cell at the Location represented by the given hash

Number of rows in extent

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

◆ runIterations()

map< DurationSize, ProbabilityMap * > fs::sim::Model::runIterations ( const topo::StartPoint & start_point,
DurationSize start,
Day start_day )
private

Run Iterations until confidence is reached.

Parameters
start_pointStartPoint to use for sunrise/sunset
startStart time for simulation
start_dayStart day for simulation
Returns
Map of times to ProbabilityMap for that time
Here is the call graph for this function:
Here is the caller graph for this function:

◆ runningSince()

Clock::time_point fs::sim::Model::runningSince ( ) const
inlinenodiscardconstexpr

Time that execution started.

Returns
Time that execution started
Here is the caller graph for this function:

◆ runScenarios()

int fs::sim::Model::runScenarios ( const string dir_out,
const char * weather_input,
const wx::FwiWeather & yesterday,
const char * raster_root,
const topo::StartPoint & start_point,
const tm & start_time,
const string & perimeter,
size_t size )
staticnodiscard

Run Scenarios initialized from given inputs.

Parameters
dir_outFolder to save outputs to
weather_inputName of file to read weather from
yesterdayFwiWeather yesterday used for startup indices
raster_rootDirectory to read raster inputs from
start_pointStartPoint to use for sunrise/sunset
start_timeStart time for simulation
perimeterPerimeter to initialize fire from, if there is one
sizeSize to start fire at if no Perimeter
Returns
Here is the call graph for this function:

◆ runTime()

std::chrono::seconds fs::sim::Model::runTime ( ) const
nodiscard

Duration that model has run for.

Returns
std::chrono::seconds Duration model has been running for
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveProbabilities()

DurationSize fs::sim::Model::saveProbabilities ( map< DurationSize, ProbabilityMap * > & probabilities,
const Day start_day,
const bool is_interim )
private

Save probability rasters

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

◆ scenarioCount()

int fs::sim::Model::scenarioCount ( ) const
inlinenodiscardnoexcept

How many Scenarios are in each Iteration.

Returns
How many Scenarios are in each Iteration
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setWeather()

void fs::sim::Model::setWeather ( const wx::FwiWeather & weather,
const Day start_day )

Set constant weather.

Parameters
weatherFwiWeather to use as constant weather
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shouldStop()

bool fs::sim::Model::shouldStop ( ) const
nodiscardnoexcept

Whether or not simulation has exceeded any limits that mean it should stop.

Returns
Whether or not simulation has exceeded any limits that mean it should stop
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeLimit()

Clock::duration fs::sim::Model::timeLimit ( ) const
inlinenodiscardconstexpr

Maximum amount of time simulation can run for before being stopped.

Returns
Maximum amount of time simulation can run for before being stopped
Here is the caller graph for this function:

◆ year()

int fs::sim::Model::year ( ) const
inlinenodiscardnoexcept

What year the weather is for.

Returns
What year the weather is for
Here is the caller graph for this function:

◆ yesterday()

const wx::FwiWeather * fs::sim::Model::yesterday ( ) const
inlinenoexcept

Conditions for yesterday (or constant weather)

Here is the caller graph for this function:

Member Data Documentation

◆ perimeter_

shared_ptr<topo::Perimeter> fs::sim::Model::perimeter_ = nullptr
private

Initial intensity map based off perimeter.

Perimeter to use for initializing simulations

◆ yesterday_

wx::FwiWeather fs::sim::Model::yesterday_
private

Conditions for yesterday (or constant weather)


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