8#ifndef FMToutput_Hm_included
9#define FMToutput_Hm_included
17#include "FMTBounds.hpp"
19#include <boost/serialization/string.hpp>
20#include <boost/serialization/serialization.hpp>
21#include <boost/serialization/export.hpp>
58 FMTOutput(
const std::string& lname,
const std::string& ldescription,
59 const std::string& lgroup,
60 const std::vector<FMTOutputSource>& lsources,
61 const std::vector<FMTOperator>& loperators);
128 operator std::string()
const;
145 return m_description;
224 double shuntingYard(
const std::vector<double>& sourcevalues,
const std::vector<FMTOperator>& simple_operators)
const;
234 FMTOutput boundTo(
const std::vector<FMTTheme>& themes,
const FMTPerBounds& bound,
const std::string& specialbound, std::string attribute =
"")
const;
244 std::vector<FMTOutputNode>
getNodes(std::vector<std::string>& equation,
245 double multiplier = 1,
246 bool orderbyoutputid =
false,
247 int period = 1)
const;
277 void setSources(
const std::vector<FMTOutputSource>& p_sources);
307 inline std::vector<FMTOperator>
getOpes()
const
325 return m_sources.begin()->getThemeTarget();
349 const std::vector<Core::FMTTheme>& themes)
const;
370 std::vector<const Core::FMTTheme*>
getStaticThemes(
const std::vector<Core::FMTTheme>& themes,
const Core::FMTYields& yields,
bool ignoreoutputvariables =
false)
const;
384 const std::vector<FMTTheme>& originalthemes,
385 const std::vector<const FMTTheme*>& selectedthemes,
386 const std::vector<FMTTheme>& newthemes,
387 const std::vector<FMTAction>& actions,
388 const std::vector<bool>& p_valideActions,
396 void changeSourcesId(
const std::set<int>& newoutputsorigin,
const std::set<int>& newthemeid);
416 void getRHSvalue(
const int& period,
double& lower,
double& upper)
const;
452 const std::vector<std::string>baseeq,
453 std::map<std::string, double>& results,
454 const std::vector<Core::FMTOutputNode>& nodes,
455 std::map<std::string, std::vector<std::string>>& allequations)
const;
483 const std::vector<std::string>& baseequation)
const;
505 const std::vector<FMTAction>& p_actions,
506 const std::vector<bool>& p_validActions);
515 friend class boost::serialization::access;
516 template<
class Archive>
517 void serialize(Archive& ar,
const unsigned int version)
520 ar& boost::serialization::make_nvp(
"FMTobject", boost::serialization::base_object<FMTObject>(*
this));
521 ar& boost::serialization::make_nvp(
"sources", m_sources);
522 ar& boost::serialization::make_nvp(
"operators", m_operators);
524 ar& boost::serialization::make_nvp(
"name", m_name);
525 ar& boost::serialization::make_nvp(
"description", m_description);
529 _exhandler->printExceptions(
"",
"FMTOutput::serialize", __LINE__, __FILE__);
537 std::string _getFormatedOutputName()
const;
543 bool _needWsFormat()
const;
549 std::string _toWsFormat()
const;
556 bool _sourceCounter(
const std::string& p_source)
const;
562 bool _verifyOperatorOrder()
const;
568 std::string _operatorFormat()
const;
594 std::string m_outputName;
#define FMTEXPORT
Definition: FMTutility.h:125
Filter built from masks used to preSolve and postsolve FMTMask objects.
Definition: FMTMaskFilter.h:31
Core class holding, as a boost dynamic bitset, which theme attributes are part of a mask.
Definition: FMTMask.h:96
Base class of multiple FMT classes holding a shared exception handler pointer and logger.
Definition: FMTObject.h:49
Comparator used to check if an output name already exists in a std container.
Definition: FMTOutput.h:575
FMTOutputComparator(std::string name)
Construct the comparator from the output name to find.
bool operator()(const FMTOutput &output) const
Matching test operator for the comparator.
Source of an output holding a mask, a target and values, used to compute an output.
Definition: FMTOutputSource.h:44
Class letting the user formulate a constraint in the optimize section or collect data across the grap...
Definition: FMTOutput.h:37
FMTOutput()
Default constructor for FMTOutput.
FMTOutput(const FMTOutput &rhs)
Copy constructor for FMTOutput.
size_t size() const
Return the number of output sources of the output.
bool canBeNodesOnly() const
Return true if the output can be used as nodes only in LP.
std::vector< FMTOutputSource > getSources() const
Return a copy of the output sources of the output.
Definition: FMTOutput.h:289
bool isLinear() const
Return true if the output is linear, with no variable to variable multiplication or division.
std::string m_name
Sometime output can specify multiple attributes of a given themes.
Definition: FMTOutput.h:469
FMTMask getMasksUnion() const
get the union of all masks of the sources and factor
std::string m_description
This is description of the FMTOutput has seen in the output section.
Definition: FMTOutput.h:472
FMTTheme targetTheme(const std::vector< FMTTheme > &themes) const
Return the theme targeted by the output.
void changeSourcesId(const int &outid)
Change the output origin of each source, for the optimization parser.
bool containsLevel() const
Return true if the output contains any level.
virtual ~FMTOutput()=default
Default virtual destructor for FMTOutput.
size_t hash() const
Return the hash of the output.
void setPeriod(const int &newPeriod)
Set the output sources to a single period.
void getRHSvalue(const int &period, double &lower, double &upper) const
Get the RHS values mixing a level with a variable node for a given period.
std::string m_group
This is the group of the output, if empty there's no group.
Definition: FMTOutput.h:475
void fillFromShuntingYard(const std::vector< std::string >baseeq, std::map< std::string, double > &results, const std::vector< Core::FMTOutputNode > &nodes, std::map< std::string, std::vector< std::string > > &allequations) const
Get the values of a non linear output using the shunting yard algorithm.
std::vector< std::string > getDecomposition(const std::vector< FMTTheme > &themes) const
Return all possible attribute values the output can have if the attribute target is set,...
static bool _isValidAction(const std::string &p_actionOrAggregate, const std::vector< FMTAction > &p_actions, const std::vector< bool > &p_validActions)
Return true if an action or aggregate is in the actions.
FMTOutput preSolve(const FMTMaskFilter &filter, const std::vector< FMTTheme > &originalthemes, const std::vector< const FMTTheme * > &selectedthemes, const std::vector< FMTTheme > &newthemes, const std::vector< FMTAction > &actions, const std::vector< bool > &p_valideActions, const FMTYields &yields) const
Presolve the output and remove unused output sources.
bool isInventory() const
Return true if the output contains an inventory.
bool isConstantLevel() const
Return true if all output sources of the output are constant levels.
FMTMask getVariableIntersect() const
Return the intersected mask of all variables.
FMTOutput intersectWithMask(const Core::FMTMask &mask, const std::vector< Core::FMTTheme > &themes) const
Return the output resulting from the intersection of a mask with this output.
std::vector< FMTOutputSource > m_sources
outputsources data used to generate outputnodes
Definition: FMTOutput.h:460
std::vector< FMTOperator > m_operators
vector of simple operators like +-*â€/
Definition: FMTOutput.h:463
void changeSourcesId(const std::set< int > &newoutputsorigin, const std::set< int > &newthemeid)
Change the output origin and target theme id of each source with the distance from the beginning of t...
std::vector< std::string > getThemeDecomposition(const FMTTheme &theme) const
Return all possible attribute values the output can have for the given theme.
std::string getDescription() const
Return the description of the output.
Definition: FMTOutput.h:143
void setOperators(const std::vector< FMTOperator > &p_operators)
Set new operators for the output.
void _setProportions(std::map< std::string, std::vector< std::string > > &allequations, const std::vector< std::string > &baseequation) const
Set the equation proportions for developments, turning numeric entries into proportions.
bool isConstant() const
Return true if all output sources of the output are constants.
FMTOutput(const std::string &lname, const std::string &ldescription, const std::string &lgroup, const std::vector< FMTOutputSource > &lsources, const std::vector< FMTOperator > &loperators)
Complete constructor from a name, a description, a group, sources and operators.
void setSources(const std::vector< FMTOutputSource > &p_sources)
Set new sources for the output.
std::string getName() const
Return the name of the output.
Definition: FMTOutput.h:134
std::vector< FMTOutputNode > getNodes(std::vector< std::string > &equation, double multiplier=1, bool orderbyoutputid=false, int period=1) const
Return the output nodes generated from the output sources and operators, optionally multiplied by a f...
bool isLevel() const
Return true if one output source of the output is a level.
int targetThemeId() const
Return the id of the theme targeted by the output.
Definition: FMTOutput.h:323
bool isVariableSizeOf(const size_t &masksize) const
Return true if a variable source has a mask size equal to the given size, or if no source is variable...
bool isActionBased() const
Return true if the output contains action nodes.
FMTOutput boundTo(const std::vector< FMTTheme > &themes, const FMTPerBounds &bound, const std::string &specialbound, std::string attribute="") const
Bound the output to specific period bounds and return the new output, optionally targeting a theme.
std::vector< const Core::FMTTheme * > getStaticThemes(const std::vector< Core::FMTTheme > &themes, const Core::FMTYields &yields, bool ignoreoutputvariables=false) const
Return the static themes of the whole output.
double shuntingYard(const std::vector< double > &sourcevalues, const std::vector< FMTOperator > &simple_operators) const
Evaluate the output using the shunting yard algorithm with source values and operators.
std::vector< FMTOperator > getOpes() const
Return a copy of the operators of the output.
Definition: FMTOutput.h:307
void _replaceDivision(const double &bound)
Replace the division with the bound and reverse the denominator.
Core::FMTOutput removeRHSvalue() const
Return a new output removing the extra constants from a mix of noded output and constant level.
int getTargetPeriod() const
Return the targeted period of the output if it is single period.
bool isOnlyLevel() const
Return true if all output sources of the output are levels.
bool isSinglePeriod() const
Return true if the output covers a single period of the graph.
bool empty() const
Return true if the output has no output source.
FMTOutput(const std::string &lname)
Partial constructor from a name only.
bool hasAverage() const
Return true if the output needs to be averaged.
std::string getGroup() const
Return the group of the output.
Definition: FMTOutput.h:152
double getConstantValue() const
Return the constant value if the output is a single constant.
const std::vector< FMTOutputSource > & getSourcesReference() const
Return a const reference to the output sources of the output.
Definition: FMTOutput.h:298
bool _isDivision() const
Return true if the output contains a division.
Class holding the attributes and aggregates of a single theme, describing a part of a FMTMask.
Definition: FMTTheme.h:47
FMTList containing multiple yield handlers as seen in the yield section, holding the information rela...
Definition: FMTYields.h:44
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34