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

Representation of a line in the optimize section, an objective being considered a constraint. More...

#include <FMTConstraint.h>

Inheritance diagram for Core::FMTConstraint:
[legend]
Collaboration diagram for Core::FMTConstraint:
[legend]

Public Member Functions

 FMTConstraint ()
 Default constructor for FMTConstraint.
 
 FMTConstraint (FMTconstrainttype ltype, const FMTOutput &loutput)
 Partial constructor specifying the output and the constraint type.
 
 FMTConstraint (const FMTConstraint &rhs)
 Copy constructor for FMTConstraint.
 
FMTConstraintoperator= (const FMTConstraint &rhs)
 Copy assignment operator for FMTConstraint.
 
bool operator== (const FMTConstraint &rhs) const
 Equality comparison operator of FMTConstraint.
 
bool operator!= (const FMTConstraint &rhs) const
 Inequality comparison operator of FMTConstraint.
 
bool extraVariables () const
 Return true if the constraint needs extra variables in the matrix formulation.
 
bool isGoal () const
 Return true if the constraint has a goal weight.
 
bool isSetFrom (const std::string &modeltype) const
 Return true if the constraint needs to be set from a specific model.
 
bool isReIgnore (const int &replanningperiod) const
 Return true if the constraint must be ignored from the replanning period.
 
bool doSupportRandom () const
 Return true if the constraint has only one source based on action area and supports the _RANDOM keyword.
 
Core::FMTConstraint setFrom (const std::string &modeltype, const double &value) const
 Return a new constraint set with the value of the given model type.
 
double getScheduleWeight () const
 Return the global schedule weight of the objective for a local model.
 
Core::FMTConstraint getFromReplicate (const size_t &replicate, const int &period) const
 Return a new constraint with the replicate value, if the constraint is built with a replicate table. See _REPLICATE.
 
void setFromReplicate (size_t p_replicate, int p_period)
 If the constraint is build with a replicate tables it will gives a new constraint with the corresponding replicate value See keyword _REPLICATE in optimization seciton.
 
bool gotReplicate (const int &p_period) const
 Check if the constraint contains a replicate.
 
std::vector< std::string > getPenalties (double &sense) const
 Return the names of the penalties of the constraint if it is a goal, like _GOAL(penaltyname, weight).
 
std::vector< std::string > getVariableLevels () const
 Return the level names of the constraint if it is a level.
 
void getGoal (std::string &name, double &value) const
 Fill up the name and weight of the goal of the constraint.
 
void setGoal (const std::string &goalname, const double &value)
 Set a goal with a name and a value if the constraint is not an objective.
 
void setPenalties (const std::string &penaltyoperator, const std::vector< std::string > &variables)
 Set the penalties if the constraint is an objective.
 
bool isObjective () const
 Return true if the constraint is an objective.
 
double sense () const
 Return the sense of the objective, 1 for minimisation and -1 for maximisation.
 
void getBounds (double &lower, double &upper, int period=0) const
 Fill up the lower and upper bound for a given period if the constraint applies to it.
 
void setRhs (double lower, double upper)
 Set the RHS of the constraint with a lower and upper bound.
 
void setLength (int firstPeriod=1, int lastPeriod=std::numeric_limits< int >::max())
 Set the length of the constraint.
 
void getVariations (double &lower, double &upper) const
 Get the variation for constraints like _EVEN, _SEQ or _NDY.
 
bool isMultiple () const
 Return true if the constraint allows some variability like _EVEN.
 
bool acrossPeriod () const
 Return true if the constraint needs to be set across multiple periods like _EVEN, _SEQ or _NDY.
 
size_t hash (bool hashrhs=true, bool hashoutputonly=false) const
 Return the hash of the constraint.
 
size_t hasHasOutput () const
 Return the hash of the output of the constraint.
 
void setOutput (const FMTOutput &out)
 Set the output of the constraint.
 
void setConstraintType (FMTconstrainttype ltype)
 Set the type of the constraint.
 
FMTconstrainttype getConstraintType () const
 Return the type of the constraint.
 
 operator std::string () const
 Return the string representation of the constraint as in the optimization section.
 
bool isSpatial () const
 Return true if the constraint is a spatial constraint.
 
bool isRandomAction () const
 Return true if the constraint is a random action constraint.
 
size_t getGroup () const
 Return the group of the constraint (objective = 0, spatial = 1, other = 2 or user defined).
 
size_t outputEmpty () const
 Return true if the output of the constraint is empty.
 
FMTConstraint 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 constraint, potentially returning an empty constraint. See FMTOutput::preSolve.
 
void preSolveRef (const FMTMaskFilter &p_filter, const std::vector< FMTTheme > &p_originalThemes, const std::vector< const FMTTheme * > &p_selectedThemes, const std::vector< FMTTheme > &p_newThemes, const std::vector< FMTAction > &p_actions, const std::vector< bool > &p_valideActions, const FMTYields &p_yields)
 Presolve the constraint in place. See FMTOutput::preSolve.
 
 ~FMTConstraint ()=default
 Default destructor for FMTConstraint.
 
double evaluate (const std::vector< double > &temporalvalues) const
 Return a value representing the quality of the solution for the constraint.
 
std::vector< int > getActionIds (const std::vector< Core::FMTAction > &actions) const
 Return the action ids to which the spatial constraint applies.
 
std::vector< bool > isActionsused (const std::vector< Core::FMTAction > &actions) const
 Return a vector of booleans, true for the actions to which the spatial constraint applies.
 
bool canBeTurnedToYieldsBasedOnTransitions (const std::vector< Core::FMTTheme > &p_themes, const std::vector< Core::FMTTransition > &p_trans, const std::vector< Core::FMTAction > &p_actions, const std::vector< bool > &p_valideActions) const
 Return true if the constraint can be turned to a simple action bound using a simple yield, checking the transitions.
 
void turnToYieldsBasedOnTransition (const std::vector< Core::FMTTheme > &themes, const std::vector< Core::FMTTransition > &trans, std::vector< Core::FMTAction > &actions, const std::vector< bool > &p_valideActions, Core::FMTYields &yields, const int &constraintid) const
 Turn the constraint to yields and actions based on the transitions.
 
bool canBeTurnedToYields () const
 Return true if the constraint can be turned to a simple action bound using a simple yield.
 
void turnToYieldsAndActions (const std::vector< Core::FMTTheme > &themes, std::vector< Core::FMTAction > &actions, const std::vector< bool > &p_valideActions, Core::FMTYields &yields, const int &constraintid) const
 Generate two yield handlers from the constraint and include them in the yields, modifying the actions, to reduce the matrix size.
 
int getThemeTarget () const
 Return the theme target of the constraint.
 
double getWeight () const
 Return the weight of the constraint.
 
- Public Member Functions inherited from Core::FMTOutput
 FMTOutput ()
 Default constructor for FMTOutput.
 
virtual ~FMTOutput ()=default
 Default virtual destructor for FMTOutput.
 
 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.
 
 FMTOutput (const std::string &lname)
 Partial constructor from a name only.
 
 FMTOutput (const FMTOutput &rhs)
 Copy constructor for FMTOutput.
 
FMTOutputoperator= (const FMTOutput &rhs)
 Copy assignment operator for FMTOutput.
 
bool operator== (const FMTOutput &rhs) const
 Equality comparison operator of FMTOutput, checking if they have the same name.
 
bool operator!= (const FMTOutput &rhs) const
 Inequality comparison operator of FMTOutput, checking if they have a different name.
 
FMTOutputoperator+= (const FMTOutput &rhs)
 Addition assignment operator with another FMTOutput.
 
FMTOutputoperator-= (const FMTOutput &rhs)
 Subtraction assignment operator with another FMTOutput.
 
FMTOutputoperator*= (const FMTOutputSource &p_source)
 FMTOutput multiplication assignment with a simple double to multiply the FMTOutputSource.
 
FMTOutputoperator/= (const FMTOutputSource &p_source)
 FMTOutput division assignment with a source.
 
 operator std::string () const
 Convert the output to a readable string as in an output section.
 
std::string getName () const
 Return the name of the output.
 
std::string getDescription () const
 Return the description of the output.
 
std::string getGroup () const
 Return the group of the output.
 
bool empty () const
 Return true if the output has no output source.
 
size_t size () const
 Return the number of output sources of the output.
 
bool isLinear () const
 Return true if the output is linear, with no variable to variable multiplication or division.
 
bool canBeNodesOnly () const
 Return true if the output can be used as nodes only in LP.
 
bool isLevel () const
 Return true if one output source of the output is a level.
 
bool isOnlyLevel () const
 Return true if all output sources of the output are levels.
 
bool isConstantLevel () const
 Return true if all output sources of the output are constant levels.
 
bool isConstant () const
 Return true if all output sources of the output are constants.
 
double getConstantValue () const
 Return the constant value if the output is a single constant.
 
bool containsLevel () const
 Return true if the output contains any level.
 
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.
 
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< FMTOutputNodegetNodes (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 factor.
 
bool isSinglePeriod () const
 Return true if the output covers a single period of the graph.
 
bool hasAverage () const
 Return true if the output needs to be averaged.
 
int getTargetPeriod () const
 Return the targeted period of the output if it is single period.
 
size_t hash () const
 Return the hash of the output.
 
void setSources (const std::vector< FMTOutputSource > &p_sources)
 Set new sources for the output.
 
void setOperators (const std::vector< FMTOperator > &p_operators)
 Set new operators for the output.
 
std::vector< FMTOutputSourcegetSources () const
 Return a copy of the output sources of the output.
 
const std::vector< FMTOutputSource > & getSourcesReference () const
 Return a const reference to the output sources of the output.
 
std::vector< FMTOperatorgetOpes () const
 Return a copy of the operators of the output.
 
FMTTheme targetTheme (const std::vector< FMTTheme > &themes) const
 Return the theme targeted by the output.
 
int targetThemeId () const
 Return the id of the theme targeted by the output.
 
std::vector< std::string > getThemeDecomposition (const FMTTheme &theme) const
 Return all possible attribute values the output can have for the given theme.
 
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, else an empty vector.
 
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.
 
FMTMask getVariableIntersect () const
 Return the intersected mask of all variables.
 
FMTMask getMasksUnion () const
 get the union of all masks of the sources and factor
 
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.
 
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.
 
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 the set, normally used after preSolve.
 
void changeSourcesId (const int &outid)
 Change the output origin of each source, for the optimization parser.
 
Core::FMTOutput removeRHSvalue () const
 Return a new output removing the extra constants from a mix of noded output and constant level.
 
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.
 
void setPeriod (const int &newPeriod)
 Set the output sources to a single period.
 
bool isActionBased () const
 Return true if the output contains action nodes.
 
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 isInventory () const
 Return true if the output contains an inventory.
 
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.
 
- 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)
 

Friends

class boost::serialization::access
 Serialize the FMTConstraint through its bases FMTOutput and FMTSpec for multiprocessing across multiple cpus (pickle in Python).
 

Additional Inherited Members

- 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.
 
- Protected Member Functions inherited from Core::FMTOutput
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 _isDivision () const
 Return true if the output contains a division.
 
void _replaceDivision (const double &bound)
 Replace the division with the bound and reverse the denominator.
 
- 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::FMTOutput
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.
 
- 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 Core::FMTOutput
std::vector< FMTOutputSourcem_sources
 outputsources data used to generate outputnodes
 
std::vector< FMTOperatorm_operators
 vector of simple operators like +-*‍/
 
std::string m_name
 Sometime output can specify multiple attributes of a given themes.
 
std::string m_description
 This is description of the FMTOutput has seen in the output section.
 
std::string m_group
 This is the group of the output, if empty there's no group.
 
- 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

Representation of a line in the optimize section, an objective being considered a constraint.

A FMTConstraint is also a FMTOutput with a specification (FMTSpec). The main specification used is the period bounds, RHS and variation.

Constructor & Destructor Documentation

◆ FMTConstraint() [1/3]

Core::FMTConstraint::FMTConstraint ( )

Default constructor for FMTConstraint.

◆ FMTConstraint() [2/3]

Core::FMTConstraint::FMTConstraint ( FMTconstrainttype  ltype,
const FMTOutput loutput 
)

Partial constructor specifying the output and the constraint type.

Parameters
[in]ltypethe constraint type.
[in]loutputthe output.

◆ FMTConstraint() [3/3]

Core::FMTConstraint::FMTConstraint ( const FMTConstraint rhs)

Copy constructor for FMTConstraint.

Parameters
[in]rhsthe FMTConstraint to copy.

◆ ~FMTConstraint()

Core::FMTConstraint::~FMTConstraint ( )
default

Default destructor for FMTConstraint.

Member Function Documentation

◆ acrossPeriod()

bool Core::FMTConstraint::acrossPeriod ( ) const

Return true if the constraint needs to be set across multiple periods like _EVEN, _SEQ or _NDY.

Returns
true if the constraint is across periods else false.

◆ canBeTurnedToYields()

bool Core::FMTConstraint::canBeTurnedToYields ( ) const

Return true if the constraint can be turned to a simple action bound using a simple yield.

Returns
true if the constraint can be turned to yields else false.

◆ canBeTurnedToYieldsBasedOnTransitions()

bool Core::FMTConstraint::canBeTurnedToYieldsBasedOnTransitions ( const std::vector< Core::FMTTheme > &  p_themes,
const std::vector< Core::FMTTransition > &  p_trans,
const std::vector< Core::FMTAction > &  p_actions,
const std::vector< bool > &  p_valideActions 
) const

Return true if the constraint can be turned to a simple action bound using a simple yield, checking the transitions.

Parameters
[in]p_themesthe themes.
[in]p_transthe transitions.
[in]p_actionsthe actions.
[in]p_valideActionsthe valid actions
Returns
true if the constraint can be turned to yields else false.

◆ doSupportRandom()

bool Core::FMTConstraint::doSupportRandom ( ) const

Return true if the constraint has only one source based on action area and supports the _RANDOM keyword.

Returns
true if the constraint supports random else false.

◆ evaluate()

double Core::FMTConstraint::evaluate ( const std::vector< double > &  temporalvalues) const

Return a value representing the quality of the solution for the constraint.

For a real constraint, the closer to 0 the better; for an objective, smaller is better and can be negative.

Parameters
[in]temporalvaluesthe temporal values.
Returns
the quality value.

◆ extraVariables()

bool Core::FMTConstraint::extraVariables ( ) const

Return true if the constraint needs extra variables in the matrix formulation.

Returns
true if extra variables are needed else false.

◆ getActionIds()

std::vector< int > Core::FMTConstraint::getActionIds ( const std::vector< Core::FMTAction > &  actions) const

Return the action ids to which the spatial constraint applies.

Parameters
[in]actionsthe actions.
Returns
the action ids.

◆ getBounds()

void Core::FMTConstraint::getBounds ( double &  lower,
double &  upper,
int  period = 0 
) const

Fill up the lower and upper bound for a given period if the constraint applies to it.

Parameters
[out]lowerthe lower bound.
[out]upperthe upper bound.
[in]periodthe period.

◆ getConstraintType()

FMTconstrainttype Core::FMTConstraint::getConstraintType ( ) const

Return the type of the constraint.

Returns
the constraint type.

◆ getFromReplicate()

Core::FMTConstraint Core::FMTConstraint::getFromReplicate ( const size_t &  replicate,
const int &  period 
) const

Return a new constraint with the replicate value, if the constraint is built with a replicate table. See _REPLICATE.

Parameters
[in]replicatethe replicate.
[in]periodthe period.
Returns
the constraint with the replicate value.

◆ getGoal()

void Core::FMTConstraint::getGoal ( std::string &  name,
double &  value 
) const

Fill up the name and weight of the goal of the constraint.

Parameters
[out]namethe goal name.
[out]valuethe goal weight.

◆ getGroup()

size_t Core::FMTConstraint::getGroup ( ) const

Return the group of the constraint (objective = 0, spatial = 1, other = 2 or user defined).

Returns
the group of the constraint.

◆ getPenalties()

std::vector< std::string > Core::FMTConstraint::getPenalties ( double &  sense) const

Return the names of the penalties of the constraint if it is a goal, like _GOAL(penaltyname, weight).

Parameters
[out]sensethe sense of the penalties.
Returns
the penalty names.

◆ getScheduleWeight()

double Core::FMTConstraint::getScheduleWeight ( ) const

Return the global schedule weight of the objective for a local model.

Returns
the schedule weight.

◆ getThemeTarget()

int Core::FMTConstraint::getThemeTarget ( ) const

Return the theme target of the constraint.

Returns
the theme target.

◆ getVariableLevels()

std::vector< std::string > Core::FMTConstraint::getVariableLevels ( ) const

Return the level names of the constraint if it is a level.

Returns
the level names.

◆ getVariations()

void Core::FMTConstraint::getVariations ( double &  lower,
double &  upper 
) const

Get the variation for constraints like _EVEN, _SEQ or _NDY.

Parameters
[out]lowerthe lower variation.
[out]upperthe upper variation.

◆ getWeight()

double Core::FMTConstraint::getWeight ( ) const

Return the weight of the constraint.

Returns
the weight.

◆ gotReplicate()

bool Core::FMTConstraint::gotReplicate ( const int &  p_period) const

Check if the constraint contains a replicate.

Parameters
[in]p_periodthe period.
Returns
true if the constraint contains a replicate else false.

◆ hash()

size_t Core::FMTConstraint::hash ( bool  hashrhs = true,
bool  hashoutputonly = false 
) const

Return the hash of the constraint.

Parameters
[in]hashrhsif true includes the RHS in the hash.
[in]hashoutputonlyif true hashes the output only.
Returns
the hash value.

◆ hasHasOutput()

size_t Core::FMTConstraint::hasHasOutput ( ) const

Return the hash of the output of the constraint.

Returns
the hash of the output.

◆ isActionsused()

std::vector< bool > Core::FMTConstraint::isActionsused ( const std::vector< Core::FMTAction > &  actions) const

Return a vector of booleans, true for the actions to which the spatial constraint applies.

Parameters
[in]actionsthe actions.
Returns
a vector of booleans, true for used actions.

◆ isGoal()

bool Core::FMTConstraint::isGoal ( ) const

Return true if the constraint has a goal weight.

Returns
true if the constraint has a goal weight else false.

◆ isMultiple()

bool Core::FMTConstraint::isMultiple ( ) const

Return true if the constraint allows some variability like _EVEN.

Returns
true if the constraint is multiple else false.

◆ isObjective()

bool Core::FMTConstraint::isObjective ( ) const

Return true if the constraint is an objective.

Returns
true if the constraint is an objective else false.

◆ isRandomAction()

bool Core::FMTConstraint::isRandomAction ( ) const

Return true if the constraint is a random action constraint.

Returns
true if the constraint is a random action else false.

◆ isReIgnore()

bool Core::FMTConstraint::isReIgnore ( const int &  replanningperiod) const

Return true if the constraint must be ignored from the replanning period.

Parameters
[in]replanningperiodthe replanning period.
Returns
true if the constraint must be ignored else false.

◆ isSetFrom()

bool Core::FMTConstraint::isSetFrom ( const std::string &  modeltype) const

Return true if the constraint needs to be set from a specific model.

Parameters
[in]modeltypethe model type.
Returns
true if the constraint needs to be set from the model else false.

◆ isSpatial()

bool Core::FMTConstraint::isSpatial ( ) const

Return true if the constraint is a spatial constraint.

Returns
true if the constraint is spatial else false.

◆ operator std::string()

Core::FMTConstraint::operator std::string ( ) const

Return the string representation of the constraint as in the optimization section.

Returns
the string representation of the constraint.

◆ operator!=()

bool Core::FMTConstraint::operator!= ( const FMTConstraint rhs) const

Inequality comparison operator of FMTConstraint.

Parameters
[in]rhsthe constraint to compare with.
Returns
true if both constraints are different else false.

◆ operator=()

FMTConstraint & Core::FMTConstraint::operator= ( const FMTConstraint rhs)

Copy assignment operator for FMTConstraint.

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

◆ operator==()

bool Core::FMTConstraint::operator== ( const FMTConstraint rhs) const

Equality comparison operator of FMTConstraint.

Parameters
[in]rhsthe constraint to compare with.
Returns
true if both constraints are equal else false.

◆ outputEmpty()

size_t Core::FMTConstraint::outputEmpty ( ) const

Return true if the output of the constraint is empty.

Returns
true if the output is empty else false.

◆ preSolve()

FMTConstraint Core::FMTConstraint::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 constraint, potentially returning an empty constraint. See FMTOutput::preSolve.

Parameters
[in]filterthe mask filter.
[in]originalthemesthe original themes.
[in]selectedthemesthe selected themes.
[in]newthemesthe presolved themes.
[in]actionsthe actions.
[in]p_valideActionsthe valid actions.
[in]yieldsthe yields.
Returns
the presolved constraint.

◆ preSolveRef()

void Core::FMTConstraint::preSolveRef ( const FMTMaskFilter p_filter,
const std::vector< FMTTheme > &  p_originalThemes,
const std::vector< const FMTTheme * > &  p_selectedThemes,
const std::vector< FMTTheme > &  p_newThemes,
const std::vector< FMTAction > &  p_actions,
const std::vector< bool > &  p_valideActions,
const FMTYields p_yields 
)

Presolve the constraint in place. See FMTOutput::preSolve.

Parameters
[in]p_filterthe mask filter.
[in]p_originalThemesthe original themes.
[in]p_selectedThemesthe selected themes.
[in]p_newThemesthe presolved themes.
[in]p_actionsthe actions.
[in]p_valideActionsthe valid actions.
[in]p_yieldsthe yields.

◆ sense()

double Core::FMTConstraint::sense ( ) const

Return the sense of the objective, 1 for minimisation and -1 for maximisation.

Returns
the sense of the objective.

◆ setConstraintType()

void Core::FMTConstraint::setConstraintType ( FMTconstrainttype  ltype)

Set the type of the constraint.

Parameters
[in]ltypethe constraint type to set.

◆ setFrom()

Core::FMTConstraint Core::FMTConstraint::setFrom ( const std::string &  modeltype,
const double &  value 
) const

Return a new constraint set with the value of the given model type.

Parameters
[in]modeltypethe model type.
[in]valuethe value of the global model output.
Returns
the constraint set from the model.

◆ setFromReplicate()

void Core::FMTConstraint::setFromReplicate ( size_t  p_replicate,
int  p_period 
)

If the constraint is build with a replicate tables it will gives a new constraint with the corresponding replicate value See keyword _REPLICATE in optimization seciton.

Parameters
[in]p_replicatethe replanning replicate
[in]p_periodthe period to calculate.

◆ setGoal()

void Core::FMTConstraint::setGoal ( const std::string &  goalname,
const double &  value 
)

Set a goal with a name and a value if the constraint is not an objective.

Parameters
[in]goalnamethe goal name.
[in]valuethe goal value.

◆ setLength()

void Core::FMTConstraint::setLength ( int  firstPeriod = 1,
int  lastPeriod = std::numeric_limits< int >::max() 
)

Set the length of the constraint.

Parameters
[in]firstPeriodthe first period.
[in]lastPeriodthe last period.

◆ setOutput()

void Core::FMTConstraint::setOutput ( const FMTOutput out)

Set the output of the constraint.

Parameters
[in]outthe output to set.

◆ setPenalties()

void Core::FMTConstraint::setPenalties ( const std::string &  penaltyoperator,
const std::vector< std::string > &  variables 
)

Set the penalties if the constraint is an objective.

Parameters
[in]penaltyoperatorthe penalty operator.
[in]variablesthe penalty variables.

◆ setRhs()

void Core::FMTConstraint::setRhs ( double  lower,
double  upper 
)

Set the RHS of the constraint with a lower and upper bound.

Parameters
[in]lowerthe lower bound.
[in]upperthe upper bound.

◆ turnToYieldsAndActions()

void Core::FMTConstraint::turnToYieldsAndActions ( const std::vector< Core::FMTTheme > &  themes,
std::vector< Core::FMTAction > &  actions,
const std::vector< bool > &  p_valideActions,
Core::FMTYields yields,
const int &  constraintid 
) const

Generate two yield handlers from the constraint and include them in the yields, modifying the actions, to reduce the matrix size.

Parameters
[in]themesthe themes.
[in,out]actionsthe actions.
[in]p_valideActionsthe valid actions.
[in,out]yieldsthe yields.
[in]constraintidthe constraint id.

◆ turnToYieldsBasedOnTransition()

void Core::FMTConstraint::turnToYieldsBasedOnTransition ( const std::vector< Core::FMTTheme > &  themes,
const std::vector< Core::FMTTransition > &  trans,
std::vector< Core::FMTAction > &  actions,
const std::vector< bool > &  p_valideActions,
Core::FMTYields yields,
const int &  constraintid 
) const

Turn the constraint to yields and actions based on the transitions.

Parameters
[in]themesthe themes.
[in]transthe transitions.
[in,out]actionsthe actions.
[in]p_valideActionsthe valid actions.
[in,out]yieldsthe yields.
[in]constraintidthe constraint id.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Serialize the FMTConstraint through its bases FMTOutput and FMTSpec for multiprocessing across multiple cpus (pickle in Python).

Template Parameters
Archivethe archive type.
Parameters
[in,out]arthe archive to serialize to or from.
[in]versionthe serialization version.

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