FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTOperatingAreaScheduler.h
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_Hm_included
11#define FMToperatingareascheduler_Hm_included
12
13#include "FMTMask.h"
15#include "FMTLpHeuristic.h"
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
57 {
58 // DocString: FMToperatingareaheuristic::save
65 friend class boost::serialization::access;
66 template<class Archive>
67 void serialize(Archive& ar, const unsigned int version)
68 {
69 ar & boost::serialization::make_nvp("lpsolve", boost::serialization::base_object<FMTLpHeuristic>(*this));
70 ar & BOOST_SERIALIZATION_NVP(operatingareas);
71 ar & BOOST_SERIALIZATION_NVP(adjacencyconstraints);
72 ar & BOOST_SERIALIZATION_NVP(proportionofset);
73 ar & BOOST_SERIALIZATION_NVP(userandomness);
74 ar & BOOST_SERIALIZATION_NVP(useprimal);
75 }
76 // DocString: FMTOperatingAreaScheduler::operatingareas
78 std::vector<FMTOperatingAreaScheme>operatingareas;
79 // DocString: FMTOperatingAreaScheduler::adjacencyconstraints
81 std::map<std::pair<Core::FMTMask, Core::FMTMask>, std::vector<int>>adjacencyconstraints;
82 // DocString: FMTOperatingAreaScheduler::proportionofset
84 double proportionofset;
85 // DocString: FMTOperatingAreaScheduler::userandomness
87 bool userandomness;
88 // DocString: FMTOperatingAreaScheduler::useprimal
90 bool useprimal;
91 // DocString: FMTOperatingAreaScheduler::setOperatingAreasConstraints
99 void setOperatingAreasConstraints(const Graph::FMTGraph<Graph::FMTVertexProperties, Graph::FMTEdgeProperties>& maingraph,
100 const Models::FMTModel& model,
101 const Core::FMTOutputNode& target);
102 // DocString: FMTOperatingAreaScheduler::setAdjacencyConstraints
108 bool setAdjacencyConstraints();
109 // DocString: FMTOperatingAreaScheduler::setDraw
115 std::vector<std::vector<FMTOperatingAreaScheme>::const_iterator> setDraw();
116 // DocString: FMTOperatingAreaScheduler::draw
123 std::vector<std::vector<FMTOperatingAreaScheme>::const_iterator> draw(std::vector<std::vector<FMTOperatingAreaScheme>::const_iterator>& oparea);
124 // DocString: FMTOperatingAreaScheduler::setBounds
133 size_t setBounds(const std::vector<std::vector<FMTOperatingAreaScheme>::const_iterator>& tobound,const std::vector<int>& schemestoskip=std::vector<int>(), bool keeploose=true);
134 // DocString: FMTOperatingAreaScheduler::selectScheme
141 size_t selectScheme(std::vector<size_t>& potentialschemes, const int& schemetoskip) const;
142 // DocString: FMTOperatingAreaScheduler::getBounds
154 bool getBounds(const std::vector<FMTOperatingAreaScheme>::const_iterator& operatingareaiterator,
155 std::vector<int>& targeteditems,std::vector<double>& bounds, const bool& boundall, const size_t& schemeid=0,bool keeploose=true) const;
156 // DocString: FMTOperatingAreaScheduler::unboundAll
161 void unboundAll(bool atprimal = false);
162 // DocString: FMTOperatingAreaScheduler::unbound
168 void unbound(const std::vector<std::vector<FMTOperatingAreaScheme>::const_iterator>& tounbound,bool atprimal = false);
169 // DocString: FMTOperatingAreaScheduler::closePrimalBounds
173 void closePrimalBounds();
174 // DocString: FMTOperatingAreaScheduler::setAllInteger
178 void setAllInteger();
179 // DocString: FMTOperatingAreaScheduler::resolveModel
184 int resolveModel();
185 // DocString: FMTOperatingAreaScheduler::clearRowCache
189 void clearRowCache();
190 // DocString: FMTOperatingAreaScheduler::getSolutionIndexes
196 std::vector<int> getSolutionIndexes(const std::vector<std::vector<FMTOperatingAreaScheme>::const_iterator>& opareaits) const;
197 // DocString: FMTOperatingAreaScheduler::getThreadId
202 std::string getThreadId() const;
203 // DocString: FMTOperatingAreaScheduler::completeInitialSolution
208 bool completeInitialSolution();
209 // DocString: FMTOperatingAreaScheduler::gotRejectedNodes
214 bool gotRejectedNodes() const;
215 // DocString: FMTOperatingAreaScheduler::resetBaseGreedySolution
223 void resetBaseGreedySolution(const std::vector<std::vector<FMTOperatingAreaScheme>::const_iterator>& selected,
224 const std::vector<int>& oldschemeid,
225 const std::vector<int>& oldconstraints,
226 const std::vector<double>& oldbounds);
227 // DocString: FMTOperatingAreaScheduler::releaseGreedySolution
235 bool releaseGreedySolution(const std::vector<std::vector<FMTOperatingAreaScheme>::const_iterator>& selected,
236 std::vector<int>& oldconstraints,
237 std::vector<double>& oldbounds);
238 // DocString: FMTOperatingAreaScheduler::greedyMoveSolution
245 bool greedyMoveSolution(const std::vector<std::vector<FMTOperatingAreaScheme>::const_iterator>& selected,
246 const std::vector<int>& oldschemeid);
247 // DocString: FMTOperatingAreaScheduler::setForDualInitialSolve
251 void setForDualInitialSolve();
252 // DocString: FMTOperatingAreaScheduler::initialMoveSolution
258 int initialMoveSolution(const std::vector<std::vector<FMTOperatingAreaScheme>::const_iterator>& selected);
259 // DocString: FMTOperatingAreaScheduler::resetBaseInitialSolution
263 void resetBaseInitialSolution();
264 public:
265 // DocString: FMTOperatingAreaScheduler::generateInitialProportionOfSet
271 // DocString: FMTOperatingAreaScheduler::empty
276 bool empty() const;
277 // DocString: FMTOperatingAreaScheduler::initialSolve
282 bool initialSolve() final;
283 // DocString: FMTOperatingAreaScheduler::branchNBoundSolve
288 bool branchNBoundSolve() final;
289 // DocString: FMTOperatingAreaScheduler::greedyPass
296 bool greedyPass(const double& initsol, const unsigned int& iteration) final;
297 // DocString: FMTOperatingAreaScheduler::setAsRandom
301 void setAsRandom();
302 // DocString: FMTOperatingAreaScheduler::setAsPrimal
306 void setAsPrimal();
307 // DocString: FMTOperatingAreaScheduler::setProportionOfSet
312 void setProportionOfSet(const double& proportion);
313 // DocString: FMTOperatingAreaScheduler::getSolution
320 std::vector<Core::FMTTimeYieldHandler> getSolution( const std::string& yldname) const;
321 // DocString: FMTOperatingAreaScheduler::getLevelSolution
329 std::vector<Core::FMTOutput>getLevelSolution(const std::string& outputname,const std::string& aggregate,int outputid) const;
330 // 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)
344 FMTOperatingAreaScheduler(const std::vector<FMTOperatingAreaScheme>& loperatingareas,
345 const Graph::FMTGraph<Graph::FMTVertexProperties, Graph::FMTEdgeProperties>& maingraph,
346 const Models::FMTModel& model,
347 const Core::FMTOutputNode& target,
348 Models::FMTLpSolver& basesolve, size_t lseed = 0,
349 double proportionofset = 0.25, bool userandomness = false, bool copysolver = true);
350 // DocString: FMTOperatingAreaScheduler()
355 // DocString: FMTOperatingAreaScheduler(const FMToperatingareaheuristic&)
361 // DocString: FMTOperatingAreaScheduler(const FMToperatingareaheuristic&&)
367 // DocString: FMTOperatingAreaScheduler::operator=
374 // DocString: ~FMTOperatingAreaScheduler()
379 };
380}
381BOOST_CLASS_EXPORT_KEY(Heuristics::FMTOperatingAreaScheduler)
382#endif
383#endif
#define FMTEXPORT
Definition: FMTutility.h:125
Node of an output representing a set of developments in the graph, holding a source,...
Definition: FMTOutputNode.h:25
Definition: FMTGraphVertexToYield.h:20
Base class for solving LP and MIP problems using a heuristic, holding a random generator and its own ...
Definition: FMTLpHeuristic.h:34
Heuristic to solve the spatialization problem across a landscape for multiple operating areas.
Definition: FMTOperatingAreaScheduler.h:57
bool initialSolve() final
Solve the heuristic problem until an initial solution is found for each operating area.
bool empty() const
Return true if the operating areas are empty.
double generateInitialProportionOfSet() const
Compute a good proportion of set for the initialSolve, defaulting to 0.25 and decreasing linearly wit...
Operating area scheme giving information about its opening time, green up and return time.
Definition: FMTOperatingAreaScheme.h:42
Base class for the different models in FMT.
Definition: FMTModel.h:62
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
Definition: FMTAreaParser.h:35
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
STL namespace.