8#ifndef FMTMODEL_H_INCLUDED
9#define FMTMODEL_H_INCLUDED
21#include <boost/serialization/vector.hpp>
22#include <boost/serialization/map.hpp>
23#include <boost/serialization/unordered_map.hpp>
24#include <boost/serialization/export.hpp>
31 template<
class T1,
class T2>
34 class FMTgraphvertextoyield;
44 class FMTspatialschedule;
45 class FMTspatialnodescache;
61 template<
class T1,
class T2>
83 std::vector<Core::FMTschedule>
aggregateSchedules(
const std::vector<Core::FMTschedule>& p_schedules)
const;
100 FMTmodel(
const std::vector<Core::FMTactualdevelopment>& larea,
const std::vector<Core::FMTtheme>& lthemes,
101 const std::vector<Core::FMTaction>& lactions,
103 const std::string& lname,
const std::vector<Core::FMToutput>& loutputs, std::vector<Core::FMTconstraint> lconstraints = std::vector<Core::FMTconstraint>(),
129 virtual std::vector<Core::FMTactualdevelopment>
getarea(
int period = 0,
bool beforegrowanddeath =
false)
const;
135 virtual std::unique_ptr<FMTmodel>
getcopy(
int period = 0)
const;
165 virtual std::unique_ptr<FMTmodel>
presolve(std::vector<Core::FMTactualdevelopment> optionaldevelopments = std::vector<Core::FMTactualdevelopment>())
const;
177 const FMTmodel& originalbasemodel)
const;
258 const std::vector<Core::FMTtheme>& lthemes);
264 const std::vector<Core::FMTtheme>& lthemes);
277 std::string action = std::string(), std::string yield = std::string(), std::string description = std::string(),
int targettheme = -1);
287 yields.unshrink(themes);
288 for (
const auto& yldhandler : yieldhandlers)
290 std::unique_ptr<Core::FMTyieldhandler> yldhandlerptr = yldhandler.clone();
291 yields.push_back(yldhandlerptr->getmask(), yldhandlerptr);
296 _exhandler->printexceptions(
"",
"FMTmodel:::addyieldhandlers", __LINE__, __FILE__);
321 void setarea(
const std::vector<Core::FMTactualdevelopment>& ldevs);
326 void setthemes(
const std::vector<Core::FMTtheme>& lthemes);
331 void setactions(
const std::vector<Core::FMTaction>& lactions);
361 void setoutputs(
const std::vector<Core::FMToutput>& newoutputs);
417 bool ignoreoutputvariables =
false,
418 std::vector<Core::FMTtheme> basethemes = std::vector<Core::FMTtheme>())
const;
456 std::vector<Core::FMTactualdevelopment> selection,
bool withlock =
true)
const;
461 virtual std::vector<Core::FMTconstraint>
getreplanningconstraints(
const std::string& modeltype,
const std::vector<Core::FMTconstraint>& localconstraints,
const int& period)
const;
466 virtual bool doplanning(
const bool& solve, std::vector<Core::FMTschedule> schedules = std::vector<Core::FMTschedule>());
486 virtual std::map<std::string, std::vector<std::vector<double>>>
getoutputsfromperiods(
const std::vector<Core::FMToutput>& theoutputs,
492 virtual std::unique_ptr<FMTmodel>
clone()
const;
527 bool setcompresstime(
const int& periodstart,
const int& periodstop,
const int& value);
542 std::vector<Core::FMTconstraint>
gettacticalconstraints(
double penalty = 999999,
double scheduleweight = 999999,
double objective = 0,
double objectivefactor = 1.0)
const;
552 virtual bool build(std::vector<Core::FMTschedule> schedules = std::vector<Core::FMTschedule>())
583 std::vector<Core::FMTactualdevelopment>
area;
640 virtual void swap_ptr(
const std::unique_ptr<FMTmodel>& rhs);
663 friend class boost::serialization::access;
664 template<
class Archive>
665 void save(Archive& ar,
const unsigned int version)
const
667 ar& boost::serialization::make_nvp(
"FMTobject", boost::serialization::base_object<FMTobject>(*
this));
668 FMTobject::forcesave(ar, version);
669 ar& BOOST_SERIALIZATION_NVP(parameters);
670 ar& BOOST_SERIALIZATION_NVP(area);
671 ar& BOOST_SERIALIZATION_NVP(themes);
672 ar& BOOST_SERIALIZATION_NVP(actions);
673 ar& BOOST_SERIALIZATION_NVP(transitions);
674 ar& BOOST_SERIALIZATION_NVP(yields);
675 ar& BOOST_SERIALIZATION_NVP(lifespan);
676 ar& BOOST_SERIALIZATION_NVP(outputs);
677 ar& BOOST_SERIALIZATION_NVP(constraints);
678 ar& BOOST_SERIALIZATION_NVP(name);
684 template<
class Archive>
685 void load(Archive& ar,
const unsigned int version)
687 ar& boost::serialization::make_nvp(
"FMTobject", boost::serialization::base_object<FMTobject>(*
this));
688 FMTobject::forceload(ar, version);
689 ar& BOOST_SERIALIZATION_NVP(parameters);
690 ar& BOOST_SERIALIZATION_NVP(area);
691 ar& BOOST_SERIALIZATION_NVP(themes);
692 ar& BOOST_SERIALIZATION_NVP(actions);
693 ar& BOOST_SERIALIZATION_NVP(transitions);
694 ar& BOOST_SERIALIZATION_NVP(yields);
695 ar& BOOST_SERIALIZATION_NVP(lifespan);
696 ar& BOOST_SERIALIZATION_NVP(outputs);
697 ar& BOOST_SERIALIZATION_NVP(constraints);
698 ar& BOOST_SERIALIZATION_NVP(name);
701 BOOST_SERIALIZATION_SPLIT_MEMBER()
708 void validatelistmasks(const
Core::FMTlist<T>& container)
const
711 for (
const auto& listobject : container)
713 std::string name = std::string(listobject.first);
719 _exhandler->raisefromcatch(
"",
"FMTmodel::validatelistmasks", __LINE__, __FILE__);
735 std::map<std::string, std::pair<std::string,Core::FMTmask>> aggregateActions(
const std::vector<std::string>& p_ActionsMapping);
741 void aggregateTransitions(
const std::map<std::string, std::pair<std::string, Core::FMTmask>>& p_Filters);
749 void aggregateOutputs(
const std::map<std::string, std::pair<std::string, Core::FMTmask>>& p_Filters,
750 std::vector<Core::FMToutput*>& p_Outputs);
771 std::string model_name;
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTaction.hpp:42
Definition: FMTlifespans.hpp:24
Definition: FMTmask.hpp:96
Definition: FMTmaskfilter.hpp:27
Definition: FMTobject.hpp:50
Definition: FMToutput.hpp:39
Definition: FMToutputnode.hpp:20
Definition: FMTschedule.hpp:31
Definition: FMTbounds.hpp:342
static bool validate(const std::vector< Core::FMTtheme > &themes, std::string &mask, std::string otherinformation=std::string())
Definition: FMTtransition.hpp:37
Definition: FMTyields.hpp:40
Definition: FMTgraph.hpp:78
Definition: FMTgraphvertextoyield.hpp:27
Definition: FMTlinegraph.hpp:30
Definition: FMTlogger.hpp:37
Definition: FMTmodel.hpp:60
Core::FMTmask getdynamicmask(const Core::FMToutput &output, bool ignoreoutputvariables=false) const
void setname(const std::string &newname)
virtual void clearcache()
std::vector< int > getcompresstime() const
Core::FMTyields yields
Yields data comming from the yield file.
Definition: FMTmodel.hpp:595
void setyields(const Core::FMTyields &lylds)
virtual Core::FMTschedule getsolution(int period, bool withlock=false) const
void addyieldhandlersfromptr(const std::vector< std::unique_ptr< Core::FMTyieldhandler > > &yieldhandlers)
void addyieldhandlers(const std::vector< T > &yieldhandlers)
Definition: FMTmodel.hpp:284
Core::FMTlifespans getlifespan() const
Definition: FMTmodel.hpp:233
static Core::FMTtransition defaultdeathtransition(const Core::FMTlifespans &llifespan, const std::vector< Core::FMTtheme > <hemes)
std::vector< Core::FMTconstraint > constraints
Outputs comming from the optimization file.
Definition: FMTmodel.hpp:604
virtual bool setparameter(const FMTintmodelparameters &key, const int &value)
virtual void swap_ptr(const std::unique_ptr< FMTmodel > &rhs)
bool isstaticnode(const Core::FMToutputnode &node, double ratioofset=0.1) const
void push_back(const FMTmodel &rhs)
std::vector< size_t > statictransitionthemes
The location of the themes static from transitions.
Definition: FMTmodel.hpp:610
FMTmodel(const std::vector< Core::FMTactualdevelopment > &larea, const std::vector< Core::FMTtheme > <hemes, const std::vector< Core::FMTaction > &lactions, const std::vector< Core::FMTtransition > <ransitions, const Core::FMTyields &lyields, const Core::FMTlifespans &llifespan, const std::string &lname, const std::vector< Core::FMToutput > &loutputs, std::vector< Core::FMTconstraint > lconstraints=std::vector< Core::FMTconstraint >(), FMTmodelparameters lparameters=FMTmodelparameters())
FMTmodelstats getmodelstats() const
virtual void postsolve(const FMTmodel &originalbasemodel)
std::vector< Core::FMTconstraint > goalconstraints(double penalty=999999) const
void setconstraints(const std::vector< Core::FMTconstraint > &lconstraint)
std::string getname() const
Definition: FMTmodel.hpp:193
FMTmodel(FMTmodel &&rhs)=default
Core::FMTmask getstaticmask(const Core::FMToutputnode &node, bool ignoreoutputvariables=false) const
void setarea(const std::vector< Core::FMTactualdevelopment > &ldevs)
std::vector< Core::FMTtheme > themes
Model themes of the landscape section file.
Definition: FMTmodel.hpp:586
std::vector< Core::FMToutput > getoutputs() const
Definition: FMTmodel.hpp:241
Core::FMTyields getyields() const
Definition: FMTmodel.hpp:225
virtual std::map< std::string, std::vector< std::vector< double > > > getoutputsfromperiods(const std::vector< Core::FMToutput > &theoutputs, const int &firstperiod, const int &lastperiod, Core::FMToutputlevel level=Core::FMToutputlevel::standard) const
virtual bool isoptimal() const
std::vector< Core::FMTschedule > setupschedulesforbuild(const std::vector< Core::FMTschedule > &schedules) const
Models::FMTmodel aggregateAllActions(const std::vector< std::string > &p_Aggregates) const
Aggregate actions together and create en enterly new model with new -actions,transitions,...
std::vector< Core::FMTtransition > gettransitions() const
Definition: FMTmodel.hpp:217
std::vector< Core::FMTtheme > locatestaticthemes(const Core::FMToutputnode &output, bool ignoreoutputvariables=false) const
virtual void showparameters(const bool &showhelp=false) const
std::vector< Core::FMTtransition > transitions
Model transitions from the transition file and also the _death transition.
Definition: FMTmodel.hpp:592
size_t getseriesmaxsize() const
std::vector< Core::FMTtheme > locatedynamicthemes(const Core::FMToutput &outpu, bool ignoreoutputvariables=false) const
std::vector< Core::FMToutput > outputs
Outputs comming from the ouput file.
Definition: FMTmodel.hpp:601
Core::FMTmaskfilter getpostsolvefilter(const std::vector< Core::FMTtheme > &originalthemes, const Core::FMTmask &devmask) const
virtual std::vector< Core::FMTconstraint > getreplanningconstraints(const std::string &modeltype, const std::vector< Core::FMTconstraint > &localconstraints, const int &period) const
virtual bool setparameter(const FMTboolmodelparameters &key, const bool &value)
std::vector< Core::FMTaction > getactions() const
Definition: FMTmodel.hpp:209
std::vector< Core::FMTtheme > getthemes() const
Definition: FMTmodel.hpp:201
void cleanactionsntransitions()
virtual std::vector< Core::FMTactualdevelopment > getarea(int period=0, bool beforegrowanddeath=false) const
virtual std::unique_ptr< FMTmodel > getcopy(int period=0) const
std::vector< Core::FMTactualdevelopment > area
Actualdevelopments for period 0, seen in the area section or the shapefile/raster.
Definition: FMTmodel.hpp:583
bool setcompresstime(const int &periodstart, const int &periodstop, const int &value)
virtual std::unique_ptr< FMTmodel > clone() const
void setareaperiod(const int &period)
std::vector< Core::FMTtheme > getstaticpresolvethemes() const
virtual void setparallellogger(Logging::FMTlogger &logger)
void setlifespan(const Core::FMTlifespans &llifespan)
Core::FMTmask getdynamicmask(const Core::FMToutputnode &node, bool ignoreoutputvariables=false) const
void settransitions(const std::vector< Core::FMTtransition > <ransitions)
void setoutputs(const std::vector< Core::FMToutput > &newoutputs)
std::vector< Core::FMTtheme > locatenodestaticthemes(const Core::FMToutputnode &node, bool ignoreoutputvariables=false, std::vector< Core::FMTtheme > basethemes=std::vector< Core::FMTtheme >()) const
std::vector< Core::FMTtheme > locatestaticthemes(const Core::FMToutput &output, bool ignoreoutputvariables=false) const
Core::FMTschedule presolveschedule(const Core::FMTschedule &originalbaseschedule, const FMTmodel &originalbasemodel) const
std::vector< size_t > getstatictransitionthemes() const
int getparameter(const FMTintmodelparameters &key) const
std::vector< Core::FMTschedule > aggregateSchedules(const std::vector< Core::FMTschedule > &p_schedules) const
Build new schedule based on p_schedules with the corresponding aggregated actions.
void setactions(const std::vector< Core::FMTaction > &lactions)
virtual bool doplanning(const bool &solve, std::vector< Core::FMTschedule > schedules=std::vector< Core::FMTschedule >())
FMTmodel(const FMTmodel &rhs)
void addoutput(const std::string &name, const std::string &maskstring, Core::FMTotar outputtarget, std::string action=std::string(), std::string yield=std::string(), std::string description=std::string(), int targettheme=-1)
std::string name
The name of the Model (name of the .pri file without extension)
Definition: FMTmodel.hpp:607
Core::FMTlifespans lifespan
lifespan data comming from the lifespan file
Definition: FMTmodel.hpp:598
virtual bool solve()
Definition: FMTmodel.hpp:561
void cleartransitioncache()
virtual double getobjectivevalue() const
FMTmodel basepresolve() const
bool getparameter(const FMTboolmodelparameters &key) const
virtual std::unique_ptr< FMTmodel > presolve(std::vector< Core::FMTactualdevelopment > optionaldevelopments=std::vector< Core::FMTactualdevelopment >()) const
virtual ~FMTmodel()=default
static Core::FMTaction defaultdeathaction(const Core::FMTlifespans &llifespan, const std::vector< Core::FMTtheme > <hemes)
double getinitialarea() const
Core::FMTschedule getpotentialschedule(std::vector< Core::FMTactualdevelopment > toremove, std::vector< Core::FMTactualdevelopment > selection, bool withlock=true) const
virtual bool setparameter(const FMTdblmodelparameters &key, const double &value)
FMTmodelparameters parameters
Definition: FMTmodel.hpp:580
std::vector< Core::FMTtheme > locatestatictransitionsthemes() const
void setthemes(const std::vector< Core::FMTtheme > <hemes)
std::vector< Core::FMTconstraint > gettacticalconstraints(double penalty=999999, double scheduleweight=999999, double objective=0, double objectivefactor=1.0) const
Core::FMTmask getbasemask(std::vector< Core::FMTactualdevelopment > optionaldevelopments) const
Core::FMTmask getselectedmask(const std::vector< Core::FMTtheme > &originalthemes) const
Core::FMTmaskfilter getpresolvefilter(const std::vector< Core::FMTtheme > &originalthemes) const
bool useactionserie() const
std::vector< Core::FMTconstraint > getconstraints() const
Definition: FMTmodel.hpp:249
std::vector< Core::FMTaction > actions
Model actions from the action file and also the _death action.
Definition: FMTmodel.hpp:589
virtual std::map< std::string, double > getoutput(const Core::FMToutput &output, int period, Core::FMToutputlevel level=Core::FMToutputlevel::standard) const
virtual bool build(std::vector< Core::FMTschedule > schedules=std::vector< Core::FMTschedule >())
Definition: FMTmodel.hpp:552
double getparameter(const FMTdblmodelparameters &key) const
Definition: FMTmodel.hpp:768
FMTmodelcomparator(std::string name)
bool operator()(const FMTmodel &model) const
Definition: FMTmodelparameters.hpp:76
Definition: FMTmodelstats.hpp:24
Definition: FMTmodelparser.hpp:51
Definition: FMTspatialnodescache.hpp:33
Definition: FMTspatialschedule.hpp:44
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
FMToutputlevel
Definition: FMTutility.hpp:17
@ standard
Definition: FMTutility.hpp:18
FMTotar
Definition: FMTutility.hpp:74
Namespace for using/building unidirectional graphs in FMT.
Definition: FMTareaparser.hpp:31
Namespace containing all enumerator and classes used to construct or manipulate the different type of...
Definition: FMTareaparser.hpp:50
FMTdblmodelparameters
Definition: FMTmodelparameters.hpp:37
FMTintmodelparameters
Definition: FMTmodelparameters.hpp:24
FMTboolmodelparameters
Definition: FMTmodelparameters.hpp:45
Namespace handling all FMT's parsers. Everything related to I/O should be located in this namespace.
Definition: FMTactionparser.hpp:26
The spatial namespace provides classes for spatialy explicit simulation/optimization based on raster ...
Definition: FMTareaparser.hpp:36