7#ifndef FMTSPATIALGRAPHS_H
8#define FMTSPATIALGRAPHS_H
16#include <unordered_map>
17#include <boost/unordered_map.hpp>
45 class FMTVirtualLineGraph;
118 size_t p_family)
const;
198 bool WithLock =
false)
const;
251 using family_iterator = std::vector<std::map<Graph::FMTLineGraph, FMTGraphInfo>>::iterator;
252 std::vector<std::map<Graph::FMTLineGraph, FMTGraphInfo>>m_AllGraphs;
253 size_t m_LastGraphId;
254 std::vector<std::vector<size_t>>m_Constraints;
255 boost::unordered_map<Core::FMTMask, size_t>m_GraphsMasks;
257 std::vector<size_t>m_ConstraintsId;
262 std::unordered_map<std::size_t, std::vector<std::weak_ptr<const FMTGraphValues>>> m_ValuesPool;
269 std::shared_ptr<const FMTGraphValues> _internValues(
const std::vector<double>& p_Values);
283 std::vector<size_t> _buildGraphs(
const Models::FMTModel& p_model,
double p_CellSize);
290 void _buildConstraintsValues(
291 family_iterator FirstGraphFamily,
292 family_iterator GraphFamilyEnd);
299 void _buildConstraintsValues(
311 size_t _fillValuesFromLastPeriod(
313 FMTSpatialGraphs::iterator p_Graph,
314 size_t p_ConstraintId,
315 std::vector<double>& p_constraintValues)
const;
336 size_t _getNonSpatialId(
size_t p_Constraint)
const;
345 void _fillConstraintResults(
size_t p_Constraint,
347 std::vector<double>& p_results,
362 size_t _getMaxGraphLength()
const;
368 size_t _getMinGraphLength()
const;
374 void _removeGraphsShorterThan(
size_t p_GraphSize);
389 std::vector<double> _getConstraintsValueFromSolution(
size_t p_ConstraintId,
398 std::vector<double> _getConstraintsValueFromTracker(
size_t p_ConstraintId,
406 std::vector<std::vector<double>> _getConstraintsValues(
const FMTSolutionTracker& p_solution)
const;
412 void _buildTacker(
const std::vector<size_t>& p_solution);
Core class holding, as a boost dynamic bitset, which theme attributes are part of a mask.
Definition: FMTMask.h:96
Base class of multiple FMT classes holding a shared exception handler pointer and logger.
Definition: FMTObject.h:49
Class letting the user formulate a constraint in the optimize section or collect data across the grap...
Definition: FMTOutput.h:37
Simple graph where each action generates a single new vertex (0-—0-—0-—0), used with FMTLayer to simu...
Definition: FMTLineGraph.h:27
Base class for the different models in FMT.
Definition: FMTModel.h:62
Information about a spatial line graph: its id and the interned constraint values shared across ident...
Definition: FMTGraphInfo.h:22
Track the constraint values of a spatial solution as line graphs are added to or removed from the sol...
Definition: FMTSolutionTracker.h:36
Container of the line graphs of a spatially explicit model, organized by constraint family,...
Definition: FMTSpatialGraphs.h:52
void swap(FMTSpatialGraphs &p_Other)
Swap this FMTSpatialGraphs with another one.
const Models::FMTModel & getModel() const
Return the model of the spatial graphs.
void deleteNonCompleteGraphs()
Delete the graphs that are not complete.
FMTSpatialGraphs()=default
Default constructor for FMTSpatialGraphs.
size_t getCategoryOf(int p_themeId, size_t p_family) const
Return the category of a theme for a constraint family.
double getConstraintsValue(size_t NonSpatialConstraintId, const FMTSolutionTracker &p_solution) const
Return the value of a non spatial constraint for a solution.
const_iterator setIterator(const Graph::FMTLineGraph &p_Graph, size_t p_family)
Add a graph to a constraint family and return its iterator.
void addToSolution(FMTSolutionTracker &p_solution, size_t p_family, const_iterator p_iterator)
Add a graph to a solution for a constraint family.
void removeToSolution(FMTSolutionTracker &p_solution, size_t p_family, const_iterator p_iterator)
Remove a graph from a solution for a constraint family.
const_iterator setNaturalGrowthIterator(size_t p_family)
Add the natural growth graph to a constraint family and return its iterator.
FMTSolutionTracker getBaseSolution() const
Return the base solution tracker.
const_iterator getIterator(const Graph::FMTLineGraph &p_Graph, size_t p_family) const
Return the iterator of a graph in a constraint family.
bool isNotNull(size_t p_family, const_iterator p_iterator) const
Return true if a graph iterator of a constraint family is not null.
FMTSpatialGraphs & operator=(const FMTSpatialGraphs &)=default
Default copy assignment operator for FMTSpatialGraphs.
std::vector< Core::FMTSchedule > getSchedules(const FMTSolutionTracker &p_Solution, bool WithLock=false) const
Return the schedules of a spatial solution.
size_t getNumberOfCategories(int p_themeId) const
Return the number of categories of a theme.
FMTVirtualLineGraph setVirtualGraph(const Graph::FMTLineGraph &p_LineGraph)
Set and return the virtual line graph of a line graph.
FMTVirtualLineGraph getVirtualGraph(const Graph::FMTLineGraph &p_LineGraph)
Return the virtual line graph of a line graph.
void enableSolutionTracker(FMTSolutionTracker &p_tracker) const
Enable the tracking of the constraint values on a solution tracker.
FMTSpatialGraphs(const FMTSpatialGraphs &p_rhs)=default
Default copy constructor for FMTSpatialGraphs.
const_iterator getBaseIterator(size_t p_family) const
Return the base graph iterator of a constraint family.
std::map< Graph::FMTLineGraph, FMTGraphInfo >::const_iterator const_iterator
Definition: FMTSpatialGraphs.h:55
void setModel(const Models::FMTModel &p_model)
Set the model of the spatial graphs.
FMTSpatialGraphs(const Models::FMTModel &p_model, double p_CellSize)
Construct a FMTSpatialGraphs from a model and a cell size, building all the line graphs.
const_iterator getLastPeriodIterator(size_t p_family, const_iterator p_iterator) const
Return the last period graph iterator of a graph in a constraint family.
std::map< std::string, double > getOutput(const FMTSolutionTracker &p_Solution, const Core::FMTOutput &p_output, int p_period, Core::FMToutputlevel level) const
Return the output value of a solution for a period.
Lightweight handle to a line graph stored in a FMTSpatialGraphs, forwarding output and solution opera...
Definition: FMTVirtualLineGraph.h:46
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
FMToutputlevel
Enumerator describing the level of detail of an output (standard, total only, development).
Definition: FMTutility.h:22
Definition: FMTAreaParser.h:35
Namespace containing all enumerator and classes used to construct or manipulate the different type of...
Definition: FMTAreaParser.h:54
Definition: FMTAreaParser.h:40