FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTOpAreaSchedulerTask.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#ifndef FMTopareaschedulertask_Hm_included
9#define FMTopareaschedulertask_Hm_included
10
11#include "FMTutility.h"
12#include "FMTTask.h"
13#include <vector>
14#include <memory>
15#include <string>
16#include <chrono>
17#include <boost/thread.hpp>
18#include "FMTOutput.h"
19
20namespace Core
21{
22 class FMTOutputNode;
23 class FMTConstraint;
24}
25
26
27namespace Models
28{
29 class FMTLpModel;
30}
31
32namespace Heuristics
33{
34 class FMTOperatingAreaScheme;
35 class FMTOperatingAreaScheduler;
36}
37
39namespace Parallel
40{
41 // DocString: FMTOpAreaSchedulerTask
47 {
48 // DocString: FMTOpAreaSchedulerTask::generalmutex
50 static boost::mutex generalmutex;
51 // DocString: FMTOpAreaSchedulerTask::bestscheduler;
53 std::shared_ptr<Heuristics::FMTOperatingAreaScheduler>bestscheduler;
54 // DocString: FMTOpAreaSchedulerTask::actualscheduler
56 std::unique_ptr<Heuristics::FMTOperatingAreaScheduler>actualscheduler;
57 // DocString: FMTOpAreaSchedulerTask::solutionlocation
59 static std::string solutionlocation;
60 // DocString: FMTOpAreaSchedulerTask::iterations
62 static unsigned int iterations;
63 // DocString: FMTOpAreaSchedulerTask::stoptime
65 static std::chrono::time_point<std::chrono::high_resolution_clock>stoptime;
66 // DocString: FMTOpAreaSchedulerTask::irelax_objective
68 static double relax_objective;
69 // DocString: FMTOpAreaSchedulerTask::outyldname
71 static std::string outyldname;
72 // DocString: FMTOpAreaSchedulerTask::basemodel
74 static std::unique_ptr<Models::FMTLpModel>basemodel;
75 // DocString: FMTOpAreaSchedulerTask::lastspawned
77 int lastspawned;
78 // DocString: FMTOpAreaSchedulerTask::solveInitialModel
84 double solveInitialModel(Models::FMTLpModel& model) const;
85 // DocString: FMTOpAreaSchedulerTask::setInitialScheduler
92 void setInitialScheduler(Models::FMTLpModel& model,
93 const std::vector<Heuristics::FMTOperatingAreaScheme>& opareas,const Core::FMTOutputNode& node);
94 // DocString: FMTOpAreaSchedulerTask::getStopPoint
100 std::chrono::time_point<std::chrono::high_resolution_clock>getStopPoint(const int& timegap) const;
101 // DocString: FMTOpAreaSchedulerTask::getConstraintsSolution
107 void getConstraintsSolution(std::vector<Core::FMTOutput>& outputs,std::vector<Core::FMTConstraint>& constraints) const;
108 // DocString: FMTOpAreaSchedulerTask::writeFinalModel
112 void writeFinalModel() const;
113 // DocString: FMTOpAreaSchedulerTask::writeSolution
117 void writeSolution() const;
118 // DocString: FMTOpAreaSchedulerTask::gotInitialSolution
123 bool gotInitialSolution() const;
124 // DocString: FMTOpAreaSchedulerTask::evaluateAndCopy
128 void evaluateAndCopy();
129 // DocString: FMTOpAreaSchedulerTask::goodToGo
134 bool goodToGo() const;
135 // DocString: FMTOpAreaSchedulerTask::getReturnTimeFromOutput
143 std::vector<Heuristics::FMTOperatingAreaScheme> getReturnTimeFromOutput(Models::FMTLpModel& model,
144 const std::vector<Heuristics::FMTOperatingAreaScheme>& opareas,
145 const Core::FMTOutput& output) const;
146 public:
147 // DocString: FMTOpAreaSchedulerTask::FMTOpAreaSchedulerTask()
152 // DocString: FMTOpAreaSchedulerTask::FMTOpAreaSchedulerTask(const FMTOpAreaSchedulerTask&)
158 // DocString: FMTOpAreaSchedulerTask::operator=(const FMTOpAreaSchedulerTask&)
165 // DocString: FMTOpAreaSchedulerTask::~FMTOpAreaSchedulerTask()
169 virtual ~FMTOpAreaSchedulerTask()=default;
170 // DocString: FMTOpAreaSchedulerTask::clone
175 std::unique_ptr<FMTTask>clone() const;
176 // DocString: FMTOpAreaSchedulerTask::FMTOpAreaSchedulerTask(...)
190 const std::vector<Heuristics::FMTOperatingAreaScheme>& opareas,
191 const Core::FMTOutputNode& node,
192 const std::string& outputlocation,
193 const std::string& outputyieldname,
194 const unsigned int& maxiterations,
195 const int& maxtime,
196 Core::FMTOutput returntime_output = Core::FMTOutput());
197 // DocString: FMTOpAreaSchedulerTask::split
203 virtual std::vector<std::unique_ptr<FMTTask>>split(const unsigned int& numberoftasks) const;
204 // DocString: FMTOpAreaSchedulerTask::spawn
209 virtual std::unique_ptr<FMTTask>spawn();
210 // DocString: FMTOpAreaSchedulerTask::work
214 virtual void work();
215 // DocString: FMTOpAreaSchedulerTask::finalize
219 virtual void finalize();
220 // DocString: FMTopareaschedulertask::passInLogger
225 void passInLogger(const std::unique_ptr<Logging::FMTLogger>& logger) override;
226 // DocString: FMTopareaschedulertask::SupportsMultiThreading()
231 bool SupportsMultiThreading() const override;
232
233 };
234
235}
236
237
238
239#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
Class letting the user formulate a constraint in the optimize section or collect data across the grap...
Definition: FMTOutput.h:37
Type III LP forest planning model, with the graph divided per period.
Definition: FMTLpModel.h:54
Task to find a suboptimal schedule for the operating areas of a FMTLpModel.
Definition: FMTOpAreaSchedulerTask.h:47
virtual ~FMTOpAreaSchedulerTask()=default
Destructor for FMTOpAreaSchedulerTask, taking care of writing the solution.
void passInLogger(const std::unique_ptr< Logging::FMTLogger > &logger) override
Pass in the logger.
virtual std::unique_ptr< FMTTask > spawn()
Spawn a minimal task from the master task.
bool SupportsMultiThreading() const override
Check if the task support multithreading.
std::unique_ptr< FMTTask > clone() const
Clone function for FMTOpAreaSchedulerTask.
FMTOpAreaSchedulerTask(const FMTOpAreaSchedulerTask &rhs)
Default copy constructor for FMTOpAreaSchedulerTask.
virtual void finalize()
Write the solution at finalization.
virtual void work()
Main function doing the operating area scheduling task.
FMTOpAreaSchedulerTask(const Models::FMTLpModel &model, const std::vector< Heuristics::FMTOperatingAreaScheme > &opareas, const Core::FMTOutputNode &node, const std::string &outputlocation, const std::string &outputyieldname, const unsigned int &maxiterations, const int &maxtime, Core::FMTOutput returntime_output=Core::FMTOutput())
Construct a FMTOpAreaSchedulerTask from a model, calling doPlanning on it and obtaining the operating...
virtual std::vector< std::unique_ptr< FMTTask > > split(const unsigned int &numberoftasks) const
Split the main task into multiple operating area scheduler tasks.
FMTOpAreaSchedulerTask()=default
Default constructor for FMTOpAreaSchedulerTask.
Task for parallel jobs.
Definition: FMTTask.h:27
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
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
Namespace for parallel tasking may include multithreading / multiprocessing.
Definition: FMTOpAreaSchedulerTask.h:40