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

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

#include <Model.h>

Collaboration diagram for fs::Model:

Public Member Functions

Cell cell (const XYIdx xy) const
 
constexpr Idx height () const
 
constexpr Idx width () const
 
constexpr MathSize cellSize () const
 Cell width and height (m)
 
constexpr const Environment & environment () 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.
 
constexpr Clock::duration interimTimeLimit () const
 Time between generating interim outputs (s)
 
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 isUnderSimulationCountMinimum () const noexcept
 Whether or not simulation is under min simulation count.
 
size_t activeSimulationsStillRequired () const noexcept
 How many active simulations are still needed.
 
bool isOverSimulationCountMaximum () const noexcept
 Whether or not simulation is over max simulation count.
 
int year () const noexcept
 What year the weather is for.
 
size_t ignitionScenarios () const noexcept
 How many ignition scenarios are being used.
 
size_t 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.
 
std::chrono::seconds timeSinceLastSave () const
 
shared_ptr< ProbabilityMap > makeProbabilityMap (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 tm &start_time, const string_view output_directory, const StartPoint &start_point, Environment *env)
 Constructor.
 
 Model (const tm &start_time, const string_view output_directory, const StartPoint &start_point, Environment *env, const Settings &settings)
 
 Model (Model &&rhs) noexcept=delete
 
 Model (const Model &rhs)=delete
 
Model & operator= (Model &&rhs) noexcept=delete
 
Model & operator= (const Model &rhs)=delete
 
void setWeather (const FwiWeather &weather, const Day start_day)
 Set constant weather.
 
void readWeather (const FwiWeather &yesterday, const MathSize latitude, const string &filename)
 Read weather used for Scenarios.
 
void makeStarts (Coordinates coordinates, const Point &point, const LazyPath &perim, size_t size)
 Make starts based on desired point and where nearest combustible cells are.
 
Iteration readScenarios (const StartPoint &start_point, DurationSize start, Day start_day, Day last_date)
 Create an Iteration by initializing Scenarios.
 
ptr< const FwiWeather > yesterday () const noexcept
 
MathSize initial_size () const
 Initial fire size at start of scenario.
 

Static Public Member Functions

static int runScenarios (const string_view output_directory, const LazyPath &weather_input, const FwiWeather &yesterday, const char *raster_root, const StartPoint &start_point, const tm &start_time, const LazyPath &perimeter, const 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 SafeVector &sizes)
 Add statistics for completed iterations.
 
map< DurationSize, shared_ptr< ProbabilityMap > > runIterations (const 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, shared_ptr< ProbabilityMap > > &probabilities, const Day start_day, const bool is_interim)
 
void findStarts (const XYIdx &location)
 Find Cell(s) that can burn closest to Location.
 

Private Attributes

const string output_directory_
 
tm start_time_ {}
 Start time of simulation.
 
array< int, MAX_DAYS > nd_ {}
 Differences between date and the date of minimum foliar moisture content.
 
map< size_t, FireWeather > wx_ {}
 Map of scenario number to weather stream.
 
map< size_t, FireWeather > wx_daily_ {}
 Map of scenario number to weather stream.
 
vector< XYIdx > 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.
 
Clock::time_point no_interim_save_since_
 Time of last interim save.
 
Clock::duration interim_save_interval_
 
shared_ptr< Perimeter > perimeter_ = nullptr
 Perimeter to use for initializing simulations.
 
Environment * env_ {nullptr}
 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 should_output_interim_ = false
 If simulation is past the time interval between interim outputs.
 
bool is_being_cancelled_ = false
 If simulation is being cancelled.
 
atomic< size_t > scenarios_done_ = 0
 How many scenarios have been completed.
 
atomic< size_t > scenarios_required_done_ = 0
 How many scenarios out of first iteration have been completed.
 
atomic< size_t > scenarios_last_save_ = 0
 Scenarios completed at time of last interim save.
 
size_t scenarios_per_iteration_ = 0
 Number of scenarios per iteration.
 
size_t iterations_done_ = 0
 How many iterations have been completed.
 
bool interim_changed_ = true
 If interim outputs are different than last time they were saved.
 
bool is_under_simulation_minimum_ {true}
 If simulation is undex min simulation count.
 
size_t active_simulations_still_required_ {}
 Number of active simulations still required.
 
bool is_over_simulation_count_ = false
 If simulation is over max simulation count.
 
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::Model::Model ( const tm & start_time,
const string_view output_directory,
const StartPoint & start_point,
Environment * env )

Constructor.

Parameters
start_pointStartPoint to use for sunrise/sunset times
envEnvironment to run simulations in

Member Function Documentation

◆ activeSimulationsStillRequired()

size_t fs::Model::activeSimulationsStillRequired ( ) const
nodiscardnoexcept

How many active simulations are still needed.

Returns
How many active simulations are still needed
Here is the caller graph for this function:

◆ add_statistics()

bool fs::Model::add_statistics ( vector< MathSize > * all_sizes,
vector< MathSize > * means,
vector< MathSize > * pct,
const 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:

◆ cellSize()

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

◆ environment()

const Environment & fs::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::Model::findStarts ( const XYIdx & 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:

◆ ignitionScenarios()

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

◆ interimTimeLimit()

Clock::duration fs::Model::interimTimeLimit ( ) const
inlinenodiscardconstexpr

Time between generating interim outputs (s)

Returns
Time between generating interim outputs (s)
Here is the caller graph for this function:

◆ isOutOfTime()

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

◆ isOverSimulationCountMaximum()

bool fs::Model::isOverSimulationCountMaximum ( ) 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:

◆ isUnderSimulationCountMinimum()

bool fs::Model::isUnderSimulationCountMinimum ( ) const
nodiscardnoexcept

Whether or not simulation is under min simulation count.

Returns
Whether or not simulation is under min simulation count
Here is the caller graph for this function:

◆ makeProbabilityMap()

shared_ptr< ProbabilityMap > fs::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::Model::makeStarts ( Coordinates coordinates,
const Point & point,
const LazyPath & 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::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::Model::readScenarios ( const 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 caller graph for this function:

◆ readWeather()

void fs::Model::readWeather ( const 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:

◆ runIterations()

map< DurationSize, shared_ptr< ProbabilityMap > > fs::Model::runIterations ( const 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::Model::runningSince ( ) const
inlinenodiscardconstexpr

Time that execution started.

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

◆ runScenarios()

int fs::Model::runScenarios ( const string_view output_directory,
const LazyPath & weather_input,
const FwiWeather & yesterday,
const char * raster_root,
const StartPoint & start_point,
const tm & start_time,
const LazyPath & perimeter,
const size_t size )
staticnodiscard

Run Scenarios initialized from given inputs.

Parameters
output_directoryFolder 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::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::Model::saveProbabilities ( map< DurationSize, shared_ptr< 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()

size_t fs::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::Model::setWeather ( const FwiWeather & weather,
const Day start_day )

Set constant weather.

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

◆ shouldStop()

bool fs::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::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::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()

ptr< const FwiWeather > fs::Model::yesterday ( ) const
inlinenoexcept

Conditions for yesterday (or constant weather)

Here is the caller graph for this function:

Member Data Documentation

◆ interim_save_interval_

Clock::duration fs::Model::interim_save_interval_
private

\briefTime between generating interim outputs

◆ yesterday_

FwiWeather fs::Model::yesterday_
private

Conditions for yesterday (or constant weather)


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