FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
PYexportHeuristics.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 PYEXPORTHEURISTICS_H_INCLUDED
9#define PYEXPORTHEURISTICS_H_INCLUDED
10
11
12#include "FMTOperatingArea.h"
17//#include "FMTLpHeuristicMtHandler.h"
18#include "FMTLpSolver.h"
19#include "PYdefinitions.h"
20#include "boost/python.hpp"
21#include "FMTpythonpickle.h"
22
23namespace Python
24{
26{
27 namespace bp = boost::python;
28 bp::object HeuristicsModule(bp::handle<>(bp::borrowed(PyImport_AddModule("FMT.Heuristics"))));
29 bp::scope().attr("Heuristics") = HeuristicsModule;
30 bp::scope HeuristicsModule_scope = HeuristicsModule;
31 bp::scope().attr("__doc__") = ".. module:: Heuristics\n"
32 "\n"
33 " :platform: Unix, Windows\n"
34 " :synopsis: Module used for Heuristics.\n"
35 "\n";
36 #ifdef FMTWITHOSI
37
38 /*bp::class_<Heuristics::FMTLpHeuristicMtHandler>("FMTlpheuristicmthandler", "@DocString(FMTLpHeuristicMtHandler)")
39 //.def(bp::init<std::vector<Heuristics::FMTOperatingAreaScheduler>&>())
40 //.def(bp::init<std::vector<Heuristics::FMTOperatingAreaClusterer>&>())
41 .def(bp::init<boost::python::list&,const double&>())
42 .def("initialSolve", &Heuristics::FMTLpHeuristicMtHandler::initialSolve,
43 "@DocString(FMTLpHeuristicMtHandler::initialSolve)")
44 .def("greedySolve", &Heuristics::FMTLpHeuristicMtHandler::greedySolve,
45 "@DocString(FMTLpHeuristicMtHandler::greedySolve)");*/
46
47 bp::class_<Heuristics::FMTOperatingArea>("FMToperatingarea", "@DocString(FMTOperatingArea)")
48 .def(bp::init<const Core::FMTMask&, const double&>())
49 .def_pickle(FMT_pickle_suite<Heuristics::FMTOperatingArea>())
51 "@DocString(FMTOperatingArea::getneighbors)")
53 "@DocString(FMTOperatingArea::setneighbors)")
55 "@DocString(FMTOperatingArea::getmask)")
56 .def("getneihgborsperimeter", &Heuristics::FMTOperatingArea::getNeighborsPerimeter,
57 "@DocString(FMTOperatingArea::getneihgborsperimeter)");
58
59 definePyList<Heuristics::FMTOperatingArea>();
60
61 bp::class_<Heuristics::FMTOperatingAreaScheme,bp::bases<Heuristics::FMTOperatingArea>>("FMToperatingareascheme", "@DocString(FMTOperatingAreaScheme)")
62 .def(bp::init<const Heuristics::FMTOperatingArea&,const size_t&,const size_t&,
63 const size_t&, const size_t&, const size_t&, const size_t&, double>())
65 "@DocString(FMTOperatingAreaScheme::preSolve)");
66
67 definePyList<Heuristics::FMTOperatingAreaScheme>();
68
69 bp::class_<Heuristics::FMTOperatingAreaClusterBinary,bp::bases<Heuristics::FMTOperatingArea>>("FMToperatingareaclusterbinary", "@DocString(FMTOperatingAreaClusterBinary)");
70
71 definePyList<Heuristics::FMTOperatingAreaClusterBinary>();
72
73 bp::class_<Heuristics::FMTOperatingAreaCluster>("FMToperatingareacluster", "@DocString(FMTOperatingAreaCluster)")
74 .def(bp::init<const Heuristics::FMTOperatingAreaCluster&,const double&, const double&>())
76 "@DocString(FMTOperatingAreaCluster::getfilteredcluster)")
78 "@DocString(FMTOperatingAreaCluster::getallmasks)")
80 "@DocString(FMTOperatingAreaCluster::getcentroid)")
82 "@DocString(FMTOperatingAreaCluster::setminimalarea)")
84 "@DocString(FMTOperatingAreaCluster::setmaximalarea)");
85
86 definePyList<Heuristics::FMTOperatingAreaCluster>();
87
88 bp::class_<Heuristics::FMTLpHeuristic, bp::bases<Core::FMTObject, Models::FMTLpSolver>>("FMTlpheuristic", "@DocString(Heuristics::FMTLpHeuristic)");
89
90 bp::class_<Heuristics::FMTOperatingAreaClusterer, bp::bases<Heuristics::FMTLpHeuristic>>("Heuristics::FMToperatingareaclusterer", "@DocString(FMTOperatingAreaClusterer)")
92 "@DocString(FMTOperatingAreaClusterer::initialsolve)")
94 "@DocString(FMTOperatingAreaClusterer::branchnboundsolve)")
96 "@DocString(FMTOperatingAreaClusterer::setnumberofsimulationpass)")
98 "@DocString(FMTOperatingAreaClusterer::getsolution)");
99
100 definePyList<Heuristics::FMTOperatingAreaClusterer>();
101
102 bp::class_<Heuristics::FMTOperatingAreaScheduler, bp::bases<Heuristics::FMTLpHeuristic>>("Heuristics::FMToperatingareascheduler", "@DocString(FMTOperatingAreaScheduler)")
104 "@DocString(FMTOperatingAreaScheduler::initialsolve)")
106 "@DocString(FMTOperatingAreaScheduler::branchnboundsolve)")
108 "@DocString(FMToperatingareaheuristic::getsolution)")
110 "@DocString(FMTOperatingAreaScheduler::setasprimal)")
112 "@DocString(FMTOperatingAreaScheduler::setproportionofset)");
113
114 definePyList<Heuristics::FMTOperatingAreaScheduler>();
115 #endif
116 }
117}
118#endif
FMTOperatingAreaClusterBinary getCentroid() const
Return the centroid binary of the cluster.
Definition: FMTOperatingAreaCluster.h:80
void setMinimalArea(const double &newminimalarea)
Set the minimal area of the cluster.
FMTOperatingAreaCluster getFilteredCluster(const Core::FMTMask &filterMask) const
Return a cluster with the binaries not falling in a mask definition removed, which can reduce the num...
void setMaximalArea(const double &newmaximalarea)
Set the potential maximal area of the cluster.
std::vector< Core::FMTMask > getAllMasks() const
Return all the masks contained by the cluster, including the operating area centroid.
std::vector< FMTOperatingAreaCluster > getSolution() const
Return the clustering solution with cleaned operating clusters.
void setNumberOfSimulationPass(const int &pass)
Set the number of passes made by the heuristic to get a better objective or a feasible solution durin...
bool initialSolve() final
Solve the heuristic problem using the fire spread heuristic to get a good initial clustering solution...
bool branchNBoundSolve() final
Solve the problem using branch and bound on the primal formulation, using the heuristic solution as a...
void setAsPrimal()
Set the primal member to true.
bool branchNBoundSolve() final
Solve the problem using branch and bound on the primal formulation, using the heuristic solution as a...
bool initialSolve() final
Solve the heuristic problem until an initial solution is found for each operating area.
void setProportionOfSet(const double &proportion)
Set the allowed proportion of operating area status change before resolving the problem.
std::vector< Core::FMTTimeYieldHandler > getSolution(const std::string &yldname) const
Return the actual solution as a vector of time yield handlers, one per operating area.
FMTOperatingAreaScheme preSolve(const Core::FMTMask &selectedmask, const std::vector< Core::FMTTheme > &presolvedthemes) const
Return a presolved FMTOperatingAreaScheme using a mask and a subset of the original themes.
Operating area giving information about its mask, neighbors and neighbors perimeter.
Definition: FMTOperatingArea.h:29
double getNeighborsPerimeter() const
Return the percentage of perimeter the operating area needs to share with another operating area to b...
std::vector< Core::FMTMask > getNeighbors() const
Return a copy of the neighbors masks of the operating area.
void setNeighbors(const std::vector< Core::FMTMask > &lneighbors)
Set the neighbors masks of the operating area.
Core::FMTMask getMask() const
Return the mask of the operating area.
Definition: PYdefinitions.h:14
void exportHeuristics()
Definition: PYexportHeuristics.h:25