10#ifndef FMToperatingareascheme_Hm_included
11#define FMToperatingareascheme_Hm_included
17#include <boost/serialization/serialization.hpp>
18#include <boost/serialization/nvp.hpp>
19#include <boost/serialization/export.hpp>
20#include "FMTGraph.hpp"
50 friend class boost::serialization::access;
51 template<
class Archive>
52 void serialize(Archive& ar,
const unsigned int version)
54 ar & boost::serialization::make_nvp(
"operatingarea", boost::serialization::base_object<FMTOperatingArea>(*
this));
55 ar & BOOST_SERIALIZATION_NVP(openingconstraints);
56 ar & BOOST_SERIALIZATION_NVP(openingbinaries);
57 ar & BOOST_SERIALIZATION_NVP(maximalschemesconstraint);
58 ar & BOOST_SERIALIZATION_NVP(schemesperiods);
59 ar & BOOST_SERIALIZATION_NVP(openingtime);
60 ar & BOOST_SERIALIZATION_NVP(returntime);
61 ar & BOOST_SERIALIZATION_NVP(repetition);
62 ar & BOOST_SERIALIZATION_NVP(greenup);
66 std::vector<std::vector<int>>openingconstraints;
69 std::vector<int>openingbinaries;
72 int maximalschemesconstraint;
75 std::vector<std::vector<int>>schemesperiods;
90 size_t startingperiod;
100 int rejectednodescid;
116 size_t getBestSchemeId(
const double* primalsolution)
const;
140 const double* primalsolution,
168 double getRowsActivitySum(
const std::vector<int>& rows,
const double* dualsolution)
const;
177 bool isThresholdActivityRows(
const std::vector<int>& rows,
const double* dualsolution,
double tempThreshold = -1)
const;
186 std::vector<double>fillPattern(
const std::vector<double>& pattern,
const int& startat)
const;
194 void closeNoActivity(std::vector<double>& filleduppattern,
const size_t& selected,
const double* dualsolution)
const;
200 int getMaxPeriod()
const;
208 void setReturnTime(
const size_t& minimalreturntime,
const size_t& maximalreturntime);
355 const double* p_upperbounds,
const std::vector<FMTOperatingAreaScheme>& p_neighbors)
const;
365 const std::vector<FMTOperatingAreaScheme>& p_neighbors)
const;
420 bool boundPrimalScheme(std::vector<int>& targets, std::vector<double>& bounds,
const size_t& schemeid)
const;
431 bool unboundDualScheme(
const double* rowactivities, std::vector<int>& targets, std::vector<double>& bounds,
const size_t& schemeid,
bool looseset=
true)
const;
447 std::vector<double>
getDualSolution(
const double* upperbounds,
const double* dualsolution,
bool& canbreakneighboring)
const;
470 const double* primalsolution,
471 const std::vector<int>& actionIDS);
486 const size_t& lrepetition,
const size_t& lgreenup,
const size_t& lstartingperiod,
double minimalarearatio=0.0);
513 void fillBoundsNVariables(
const double* lowerb,
const double* upperb, std::vector<int>& constraintstargets,std::vector<double>&bounds)
const;
587 double _maxNearThresholdActivityRows(
const std::vector<int>& rows,
const double* dualsolution)
const;
594 size_t _findIndexLocation(
int binary)
const;
603 void _addPotentialResults(
604 size_t indexlocation,
605 std::vector<size_t>& potentialindexes,
606 std::vector<double>& potentialValues,
607 const double* dualsolution)
const;
614 static bool _checkDoubleIncludes(
const std::vector<std::vector<int>>& openingconstraints);
#define FMTEXPORT
Definition: FMTutility.h:125
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
Definition: FMTGraphVertexToYield.h:20
Comparator to find a FMTOperatingAreaScheme with std::find_if when operating area schemes are in an s...
Definition: FMTOperatingAreaScheme.h:622
FMTOperatingAreaSchemeComparator(const Core::FMTMask &lmask)
Construct the comparator from a mask reference.
bool operator()(const FMTOperatingAreaScheme &oparea) const
Comparator for FMTOperatingAreaScheme.
Operating area scheme giving information about its opening time, green up and return time.
Definition: FMTOperatingAreaScheme.h:42
double getThreshold() const
Get the threshold.
size_t boundAllDualSchemes(std::vector< int > &targets, std::vector< double > &bounds) const
Push the constraint indexes into the targets vector and push the bound value into the bounds.
double getBinariesSum(const double *primalsolution) const
Summarize the value of all the binary variables for all the potential schemes from the primal solutio...
bool unboundDualScheme(const double *rowactivities, std::vector< int > &targets, std::vector< double > &bounds, const size_t &schemeid, bool looseset=true) const
Push the constraints of a scheme into the targets vector with -inf and the area bounds,...
bool havePotentialSolution(const double *primalsolution) const
Check if a scheme binary has a value greater than 0 in the primal solution, indicating a potential sc...
size_t unboundAllPrimalSchemes(std::vector< int > &targets, std::vector< double > &bounds) const
Push the binary indexes into the targets vector and push 0 and 1 into the bounds.
FMTOperatingAreaScheme(const FMTOperatingArea &oparea, const size_t &lopeningtime, const size_t &lreturntime, const size_t &lmaxreturntime, const size_t &lrepetition, const size_t &lgreenup, const size_t &lstartingperiod, double minimalarearatio=0.0)
Main constructor for FMTOperatingAreaScheme.
size_t unboundAllDualSchemes(std::vector< int > &targets, std::vector< double > &bounds) const
Push the constraint indexes into the targets vector, push -inf and the area into the bounds,...
bool boundPrimalScheme(std::vector< int > &targets, std::vector< double > &bounds, const size_t &schemeid) const
Push the variable index of a scheme binary into the targets vector and push 1 and 1 into the bounds.
FMTOperatingAreaScheme(const FMTOperatingAreaScheme &rhs)=default
Copy constructor for FMTOperatingAreaScheme.
size_t getStartingPeriod() const
Return the starting period at which all the schemes of the operating area start.
bool isPrimalBounded(const double *lowerbounds, const double *upperbounds) const
Return true if any binary lower or upper bound is set to 1.
FMTOperatingAreaScheme()=default
Default constructor for FMTOperatingAreaScheme.
bool empty() const
Check if the operating area is empty, which is possible if there is no potential development to opera...
~FMTOperatingAreaScheme()=default
Default destructor for FMTOperatingAreaScheme.
const int & getRejectedNodesCid() const
Return the constraint id of the rejected nodes.
size_t getMaximalReturnTime() const
Get the maximal return time.
size_t getNumberOfScheme() const
Return the number of schemes of the operating area, only usable after schemesToLp has been called.
void setConstraints(const std::vector< std::vector< Graph::FMTGraph< Graph::FMTVertexProperties, Graph::FMTEdgeProperties >::FMTvertex_descriptor > > &vertices, const std::vector< Graph::FMTGraph< Graph::FMTVertexProperties, Graph::FMTEdgeProperties >::FMTvertex_descriptor > &totalareavertices, const Graph::FMTGraph< Graph::FMTVertexProperties, Graph::FMTEdgeProperties > &graph, Models::FMTLpSolver &solver, const double *primalsolution, const std::vector< int > &actionIDS)
Set up the constraints and variables using a matrix build and a primal solution, filling all the matr...
void fillBoundsNVariables(const double *lowerb, const double *upperb, std::vector< int > &constraintstargets, std::vector< double > &bounds) const
For each scheme constraint, take the constraint bounds of the actual model.
size_t getNumberOfSimpleScheme() const
Return the number of simple schemes with a fixed return time and opening time.
const int & getMaximalSchemesConstraint() const
Return the constraint id ensuring that only one scheme is chosen.
size_t getOpeningTime() const
Get the opening time.
const size_t & getGreenUp() const
Return the green up.
Definition: FMTOperatingAreaScheme.h:577
size_t getMinimalReturnTime() const
Get the minimal return time.
double getActivitySum(const double *dualsolution) const
Summarize the value of all the constraints for all the potential schemes from the dual solution.
size_t getPrimalSolutionIndex(const double *primalsolution) const
Return the index of the scheme the operating area is bounded to, from the primal solution.
std::vector< double > getDualSolution(const double *upperbounds, const double *dualsolution, bool &canbreakneighboring) const
Return the yield solution of the dual problem by setting the selected scheme solution into a vector.
void getRessourcesToDelete(std::vector< int > &colstodelete, std::vector< int > &rowstodelete) const
Push all the variables and constraints of the operating area into the columns and rows to delete vect...
std::vector< size_t > getPotentialPrimalSchemes(const double *p_primalsolution, const double *p_lowerbounds, const double *p_upperbounds, const std::vector< FMTOperatingAreaScheme > &p_neighbors) const
Return the potential scheme indexes from the primal solution, its bounds and the neighboring operatin...
bool isAllDualBounded(const double *upperbounds) const
Return false if any constraint upper bound is different from 0.
std::vector< double > getDualLowerBounds(const double *lowerbounds, const double *upperbounds) const
Return the lower bounds of the solution for bounding the minimal harvested area.
std::vector< double > getPrimalSolution(const double *primalsolution) const
Return the yield solution of the primal problem by summing up all the binary variables into a single ...
bool isDualBounded(const double *upperbounds) const
Return true if any constraint upper bound is set to 0.
FMTOperatingAreaScheme preSolve(const Core::FMTMask &selectedmask, const std::vector< Core::FMTTheme > &presolvedthemes) const
Return a presolved FMTOperatingAreaScheme using a mask and a subset of the original themes.
bool isAllPrimalBounded(const double *lowerbounds, const double *upperbounds) const
Return false if any binary lower or upper bound is not set to 1.
bool haveActivitySolution(const double *dualsolution) const
Check if a set of scheme constraints has an activity value greater than 0 in the dual solution,...
bool isThresholdActivity(const double *dualsolution) const
Return true if every constraint activity is above the threshold.
bool getDualSolutionIndex(const double *upperbound, size_t &locid) const
Return the index of the scheme used by the operating area from the rows upper bounds.
void pushBinaries(std::vector< int > &targets) const
Push all the binaries into a targets vector.
std::map< int, std::vector< int > > getCommonBinaries(const FMTOperatingAreaScheme &neighbor) const
Return a map with the binary indexes of this operating area as keys and the binary indexes of the nei...
size_t getRepetition() const
Get the repetition of the pattern.
const std::vector< int > & getOpeningBinaries() const
Return the variable indexes of the binaries of all the potential schemes of the operating area.
void setReturnTime(const size_t &minimalreturntime, const size_t &maximalreturntime)
Set the minimal and maximal return time.
std::vector< size_t > getPotentialDualSchemes(const double *p_dualsolution, const double *p_upperbound, const std::vector< FMTOperatingAreaScheme > &p_neighbors) const
Return the potential scheme indexes from the dual solution, the rows upper bounds and the neighboring...
const std::vector< std::vector< int > > & getOpeningConstraints() const
Return the opening constraints of the operating area.
size_t boundAllPrimalSchemes(std::vector< int > &targets, std::vector< double > &bounds, double boundvalue=1.0) const
Push the variable indexes into the targets vector and push the bound value into the bounds.
Operating area giving information about its mask, neighbors and neighbors perimeter.
Definition: FMTOperatingArea.h:29
Abstract class to ease the usage of the OsiSolverInterface in FMT for linear programming models.
Definition: FMTLpSolver.h:49
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
Namespace regrouping all tools for solving LP/MIP problems using an heuristic.
Definition: FMTAreaParser.h:47
Namespace containing all enumerator and classes used to construct or manipulate the different type of...
Definition: FMTAreaParser.h:54