FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Parallel::FMTReplanningTask Class Reference

Replanning task using global, stochastic and local abstract models to simulate natural disturbances over several replanning periods for multiple replications. More...

#include <FMTReplanningTask.h>

Inheritance diagram for Parallel::FMTReplanningTask:
[legend]
Collaboration diagram for Parallel::FMTReplanningTask:
[legend]

Public Member Functions

 FMTReplanningTask ()=default
 Default constructor for FMTReplanningTask.
 
 FMTReplanningTask (const FMTReplanningTask &rhs)=default
 Default copy constructor for FMTReplanningTask.
 
FMTReplanningTaskoperator= (const FMTReplanningTask &rhs)=default
 Default copy assignment operator for FMTReplanningTask.
 
virtual ~FMTReplanningTask ()=default
 Default destructor for FMTReplanningTask.
 
std::unique_ptr< FMTTaskclone () const
 Clone function for FMTReplanningTask.
 
 FMTReplanningTask (const Models::FMTModel &globalm, const Models::FMTModel &stochasticm, const Models::FMTModel &localm, const std::vector< Core::FMTOutput > &outputs, const std::string &outputlocation, const std::string &gdaldriver, const std::vector< std::string > &creationoptions, const int &replicates, const int &replanningperiodssize, const double &minimaldrift, Core::FMToutputlevel outputlevel, const bool writeSchedule=false)
 Construct a FMTReplanningTask from the models and the replanning parameters.
 
 FMTReplanningTask (const Models::FMTModel &globalm, const Models::FMTModel &stochasticm, const Models::FMTModel &localm, const std::string &outputlocation, const std::string &gdaldriver, const std::vector< std::string > &creationoptions, Core::FMToutputlevel outputlevel)
 Short constructor for the replanning task using the outputs of the global model and 0.5 as minimal drift.
 
void setReplicates (const int &replicatesnumber)
 Set the number of replicates to use.
 
void setReplicates (const int &replicatesnumbermin, const int &replicatesnumbermax)
 Set the range of replicates to use.
 
void setReplanningPeriods (const int &periodsnumber)
 Set the number of replanning periods.
 
virtual std::vector< std::unique_ptr< FMTTask > > split (const unsigned int &numberoftasks) const
 Split the main task into multiple replanning tasks.
 
virtual std::unique_ptr< FMTTaskspawn ()
 Spawn a minimal task from the master task.
 
virtual void work ()
 Main function doing the replanning task.
 
virtual void finalize ()
 Take care of writing the drift probabilities at finalization.
 
void passInLogger (const std::unique_ptr< Logging::FMTLogger > &logger) override
 Pass in the logger.
 
void setWriteSchedule (const bool p_write)
 Set whether a replanning schedule is written for each replicate.
 
bool SupportsMultiThreading () const override
 Check if the task support multithreading.
 
- Public Member Functions inherited from Parallel::FMTTask
 FMTTask ()
 Default constructor for FMTTask.
 
virtual ~FMTTask ()=default
 Default virtual destructor for FMTTask.
 
 FMTTask (const FMTTask &rhs)
 Default copy constructor for FMTTask.
 
FMTTaskoperator= (const FMTTask &rhs)
 Default copy assignment operator for FMTTask.
 
virtual std::unique_ptr< FMTTaskclone () const
 Clone function for FMTTask.
 
virtual std::vector< std::unique_ptr< FMTTask > > split (const unsigned int &numberoftasks) const
 Split the actual task into multiple tasks.
 
virtual std::unique_ptr< FMTTaskspawn ()
 Spawn a minimal task from the master task.
 
virtual void work ()
 Main job executed by the thread.
 
virtual void run ()
 Set up the crash handler and call work.
 
virtual void finalize ()
 Called right after the last task is done, when overridden.
 
virtual bool SupportsMultiThreading () const
 Check if the task support multithreading.
 
- Public Member Functions inherited from Core::FMTObject
 FMTObject ()
 Default constructor for FMTObject.
 
virtual ~FMTObject ()
 Default virtual destructor for FMTObject.
 
 FMTObject (const std::unique_ptr< Exception::FMTExceptionHandler > exhandler)
 Construct a FMTObject passing in the exception handler of another FMTObject.
 
 FMTObject (const FMTObject &rhs)
 Copy constructor for FMTObject.
 
FMTObjectoperator= (const FMTObject &rhs)
 Copy assignment operator for FMTObject.
 
virtual void passInLogger (const std::unique_ptr< Logging::FMTLogger > &logger)
 Pass in the logger of another FMTObject.
 
void passInExceptionHandler (const std::unique_ptr< Exception::FMTExceptionHandler > &exhandler)
 Pass in the exception handler of another FMTObject.
 
void redirectLogToFile (const std::string &location)
 Redirect the log to a specific file, appending to it.
 
virtual void setDefaultLogger ()
 Create and set a default logger to the FMTObject.
 
virtual void setQuietLogger ()
 Create and set a quiet logger to the FMTObject.
 
virtual void setTaskLogger ()
 Create and set a task logger to the FMTObject.
 
virtual void setDebugLogger ()
 Create and set a debug logger to the FMTObject.
 
void setDefaultExceptionHandler ()
 Create and set a default exception handler to the FMTObject.
 
void setQuietExceptionHandler ()
 Create and set a quiet exception handler to the FMTObject.
 
void setDebugExceptionHandler ()
 Create and set a debug exception handler to the FMTObject.
 
void setFreeExceptionHandler ()
 Create and set a free exception handler to the FMTObject.
 
void disableNestedExceptions ()
 Disable the nested exception throw of the exception handler.
 
void enableNestedExceptions ()
 Enable the nested exception throw of the exception handler.
 
void setErrorsToWarnings (const std::vector< Exception::FMTexc > &errors)
 Set a list of errors to be cast to warnings on the exception handler.
 
void setMaxWarningsBeforeSilenced (const size_t &maxwarningcount)
 Set the number of warnings raised before being silenced.
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Additional Inherited Members

- Static Public Member Functions inherited from Parallel::FMTTask
static std::string getThreadId ()
 Return true if the job is all done.
 
static void setTotalThreads (const size_t &p_threads)
 Set the total amount of threads.
 
- Static Public Member Functions inherited from Core::FMTObject
static Logging::FMTLoggergetLogger ()
 get a pointer to the actual logger.
 
static Exception::FMTExceptionHandlergetExceptionHandler ()
 get a pointer to the actual exception handler.
 
static std::string getRuntimeLocation ()
 Return the location of the FMT shared library.
 
static unsigned long long getAvailableMemory ()
 Return the available memory in bytes.
 
static void setTerminateStack ()
 will write the stack in the log when terminate called and raise a function failed.
 
static void setAbortStack ()
 will write the stack in the log when abort called with SIGABRT and raise a function failed.
 
- Public Attributes inherited from Parallel::FMTTask
bool done
 If the task is done true else false.
 
- Protected Member Functions inherited from Parallel::FMTTask
std::vector< size_t > _splitWork (int numberoftasks, const int &totalworksize) const
 Change the status of the task.
 
void _decrementWorkingThread ()
 Decrement the number of working threads.
 
void _checkpoint ()
 Wait for the other threads to finish their jobs, then continue.
 
void _setCrashHandlers ()
 Set the terminate and abort handlers before running the global function in the thread, and set the se_translator on Windows.
 
- Protected Member Functions inherited from Core::FMTObject
template<class Archive >
void forceSave (Archive &ar, const unsigned int version) const
 Force the serialization to save useful information, which the default FMTObject serialization does not.
 
template<class Archive >
void forceLoad (Archive &ar, const unsigned int version)
 Force the serialization to load useful information, which the default FMTObject serialization does not.
 
void checkSignals () const
 Check if the user has sent a ctrl-c signal using boost::python to FMT.
 
void setCplHandler ()
 Pass the FMT exception handler to the GDAL exception handler (GDAL only).
 
- Static Protected Member Functions inherited from Core::FMTObject
static std::chrono::time_point< std::chrono::high_resolution_clock > getClock ()
 Return a clock of the current time.
 
template<class chrono >
static double getDuration (const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
 Return the time elapsed since a start clock as a double.
 
static std::string getDurationInSeconds (const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
 Return the time elapsed since a start clock in seconds as a string.
 
static void _logStack ()
 Log the stack trace...
 
static void _terminate ()
 Raise an error with the boost stacktrace.
 
static void _abort (int p_signal)
 Raise an error with the boost stacktrace on abort.
 
- Protected Attributes inherited from Parallel::FMTTask
std::unique_ptr< Logging::FMTLoggerm_tasklogger
 
- Static Protected Attributes inherited from Parallel::FMTTask
static boost::recursive_mutex m_taskmutex
 Recursive mutex for the task.
 
- Static Protected Attributes inherited from Core::FMTObject
static std::unique_ptr< Exception::FMTExceptionHandler_exhandler
 A shared pointer to the exception handler.
 
static std::unique_ptr< Logging::FMTLogger_logger
 A shared pointer to the logger.
 

Detailed Description

Replanning task using global, stochastic and local abstract models to simulate natural disturbances over several replanning periods for multiple replications.

The replications may generate different results because of the pseudo random constraints and seed used in the simulations and optimizations of each abstract model.

Constructor & Destructor Documentation

◆ FMTReplanningTask() [1/4]

Parallel::FMTReplanningTask::FMTReplanningTask ( )
default

Default constructor for FMTReplanningTask.

◆ FMTReplanningTask() [2/4]

Parallel::FMTReplanningTask::FMTReplanningTask ( const FMTReplanningTask rhs)
default

Default copy constructor for FMTReplanningTask.

Parameters
[in]rhsthe FMTReplanningTask to copy.

◆ ~FMTReplanningTask()

virtual Parallel::FMTReplanningTask::~FMTReplanningTask ( )
virtualdefault

Default destructor for FMTReplanningTask.

◆ FMTReplanningTask() [3/4]

Parallel::FMTReplanningTask::FMTReplanningTask ( const Models::FMTModel globalm,
const Models::FMTModel stochasticm,
const Models::FMTModel localm,
const std::vector< Core::FMTOutput > &  outputs,
const std::string &  outputlocation,
const std::string &  gdaldriver,
const std::vector< std::string > &  creationoptions,
const int &  replicates,
const int &  replanningperiodssize,
const double &  minimaldrift,
Core::FMToutputlevel  outputlevel,
const bool  writeSchedule = false 
)

Construct a FMTReplanningTask from the models and the replanning parameters.

The models need to have common sections.

Parameters
[in]globalmthe global model.
[in]stochasticmthe stochastic model.
[in]localmthe local model.
[in]outputsthe outputs to write.
[in]outputlocationthe output location.
[in]gdaldriverthe GDAL driver of the output file.
[in]creationoptionsthe creation options.
[in]replicatesthe number of replicates.
[in]replanningperiodssizethe number of replanning periods.
[in]minimaldriftthe minimal drift.
[in]outputlevelthe output level.
[in]writeScheduleif true writes a schedule for each replicate.

◆ FMTReplanningTask() [4/4]

Parallel::FMTReplanningTask::FMTReplanningTask ( const Models::FMTModel globalm,
const Models::FMTModel stochasticm,
const Models::FMTModel localm,
const std::string &  outputlocation,
const std::string &  gdaldriver,
const std::vector< std::string > &  creationoptions,
Core::FMToutputlevel  outputlevel 
)

Short constructor for the replanning task using the outputs of the global model and 0.5 as minimal drift.

You then need to set the number of replanning periods, the global weight and the number of replicates.

Parameters
[in]globalmthe global model.
[in]stochasticmthe stochastic model.
[in]localmthe local model.
[in]outputlocationthe output location.
[in]gdaldriverthe GDAL driver.
[in]creationoptionsthe creation options.
[in]outputlevelthe output level.

Member Function Documentation

◆ clone()

std::unique_ptr< FMTTask > Parallel::FMTReplanningTask::clone ( ) const
virtual

Clone function for FMTReplanningTask.

Returns
a unique pointer to the cloned task.

Reimplemented from Parallel::FMTTask.

◆ finalize()

virtual void Parallel::FMTReplanningTask::finalize ( )
virtual

Take care of writing the drift probabilities at finalization.

Reimplemented from Parallel::FMTTask.

◆ operator=()

FMTReplanningTask & Parallel::FMTReplanningTask::operator= ( const FMTReplanningTask rhs)
default

Default copy assignment operator for FMTReplanningTask.

Parameters
[in]rhsthe FMTReplanningTask to copy.
Returns
a reference to this FMTReplanningTask.

◆ passInLogger()

void Parallel::FMTReplanningTask::passInLogger ( const std::unique_ptr< Logging::FMTLogger > &  logger)
overridevirtual

Pass in the logger.

Parameters
[in]loggerthe logger.

Reimplemented from Core::FMTObject.

◆ setReplanningPeriods()

void Parallel::FMTReplanningTask::setReplanningPeriods ( const int &  periodsnumber)

Set the number of replanning periods.

Parameters
[in]periodsnumberthe number of periods.

◆ setReplicates() [1/2]

void Parallel::FMTReplanningTask::setReplicates ( const int &  replicatesnumber)

Set the number of replicates to use.

Parameters
[in]replicatesnumberthe number of replicates.

◆ setReplicates() [2/2]

void Parallel::FMTReplanningTask::setReplicates ( const int &  replicatesnumbermin,
const int &  replicatesnumbermax 
)

Set the range of replicates to use.

Parameters
[in]replicatesnumberminthe minimal replicate number.
[in]replicatesnumbermaxthe maximal replicate number.

◆ setWriteSchedule()

void Parallel::FMTReplanningTask::setWriteSchedule ( const bool  p_write)

Set whether a replanning schedule is written for each replicate.

Parameters
[in]p_writeif true writes a schedule for each replicate.

◆ spawn()

virtual std::unique_ptr< FMTTask > Parallel::FMTReplanningTask::spawn ( )
virtual

Spawn a minimal task from the master task.

Returns
a unique pointer to the spawned task.

Reimplemented from Parallel::FMTTask.

◆ split()

virtual std::vector< std::unique_ptr< FMTTask > > Parallel::FMTReplanningTask::split ( const unsigned int &  numberoftasks) const
virtual

Split the main task into multiple replanning tasks.

Parameters
[in]numberoftasksthe number of tasks.
Returns
the split tasks.

Reimplemented from Parallel::FMTTask.

◆ SupportsMultiThreading()

bool Parallel::FMTReplanningTask::SupportsMultiThreading ( ) const
overridevirtual

Check if the task support multithreading.

Returns
true if it support

Reimplemented from Parallel::FMTTask.

◆ work()

virtual void Parallel::FMTReplanningTask::work ( )
virtual

Main function doing the replanning task.

Reimplemented from Parallel::FMTTask.


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