FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMToperatingareascheme.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2019 Gouvernement du Québec
3
4SPDX-License-Identifier: LiLiQ-R-1.1
5License-Filename: LICENSES/EN/LiLiQ-R11unicode.txt
6*/
7
8#ifdef FMTWITHOSI
9
10#ifndef FMToperatingareascheme_H_INCLUDED
11#define FMToperatingareascheme_H_INCLUDED
12
13#include "FMToperatingarea.hpp"
14#include <vector>
15#include <map>
16#include <memory>
17#include <boost/serialization/serialization.hpp>
18#include <boost/serialization/nvp.hpp>
19#include <boost/serialization/export.hpp>
20#include "FMTgraph.hpp"
21
22
23namespace Core
24{
25 class FMTmask;
26}
27
28namespace Models
29{
30 class FMTlpsolver;
31}
32
33
34namespace Heuristics
35 {
36 // DocString: FMToperatingareascheme
44 {
45 // DocString: FMToperatingareascheme::serialize
49 friend class boost::serialization::access;
50 template<class Archive>
51 void serialize(Archive& ar, const unsigned int version)
52 {
53 ar & boost::serialization::make_nvp("operatingarea", boost::serialization::base_object<FMToperatingarea>(*this));
54 ar & BOOST_SERIALIZATION_NVP(openingconstraints);
55 ar & BOOST_SERIALIZATION_NVP(openingbinaries);
56 ar & BOOST_SERIALIZATION_NVP(maximalschemesconstraint);
57 ar & BOOST_SERIALIZATION_NVP(schemesperiods);
58 ar & BOOST_SERIALIZATION_NVP(openingtime);
59 ar & BOOST_SERIALIZATION_NVP(returntime);
60 ar & BOOST_SERIALIZATION_NVP(repetition);
61 ar & BOOST_SERIALIZATION_NVP(greenup);
62 }
63 // DocString: FMToperatingareascheme::openingconstraints
65 std::vector<std::vector<int>>openingconstraints;
66 // DocString: FMToperatingareascheme::openingbinaries
68 std::vector<int>openingbinaries;
69 // DocString: FMToperatingareascheme::maximalschemesconstraint
71 int maximalschemesconstraint;
72 // DocString: FMToperatingareascheme::schemesperiods
74 std::vector<std::vector<int>>schemesperiods;
75 // DocString: FMToperatingareascheme::openingtime
77 size_t openingtime;
78 // DocString: FMToperatingareascheme::returntime
80 size_t returntime;
81 // DocString: FMToperatingareascheme::repetition
83 size_t repetition;
84 // DocString: FMToperatingareascheme::greenup
86 size_t greenup;
87 // DocString: FMToperatingareascheme::startingperiod
89 size_t startingperiod;
90 // DocString: FMToperatingareascheme::threshold
92 double threshold;
93 // DocString: FMToperatingareascheme::maxreturntime
95 //between return time and maxreturntime for each closing
96 size_t maxreturntime;
97 // DocString: FMToperatingareascheme::rejectednodescid
99 int rejectednodescid;
100 // DocString: FMToperatingareascheme::getarea
105 double getprimalarea(const double* primalsolution, const Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>& maingraph, const std::vector<Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>::FMTvertex_descriptor>& verticies) const;
106 // DocString: FMToperatingareascheme::getbestschemeid
111 size_t getbestschemeid(const double* primalsolution) const;
112 // DocString: FMToperatingareascheme::generateschemes
121 std::vector<std::vector<std::vector<Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>::FMTvertex_descriptor>>> generateschemes(const std::vector<std::vector<Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>::FMTvertex_descriptor>>& verticies);
122 // DocString: FMToperatingareascheme::schemestoLP
129 void schemestoLP(const std::vector<std::vector<std::vector<Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>::FMTvertex_descriptor>>>& schemes,
130 const std::vector<std::vector<Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>::FMTvertex_descriptor>>& periodictargetednodes,
132 Models::FMTlpsolver& solver,
133 const double* primalsolution,
134 const Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>& maingraph, const std::vector<int>& actionIDS);
135
136 // DocString: FMToperatingareascheme::getignoredverticies
140 std::vector<Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>::FMTvertex_descriptor> getignoredverticies(const std::vector<std::vector<std::vector<Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>::FMTvertex_descriptor>>>& schemes,
141 const std::vector<std::vector<Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>::FMTvertex_descriptor>>& targetedperiodsverticies) const;
142
143 // DocString: FMToperatingareascheme::schemestoperiods
148 std::vector<std::vector<int>> schemestoperiods(const std::vector<std::vector<std::vector<Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>::FMTvertex_descriptor>>>& schemes, const Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>& maingraph) const;
149 // DocString: FMToperatingareascheme::getrowsactivitysum
154 double getrowsactivitysum(const std::vector<int>& rows, const double* dualsolution) const;
155 // DocString: FMToperatingareascheme::isthresholdactivityrows
159 bool isthresholdactivityrows(const std::vector<int>& rows, const double* dualsolution) const;
160 // DocString: FMToperatingareascheme::fillpattern
166 std::vector<double>fillpattern(const std::vector<double>& pattern, const int& startat) const;
167 // DocString: FMToperatingareascheme::closenoactivity
171 void closenoactivity(std::vector<double>& filleduppattern, const size_t& selected, const double* dualsolution) const;
172 // DocString: FMToperatingareascheme::getmaxperiod
176 int getmaxperiod() const;
177 public:
178 // DocString: FMToperatingareascheme::setreturntime
182 void setreturntime(const size_t& minimalreturntime,const size_t& maximalreturntime);
183 // DocString: FMToperatingareascheme::getthreshold
187 double getthreshold() const;
188 // DocString: FMToperatingareascheme::getopeningtime
192 size_t getopeningtime() const;
193 // DocString: FMToperatingareascheme::getminimalreturntime
197 size_t getminimalreturntime() const;
198 // DocString: FMToperatingareascheme::getrepetition
202 size_t getrepetition() const;
203 // DocString: FMToperatingareascheme::getmaximalreturntime
207 size_t getmaximalreturntime() const;
208 // DocString: FMToperatingareascheme::empty
212 bool empty() const;
213 // DocString: FMToperatingareascheme::getopeningbinaries
217 const std::vector<int>& getopeningbinaries() const;
218 // DocString: FMToperatingareascheme::getstartingperiod
222 size_t getstartingperiod() const;
223 // DocString: FMToperatingareascheme::getbinariessum
227 double getbinariessum(const double* primalsolution) const;
228 // DocString: FMToperatingareascheme::getactivitysum
232 double getactivitysum(const double* dualsolution) const;
233 // DocString: FMToperatingareascheme::getthresholdactivity
237 bool isthresholdactivity(const double* dualsolution) const;
238 // DocString: FMToperatingareascheme::getcommonbinairies
245 std::map<int, std::vector<int>> getcommonbinairies(const FMToperatingareascheme& neighbor) const;
246 // DocString: FMToperatingareascheme::getprimalsolutionindex
251 size_t getprimalsolutionindex(const double* primalsolution) const;
252 // DocString: FMToperatingareascheme::getdualsolutionindex
257 bool getdualsolutionindex(const double* upperbound, size_t& locid) const;
258 // DocString: FMToperatingareascheme::havepotentialsolution
263 bool havepotentialsolution(const double* primalsolution) const;
264 // DocString: FMToperatingareascheme::haveactivitysolution
269 bool haveactivitysolution(const double* dualsolution) const;
270 // DocString: FMToperatingareascheme::isallprimalbounded
274 bool isallprimalbounded(const double* lowerbounds, const double* upperbounds) const;
275 // DocString: FMToperatingareascheme::isalldualbounded
279 bool isalldualbounded(const double* upperbounds) const;
280 // DocString: FMToperatingareascheme::isprimalbounded
284 bool isprimalbounded(const double* lowerbounds, const double* upperbounds) const;
285 // DocString: FMToperatingareascheme::isdualbounded
289 bool isdualbounded(const double* upperbounds) const;
290 // DocString: FMToperatingareascheme::getpotentialprimalschemes
296 std::vector<size_t>getpotentialprimalschemes(const double* primalsolution, const double* lowerbounds, const double* upperbounds,const std::vector<FMToperatingareascheme>& neighbors) const;
297 // DocString: FMToperatingareascheme::getpotentialdualschemes
303 std::vector<size_t>getpotentialdualschemes(const double* dualsolution, const double* upperbound, const std::vector<FMToperatingareascheme>& neighbors) const;
304 // DocString: FMToperatingareascheme::getressourcestodelete
309 void getressourcestodelete(std::vector<int>& colstodelete, std::vector<int>& rowstodelete) const; //Remove all variable and constraints related to the operating area from the solver
310 // DocString: FMToperatingareascheme::pushbinaries
314 void pushbinaries(std::vector<int>& targets) const;
315 // DocString: FMToperatingareascheme::unboundallprimalschemes
319 size_t unboundallprimalschemes(std::vector<int>& targets, std::vector<double>& bounds) const;
320 // DocString: FMToperatingareascheme::unboundalldualschemes
324 size_t unboundalldualschemes(std::vector<int>& targets, std::vector<double>& bounds) const;
325 // DocString: FMToperatingareascheme::boundallprimalschemes
329 size_t boundallprimalschemes(std::vector<int>& targets, std::vector<double>& bounds,double boundvalue = 1.0) const;
330 // DocString: FMToperatingareascheme::boundalldualschemes
334 size_t boundalldualschemes(std::vector<int>& targets, std::vector<double>& bounds) const;
335 // DocString: FMToperatingareascheme::boundprimalscheme
339 bool boundprimalscheme(std::vector<int>& targets, std::vector<double>& bounds, const size_t& schemeid) const;
340 // DocString: FMToperatingareascheme::unbounddualscheme
345 bool unbounddualscheme(const double* rowactivities, std::vector<int>& targets, std::vector<double>& bounds, const size_t& schemeid, bool looseset=true) const;
346 // DocString: FMToperatingareascheme::getprimalsolution
351 std::vector<double> getprimalsolution(const double* primalsolution) const;
352 // DocString: FMToperatingareascheme::getdualsolution
357 std::vector<double> getdualsolution(const double* upperbounds, const double* dualsolution, bool& canbreakneighboring) const;
358 // DocString: FMToperatingareascheme::getduallowerbounds
362 std::vector<double> getduallowerbounds(const double* lowerbounds,const double* upperbounds) const;
363 // DocString: FMToperatingareascheme::setconstraints
372 const double* primalsolution,
373 const std::vector<int>& actionIDS);
374 // DocString: FMToperatingareascheme(const FMToperatingarea,const size_t, const size_t,const size_t,const size_t,const size_t)
381 FMToperatingareascheme(const FMToperatingarea& oparea,const size_t& lopeningtime, const size_t& lreturntime, const size_t& lmaxreturntime,
382 const size_t& lrepetition, const size_t& lgreenup,const size_t& lstartingperiod,double minimalarearatio=0.0);
383 // DocString: FMToperatingareascheme()
388 // DocString: FMToperatingareascheme(const FMToperatingarea)
393 // DocString: FMToperatingareascheme::operator=
397 FMToperatingareascheme& operator = (const FMToperatingareascheme& rhs)=default;
398 // DocString: FMToperatingareascheme::fillboundsnvariables
402 void fillboundsnvariables(const double* lowerb, const double* upperb, std::vector<int>& constraintstargets,std::vector<double>&bounds) const;
403 // DocString: FMToperatingareascheme::operator==
407 bool operator == (const FMToperatingareascheme& rhs) const;
408 // DocString: FMToperatingareascheme::operator!=
412 bool operator != (const FMToperatingareascheme& rhs) const;
413 // DocString: ~FMToperatingareascheme()
418 // DocString: FMToperatingareascheme::presolve
423 FMToperatingareascheme presolve(const Core::FMTmask& selectedmask,const std::vector<Core::FMTtheme>&presolvedthemes) const;
424 // DocString: FMToperatingareascheme::getnumberofscheme
428 size_t getnumberofscheme() const;
429 // DocString: FMToperatingareascheme::getnumberofsimplescheme
434 // DocString: FMToperatingareascheme::getrejectednodescid
438 const int& getrejectednodescid() const;
439 // DocString: FMToperatingareascheme::getschemesperiods
443 const std::vector<std::vector<int>>& getopeningconstraints() const;
444 // DocString: FMToperatingareascheme::maximalschemesconstraint
448 const int& getmaximalschemesconstraint() const;
449
450 const size_t& getgreenup() const { return greenup; };
451
452 };
453
454 // DocString: FMToperatingareaschemecomparator
459 {
460 // DocString: FMToperatingareaschemecomparator::mask
462 Core::FMTmask mask;
463 public:
464 // DocString: FMToperatingareaschemecomparator(const Core::FMTmask)
469 // DocString: FMToperatingareaschemecomparator::operator()
473 bool operator()(const FMToperatingareascheme& oparea) const;
474
475 };
476
477 }
478 BOOST_CLASS_EXPORT_KEY(Heuristics::FMToperatingareascheme)
479#endif
480#endif
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTmask.hpp:96
Definition: FMTgraph.hpp:78
boost::graph_traits< FMTadjacency_list >::vertex_descriptor FMTvertex_descriptor
Definition: FMTgraph.hpp:110
Definition: FMToperatingarea.hpp:29
Definition: FMToperatingareascheme.hpp:44
std::vector< size_t > getpotentialprimalschemes(const double *primalsolution, const double *lowerbounds, const double *upperbounds, const std::vector< FMToperatingareascheme > &neighbors) const
size_t unboundalldualschemes(std::vector< int > &targets, std::vector< double > &bounds) const
const std::vector< std::vector< int > > & getopeningconstraints() const
const std::vector< int > & getopeningbinaries() const
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)
const size_t & getgreenup() const
Definition: FMToperatingareascheme.hpp:450
bool isallprimalbounded(const double *lowerbounds, const double *upperbounds) const
void setreturntime(const size_t &minimalreturntime, const size_t &maximalreturntime)
std::vector< double > getprimalsolution(const double *primalsolution) const
void getressourcestodelete(std::vector< int > &colstodelete, std::vector< int > &rowstodelete) const
bool haveactivitysolution(const double *dualsolution) 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)
std::vector< double > getdualsolution(const double *upperbounds, const double *dualsolution, bool &canbreakneighboring) const
std::vector< size_t > getpotentialdualschemes(const double *dualsolution, const double *upperbound, const std::vector< FMToperatingareascheme > &neighbors) const
size_t boundallprimalschemes(std::vector< int > &targets, std::vector< double > &bounds, double boundvalue=1.0) const
bool getdualsolutionindex(const double *upperbound, size_t &locid) const
bool isalldualbounded(const double *upperbounds) const
void fillboundsnvariables(const double *lowerb, const double *upperb, std::vector< int > &constraintstargets, std::vector< double > &bounds) const
const int & getrejectednodescid() const
bool isprimalbounded(const double *lowerbounds, const double *upperbounds) const
FMToperatingareascheme presolve(const Core::FMTmask &selectedmask, const std::vector< Core::FMTtheme > &presolvedthemes) const
bool isdualbounded(const double *upperbounds) const
size_t unboundallprimalschemes(std::vector< int > &targets, std::vector< double > &bounds) const
void pushbinaries(std::vector< int > &targets) const
bool havepotentialsolution(const double *primalsolution) const
size_t boundalldualschemes(std::vector< int > &targets, std::vector< double > &bounds) const
double getbinariessum(const double *primalsolution) const
std::map< int, std::vector< int > > getcommonbinairies(const FMToperatingareascheme &neighbor) const
bool isthresholdactivity(const double *dualsolution) const
const int & getmaximalschemesconstraint() const
size_t getprimalsolutionindex(const double *primalsolution) const
std::vector< double > getduallowerbounds(const double *lowerbounds, const double *upperbounds) const
FMToperatingareascheme(const FMToperatingareascheme &rhs)=default
double getactivitysum(const double *dualsolution) 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
Definition: FMToperatingareascheme.hpp:459
bool operator()(const FMToperatingareascheme &oparea) const
FMToperatingareaschemecomparator(const Core::FMTmask &lmask)
Definition: FMTlpsolver.hpp:39
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
Namespace regrouping all tools for solving LP/MIP problems using an heuristic.
Definition: FMTareaparser.hpp:43
Namespace containing all enumerator and classes used to construct or manipulate the different type of...
Definition: FMTareaparser.hpp:50