29 #include "../../common/Exception.h" 
   30 #include "../../common/Translator.h" 
   31 #include "../../common/progress/TaskProgress.h" 
   32 #include "../../dataaccess/datasource/DataSource.h" 
   33 #include "../../dataaccess/datasource/DataSourceManager.h" 
   34 #include "../../dataaccess/utils/Utils.h" 
   35 #include "../../datatype/SimpleProperty.h" 
   36 #include "../../geometry/Geometry.h" 
   37 #include "../../geometry/GeometryProperty.h" 
   38 #include "../../graph/core/AbstractGraph.h" 
   39 #include "../../graph/core/Edge.h" 
   40 #include "../../graph/core/Vertex.h" 
   41 #include "../../memory/DataSet.h" 
   42 #include "../../memory/DataSetItem.h" 
   59   assert(m_inputParams->m_ds.get());
 
   60   assert(m_inputParams->m_dsType.get());
 
   63   std::size_t eventIdx = m_inputParams->m_dsType->getPropertyPosition(m_inputParams->m_eventAttrName);
 
   64   int eventType = m_inputParams->m_ds->getPropertyDataType(eventIdx);
 
   65   int gpmEventIdx = 
te::sa::AssociateGPMVertexAttribute(m_inputParams->m_gpm.get(), m_inputParams->m_ds.get(), m_inputParams->m_gpmAttrLink, m_inputParams->m_eventAttrName, eventType);
 
   68   std::size_t popIdx = m_inputParams->m_dsType->getPropertyPosition(m_inputParams->m_populationAttrName);
 
   69   int popType = m_inputParams->m_ds->getPropertyDataType(popIdx);
 
   70   int gpmPopIdx = 
te::sa::AssociateGPMVertexAttribute(m_inputParams->m_gpm.get(), m_inputParams->m_ds.get(), m_inputParams->m_gpmAttrLink, m_inputParams->m_populationAttrName, popType);
 
   73   std::auto_ptr<te::da::DataSetType> outDsType = createDataSetType(m_inputParams->m_dsType.get());
 
   74   std::auto_ptr<te::mem::DataSet> outDs = createDataSet(m_inputParams->m_ds.get(), outDsType.get());
 
   77   eventIdx = outDsType->getPropertyPosition(m_inputParams->m_eventAttrName);
 
   78   popIdx = outDsType->getPropertyPosition(m_inputParams->m_populationAttrName);
 
   80   std::size_t idIdx = outDsType->getPropertyPosition(m_inputParams->m_gpmAttrLink);
 
   85   runBayesLocal(outDs.get(), idIdx, eventIdx, popIdx, neighEventIdx, neighPopIdx, bayesIdx, gpmEventIdx, gpmPopIdx);
 
   88   saveDataSet(outDs.get(), outDsType.get());
 
   93   m_inputParams.reset(inParams);
 
   94   m_outputParams.reset(outParams);
 
  102   std::map<std::string, std::string> options;
 
  104   m_outputParams->m_ds->createDataSet(dsType, options);
 
  106   m_outputParams->m_ds->add(m_outputParams->m_outputDataSetName, dataSet, options);
 
  111   std::auto_ptr<te::da::DataSetType> dataSetType(
new te::da::DataSetType(m_outputParams->m_outputDataSetName));
 
  114   std::vector<te::dt::Property*> propertyVec = dsType->
getProperties();
 
  116   for(std::size_t t = 0; t < propertyVec.size(); ++t)
 
  124     dataSetType->add(newProp);
 
  129   dataSetType->add(neighEvent);
 
  133   dataSetType->add(neighPop);
 
  137   dataSetType->add(bayesProperty);
 
  155     for(std::size_t t = 0; t < nProp; ++t)
 
  172     outDataset->add(outDSetItem);
 
  179           std::size_t neighEventIdx, std::size_t neighPopIdx, std::size_t bayesIdx, std::size_t gpmEventIdx, std::size_t gpmPopIdx)
 
  181   assert(m_inputParams->m_gpm.get());
 
  190     task.
setMessage(
TE_TR(
"Calculating events and population for each element."));
 
  199       int id = atoi(strId.c_str());
 
  201       double totEvent = ds->
getDouble(eventIdx);
 
  209         std::set<int>::iterator itNeighbours = neighbours.begin();
 
  210         while(itNeighbours != neighbours.end())
 
  218               vTo = graph->getVertex(e->
getIdTo());
 
  260       int id = atoi(strId.c_str());
 
  262       double myEvent = ds->
getDouble(eventIdx);
 
  265       double totEvent = ds->
getDouble(neighEventIdx);
 
  266       double totPop = ds->
getDouble(neighPopIdx);
 
  271       double mean = totEvent / totPop;
 
  273       double thetaI = (myPop > 0) ? myEvent / myPop : 0.0;
 
  280         std::set<int>::iterator itNeighbours = neighbours.begin();
 
  281         int nNeighbours = (int)neighbours.size();
 
  285           double variance = myPop * pow((myEvent / myPop) - mean, 2);
 
  287           while(itNeighbours != neighbours.end())
 
  295                 vTo = graph->getVertex(e->
getIdTo());
 
  305               variance += toPop * pow((toEvent / toPop) - mean, 2);
 
  313           double aux = variance - (mean * ((double)nNeighbours + 1.) / totPop);
 
  320           if(aux != 0. || mean != 0.)
 
  321             wI = aux / (aux + (mean / myPop));
 
  323           thetaI = wI * (myEvent / myPop) + (1 - wI) * mean;
 
  327       ds->
setDouble(bayesIdx, thetaI * m_inputParams->m_rate);
 
std::size_t size() const 
It returns the collection size, if it is known. 
 
#define TE_SA_BAYESPOP_ATTR_NAME
 
Class that represents the Bayes output parameters. 
 
This file contains a class that represents the bayes global operation. 
 
void setMessage(const std::string &message)
Set the task message. 
 
Utility functions for the data access module. 
 
void saveDataSet(te::da::DataSet *dataSet, te::da::DataSetType *dsType)
 
void setDouble(std::size_t i, double value)
It sets the value of the i-th property. 
 
An atomic property like an integer or double. 
 
A class that models the description of a dataset. 
 
virtual Property * clone() const =0
It returns a clone of the object. 
 
This class can be used to inform the progress of a task. 
 
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property. 
 
std::vector< te::dt::AbstractData * > & getAttributes()
It returns the vector of attributes associated with this element. 
 
#define TE_TR(message)
It marks a string in order to get translated. 
 
It models a property definition. 
 
bool isActive() const 
Verify if the task is active. 
 
From the point of view of graph theory, vertices are treated as featureless and indivisible objects...
 
void setTotalSteps(int value)
Set the task total stepes. 
 
void setId(unsigned int id)
It sets the property identifier. 
 
Class used to define the edge struct of a graph. Its compose with a identifier, the vertex origin and...
 
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection. 
 
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
 
~BayesLocalOperation()
Virtual destructor. 
 
BayesLocalOperation()
Default constructor. 
 
const std::vector< Property * > & getProperties() const 
It returns the list of properties describing the CompositeProperty. 
 
Abstract class used to define the main functions of graph struct. All graph implementations must used...
 
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1. 
 
virtual std::string getAsString(std::size_t i, int precision=0) const 
Method for retrieving a data value as a string plain representation. 
 
A base class for values that can be retrieved from the data access module. 
 
std::set< int > & getSuccessors()
Returns the Successors vector. 
 
int getIdFrom()
It returns the vertex origin identification. 
 
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset. 
 
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
 
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection. 
 
bool moveNext()
It moves the internal pointer to the next item of the collection. 
 
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
 
A dataset is the unit of information manipulated by the data access module of TerraLib. 
 
#define TE_SA_BAYESEVENT_ATTR_NAME
 
double getDouble(std::size_t i) const 
Method for retrieving a double attribute value. 
 
void runBayesLocal(te::mem::DataSet *ds, std::size_t idIdx, std::size_t eventIdx, std::size_t popIdx, std::size_t neighEventIdx, std::size_t neighPopIdx, std::size_t bayesIdx, std::size_t gpmEventIdx, std::size_t gpmPopIdx)
 
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection. 
 
TESAEXPORT double GetDataValue(te::dt::AbstractData *ad)
Function used to get the numeric value from a gpm property. 
 
TESAEXPORT int AssociateGPMVertexAttribute(te::sa::GeneralizedProximityMatrix *gpm, te::da::DataSource *ds, std::string dataSetName, std::string attrLink, std::string attr, int dataType, int srid=TE_UNKNOWN_SRS, int subType=te::gm::UnknownGeometryType)
Function used to set a an attribute valeu from a dataset to the vertex objects from a gpm...
 
void setParameters(te::sa::BayesInputParams *inParams, te::sa::BayesOutputParams *outParams)
 
std::auto_ptr< te::mem::DataSet > createDataSet(te::da::DataSet *inputDataSet, te::da::DataSetType *dsType)
 
#define TE_SA_BAYES_ATTR_NAME
 
void setDouble(std::size_t i, double value)
 
std::auto_ptr< te::da::DataSetType > createDataSetType(te::da::DataSetType *dsType)
 
virtual std::auto_ptr< te::dt::AbstractData > getValue(std::size_t i) const 
Method for retrieving any other type of data value stored in the data source. 
 
void execute()
Function to execute the bayes operation. 
 
int getIdTo()
It returns the vertex destiny identification. 
 
void setParent(Property *p)
It associate this property to the informed parent.