FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMToperatingareascheduler.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 FMToperatingareascheduler_H_INCLUDED
11#define FMToperatingareascheduler_H_INCLUDED
12
13#include "FMTmask.hpp"
15#include "FMTlpheuristic.hpp"
16
17
18
19
20#include <random>
21#include <memory>
22#include <map>
23#include <vector>
24//#include <chrono>
25#include <boost/serialization/serialization.hpp>
26#include <boost/serialization/nvp.hpp>
27#include <boost/serialization/export.hpp>
28
29
30namespace Graph
31{
32 template<class T1, class T2>
33 class FMTgraph;
34}
35
36namespace Models
37{
38 class FMTmodel;
39}
40
41namespace Core
42{
43 class FMToutputnode;
44 class FMTtimeyieldhandler;
45 class FMToutput;
46}
47
48
49namespace Heuristics
50{
51 // DocString: FMToperatingareascheduler
63 {
64 // DocString: FMToperatingareaheuristic::save
68 friend class boost::serialization::access;
69 template<class Archive>
70 void serialize(Archive& ar, const unsigned int version)
71 {
72 ar & boost::serialization::make_nvp("lpsolve", boost::serialization::base_object<FMTlpheuristic>(*this));
73 ar & BOOST_SERIALIZATION_NVP(operatingareas);
74 ar & BOOST_SERIALIZATION_NVP(adjacencyconstraints);
75 ar & BOOST_SERIALIZATION_NVP(proportionofset);
76 ar & BOOST_SERIALIZATION_NVP(userandomness);
77 ar & BOOST_SERIALIZATION_NVP(useprimal);
78 }
79 // DocString: FMToperatingareascheduler::operatingareas
81 std::vector<FMToperatingareascheme>operatingareas;
82 // DocString: FMToperatingareascheduler::adjacencyconstraints
84 std::map<std::pair<Core::FMTmask, Core::FMTmask>, std::vector<int>>adjacencyconstraints;
85 // DocString: FMToperatingareascheduler::proportionofset
87 double proportionofset;
88 // DocString: FMToperatingareascheduler::userandomness
90 bool userandomness;
91 // DocString: FMToperatingareascheduler::useprimal
93 bool useprimal;
94 // DocString: FMToperatingareascheduler::setoperatingareasconstraints
100 void setoperatingareasconstraints(const Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>& maingraph,
101 const Models::FMTmodel& model,
102 const Core::FMToutputnode& target);
103 // DocString: FMToperatingareascheduler::setadjacencyconstraints
109 bool setadjacencyconstraints();
110 // DocString: FMToperatingareascheduler::setdraw
116 std::vector<std::vector<FMToperatingareascheme>::const_iterator> setdraw();
117 // DocString: FMToperatingareascheduler::draw
123 std::vector<std::vector<FMToperatingareascheme>::const_iterator> draw(std::vector<std::vector<FMToperatingareascheme>::const_iterator>& oparea);
124 // DocString: FMToperatingareascheduler::setbounds
130 size_t setbounds(const std::vector<std::vector<FMToperatingareascheme>::const_iterator>& tobound,const std::vector<int>& schemestoskip=std::vector<int>(), bool keeploose=true);
131 // DocString: FMToperatingareascheduler::selectscheme
135 size_t selectscheme(std::vector<size_t>& potentialschemes, const int& schemetoskip) const;
136 // DocString: FMToperatingareascheduler::getbounds
141 bool getbounds(const std::vector<FMToperatingareascheme>::const_iterator& operatingareaiterator,
142 std::vector<int>& targeteditems,std::vector<double>& bounds, const bool& boundall, const size_t& schemeid=0,bool keeploose=true) const;
143 // DocString: FMToperatingareascheduler::unboundall
148 void unboundall(bool atprimal = false);
149 // DocString: FMToperatingareascheduler::unbound
154 void unbound(const std::vector<std::vector<FMToperatingareascheme>::const_iterator>& tounbound,bool atprimal = false);
155 // DocString: FMToperatingareascheduler::closeprimalbounds
159 void closeprimalbounds();
160 // DocString: FMToperatingareascheduler::setallinteger
166 void setallinteger();
167 // DocString: FMToperatingareascheduler::resolvemodel
172 int resolvemodel();
173 // DocString: FMToperatingareascheduler::clearrowcache
178 void clearrowcache();
179 // DocString: FMToperatingareascheduler::getsolutionindexes
180 /*
181 Return the scheme index which is bounded for each operatingareascheme pass to the function in the same order.
182 */
183 std::vector<int> getsolutionindexes(const std::vector<std::vector<FMToperatingareascheme>::const_iterator>& opareaits) const;
184 // DocString: FMToperatingareascheduler::getthreadid
185 /*
186 Return thread id to log it into functions greedypass and initialsove
187 */
188 std::string getthreadid() const;
189 // DocString: FMToperatingareascheduler::completeinitialsolution
196 bool completeinitialsolution();
197 // DocString: FMToperatingareascheduler::gotrejectednodes
201 bool gotrejectednodes() const;
202 // DocString: FMToperatingareascheduler::resetbasegreedysolution
207 void resetbasegreedysolution(const std::vector<std::vector<FMToperatingareascheme>::const_iterator>& selected,
208 const std::vector<int>& oldschemeid,
209 const std::vector<int>& oldconstraints,
210 const std::vector<double>& oldbounds);
211 // DocString: FMToperatingareascheduler::releasegreedysolution
217 bool releasegreedysolution(const std::vector<std::vector<FMToperatingareascheme>::const_iterator>& selected,
218 std::vector<int>& oldconstraints,
219 std::vector<double>& oldbounds);
220 // DocString: FMToperatingareascheduler::greedymovesolution
225 bool greedymovesolution(const std::vector<std::vector<FMToperatingareascheme>::const_iterator>& selected,
226 const std::vector<int>& oldschemeid);
227 // DocString: FMToperatingareascheduler::setfordualinitialsolve
232 void setfordualinitialsolve();
233 // DocString: FMToperatingareascheduler::initialmovesolution
237 int initialmovesolution(const std::vector<std::vector<FMToperatingareascheme>::const_iterator>& selected);
238 // DocString: FMToperatingareascheduler::resetbaseinitialsolution
243 void resetbaseinitialsolution();
244 public:
245 // DocString: FMToperatingareascheduler::generateinitialproportionofset
246 /*
247 Try to calculate a good proportion of set for the initialsolve...if anything goes wrong it will be 0.25 If more complexity is
248 detected using the FMToperatingareascheme getnumberofscheme vs the getnumberofsimplescheme it will get the difference and use a factor of 0.00025
249 to decrease in a linear fashion the propotion of set to a minimum of 0.01.
250 */
252 // DocString: FMToperatingareascheduler::empty
256 bool empty() const;
257 // DocString: FMToperatingareascheduler::initialsolve
262 bool initialsolve() final;
263 // DocString: FMToperatingareascheduler::branchnboundsolve
268 bool branchnboundsolve() final;
269 // DocString: FMToperatingareascheduler::greedypass
273 bool greedypass(const double& initsol, const unsigned int& iteration) final;
274 // DocString: FMToperatingareascheduler::setasrandom
278 void setasrandom();
279 // DocString: FMToperatingareascheduler::setasprimal
283 void setasprimal();
284 // DocString: FMToperatingareascheduler::setproportionofset
288 void setproportionofset(const double& proportion);
289 // DocString: FMToperatingareascheduler::getsolution
297 std::vector<Core::FMTtimeyieldhandler> getsolution( const std::string& yldname) const;
298 // DocString: FMToperatingareascheduler::getlevelsolution
303 std::vector<Core::FMToutput>getlevelsolution(const std::string& outputname,const std::string& aggregate,int outputid) const;
304 // DocString: FMToperatingareascheduler(const std::vector<FMToperatingarea>,const Graph::FMTgraph,const Models::FMTmodel,const Core::FMToutputnode,std::shared_ptr<OsiSolverInterface>,const Models::FMTsolverinterface,size_t lseed,double proportionofset,bool userandomness,bool copysolver)
312 FMToperatingareascheduler(const std::vector<FMToperatingareascheme>& loperatingareas,
313 const Graph::FMTgraph<Graph::FMTvertexproperties, Graph::FMTedgeproperties>& maingraph,
314 const Models::FMTmodel& model,
315 const Core::FMToutputnode& target,
316 Models::FMTlpsolver& basesolve, size_t lseed = 0,
317 double proportionofset = 0.25, bool userandomness = false, bool copysolver = true);
318 // DocString: FMToperatingareascheduler()
323 // DocString: FMToperatingareascheduler(const FMToperatingareaheuristic&)
328 // DocString: FMToperatingareascheduler(const FMToperatingareaheuristic&&)
333 // DocString: FMToperatingareascheduler::operator=
338 // DocString: FMToperatingareascheduler::isfeasible
343 };
344}
345BOOST_CLASS_EXPORT_KEY(Heuristics::FMToperatingareascheduler)
346#endif
347#endif
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMToutputnode.hpp:20
Definition: FMTgraph.hpp:78
Definition: FMTlpheuristic.hpp:40
Definition: FMToperatingareascheduler.hpp:63
Definition: FMToperatingareascheme.hpp:44
Definition: FMTmodel.hpp:60
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
Namespace for using/building unidirectional graphs in FMT.
Definition: FMTareaparser.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