FMT 0.9.8
Forest management tools for forest planning
|
#include <FMToperatingareascheme.hpp>
Public Member Functions | |
void | setreturntime (const size_t &minimalreturntime, const size_t &maximalreturntime) |
double | getthreshold () const |
size_t | getopeningtime () const |
size_t | getminimalreturntime () const |
size_t | getrepetition () const |
size_t | getmaximalreturntime () const |
bool | empty () const |
const std::vector< int > & | getopeningbinaries () const |
size_t | getstartingperiod () const |
double | getbinariessum (const double *primalsolution) const |
double | getactivitysum (const double *dualsolution) const |
bool | isthresholdactivity (const double *dualsolution) const |
std::map< int, std::vector< int > > | getcommonbinairies (const FMToperatingareascheme &neighbor) const |
size_t | getprimalsolutionindex (const double *primalsolution) const |
bool | getdualsolutionindex (const double *upperbound, size_t &locid) const |
bool | havepotentialsolution (const double *primalsolution) const |
bool | haveactivitysolution (const double *dualsolution) const |
bool | isallprimalbounded (const double *lowerbounds, const double *upperbounds) const |
bool | isalldualbounded (const double *upperbounds) const |
bool | isprimalbounded (const double *lowerbounds, const double *upperbounds) const |
bool | isdualbounded (const double *upperbounds) const |
std::vector< size_t > | getpotentialprimalschemes (const double *primalsolution, const double *lowerbounds, const double *upperbounds, const std::vector< FMToperatingareascheme > &neighbors) const |
std::vector< size_t > | getpotentialdualschemes (const double *dualsolution, const double *upperbound, const std::vector< FMToperatingareascheme > &neighbors) const |
void | getressourcestodelete (std::vector< int > &colstodelete, std::vector< int > &rowstodelete) const |
void | pushbinaries (std::vector< int > &targets) const |
size_t | unboundallprimalschemes (std::vector< int > &targets, std::vector< double > &bounds) const |
size_t | unboundalldualschemes (std::vector< int > &targets, std::vector< double > &bounds) const |
size_t | boundallprimalschemes (std::vector< int > &targets, std::vector< double > &bounds, double boundvalue=1.0) const |
size_t | boundalldualschemes (std::vector< int > &targets, std::vector< double > &bounds) const |
bool | boundprimalscheme (std::vector< int > &targets, std::vector< double > &bounds, const size_t &schemeid) const |
bool | unbounddualscheme (const double *rowactivities, std::vector< int > &targets, std::vector< double > &bounds, const size_t &schemeid, bool looseset=true) const |
std::vector< double > | getprimalsolution (const double *primalsolution) const |
std::vector< double > | getdualsolution (const double *upperbounds, const double *dualsolution, bool &canbreakneighboring) const |
std::vector< double > | getduallowerbounds (const double *lowerbounds, const double *upperbounds) const |
void | setconstraints (const std::vector< std::vector< Graph::FMTgraph< Graph::FMTvertexproperties, Graph::FMTedgeproperties >::FMTvertex_descriptor > > &verticies, const std::vector< Graph::FMTgraph< Graph::FMTvertexproperties, Graph::FMTedgeproperties >::FMTvertex_descriptor > &totalareaverticies, const Graph::FMTgraph< Graph::FMTvertexproperties, Graph::FMTedgeproperties > &graph, Models::FMTlpsolver &solver, const double *primalsolution, const std::vector< int > &actionIDS) |
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) | |
FMToperatingareascheme ()=default | |
FMToperatingareascheme (const FMToperatingareascheme &rhs)=default | |
FMToperatingareascheme & | operator= (const FMToperatingareascheme &rhs)=default |
void | fillboundsnvariables (const double *lowerb, const double *upperb, std::vector< int > &constraintstargets, std::vector< double > &bounds) const |
bool | operator== (const FMToperatingareascheme &rhs) const |
bool | operator!= (const FMToperatingareascheme &rhs) const |
~FMToperatingareascheme ()=default | |
FMToperatingareascheme | presolve (const Core::FMTmask &selectedmask, const std::vector< Core::FMTtheme > &presolvedthemes) const |
size_t | getnumberofscheme () const |
size_t | getnumberofsimplescheme () const |
const int & | getrejectednodescid () const |
const std::vector< std::vector< int > > & | getopeningconstraints () const |
const int & | getmaximalschemesconstraint () const |
const size_t & | getgreenup () const |
Public Member Functions inherited from Heuristics::FMToperatingarea | |
FMToperatingarea & | operator+= (const double &value) |
std::vector< Core::FMTmask > | getneighbors () const |
double | getarea () const |
double | getneihgborsperimeter () const |
Core::FMTmask | getmask () const |
void | setneighbors (const std::vector< Core::FMTmask > &lneighbors) |
FMToperatingarea (const Core::FMTmask &lmask, const double &lneihgborsperimeter) | |
void | setarea (const double &newarea) |
FMToperatingarea ()=default | |
FMToperatingarea (const FMToperatingarea &rhs)=default | |
FMToperatingarea & | operator= (const FMToperatingarea &rhs)=default |
bool | operator== (const FMToperatingarea &rhs) const |
bool | operator!= (const FMToperatingarea &rhs) const |
virtual | ~FMToperatingarea ()=default |
FMToperatingarea | presolveoperatingarea (const Core::FMTmaskfilter &filter, const std::vector< Core::FMTtheme > &presolvedthemes) const |
FMToperatingarea | postsolveoperatingarea (const Core::FMTmaskfilter &filter, const std::vector< Core::FMTtheme > &basethemes) const |
Friends | |
class | boost::serialization::access |
Additional Inherited Members | |
Protected Attributes inherited from Heuristics::FMToperatingarea | |
Core::FMTmask | mask |
The mask describing the operating area. | |
std::vector< Core::FMTmask > | neighbors |
Neighbors mask of the operating area. | |
double | neihgborsperimeter |
neighborsperimeter is the ratio a operatingarea needs to share to a other operatingarea to be considered neighbor. | |
double | _area |
The initial area of the operating area used as big M for the MIP. | |
FMToperatingareascheme gives informations about a given operating area scheme it's openingtime,greenup,returntime. FMToperatingscheme area have to be based on static themes (not used within transitions). Multiple potential schedules will be generated for the FMToperatingarea formulated as a heuristic and/or MIP.
Heuristics::FMToperatingareascheme::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 FMToperatingareascheme constructor targeting the user. Before synchronizing everything to the solverinterface, the user has to provide to the heuristics all the green-up, returntime etc.... for each operating area. The minimalarearatio is the minimal ratio needed to open the COS... The fullenum is to set the class parameter fullenumeration
|
default |
Default FMToperatingareascheme constructor
|
default |
FMToperatingareascheme copy constructor
|
default |
Default FMToperatingareascheme destructor
size_t Heuristics::FMToperatingareascheme::boundalldualschemes | ( | std::vector< int > & | targets, |
std::vector< double > & | bounds | ||
) | const |
Push constraints index into vector (targets) and push (boundvalue ) into (bounds).
size_t Heuristics::FMToperatingareascheme::boundallprimalschemes | ( | std::vector< int > & | targets, |
std::vector< double > & | bounds, | ||
double | boundvalue = 1.0 |
||
) | const |
Push variables index into vector (targets) and push (boundvalue ) into (bounds).
bool Heuristics::FMToperatingareascheme::boundprimalscheme | ( | std::vector< int > & | targets, |
std::vector< double > & | bounds, | ||
const size_t & | schemeid | ||
) | const |
Using the scheme binary variable of a given (schemeid) push it's variable index into (targets) and push into (bounds) (1 and 1)
bool Heuristics::FMToperatingareascheme::empty | ( | ) | const |
Check if the operating area is empty can be possible if there's no potential developpement to operate.
void Heuristics::FMToperatingareascheme::fillboundsnvariables | ( | const double * | lowerb, |
const double * | upperb, | ||
std::vector< int > & | constraintstargets, | ||
std::vector< double > & | bounds | ||
) | const |
For each scheme consttraints go take the constraints bounds of the actual model.
double Heuristics::FMToperatingareascheme::getactivitysum | ( | const double * | dualsolution | ) | const |
Looking at the (dualsolution) we summarize the value of all constraints for all potential schemes.
double Heuristics::FMToperatingareascheme::getbinariessum | ( | const double * | primalsolution | ) | const |
Looking at the (primalsolution) we summarize the value of all binary variables for all potential schemes.
std::map< int, std::vector< int > > Heuristics::FMToperatingareascheme::getcommonbinairies | ( | const FMToperatingareascheme & | neighbor | ) | const |
Using the greenup data member of each operating area (neighbor and this) we get the map<> key = this binary index and elements are a vector of binary indexes of the neighbor. We need this function to validate which schemes of an operating area is constraining the usage of the schemes of a other (neighbor).
std::vector< double > Heuristics::FMToperatingareascheme::getduallowerbounds | ( | const double * | lowerbounds, |
const double * | upperbounds | ||
) | const |
Gets the lowerbounds of the solution for bounding the minimal harvested area.
std::vector< double > Heuristics::FMToperatingareascheme::getdualsolution | ( | const double * | upperbounds, |
const double * | dualsolution, | ||
bool & | canbreakneighboring | ||
) | const |
Gets the yield solution of the dual problem using (dualsolution) it set the selected scheme solution into a vector of double.
bool Heuristics::FMToperatingareascheme::getdualsolutionindex | ( | const double * | upperbound, |
size_t & | locid | ||
) | const |
This function gets the index of the scheme used (locid) by the operating area using the (rows upperbound), is no scheme index is found the function returns false.
|
inline |
size_t Heuristics::FMToperatingareascheme::getmaximalreturntime | ( | ) | const |
Get the maximal return time.
const int & Heuristics::FMToperatingareascheme::getmaximalschemesconstraint | ( | ) | const |
size_t Heuristics::FMToperatingareascheme::getminimalreturntime | ( | ) | const |
Get the minimal return time.
size_t Heuristics::FMToperatingareascheme::getnumberofscheme | ( | ) | const |
Return the number of scheme for the OA. Can only be used if schemestoLP has been set called...
size_t Heuristics::FMToperatingareascheme::getnumberofsimplescheme | ( | ) | const |
Return the number of simple scheme with fixed returntime + openingtime
const std::vector< int > & Heuristics::FMToperatingareascheme::getopeningbinaries | ( | ) | const |
Getter returning variables index of the binaries of all potential schemes of the operatingarea.
const std::vector< std::vector< int > > & Heuristics::FMToperatingareascheme::getopeningconstraints | ( | ) | const |
size_t Heuristics::FMToperatingareascheme::getopeningtime | ( | ) | const |
Get the opening time
std::vector< size_t > Heuristics::FMToperatingareascheme::getpotentialdualschemes | ( | const double * | dualsolution, |
const double * | upperbound, | ||
const std::vector< FMToperatingareascheme > & | neighbors | ||
) | const |
Using the (dualsolution), rows (upperbounds) and the neighboring operating area, this function get the potential sheme indexes. The order begin with the scheme with more area used to the scehme with the less area used but > 0.
std::vector< size_t > Heuristics::FMToperatingareascheme::getpotentialprimalschemes | ( | const double * | primalsolution, |
const double * | lowerbounds, | ||
const double * | upperbounds, | ||
const std::vector< FMToperatingareascheme > & | neighbors | ||
) | const |
Using the (primalsolution), variables (lowerbounds)(upperbounds) and the neighboring operating area, this function get the potential sheme indexes. The order begin with the scheme with more area used to the scehme with the less area used but > 0.
std::vector< double > Heuristics::FMToperatingareascheme::getprimalsolution | ( | const double * | primalsolution | ) | const |
Gets the yield solution of the primal problem using (primalsolution) it sums up all binary variables into a single vector of double.
size_t Heuristics::FMToperatingareascheme::getprimalsolutionindex | ( | const double * | primalsolution | ) | const |
Only when a operating area is bounded to a given scheme we can use this function that gets the index of the bounded scheme looking at the (primalsolution)
const int & Heuristics::FMToperatingareascheme::getrejectednodescid | ( | ) | const |
size_t Heuristics::FMToperatingareascheme::getrepetition | ( | ) | const |
Get the repetition of the pattern.
void Heuristics::FMToperatingareascheme::getressourcestodelete | ( | std::vector< int > & | colstodelete, |
std::vector< int > & | rowstodelete | ||
) | const |
Push all the variables of this operating area to the (colstodelete) vector and push all the co of this operating area to the (colstodelete) vector and
size_t Heuristics::FMToperatingareascheme::getstartingperiod | ( | ) | const |
Getter returning starting period at which all schemes of the operating area starts.
double Heuristics::FMToperatingareascheme::getthreshold | ( | ) | const |
Get the threshold
bool Heuristics::FMToperatingareascheme::haveactivitysolution | ( | const double * | dualsolution | ) | const |
Checks if by any chance we have a set of scheme constraint with a activity value > 0 using the (dualsolution) indicating that there's a potential scheme to choose for dual.
bool Heuristics::FMToperatingareascheme::havepotentialsolution | ( | const double * | primalsolution | ) | const |
Checks if by any chance we have a scheme binary with a value > 0 using the (primalsolution) indicating that there's a potential scheme to choose for primal.
bool Heuristics::FMToperatingareascheme::isalldualbounded | ( | const double * | upperbounds | ) | const |
Will return false if any constraint (upperbounds) is different from 0.
bool Heuristics::FMToperatingareascheme::isallprimalbounded | ( | const double * | lowerbounds, |
const double * | upperbounds | ||
) | const |
Will return false if any binary (lowerbounds) or (upperbounds) is not set to 1.
bool Heuristics::FMToperatingareascheme::isdualbounded | ( | const double * | upperbounds | ) | const |
Will return true if any constraints (upperbounds) is set to 0.
bool Heuristics::FMToperatingareascheme::isprimalbounded | ( | const double * | lowerbounds, |
const double * | upperbounds | ||
) | const |
Will return true if any binary (lowerbounds) or (upperbounds) is set to 1.
bool Heuristics::FMToperatingareascheme::isthresholdactivity | ( | const double * | dualsolution | ) | const |
Will return true if every constraint has above threshold
bool Heuristics::FMToperatingareascheme::operator!= | ( | const FMToperatingareascheme & | rhs | ) | const |
Comparison operator of FMToperatingareascheme
|
default |
FMToperatingareascheme copy assignment
bool Heuristics::FMToperatingareascheme::operator== | ( | const FMToperatingareascheme & | rhs | ) | const |
Comparison operator of FMToperatingareascheme
FMToperatingareascheme Heuristics::FMToperatingareascheme::presolve | ( | const Core::FMTmask & | selectedmask, |
const std::vector< Core::FMTtheme > & | presolvedthemes | ||
) | const |
Using a FMTmask (selectedmask) and a subset of the original FMTthemes used to construct the FMTmask, it returns a presolved FMTmask with potentialy less data.
void Heuristics::FMToperatingareascheme::pushbinaries | ( | std::vector< int > & | targets | ) | const |
Push all all binaries to a vector<> (targets)
void Heuristics::FMToperatingareascheme::setconstraints | ( | const std::vector< std::vector< Graph::FMTgraph< Graph::FMTvertexproperties, Graph::FMTedgeproperties >::FMTvertex_descriptor > > & | verticies, |
const std::vector< Graph::FMTgraph< Graph::FMTvertexproperties, Graph::FMTedgeproperties >::FMTvertex_descriptor > & | totalareaverticies, | ||
const Graph::FMTgraph< Graph::FMTvertexproperties, Graph::FMTedgeproperties > & | graph, | ||
Models::FMTlpsolver & | solver, | ||
const double * | primalsolution, | ||
const std::vector< int > & | actionIDS | ||
) |
Main function setting up constraints and variables using a (matrixbuild) and a primal solution. This function will fill-up all data member related to matrix elements (constraints and variables). The user has to synchronize matrixbuild to the matrix after iterating on all operatingarea.
void Heuristics::FMToperatingareascheme::setreturntime | ( | const size_t & | minimalreturntime, |
const size_t & | maximalreturntime | ||
) |
Set the minimal and maximal return time.
size_t Heuristics::FMToperatingareascheme::unboundalldualschemes | ( | std::vector< int > & | targets, |
std::vector< double > & | bounds | ||
) | const |
Push constraints index into vector (targets) and push into (bounds) -inf and _area and return the id of the scheme unbounded
size_t Heuristics::FMToperatingareascheme::unboundallprimalschemes | ( | std::vector< int > & | targets, |
std::vector< double > & | bounds | ||
) | const |
Push binary index into vector (targets) and push into (bounds) 0 and 1.
bool Heuristics::FMToperatingareascheme::unbounddualscheme | ( | const double * | rowactivities, |
std::vector< int > & | targets, | ||
std::vector< double > & | bounds, | ||
const size_t & | schemeid, | ||
bool | looseset = true |
||
) | const |
Using the constraints of a given (schemeid) push it's constraints index into (targets) and push into (bounds) (-inf and _area) and for all other constraints from the other schemes push them into (targets) and push into (bounds) (0 and 0)
|
friend |
serialize function is for serialization, used to do multiprocessing across multiple cpus (pickle in Pyhton)