8#ifndef FMTeventCONTAINER_H
9#define FMTeventCONTAINER_H
12#include <boost/serialization/serialization.hpp>
13#include <boost/serialization/nvp.hpp>
14#include <boost/serialization/set.hpp>
15#include <unordered_set>
16#include <boost/unordered_set.hpp>
23class FMTBindingSpatialAction;
24class FMTSpatialGraphs;
34 typedef typename std::set<FMTEvent>::value_type
value_type;
35 typedef typename std::set<FMTEvent>::iterator
iterator;
163 const int& p_periodStart,
const std::vector<std::vector<bool>>& p_actionstarget);
170 std::pair<const_iterator,const_iterator>
getBounds(
const int& period)
const;
193 const std::vector<int>& actionids,
const std::vector<FMTBindingSpatialAction>& bindings,
size_t p_GraphFamily);
201 std::vector<const_iterator>
getEvents(
const int& period,
const int& action_id)
const;
211 std::vector<const_iterator>
getEvents(
const int& period,
const int& action_id,
222 std::vector<std::vector<const_iterator>>
getMultipleEvents(
const int& period,
const std::vector<int>& action_ids,
231 std::vector<const_iterator>
getEvents(
const int& period,
const std::vector<int>& actions_id)
const;
239 std::vector<const_iterator>
getEvents(
const int& period,
const std::vector<bool>& actions_used)
const;
249 std::vector<const_iterator>
getEvents(
const int& period,
const std::vector<bool>& actions_used,
284 size_t p_GraphFamily)
const;
312 std::vector<const_iterator>
getEvents(
const int& period,
const std::set<FMTCoordinate>& territory)
const;
324 const int& p_period,
const std::vector<int>& p_actionsid)
const;
337 const double& p_lowerdistancetoevent,
338 const double& p_upperdistancetoevent,
339 const int& p_period,
const std::vector<bool>& p_actionsused,
340 boost::unordered_set<FMTEventRelation>& p_relations)
const;
353 int p_period,
size_t p_lowerBound,
size_t p_upperBound,
bool p_testLower)
const;
368 int p_themeId,
int p_FirstPeriod,
369 int p_LastPeriod,
int p_bound)
const;
384 int p_themeId,
int p_FirstPeriod,
385 int p_LastPeriod,
int p_bound)
const;
400 int p_themeId,
int p_FirstPeriod,
401 int p_LastPeriod,
int p_bound)
const;
415 int p_themeId,
int p_FirstPeriod,
416 int p_LastPeriod,
int p_bound)
const;
425 std::vector<FMTEventContainer::const_iterator>
getEventsOf(
int p_RuleId,
426 int p_MinimalPeriod,
int p_MaximalPeriod)
const;
434 double evaluateUpperBound(
int p_UpperBound)
const;
435 std::vector<FMTEventContainer::const_iterator> getEvents()
const;
444 bool _isNull()
const;
445 double _getSize()
const;
447 friend class boost::serialization::access;
455 template<
class Archive>
456 void serialize(Archive& ar,
const unsigned int version)
458 ar& boost::serialization::make_nvp(
"FMTobject", boost::serialization::base_object<FMTObject>(*
this));
459 ar& BOOST_SERIALIZATION_NVP(m_events);
462 std::set<FMTEvent> m_events;
465 const_iterator _upperBound(
const int& period)
const;
467 const_iterator _upperBound(
const int& period,
const FMTCoordinate& maxxycoord)
const;
470 const_iterator _lowerBound(
const int& period)
const;
473 const_iterator _lowerBound(
const int& period,
const FMTCoordinate& minxycoord)
const;
477 void erase(
const FMTCoordinate& coord,
const std::vector<const_iterator>& iterators);
488 void pushAction(
const std::vector<FMTEventContainer::const_iterator>& iterators,
489 const FMTCoordinate& coord,
const int& period,
const int& actionid,
490 size_t neighborsize,
size_t p_GraphFamily);
499 std::vector<FMTEventContainer::const_iterator> getAroundEvents(
const std::vector<FMTEventContainer::const_iterator>& iterators,
500 const FMTCoordinate& coord,
const size_t& neighborsize)
const;
508 void nthElements(std::vector<FMTEventContainer::const_iterator>& iterators,
const FMTCoordinate& coord,
const size_t& nelement)
const;
511 std::vector<BoundingBox> _getBoundingBoxes(
const std::vector<bool>& p_actions,
513 int p_FirstPeriod,
int p_LastPeriod)
const;
515 std::vector<BoundingBox> _getBoundingBoxes(
int p_RuleId,
517 int p_FirstPeriod,
int p_LastPeriod)
const;
519 class FMTEventIteratorSorter
#define FMTEXPORT
Definition: FMTutility.h:125
Base class of multiple FMT classes holding a shared exception handler pointer and logger.
Definition: FMTObject.h:49
Spatial binding of an action, holding the green up, adjacency, size and neighbors constraints used to...
Definition: FMTBindingSpatialAction.h:23
Spatially referenced coordinate holding an x and y position on a raster grid.
Definition: FMTCoordinate.h:29
Container of FMTEvent handling event comparison and distance calculation efficiently,...
Definition: FMTEventContainer.h:32
void addAction(const FMTCoordinate &coord, const int &period, const int &actionid, const FMTBindingSpatialAction &binding, size_t p_GraphFamily)
Add an action at a coordinate, adding to an existing event if possible or aggregating events based on...
double evaluateDistance(const FMTEvent &p_event, const double &p_lowerdistancetoevent, const double &p_upperdistancetoevent, const int &p_period, const std::vector< bool > &p_actionsused, boost::unordered_set< FMTEventRelation > &p_relations) const
Add up the distances of the events that are within (or not within) a distance range for a period.
std::pair< const_iterator, const_iterator > getBounds(const int &period) const
Return a pair of iterators pointing to the first and the last elements of a period.
std::vector< FMTEventContainer::const_iterator > getEventsOf(int p_RuleId, int p_MinimalPeriod, int p_MaximalPeriod) const
Return the events of a rule for a period range.
int lastPeriod() const
Return the period of the last event in the container.
FMTEventContainer()=default
Default constructor for FMTEventContainer.
const_iterator begin() const
Return a const iterator to the first event.
const_iterator find(const FMTEvent &event) const
Return a const iterator to an event.
std::vector< const_iterator > getEvents(const int &period, const std::set< FMTCoordinate > &territory) const
Return the events at a period for multiple coordinates.
std::vector< FMTEventContainer::const_iterator > getDispersionConflicts(int p_RuleId, const FMTSpatialGraphs &p_Graphs, int p_themeId, int p_FirstPeriod, int p_LastPeriod, int p_bound) const
Return the events in dispersion conflict for a rule, a theme and a period range.
const_iterator find(const int &period, const FMTCoordinate &coord) const
Return a const iterator to the first event found with a coordinate at a period.
FMTEventContainer getEventsToAdd(const FMTCoordinate &coord, const int &period, const int &actionid, const FMTBindingSpatialAction &binding, FMTEventContainer &newevents, size_t p_GraphFamily) const
Add an action to a coordinate and return the modified events whose infeasibility needs to be recalcul...
std::vector< const_iterator > getEvents(const int &period, const std::vector< int > &actions_id) const
Return the events at a period for multiple action ids.
std::vector< FMTEventContainer::const_iterator > getDispersionConflicts(const std::vector< bool > &p_actions, const FMTSpatialGraphs &p_Graphs, int p_themeId, int p_FirstPeriod, int p_LastPeriod, int p_bound) const
Return the events in dispersion conflict for a theme and a period range.
int firstPeriod() const
Return the period of the first event in the container.
std::set< FMTEvent >::const_reverse_iterator const_reverse_iterator
Definition: FMTEventContainer.h:37
std::set< FMTEvent >::iterator iterator
Definition: FMTEventContainer.h:35
void eraseCoordinate(const FMTCoordinate &p_coord, const int &p_periodStart, const std::vector< std::vector< bool > > &p_actionstarget)
Erase all the coordinates corresponding to a coordinate in the events from a period.
std::vector< const_iterator > getEvents(const int &period, const FMTCoordinate &coord) const
Return the events at a period for a coordinate.
FMTEventContainer getContainer(std::vector< FMTCoordinate > coordinates, const int &minperiod, const int &maxperiod, const size_t &buffer) const
Return a subset of the container on the coordinates of interest.
std::vector< const_iterator > getEvents(const int &period, const int &action_id, const FMTCoordinate &minimalcoordinate, const FMTCoordinate &maximalcoordinate) const
Return the events at a period for an action between a minimal and a maximal coordinate.
const_iterator end() const
Return a const iterator past the last event.
void erase(const FMTEvent &event)
Erase an event from the container.
void swap(FMTEventContainer &rhs)
Swap the events of this container with another one.
double getDispersion(const std::vector< bool > &p_actions, const FMTSpatialGraphs &p_Graphs, int p_themeId, int p_FirstPeriod, int p_LastPeriod, int p_bound) const
Evaluate the dispersion infeasibility of the events for a theme and a period range.
std::vector< std::vector< const_iterator > > getMultipleEvents(const int &period, const std::vector< int > &action_ids, const FMTCoordinate &minimalcoordinate, const FMTCoordinate &maximalcoordinate) const
Return the events at a period for multiple actions between a minimal and a maximal coordinate.
bool empty() const
Test whether the container is empty.
void addActions(const FMTCoordinate &coord, const int &period, const std::vector< int > &actionids, const std::vector< FMTBindingSpatialAction > &bindings, size_t p_GraphFamily)
Add actions at a coordinate, adding to an existing event if possible or aggregating events based on t...
std::set< FMTEvent >::value_type value_type
Definition: FMTEventContainer.h:34
std::vector< const_iterator > getEvents(const int &period, const std::vector< bool > &actions_used) const
Return the events at a period for the used actions.
double getDispersion(int p_RuleId, const FMTSpatialGraphs &p_Graphs, int p_themeId, int p_FirstPeriod, int p_LastPeriod, int p_bound) const
Evaluate the dispersion infeasibility of the events for a rule, a theme and a period range.
FMTEventContainer & operator=(const FMTEventContainer &rhs)=default
Copy assignment operator for FMTEventContainer.
size_t size() const
Return the number of events in the container.
double minimalDistance(const FMTEvent &p_event, const unsigned int &p_distancel, const int &p_period, const std::vector< int > &p_actionsid) const
Return the minimal distance between an event and the other events for a period, or the distance plus ...
void merge(const FMTEventContainer &levents)
Merge another FMTEventContainer into this one.
std::vector< const_iterator > getEvents(const int &period, const std::vector< bool > &actions_used, const FMTCoordinate &minimalcoordinate, const FMTCoordinate &maximalcoordinate) const
Return the events at a period for the used actions between a minimal and a maximal coordinate.
FMTEventContainer getEventsToErase(const int &fromperiod, const std::vector< std::vector< bool > > &actionstarget, const FMTCoordinate &coord, const size_t &buffer, FMTEventContainer &newevents) const
Return the events to erase when removing a coordinate, starting from a period based on a buffer aroun...
double evaluateSize(const std::vector< bool > &p_actions, int p_period, size_t p_lowerBound, size_t p_upperBound, bool p_testLower) const
Evaluate the size infeasibility of the events for a period against a size range.
void insert(const FMTEvent &event)
Insert an event in the container.
std::vector< const_iterator > getEvents(const int &period, const int &action_id) const
Return the events at a period for an action.
const_iterator erase(const const_iterator event)
Erase an event from the container and return the next iterator.
bool operator==(const FMTEventContainer &rhs) const
Comparison operator for FMTEventContainer.
FMTEventContainer(const FMTEventContainer &rhs)=default
Copy constructor for FMTEventContainer.
void clear()
Clear the content of the container.
~FMTEventContainer()=default
Default destructor for FMTEventContainer.
std::set< FMTEvent >::const_iterator const_iterator
Definition: FMTEventContainer.h:36
FMTEventContainer addUpdate(const FMTEventContainer &newevents, const FMTEventContainer &eventstoremove)
Update the container by adding the new events and removing the events to remove, used to compute the ...
Base class for a spatial event (FMTsaevent or FMTsesevent): a set of FMTCoordinate corresponding to t...
Definition: FMTEvent.h:28
Container of the line graphs of a spatially explicit model, organized by constraint family,...
Definition: FMTSpatialGraphs.h:52
Definition: FMTAreaParser.h:40