Pixel Class Reference

Pixel-level class. More...

#include <Pixel.h>

Inheritance diagram for Pixel:

Inheritance graph
[legend]
Collaboration diagram for Pixel:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Pixel (double ID_h, ThreadManager *MTHREAD_h)
 ~Pixel ()
double getDoubleValue (string layerName_h) const
 Return the value for a specific layer.
void initObjects ()
void acquireObject (ModelObject acquiredObject_h, int case_h=STAGE_NORMAL)
 Associate a new object to the agent.
void newYear ()
void setRandomRenting (string contractType)
 Set a new, random-duration, rental contract. For now only "agrContract" is implemented. Take account of objects included in the plots.
bool isAgricultural () const
double getStartingRentalCosts () const
 Return the initial renting costs for this plot type (exogenous).
void destroyRentalContract ()
 Destroy the rental contract when it goes out-of-scope or when the farm leave freeing the land.
int getLastRentingYear () const
 last year before the rental contract will be ended
int getStartRentingYear () const
int getRentingTerm () const
int getRentingAge () const
int getRemainingRentingAge () const
double getID () const
int getX () const
int getY () const
vector< Pixel * > getPixelsAtDistLevel (int distLevel_h) const
 Return a vector of pixels at the specified distance (in levels, not in physical units).
Agent_spacegetOwner ()
Agent_spacegetTenant ()
string getPxComments () const
Agent_spacegetCachedAgent ()
double getCachedDouble () const
vector< ModelObject * > getIncludedObjects ()
 Return pointers to objects located on this pixel.
vector< string > getIncludedObjectNames () const
int countMyObjects () const
double getRentalCosts () const
double getShRentalPriceCoeff () const
void setValue (string layerName_h, double value_h)
 Insert a new layer and its value.
void changeValue (string layerName_h, double value_h)
 Change the value of an existing layer.
void setCoordinates (int x_h, int y_h)
void setOwner (Agent_space *owner_h)
void setTenant (Agent_space *tenant_h)
void setPxComments (std::string pxComments_h)
void setCachedAgent (Agent_space *cachedAgent_h)
void setCachedDouble (double cachedDouble_h)
void clearCache ()
void setRemainingRentingTerm (int years_h)
void setRentingTerm (int years)
void setRentalCosts (double rentalCosts_h)
void setShRentalPriceCoeff (double shRentalPriceCoeff_h)

Private Attributes

map< string, double > values
 Map of values for each layer.
double ID
int pxX
int pxY
string pxComments
Agent_spacepxOwner
Agent_spacepxTenant
Agent_spacecachedAgent
 Cachable pointer to Agent_space used in some optimized algorithms.
double cachedDouble
 Cachable double used in some optimized algorithms.
vector< ModelObjectmyObjects
 Vector of spacial objects guested on this plot.
int rentingTerm
 how many years the object can live. rentingTerm= lastYear-startYear The object start with age=0 and is destroied at the end of year when it reach lifeTerm-1.. currentAge never go to lifeTerm
int startRentingYear
 year when the object was created
double rentalCosts
double shRentalPriceCoeff
 Ratio between the shadow price of this plot in comparition with the avg rental price of its type (calculted on the first year).

Detailed Description

Pixel-level class.

This class manage the info at the pixel level. A vector of pixel objects is owned by the class Gis.

Author:
Antonello Lobianco

Definition at line 44 of file Pixel.h.


Constructor & Destructor Documentation

Pixel ( double  ID_h,
ThreadManager MTHREAD_h 
)

Definition at line 25 of file Pixel.cpp.

~Pixel (  ) 

Definition at line 37 of file Pixel.cpp.


Member Function Documentation

double getDoubleValue ( string  layerName_h  )  const

Return the value for a specific layer.

Definition at line 129 of file Pixel.cpp.

Referenced by Opt::addPixel(), ThreadManager::computeQuery(), Layers::countMyPixels(), Agent_farmer::filterActivity(), Manager_farmers::locateMyAgents(), Layers::print(), Layers::printBinMap(), and Layers::randomShuffle().

Here is the caller graph for this function:

void initObjects (  ) 

Initialize the pixel with a suitable object

Definition at line 176 of file Pixel.cpp.

void acquireObject ( ModelObject  acquiredObject_h,
int  case_h = STAGE_NORMAL 
)

Associate a new object to the agent.

Parameters:
case_h stage (STAGE_INIT or STAGE_NORMAL)

Definition at line 144 of file Pixel.cpp.

Referenced by Agent_farmer::collectProductionEffects(), and initObjects().

Here is the caller graph for this function:

void newYear (  ) 

Definition at line 204 of file Pixel.cpp.

Referenced by Scheduler::run(), and SuperAgentManager::update().

Here is the caller graph for this function:

void setRandomRenting ( string  contractType  ) 

Set a new, random-duration, rental contract. For now only "agrContract" is implemented. Take account of objects included in the plots.

This function set a new renting contract for the plot. There could be more type of contract, but now only the "agrContract" type is implemented. Normally contracts are randomly choosed betweer a minimum and a maximum. However, if objects are present in such plots and we are not in the init stage, contracts can not be longer than the object remaining age.

Definition at line 242 of file Pixel.cpp.

Referenced by Manager_farmers::assignPlot().

Here is the caller graph for this function:

bool isAgricultural (  )  const

Definition at line 280 of file Pixel.cpp.

double getStartingRentalCosts (  )  const

Return the initial renting costs for this plot type (exogenous).

Definition at line 314 of file Pixel.cpp.

Referenced by Manager_farmers::locateMyAgents().

Here is the caller graph for this function:

void destroyRentalContract (  ) 

Destroy the rental contract when it goes out-of-scope or when the farm leave freeing the land.

Used when the rental contract go out of time-scope or when the farms leave freeing the land

Definition at line 226 of file Pixel.cpp.

Referenced by newYear().

Here is the caller graph for this function:

int getLastRentingYear (  )  const [inline]

last year before the rental contract will be ended

Definition at line 65 of file Pixel.h.

Referenced by acquireObject(), and newYear().

Here is the caller graph for this function:

int getStartRentingYear (  )  const [inline]

Definition at line 66 of file Pixel.h.

int getRentingTerm (  )  const [inline]

Definition at line 67 of file Pixel.h.

Referenced by getRemainingRentingAge().

Here is the caller graph for this function:

int getRentingAge (  )  const

Definition at line 309 of file Pixel.cpp.

Referenced by getRemainingRentingAge().

Here is the caller graph for this function:

int getRemainingRentingAge (  )  const [inline]

Definition at line 69 of file Pixel.h.

double getID (  )  const [inline]

Definition at line 73 of file Pixel.h.

Referenced by Opt::addPixel(), and Agent_base::answerStats().

Here is the caller graph for this function:

int getX (  )  const [inline]

Definition at line 74 of file Pixel.h.

Referenced by Agent_base::answerStats(), ThreadManager::computeQuery(), Gis::getDistance(), getDoubleValue(), and getPixelsAtDistLevel().

Here is the caller graph for this function:

int getY (  )  const [inline]

Definition at line 75 of file Pixel.h.

Referenced by Agent_base::answerStats(), ThreadManager::computeQuery(), Gis::getDistance(), getDoubleValue(), and getPixelsAtDistLevel().

Here is the caller graph for this function:

vector< Pixel * > getPixelsAtDistLevel ( int  distLevel_h  )  const

Return a vector of pixels at the specified distance (in levels, not in physical units).

The function return a vector of pointers to Pixels at the gived distance from the caller pixel.\ The list start with those on the Top, then add those on the right, those on the bottom and those on the left. Finally it had the corner pixels (that are more far).\ It takes into consideration borders correctly.

Fully tested on internal points as well semi-border cases, border cases and corner cases. ALL OK.

Parameters:
distLevel_h Distance in number of adiacent pixels. It has to be at least 1 (the function return an error if it is 0).

Definition at line 51 of file Pixel.cpp.

Agent_space* getOwner (  )  [inline]

Definition at line 78 of file Pixel.h.

Referenced by Manager_farmers::quotePlot().

Here is the caller graph for this function:

Agent_space* getTenant (  )  [inline]

Definition at line 79 of file Pixel.h.

string getPxComments (  )  const [inline]

Definition at line 80 of file Pixel.h.

Agent_space* getCachedAgent (  )  [inline]

Definition at line 81 of file Pixel.h.

double getCachedDouble (  )  const [inline]

Definition at line 82 of file Pixel.h.

vector< ModelObject * > getIncludedObjects (  ) 

Return pointers to objects located on this pixel.

Definition at line 186 of file Pixel.cpp.

vector< string > getIncludedObjectNames (  )  const

Definition at line 195 of file Pixel.cpp.

Referenced by Opt::addPixel().

Here is the caller graph for this function:

int countMyObjects (  )  const [inline]

Definition at line 86 of file Pixel.h.

double getRentalCosts (  )  const [inline]

Definition at line 87 of file Pixel.h.

double getShRentalPriceCoeff (  )  const [inline]

Definition at line 88 of file Pixel.h.

void setValue ( string  layerName_h,
double  value_h 
)

Insert a new layer and its value.

Definition at line 113 of file Pixel.cpp.

void changeValue ( string  layerName_h,
double  value_h 
)

Change the value of an existing layer.

Definition at line 118 of file Pixel.cpp.

Referenced by Manager_farmers::assignPlot(), Agent_farmer::collectProductionEffects(), Manager_farmers::locateMyAgents(), Layers::randomShuffle(), and Manager_farmers::removeFromModel().

Here is the caller graph for this function:

void setCoordinates ( int  x_h,
int  y_h 
) [inline]

Definition at line 95 of file Pixel.h.

void setOwner ( Agent_space owner_h  )  [inline]

Definition at line 96 of file Pixel.h.

Referenced by Manager_farmers::assignPlot().

Here is the caller graph for this function:

void setTenant ( Agent_space tenant_h  )  [inline]

Definition at line 97 of file Pixel.h.

Referenced by Manager_farmers::assignPlot().

Here is the caller graph for this function:

void setPxComments ( std::string  pxComments_h  )  [inline]

Definition at line 98 of file Pixel.h.

void setCachedAgent ( Agent_space cachedAgent_h  )  [inline]

Definition at line 99 of file Pixel.h.

void setCachedDouble ( double  cachedDouble_h  )  [inline]

Definition at line 100 of file Pixel.h.

void clearCache (  )  [inline]

Definition at line 101 of file Pixel.h.

void setRemainingRentingTerm ( int  years_h  ) 

Definition at line 301 of file Pixel.cpp.

Referenced by Manager_farmers::locateMyAgents(), and setRandomRenting().

Here is the caller graph for this function:

void setRentingTerm ( int  years  )  [inline]

Definition at line 103 of file Pixel.h.

Referenced by acquireObject().

Here is the caller graph for this function:

void setRentalCosts ( double  rentalCosts_h  )  [inline]

Definition at line 104 of file Pixel.h.

Referenced by Manager_farmers::assignPlot().

Here is the caller graph for this function:

void setShRentalPriceCoeff ( double  shRentalPriceCoeff_h  )  [inline]

Definition at line 105 of file Pixel.h.


Member Data Documentation

map<string, double> values [private]

Map of values for each layer.

Definition at line 105 of file Pixel.h.

Referenced by changeValue(), getDoubleValue(), and setValue().

double ID [private]

Definition at line 111 of file Pixel.h.

Referenced by getID().

int pxX [private]

Definition at line 112 of file Pixel.h.

Referenced by getX(), and setCoordinates().

int pxY [private]

Definition at line 113 of file Pixel.h.

Referenced by getY(), and setCoordinates().

string pxComments [private]

Definition at line 114 of file Pixel.h.

Referenced by getPxComments(), and setPxComments().

Agent_space* pxOwner [private]

Definition at line 115 of file Pixel.h.

Referenced by acquireObject(), getOwner(), Pixel(), and setOwner().

Agent_space* pxTenant [private]

Definition at line 116 of file Pixel.h.

Referenced by acquireObject(), destroyRentalContract(), getTenant(), Pixel(), and setTenant().

Agent_space* cachedAgent [private]

Cachable pointer to Agent_space used in some optimized algorithms.

Definition at line 117 of file Pixel.h.

Referenced by clearCache(), getCachedAgent(), Pixel(), and setCachedAgent().

double cachedDouble [private]

Cachable double used in some optimized algorithms.

Definition at line 118 of file Pixel.h.

Referenced by clearCache(), getCachedDouble(), and setCachedDouble().

vector<ModelObject> myObjects [private]

Vector of spacial objects guested on this plot.

Definition at line 119 of file Pixel.h.

Referenced by acquireObject(), countMyObjects(), getIncludedObjectNames(), getIncludedObjects(), newYear(), and setRandomRenting().

int rentingTerm [private]

how many years the object can live. rentingTerm= lastYear-startYear The object start with age=0 and is destroied at the end of year when it reach lifeTerm-1.. currentAge never go to lifeTerm

Definition at line 122 of file Pixel.h.

Referenced by destroyRentalContract(), getLastRentingYear(), getRentingTerm(), Pixel(), setRemainingRentingTerm(), and setRentingTerm().

int startRentingYear [private]

year when the object was created

Definition at line 124 of file Pixel.h.

Referenced by destroyRentalContract(), getLastRentingYear(), getRentingAge(), getStartRentingYear(), Pixel(), and setRemainingRentingTerm().

double rentalCosts [private]

Definition at line 125 of file Pixel.h.

Referenced by destroyRentalContract(), getRentalCosts(), Pixel(), and setRentalCosts().

double shRentalPriceCoeff [private]

Ratio between the shadow price of this plot in comparition with the avg rental price of its type (calculted on the first year).

Definition at line 126 of file Pixel.h.

Referenced by getShRentalPriceCoeff(), and Pixel().


The documentation for this class was generated from the following files: