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

#include <FMToperatingareascheduler.hpp>

Inheritance diagram for Heuristics::FMToperatingareascheduler:
[legend]
Collaboration diagram for Heuristics::FMToperatingareascheduler:
[legend]

Public Member Functions

double generateinitialproportionofset () const
 
bool empty () const
 
bool initialsolve () final
 
bool branchnboundsolve () final
 
bool greedypass (const double &initsol, const unsigned int &iteration) final
 
void setasrandom ()
 
void setasprimal ()
 
void setproportionofset (const double &proportion)
 
std::vector< Core::FMTtimeyieldhandlergetsolution (const std::string &yldname) const
 
std::vector< Core::FMToutputgetlevelsolution (const std::string &outputname, const std::string &aggregate, int outputid) const
 
 FMToperatingareascheduler (const std::vector< FMToperatingareascheme > &loperatingareas, const Graph::FMTgraph< Graph::FMTvertexproperties, Graph::FMTedgeproperties > &maingraph, const Models::FMTmodel &model, const Core::FMToutputnode &target, Models::FMTlpsolver &basesolve, size_t lseed=0, double proportionofset=0.25, bool userandomness=false, bool copysolver=true)
 
 FMToperatingareascheduler ()=default
 
 FMToperatingareascheduler (const FMToperatingareascheduler &rhs)
 
 FMToperatingareascheduler (FMToperatingareascheduler &&rhs)=default
 
FMToperatingareascheduleroperator= (const FMToperatingareascheduler &rhs)
 
 ~FMToperatingareascheduler ()
 
- Public Member Functions inherited from Heuristics::FMTlpheuristic
void setgeneratorseed (const size_t &lseed)
 
 FMTlpheuristic (Models::FMTlpsolver &basesolve, size_t lseed=0, bool copysolver=true)
 
 FMTlpheuristic (const Models::FMTsolverinterface &interfacetype, const size_t &lseed)
 
 FMTlpheuristic ()=default
 
 FMTlpheuristic (const FMTlpheuristic &rhs)
 
 FMTlpheuristic (FMTlpheuristic &&rhs)=default
 
FMTlpheuristicoperator= (const FMTlpheuristic &rhs)
 
virtual bool branchnboundsolve ()
 
virtual bool greedypass (const double &initsol, const unsigned int &iteration)
 
virtual void paralleloptimize (const double &initbestsolution, const unsigned int &iterations, const double &maxtime, const std::chrono::steady_clock::time_point &Starttime)
 
virtual ~FMTlpheuristic ()=default
 
- Public Member Functions inherited from Models::FMTlpsolver
void swap (FMTlpsolver &rhs)
 
void passinlogger (const std::shared_ptr< Logging::FMTlogger > &logger) override
 
void unmarkHotStart ()
 
bool stockresolve ()
 
 FMTlpsolver ()
 
virtual ~FMTlpsolver ()=default
 
 FMTlpsolver (const FMTlpsolver &rhs)
 
 FMTlpsolver (FMTlpsolver &&rhs)=default
 
FMTlpsolveroperator= (const FMTlpsolver &rhs)
 
FMTlpsolveroperator= (FMTlpsolver &&rhs)=default
 
 FMTlpsolver (FMTsolverinterface lsolvertype)
 
bool operator== (const FMTlpsolver &rhs) const
 
bool operator!= (const FMTlpsolver &rhs) const
 
virtual bool resolve ()
 
virtual bool initialsolve ()
 
void setnumberofthreads (const size_t &nthread)
 
void setMIPgaptolerance (const double &gap)
 
void setoptimizerMAXtime (const double &time)
 
void MIPparameters ()
 
double getObjValue () const
 
int getiterationcount () const
 
void passinsolver (const FMTlpsolver &solver)
 
void passinmessagehandler (Logging::FMTlogger &logger)
 
void setsolvertype (FMTsolverinterface &lsolvertype) const
 
bool gotlicense () const
 
std::string getsolvername () const
 
int getNumCols () const
 
int getNumRows () const
 
const double * getObjCoefficients () const
 
const double * getColLower () const
 
const double * getColUpper () const
 
const double * getColSolution () const
 
const double * getRowPrice () const
 
const double * getRowActivity () const
 
const double * getRowUpper () const
 
const double * getRowLower () const
 
int getrow (int whichRow, double &rowLower, double &rowUpper, std::vector< int > &indices, std::vector< double > &elements) const
 
int getcol (int whichCol, double &colLower, double &colUpper, double &objectiveValue, std::vector< int > &indices, std::vector< double > &elements) const
 
double getObjSense () const
 
void setObjective (const double *objectivevalues)
 
void setObjSense (const double &newsense)
 
void addRow (int numberInRow, const int *columns, const double *elements, double rowLower=-std::numeric_limits< double >::max(), double rowUpper=std::numeric_limits< double >::max())
 
void addCol (int numberInColumn, const int *rows, const double *elements, double columnLower=0.0, double columnUpper=std::numeric_limits< double >::max(), double objectiveValue=0.0)
 
void addRows (const int numrows, const int *rowStarts, const int *columns, const double *elements, const double *rowlb, const double *rowub)
 
void addCols (const int numcols, const int *columnStarts, const int *rows, const double *elements, const double *collb, const double *colub, const double *obj)
 
bool isProvenOptimal () const
 
void deleteRow (const int &rowindex)
 
void deleteCol (const int &colindex)
 
void deleteRows (int numberofrows, const int *rowindexes)
 
void deleteCols (int numberofcols, const int *colindexes)
 
void setColSolution (const double *newsolution)
 
void setRowPrice (const double *rowprice)
 
void setColSetBounds (const int *indexFirst, const int *indexLast, const double *boundlist)
 
void setRowSetBounds (const int *indexFirst, const int *indexLast, const double *boundlist)
 
void setInteger (const int &colindex)
 
void setInteger (const int *indices, int len)
 
void setcolname (const std::string &name, const int &columnid) const
 
void setrowname (const std::string &name, const int &rowid) const
 
void writeLP (const std::string &location) const
 
void writeMPS (const std::string &location) const
 
void branchAndBound ()
 
void enablematrixcaching ()
 
void disablematrixcaching ()
 
FMTsolverinterface getsolvertype () const
 
void synchronize ()
 
void sortdeletedcache ()
 
const std::vector< int > & getcachedeletedconstraints () const
 
const std::vector< int > & getcachedeletedvariables () const
 
std::string lowernuppertostr (const double &lower, const double &upper) const
 
std::string getcacheelements () const
 
void updaterowsandcolsnames (bool shortformat=true)
 
std::string getmskerrordesc (int error) const
 
- Public Member Functions inherited from Core::FMTobject
 FMTobject ()
 
virtual ~FMTobject ()
 
 FMTobject (const std::shared_ptr< Exception::FMTexceptionhandler > exhandler)
 
 FMTobject (const FMTobject &rhs)
 
FMTobjectoperator= (const FMTobject &rhs)
 
virtual void passinlogger (const std::shared_ptr< Logging::FMTlogger > &logger)
 
void passinexceptionhandler (const std::shared_ptr< Exception::FMTexceptionhandler > &exhandler)
 
void redirectlogtofile (const std::string &location)
 
virtual void setdefaultlogger ()
 
virtual void setquietlogger ()
 
virtual void settasklogger ()
 
virtual void setdebuglogger ()
 
void setdefaultexceptionhandler ()
 
void setquietexceptionhandler ()
 
void setdebugexceptionhandler ()
 
void setfreeexceptionhandler ()
 
void disablenestedexceptions ()
 
void enablenestedexceptions ()
 
void seterrorstowarnings (const std::vector< Exception::FMTexc > &errors)
 
void setmaxwarningsbeforesilenced (const size_t &maxwarningcount)
 

Friends

class boost::serialization::access
 

Additional Inherited Members

- Static Public Member Functions inherited from Core::FMTobject
static std::string getruntimelocation ()
 
static unsigned long long getavailablememory ()
 
- Protected Member Functions inherited from Models::FMTlpsolver
bool canupdatesource () const
 
std::shared_ptr< OsiSolverInterface > buildsolverinterface (const FMTsolverinterface &lsolvertype) const
 
std::shared_ptr< OsiSolverInterface > copysolverinterface (const std::shared_ptr< OsiSolverInterface > &solver_ptr, const FMTsolverinterface &lsolvertype) const
 
void clearrowcache ()
 
const CoinPackedMatrix * getMatrixByRow () const
 
const CoinPackedMatrix * getMatrixByCol () const
 
- Protected Member Functions inherited from Core::FMTobject
template<class Archive >
void forcesave (Archive &ar, const unsigned int version) const
 
template<class Archive >
void forceload (Archive &ar, const unsigned int version)
 
void checksignals () const
 
void setCPLhandler ()
 
- Static Protected Member Functions inherited from Core::FMTobject
static std::chrono::time_point< std::chrono::high_resolution_clock > getclock ()
 
template<class chrono >
static double getduration (const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
 
static std::string getdurationinseconds (const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
 
- Protected Attributes inherited from Heuristics::FMTlpheuristic
std::default_random_engine generator
 std random number generator of the heuristic each heuristic has it's own generator to generate different solution
 
size_t seed
 The random engine seed need to be a data member when serializing the class.
 
bool usingsolvercopy
 If true the heuristic will work from it's own copy of solverinterface, else it's going to work on the FMTlpmodel solverinterface.
 
- Protected Attributes inherited from Models::FMTlpsolver
FMTmatrixbuild matrixcache
 The matrix cache follow the constraints or variables that need to be added or removed to the problem.
 
FMTsolverinterface solvertype
 Solver type used maybe usefull for initialsolve or resolve to know what solver we are using to speed-up the process.
 
- Static Protected Attributes inherited from Core::FMTobject
static std::shared_ptr< Exception::FMTexceptionhandler_exhandler
 A shared pointer to the exception handler.
 
static std::shared_ptr< Logging::FMTlogger_logger
 A shared pointer to the logger.
 

Detailed Description

FMToperatingareaheuristic is a heuristics made to solve spatialization problem across landscape for multiple operating areas. MIP Forest planning problem tend to be symmetrical and tought to solve using a regular MIP solver. This heuristics is made to quickly generate good enought starting solution for those kind of Forest management problem. Before using this class the user must have sets all parameters of a vector of FMToperatingarea so that the heuristic can sets the constraints and variables of each operating area into the matrix. It's up to the user to decide to just generate a good initialsolution or generate a good initialsolution and then try to find the optimaly using a BnB solver.

Constructor & Destructor Documentation

◆ FMToperatingareascheduler() [1/4]

Heuristics::FMToperatingareascheduler::FMToperatingareascheduler ( const std::vector< FMToperatingareascheme > &  loperatingareas,
const Graph::FMTgraph< Graph::FMTvertexproperties, Graph::FMTedgeproperties > &  maingraph,
const Models::FMTmodel model,
const Core::FMToutputnode target,
Models::FMTlpsolver basesolve,
size_t  lseed = 0,
double  proportionofset = 0.25,
bool  userandomness = false,
bool  copysolver = true 
)

Main constructor used to initialize a FMToperatingareaheuristic, the constructor needs alot of information comming from a FMTlpmodel. Also constructing a FMToperatingareaheuristic is not a small task if copysolver = true because the solverinterface beging the FMTlpmodel needs to be copied. After constructing the object the operatingareaheuristic doesn't need any information about the FMTlpmodel.

◆ FMToperatingareascheduler() [2/4]

Heuristics::FMToperatingareascheduler::FMToperatingareascheduler ( )
default

Default FMToperatingareaheuristic constructor

◆ FMToperatingareascheduler() [3/4]

Heuristics::FMToperatingareascheduler::FMToperatingareascheduler ( const FMToperatingareascheduler rhs)

FMToperatingareaheuristic copy constructor

◆ FMToperatingareascheduler() [4/4]

Heuristics::FMToperatingareascheduler::FMToperatingareascheduler ( FMToperatingareascheduler &&  rhs)
default

FMToperatingareaheuristic move constructor

◆ ~FMToperatingareascheduler()

Heuristics::FMToperatingareascheduler::~FMToperatingareascheduler ( )

Return true if the actual solution of the heuristic is feasible.

Member Function Documentation

◆ branchnboundsolve()

bool Heuristics::FMToperatingareascheduler::branchnboundsolve ( )
finalvirtual

Solve problem using Branch and bound on the primal formulation. If the function is called after a call to initialsolve() it's going to use the heuristic solution has a starting MIP solution, if not it's going to directly use the BnB on the formulated problem.

Reimplemented from Heuristics::FMTlpheuristic.

◆ empty()

bool Heuristics::FMToperatingareascheduler::empty ( ) const

Return true if operatingareas is empty.

◆ generateinitialproportionofset()

double Heuristics::FMToperatingareascheduler::generateinitialproportionofset ( ) const

◆ getlevelsolution()

std::vector< Core::FMToutput > Heuristics::FMToperatingareascheduler::getlevelsolution ( const std::string &  outputname,
const std::string &  aggregate,
int  outputid 
) const

Gets the lower bounds of the solution for each operating area get 2 outputs: the first one is the level and the second one is the varaible outputs that needs to be bound to.

◆ getsolution()

std::vector< Core::FMTtimeyieldhandler > Heuristics::FMToperatingareascheduler::getsolution ( const std::string &  yldname) const

Gets the actual solution into a FMTyieldhandler format (time yield) The user can decide the (yldname) to use. Each operating area will have its own yieldhandler. If (selectedmask) and (basethemes) are given, the yieldhandler return will be postsolve. To get (selectedmask), you must call the function FMTmodel::getselectedmask() after presolving the model. (basethemes) are the themes of the original model.

◆ greedypass()

bool Heuristics::FMToperatingareascheduler::greedypass ( const double &  initsol,
const unsigned int &  iteration 
)
finalvirtual

Reimplemented from Heuristics::FMTlpheuristic.

◆ initialsolve()

bool Heuristics::FMToperatingareascheduler::initialsolve ( )
finalvirtual

Solve the heuristic problem using the original heuristic resolving the problem till finding a initial solution for each operating area. The user can use the function getsolution to first yield solution.

Reimplemented from Models::FMTlpsolver.

◆ operator=()

FMToperatingareascheduler & Heuristics::FMToperatingareascheduler::operator= ( const FMToperatingareascheduler rhs)

FMToperatingareaheuristic copy assignment

◆ setasprimal()

void Heuristics::FMToperatingareascheduler::setasprimal ( )

Sets True the useprimal data member

◆ setasrandom()

void Heuristics::FMToperatingareascheduler::setasrandom ( )

Sets True the userandomness data member

◆ setproportionofset()

void Heuristics::FMToperatingareascheduler::setproportionofset ( const double &  proportion)

Set the allowed proportion of operating area status change allowed before resolving the problem. Default = 0.25

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Save function is for serialization, used to do multiprocessing across multiple cpus (pickle in Pyhton)


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