RepastHPC  2.3.1
Observer.h
1 /*
2  * Repast for High Performance Computing (Repast HPC)
3  *
4  * Copyright (c) 2010 Argonne National Laboratory
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with
8  * or without modification, are permitted provided that the following
9  * conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * Neither the name of the Argonne National Laboratory nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  *
35  * Observer.h
36  *
37  * Created on: Jul 15, 2010
38  * Author: nick
39  */
40 
41 #ifndef OBSERVER_H_
42 #define OBSERVER_H_
43 
44 #include <typeinfo>
45 
46 #include "repast_hpc/SharedContext.h"
47 #include "repast_hpc/Properties.h"
48 #include "repast_hpc/Random.h"
49 #include "repast_hpc/DataSet.h"
50 #include "repast_hpc/RepastProcess.h"
51 
52 #include "AgentSet.h"
53 #include "RelogoAgent.h"
54 #include "RelogoDiscreteSpaceAdder.h"
55 #include "RelogoContinuousSpaceAdder.h"
56 #include "RelogoLink.h"
57 #include "WorldDefinition.h"
58 #include "creators.h"
59 #include "relogo.h"
60 #include "agent_set_functions.h"
61 
75 namespace repast {
76 
77 namespace relogo {
78 
79 class Patch;
80 class WorldCreator;
81 class DataSet;
82 
86 struct TypeInfoCmp {
87  bool operator()(const std::type_info* one, const std::type_info* two) const {
88  return one->before(*two) != 0;
89  }
90 };
91 
92 class Turtle;
93 
98 template<typename TargetType>
99 struct Caster: public std::unary_function<boost::shared_ptr<RelogoAgent>, TargetType*> {
100 
101  TargetType* operator()(boost::shared_ptr<RelogoAgent> ptr) const {
102  return static_cast<TargetType*> (ptr.get());
103  }
104 };
105 
106 
110 class Observer {
111 
112 public:
113  virtual ~Observer();
114 
121  void addDataSet(repast::DataSet* dataSet);
122 
126  void dataSetClose();
127 
132  virtual void go() = 0;
133 
139  virtual void setup(Properties& props){ }
140 
146  void _setup(Properties& props);
147 
148 
154  int minPxcor() const;
155 
161  int minPycor() const;
162 
168  int maxPxcor() const;
169 
175  int maxPycor() const;
176 
182  int randomPxcor();
183 
189  int randomPycor();
190 
196  double randomXcor();
197 
203  double randomYcor();
204 
205  /*
206  * Calculates the grid point from the space point. Under some circumstances
207  * the space point has to be changed in order to stay in sync w/r to process location
208  * with the grid point. If that has to be done, then return true.
209  *
210  * NON API method
211  */
212  bool spacePtToGridPt(std::vector<double>& spacePt, std::vector<int>& gridPt);
213 
221  template<typename AgentType>
222  AgentType* hatch(RelogoAgent* parent);
223 
238  template<typename AgentType, typename FactoryFunctor>
239  AgentType* hatch(RelogoAgent* parent, FactoryFunctor agentCreator);
240 
250  template<typename AgentType>
251  AgentType* who(const AgentId& id);
252 
264  template<typename AgentType>
265  int create(size_t count);
266 
281  template<typename AgentType, typename FactoryFunctor>
282  int create(size_t count, FactoryFunctor agentCreator);
283 
287  void removeAgent(const AgentId& id);
288 
296  template<typename AgentType>
298 
304 
312 
322  template<typename AgentType>
323  void get(AgentSet<AgentType>& agentSet);
324 
332  template<typename AgentType>
333  AgentType* get(const AgentId& id);
334 
343  template<typename AgentType>
344  AgentSet<AgentType> turtlesAt(int x, int y);
345 
356  template<typename AgentType>
357  void turtlesAt(int x, int y, AgentSet<AgentType>& set);
358 
364  int rank() const {
365  return _rank;
366  }
367 
373  const RelogoGridType* grid();
374 
380  const RelogoSpaceType* space();
381 
389  void createLink(RelogoAgent* source, RelogoAgent* target, const std::string& networkName);
390 
402  template<typename LinkCreator>
403  void createLink(RelogoAgent* source, RelogoAgent* target, const std::string& networkName, LinkCreator& creator);
404 
412  boost::shared_ptr<RelogoLink> link(RelogoAgent* source, RelogoAgent* target, const std::string& networkName);
413 
424  template<typename AgentType>
425  void predecessors(RelogoAgent* agent, const std::string& networkName, AgentSet<AgentType>& out);
426 
437  template<typename AgentType>
438  void successors(RelogoAgent* agent, const std::string& networkName, AgentSet<AgentType>& out);
439 
451  template<typename PatchType>
452  PatchType* patchAt(int x, int y);
453 
463  Patch* patchAt(int x, int y);
464 
476  Patch* patchAt(Point<double> location, double dx, double dy);
477 
489  Patch* patchAtOffset(Point<double> location, double heading, double distance);
490 
498  template<typename PatchType>
500 
508  template<typename PatchType>
509  void patches(AgentSet<PatchType>& set);
510 
520  template<typename TurtleType>
522 
534  template<typename TurtleType>
535  void turtlesOn(const RelogoAgent* agent, AgentSet<TurtleType>& out);
536 
547  template<typename AgentType>
548  void
549  inRadius(const Point<double>& center, AgentSet<RelogoAgent>& inSet, double radius, AgentSet<AgentType>& outSet);
550 
568  template<typename TurtleContent, typename Provider, typename Updater, typename AgentCreator>
569  void synchronizeTurtleStatus(Provider& provider, Updater& updater, AgentCreator& creator, RepastProcess::EXCHANGE_PATTERN exchangePattern = RepastProcess::POLL);
570 
587  template<typename TurtleContent, typename Provider, typename Updater>
588  void synchronizeTurtleStates(Provider& provider, Updater& updater);
589 
590  template<typename TurtleContent, typename Provider, typename Updater, typename AgentCreator>
591  void synchronize(Provider& provider, Updater& updater, AgentCreator& creator, RepastProcess::EXCHANGE_PATTERN exchangePattern = RepastProcess::POLL
592 #ifdef SHARE_AGENTS_BY_SET
593  , bool declareNoAgentsKeptOnAnyProcess = false
594 #endif
595  );
596 
597 
598 protected:
600 
601  Observer();
602  Properties _props;
603  int _rank;
604  GridDimensions localBounds;
606  std::vector<repast::DataSet*> dataSets;
607 
608  NetworkType* findNetwork(const std::string& name);
609 private:
610  friend class WorldCreator;
611  const static int NO_TYPE_ID;
612 
613  // first is the typeid, second is the next good id of that type.
614  typedef std::map<const std::type_info*, std::pair<int, int>, TypeInfoCmp> TypeMap;
615  typedef boost::filter_iterator<IsNotType<RelogoAgent> , Context<RelogoAgent>::const_iterator>
616  const_not_type_iterator;
617  typedef TypeMap::iterator TypeMapIterator;
618 
619 
620 
621  TypeMap typeMap;
622  static int nextTypeId;
623 
624  template<typename Agent>
625  int getTypeId();
626 
627  void initBounds(GridDimensions& bounds);
628 
629  IntUniformGenerator* rndXP, *rndYP;
630  DoubleUniformGenerator* rndX, *rndY;
631 
632 };
633 
634 template<typename AgentType>
635 AgentType* Observer::hatch(RelogoAgent* parent) {
636  return hatch<AgentType> (parent, DefaultAgentCreator<AgentType> ());
637 }
638 
639 template<typename AgentType, typename FactoryFunctor>
640 AgentType* Observer::hatch(RelogoAgent* parent, FactoryFunctor agentCreator) {
641  const std::type_info* info = &(typeid(AgentType));
642  int agentTypeId = 0;
643  int id = 0;
644  TypeMapIterator iter = typeMap.find(info);
645  if (iter == typeMap.end()) {
646  agentTypeId = nextTypeId;
647  nextTypeId++;
648  } else {
649  agentTypeId = iter->second.first;
650  id = iter->second.second;
651  }
652 
653  AgentType* agent = agentCreator(repast::AgentId(id, _rank, agentTypeId), this);
654  agent->hatchCopy(parent);
655  context.addAgent(agent);
656  agent->setxy(parent->xCor(), parent->yCor());
657  typeMap[info] = std::make_pair(agentTypeId, id + 1);
658  return agent;
659 }
660 
661 template<typename AgentType>
662 int Observer::create(size_t count) {
663  return create<AgentType> (count, DefaultAgentCreator<AgentType> ());
664 }
665 
666 template<typename AgentType>
667 int Observer::getTypeId() {
668  const std::type_info* info = &(typeid(AgentType));
669  TypeMapIterator iter = typeMap.find(info);
670  if (iter == typeMap.end())
671  return NO_TYPE_ID;
672  else
673  return iter->second.first;
674 }
675 
676 template<typename AgentType, typename FactoryFunctor>
677 int Observer::create(size_t count, FactoryFunctor agentCreator) {
678  const std::type_info* info = &(typeid(AgentType));
679  int agentTypeId = 0;
680  int id = 0;
681  TypeMapIterator iter = typeMap.find(info);
682  if (iter == typeMap.end()) {
683  agentTypeId = nextTypeId;
684  nextTypeId++;
685  } else {
686  agentTypeId = iter->second.first;
687  id = iter->second.second;
688  }
689 
691  for (size_t i = 0; i < count; i++) {
692 // AgentType* agent = agentCreator(repast::AgentId(id + i, _rank, agentTypeId), this);
693  repast::AgentId agentid(id+i, _rank, agentTypeId);
694  agentid.currentRank(_rank);
695  AgentType* agent = agentCreator(agentid, this);
696  agent->heading((float) gen.next());
697  context.addAgent(agent);
698  }
699  typeMap[info] = std::make_pair(agentTypeId, id + count);
700  return agentTypeId;
701 }
702 
703 template<typename AgentType>
704 AgentType* Observer::get(const AgentId& id) {
705  return static_cast<AgentType*> (context.getAgent(id));
706 }
707 
708 template<typename Agent>
710  AgentSet<Agent> agentSet;
711  get(agentSet);
712  return agentSet;
713 }
714 
715 template<typename AgentType>
717  int typeId = getTypeId<AgentType> ();
718  if (typeId != NO_TYPE_ID) {
719  for (SharedContext<RelogoAgent>::const_local_iterator iter = context.localBegin(); iter != context.localEnd(); ++iter) {
720  AgentId id = iter->get()->getId();
721  if (id.agentType() == typeId) {
722  agentSet.add(static_cast<AgentType*> (iter->get()));
723  }
724  }
725  }
726 }
727 
728 template<typename AgentType>
731  turtlesAt(x, y, set);
732  return set;
733 }
734 
735 template<typename AgentType>
736 void Observer::turtlesAt(int x, int y, AgentSet<AgentType>& set) {
737  int typeId = getTypeId<AgentType> ();
738  if (typeId != NO_TYPE_ID) {
739  std::vector<RelogoAgent*> out;
740  grid()->getObjectsAt(Point<int> (x, y), out);
741  filterVecToSet(out, set, typeId);
742  }
743 }
744 
745 template<typename LinkCreator>
746 void Observer::createLink(RelogoAgent* source, RelogoAgent* target, const std::string& name, LinkCreator& creator) {
747  NetworkType* net = findNetwork(name);
748  boost::shared_ptr<RelogoLink> link(creator(source, target));
749  net->addEdge(link);
750 }
751 
752 
753 template<typename AgentType>
754 void Observer::predecessors(RelogoAgent* agent, const std::string& networkName, AgentSet<AgentType>& out) {
755  int typeId = getTypeId<AgentType> ();
756  if (typeId != NO_TYPE_ID) {
757  NetworkType* net = findNetwork(networkName);
758  std::vector<RelogoAgent*> agents;
759  net->predecessors(agent, agents);
760  filterVecToSet(agents, out, typeId);
761  }
762 
763 }
764 
765 template<typename AgentType>
766 void Observer::successors(RelogoAgent* agent, const std::string& networkName, AgentSet<AgentType>& out) {
767  int typeId = getTypeId<AgentType> ();
768  if (typeId != NO_TYPE_ID) {
769  NetworkType* net = findNetwork(networkName);
770  std::vector<RelogoAgent*> agents;
771  net->successors(agent, agents);
772  filterVecToSet(agents, out, typeId);
773  }
774 }
775 
776 template<typename PatchType>
779  patches(set);
780  return set;
781 }
782 
783 template<typename PatchType>
785  boost::transform_iterator<Caster<PatchType> , Context<RelogoAgent>::const_bytype_iterator> begin(
786  context.byTypeBegin(PATCH_TYPE_ID));
787  boost::transform_iterator<Caster<PatchType> , Context<RelogoAgent>::const_bytype_iterator> end(context.byTypeEnd(
788  PATCH_TYPE_ID));
789  set.addAll(begin, end);
790 }
791 
792 template<typename PatchType>
793 PatchType* Observer::patchAt(int x, int y) {
794  return static_cast<PatchType*> (patchAt(x, y));
795 }
796 
797 template<typename TurtleType>
799  int typeId = getTypeId<TurtleType> ();
800  if (typeId != NO_TYPE_ID) {
801  std::vector<RelogoAgent*> in;
802  grid()->getObjectsAt(Point<int> (agent->pxCor(), agent->pyCor()), in);
803  filterVecToSet(in, out, typeId);
804  }
805 }
806 
807 template<typename TurtleType>
809  int typeId = getTypeId<TurtleType> ();
810  if (typeId != NO_TYPE_ID) {
811  std::vector<RelogoAgent*> in;
812  for (AgentSet<RelogoAgent>::const_as_iterator iter = agentSet.begin(); iter != agentSet.end(); ++iter) {
813  RelogoAgent* agent = *iter;
814  grid()->getObjectsAt(Point<int> (agent->pxCor(), agent->pyCor()), in);
815  }
816  filterVecToSetNoDuplicates(in, out, typeId);
817  }
818 }
819 
820 template<typename AgentType>
821 void Observer::inRadius(const Point<double>& center, AgentSet<RelogoAgent>& inSet, double radius,
822  AgentSet<AgentType>& outSet) {
823  int typeId = getTypeId<AgentType> ();
824  if (typeId != NO_TYPE_ID) {
825  double radiusSq = radius * radius;
826  std::vector<RelogoAgent*> vec;
827  const RelogoSpaceType* spc = space();
828  for (size_t i = 0; i < inSet.size(); i++) {
829  RelogoAgent* agent = inSet[i];
830  if (spc->getDistanceSq(center, agent->location()) <= radiusSq && agent->getId().agentType() == typeId) {
831  outSet.add(static_cast<AgentType*> (const_cast<RelogoAgent*> (agent)));
832  }
833  }
834  }
835 }
836 
837 template<typename TurtleContent, typename Provider, typename Updater>
838 void Observer::synchronizeTurtleStates(Provider& provider, Updater& updater) {
839  repast::RepastProcess::instance()->synchronizeAgentStates<TurtleContent>(provider, updater);
840 }
841 
842 template<typename TurtleContent, typename Provider, typename Updater, typename AgentCreator>
843 void Observer::synchronizeTurtleStatus(Provider& provider, Updater& updater, AgentCreator& creator, RepastProcess::EXCHANGE_PATTERN exchangePattern) {
844  repast::RepastProcess::instance()->synchronizeAgentStatus<RelogoAgent, TurtleContent, Provider, Updater, AgentCreator>(context, provider, updater, creator, exchangePattern);
845 }
846 
847 template<typename TurtleContent, typename Provider, typename Updater, typename AgentCreator>
848 void Observer::synchronize(Provider& provider, Updater& updater, AgentCreator& creator, RepastProcess::EXCHANGE_PATTERN exchangePattern
849 #ifdef SHARE_AGENTS_BY_SET
850  , bool declareNoAgentsKeptOnAnyProcess
851 #endif
852  ){
853 
854  context.getProjection(SPACE_NAME)->balance();
855 
856  synchronizeTurtleStatus<TurtleContent>(provider, updater, creator, exchangePattern);
857 
858 #ifdef SHARE_AGENTS_BY_SET
859  repast::RepastProcess::instance()->synchronizeProjectionInfo<RelogoAgent, TurtleContent, Provider, AgentCreator, Updater>(context, provider, updater, creator, exchangePattern, declareNoAgentsKeptOnAnyProcess);
860 #else
861  repast::RepastProcess::instance()->synchronizeProjectionInfo<RelogoAgent, TurtleContent, Provider, AgentCreator, Updater>(context, provider, updater, creator, exchangePattern);
862 #endif
863 
864 
865 // synchronizeTurtleStates<TurtleContent>(provider, updater);
866 }
867 
868 
869 template<typename AgentType>
870 AgentType* Observer::who(const AgentId& id) {
871  RelogoAgent* agent = context.getAgent(id);
872  if (agent != 0) {
873  return static_cast<AgentType*> (agent);
874  }
875  return 0;
876 }
877 
878 }
879 }
880 #endif /* OBSERVER_H_ */
repast::relogo::RelogoAgent::yCor
double yCor() const
Gets the y coordinate of the agent's location.
Definition: RelogoAgent.cpp:53
repast::Random::createUniDoubleGenerator
DoubleUniformGenerator createUniDoubleGenerator(double from, double to)
Creates a generator that produces doubles in the range [from, to).
Definition: Random.cpp:90
repast::relogo::Observer::maxPycor
int maxPycor() const
Gets the maximum y coordinate of the patches managed by this Observer.
Definition: Observer.cpp:108
repast::relogo::Observer::link
boost::shared_ptr< RelogoLink > link(RelogoAgent *source, RelogoAgent *target, const std::string &networkName)
Gets the link, if any, between the source and target agents in the named network.
Definition: Observer.cpp:271
repast::Graph::successors
virtual void successors(V *vertex, std::vector< V * > &out)
Gets the sucessors of the specified vertex and puts them in out.
Definition: Graph.h:384
repast::Grid::getDistanceSq
virtual double getDistanceSq(const Point< GPType > &pt1, const Point< GPType > &pt2) const =0
Gets the square of the distance between the two grid points.
repast::relogo::Observer::_setup
void _setup(Properties &props)
Performs internal Relogo initialization.
Definition: Observer.cpp:127
repast::relogo::Observer::successors
void successors(RelogoAgent *agent, const std::string &networkName, AgentSet< AgentType > &out)
Gets the network successors of the specified agent in the specified network and puts the result into ...
Definition: Observer.h:766
repast::relogo::Observer::randomYcor
double randomYcor()
Gets a random y coodinate of the turtles managed by this Observer.
Definition: Observer.cpp:123
repast::relogo::Observer::inRadius
void inRadius(const Point< double > &center, AgentSet< RelogoAgent > &inSet, double radius, AgentSet< AgentType > &outSet)
Puts all the agents in the inSet that are of the specified type and within the specified radius from ...
Definition: Observer.h:821
repast::relogo::Observer::createLink
void createLink(RelogoAgent *source, RelogoAgent *target, const std::string &networkName)
Creates a link between the source and target agents in the named network.
Definition: Observer.cpp:261
repast::relogo::Observer::hatch
AgentType * hatch(RelogoAgent *parent)
Hatchs an agent of the specified type.
Definition: Observer.h:635
repast::relogo::RelogoAgent
Base agent for Relogo.
Definition: RelogoAgent.h:60
repast::Random::instance
static Random * instance()
Gets the singleton instance of this Random.
Definition: Random.cpp:80
repast::relogo::Observer::space
const RelogoSpaceType * space()
Gets the space managed by this Observer.
Definition: Observer.cpp:158
repast::relogo::Observer::predecessors
void predecessors(RelogoAgent *agent, const std::string &networkName, AgentSet< AgentType > &out)
Gets the network predecessors of the specified agent in the specified network and puts the result int...
Definition: Observer.h:754
repast::DefaultNumberGenerator
Adapts the templated boost::variate_generator to the NumberGenerator interface.
Definition: Random.h:97
repast::AgentId
Agent identity information.
Definition: AgentId.h:60
repast::relogo::Observer::dataSetClose
void dataSetClose()
Non API method for closing all the datasets at the end of a sim runs.
Definition: Observer.cpp:81
repast::relogo::Observer::minPycor
int minPycor() const
Gets the minimum y coordinate of the patches managed by this Observer.
Definition: Observer.cpp:101
repast::Graph::predecessors
virtual void predecessors(V *vertex, std::vector< V * > &out)
Gets the predecessors of the specified vertex and puts them in out.
Definition: Graph.h:390
repast::relogo::TypeInfoCmp
Compare two elements of type std::type_info using 'before'.
Definition: Observer.h:86
repast::SharedNetwork::addEdge
void addEdge(boost::shared_ptr< E > edge)
Add an edge to this SharedNetwork.
Definition: SharedNetwork.h:231
repast::relogo::AgentSet
Specialized indexable collection class for agents.
Definition: AgentSet.h:82
repast::relogo::Observer::who
AgentType * who(const AgentId &id)
Gets the agent with the specified id.
Definition: Observer.h:870
repast::relogo::Observer::rank
int rank() const
Gets the process rank of this Observer.
Definition: Observer.h:364
repast::AgentId::currentRank
int currentRank() const
Gets the current process rank of this AgentId.
Definition: AgentId.h:135
repast::relogo::RelogoAgent::getId
virtual repast::AgentId & getId()
Gets the id of this RelogoAgent.
Definition: RelogoAgent.h:93
repast::relogo::Observer::randomPxcor
int randomPxcor()
Gets a random x coodinate of the patches managed by this Observer.
Definition: Observer.cpp:112
repast::relogo::Observer::setup
virtual void setup(Properties &props)
Classes that extend this should include model initialization here.
Definition: Observer.h:139
repast::relogo::Observer::synchronizeTurtleStatus
void synchronizeTurtleStatus(Provider &provider, Updater &updater, AgentCreator &creator, RepastProcess::EXCHANGE_PATTERN exchangePattern=RepastProcess::POLL)
Synchronizes the status (moved or died) of all turtles across processes.
Definition: Observer.h:843
repast::relogo::Observer::removeAgent
void removeAgent(const AgentId &id)
Removes the specified turtle from the world.
Definition: Observer.cpp:265
repast::relogo::Observer::randomPycor
int randomPycor()
Gets a random y coodinate of the patches managed by this Observer.
Definition: Observer.cpp:116
repast::relogo::Observer::grid
const RelogoGridType * grid()
Gets the grid managed by this Observer.
Definition: Observer.cpp:154
repast::relogo::AgentSet::end
as_iterator end()
Gets an iterator to the end of this AgentSet.
Definition: AgentSet.h:228
repast::Grid< RelogoAgent, int >
repast::SharedContext
Context implementation specialized for the parallel distributed simulation.
Definition: SharedContext.h:115
repast::relogo::Observer::addDataSet
void addDataSet(repast::DataSet *dataSet)
Adds a dataset to this Observer.
Definition: Observer.cpp:88
repast::relogo::RelogoAgent::pxCor
virtual int pxCor() const =0
Gets the patch x coordinate of the agent's location.
repast::relogo::Observer::go
virtual void go()=0
Called every tick of the simulation.
repast::relogo::Observer::turtles
AgentSet< Turtle > turtles()
Gets all the turtles in this world and return them in the AgentSet.
Definition: Observer.cpp:238
repast::AgentId::agentType
int agentType() const
Gets the agent type component of this AgentId.
Definition: AgentId.h:124
repast::Grid::getObjectsAt
virtual void getObjectsAt(const Point< GPType > &pt, std::vector< T * > &out) const =0
Gets all the objects found at the specified point.
repast::relogo::Observer::patches
AgentSet< PatchType > patches()
Gets an agent set of the all the patches.
Definition: Observer.h:777
repast::GridDimensions
Basic structure for specifying grid dimenions.
Definition: GridDimensions.h:58
repast::relogo::RelogoAgent::pyCor
virtual int pyCor() const =0
Gets the patch y coordinate of the agent's location.
repast::relogo::WorldCreator
Creates a the relogo world given some parameters.
Definition: WorldCreator.h:65
repast::relogo::Observer::patchAt
PatchType * patchAt(int x, int y)
Gets the patch at the specified coordinates.
Definition: Observer.h:793
repast::relogo::RelogoAgent::location
Point< double > location() const
Gets the location of this RelogoAgent.
Definition: RelogoAgent.h:111
repast::DefaultNumberGenerator::next
double next()
Gets the "next" number from this Number Generator.
Definition: Random.h:113
repast::relogo::AgentSet::add
void add(T *agent)
Adds an agent to this AgentSet.
Definition: AgentSet.h:406
repast::relogo::Observer::get
AgentSet< AgentType > get()
Gets all of the agents of the templated type and returns them in an AgentSet.
repast::relogo::Observer::create
int create(size_t count)
Create count number of agents of the specified type.
Definition: Observer.h:662
repast::relogo::Observer::synchronizeTurtleStates
void synchronizeTurtleStates(Provider &provider, Updater &updater)
Synchronizes the state of any Turtles that are shared across processes.
Definition: Observer.h:838
repast::relogo::AgentSet::begin
as_iterator begin()
Gets an iterator to the begining of this AgentSet.
Definition: AgentSet.h:210
repast::RepastProcess::synchronizeProjectionInfo
void synchronizeProjectionInfo(SharedContext< T > &context, Provider &provider, Updater &updater, AgentCreator &creator, EXCHANGE_PATTERN exchangePattern=POLL, bool declareNoAgentsKeptOnAnyProcess=false)
Synchronizes the Projection information for shared projections.
Definition: RepastProcess.h:679
repast::RepastProcess::synchronizeAgentStates
void synchronizeAgentStates(Provider &provider, Updater &updater, std::string setName=REQUEST_AGENTS_ALL)
Synchronizes the state values of shared agents.
Definition: RepastProcess.h:614
repast::RepastProcess::instance
static RepastProcess * instance()
Gets this RepastProcess.
Definition: RepastProcess.cpp:126
repast::relogo::RelogoAgent::xCor
double xCor() const
Gets the x coordinate of the agent's location.
Definition: RelogoAgent.cpp:49
repast::relogo::Observer::turtlesAt
AgentSet< AgentType > turtlesAt(int x, int y)
Gets all of the agents of the templated type at the specified patch location.
Definition: Observer.h:729
repast::relogo::AgentSet::size
size_t size() const
Gets the size of this AgentSet.
Definition: AgentSet.h:192
repast::relogo::AgentSet::addAll
void addAll(input_iterator begin, input_iterator end)
Adds all the agents from the start iterator through the end to this AgentSet.
Definition: AgentSet.h:396
repast::relogo::Caster
Unary function used in the transform_iterator that allows context iterators to return the agent maps ...
Definition: Observer.h:99
repast::relogo::DefaultAgentCreator
operator() that creates an agent of type Agent.
Definition: creators.h:61
repast::Properties
Map type object that contains key, value(string) properties.
Definition: Properties.h:77
repast::relogo::Observer::maxPxcor
int maxPxcor() const
Gets the maximum x coordinate of the patches managed by this Observer.
Definition: Observer.cpp:105
repast::relogo::Observer
Implementation of a logo Observer.
Definition: Observer.h:110
repast::relogo::Observer::patchAtOffset
Patch * patchAtOffset(Point< double > location, double heading, double distance)
Gets the patch at the heading/distance offset from the specified location or 0 if the resulting locat...
Definition: Observer.cpp:300
repast::SharedNetwork
Network implementation that can be shared across processes.
Definition: SharedNetwork.h:91
repast::RepastProcess::synchronizeAgentStatus
void synchronizeAgentStatus(SharedContext< T > &context, Provider &provider, Updater &updater, AgentCreator &creator, EXCHANGE_PATTERN exchangePattern=POLL)
Synchronizes the status (moved or died) of all agents across processes.
Definition: RepastProcess.h:892
repast::Point< double >
repast::relogo::Patch
A logo patch.
Definition: Patch.h:58
repast::relogo::Observer::randomXcor
double randomXcor()
Gets a random x coodinate of the turtles managed by this Observer.
Definition: Observer.cpp:120
repast::relogo::Turtle
Relogo Turtle implementation.
Definition: Turtle.h:59
repast::DataSet
Interface for recording and writing data.
Definition: DataSet.h:49
repast::relogo::Observer::turtlesOn
void turtlesOn(AgentSet< RelogoAgent > &agentSet, AgentSet< TurtleType > &out)
Gets all the turtles that are on any patches contained in the agentSet or on the patches where any tu...
Definition: Observer.h:808
repast::relogo::Observer::minPxcor
int minPxcor() const
Gets the minimum x coordinate of the patches managed by this Observer.
Definition: Observer.cpp:98