#include <Agent_base.h>
Inheritance diagram for Agent_base:
Public Member Functions | |
Agent_base (ThreadManager *MTHREAD_h, Manager_base *manager_h) | |
Constructor. | |
Agent_base (ThreadManager *MTHREAD_h, int uniqueID_h, Manager_base *manager_h) | |
Constructor with ID already on. | |
virtual | ~Agent_base () |
virtual void | acquireObject (ModelObject acquiredObject_h, int case_h=STAGE_NORMAL) |
Associate a new object to the agent. | |
virtual bool | filterActivity (matrixActivities *ACT)=0 |
This function will filter the activity for agent-specific parameters. E.g. subtract transport costs from the gm. A false return value means the activity has to be skipped. | |
virtual void | payInitialYearCosts ()=0 |
Pay the initial costs for the year coming (suckCosts: rental costs and maintainance costs). | |
virtual void | pay (double amount_h, bool updateResourceValues=true) |
Pay a money for whatsoever reason. Subtract liquidity and update the OPT problem. | |
virtual void | update ()=0 |
virtual void | produce ()=0 |
void | answerStats (AgentSurvey &SURVEY) |
virtual int | leaveActivity ()=0 |
virtual void | collectProductionEffects ()=0 |
void | withdraw () |
Withdraw the money needed for living from the liquidity. Made by a fixed part plus a profit-variable one. | |
void | debugOptProblem (string debugMessage="", bool useCallCounter=false) |
virtual int | getMouldLocalID () |
virtual int | getMouldCoeff () |
virtual int | getAgentLocalID () |
virtual int | getAgentUniqueID () |
virtual string | getComments () |
string | getCategory () |
double | getResource (string resourceName_h) |
virtual map< string, double > | getInitialResources () |
virtual double | getInitialResourceByName (string resourceName_h) |
virtual double | getCalculatedResourceByName (string resourceName_h) |
virtual double | getObjectResourceByName (string resourceName_h) |
virtual double | getLiquidity () |
virtual double | getCapital (bool endOfYear=false) |
Return the capital of the agent. | |
virtual double | getLandCapital () |
virtual double | getLandShPrice () |
virtual int | getNPlots (int ptype=PLOTS_ALL, int landCode_h=0) |
vector< ModelObject * > | getOwnedObjects () |
Return the owned plots, for financial analysis. | |
vector< ModelObject * > | getAvailableObjects () |
Return the available objects, for resource analysis. | |
virtual int | countMyObjects () |
double | getZ () |
virtual double | getOverallProfit () |
netProductionProfit - sunkCostsPaid | |
virtual double | getNetProductionProfit () |
virtual double | getGrossCoupledPremiums () |
virtual double | getGrossDecoupledPayment () |
virtual double | getNetTotalPremium () |
double | getSunkCostsPaid () |
double | getLiquidityShPrice () |
double | getLabourShPrice () |
virtual void | setMouldLocalID (int mouldLocalID_h) |
void | setCategory (string category_h) |
virtual void | setMouldCoeff (int mouldCoeff_h) |
virtual void | setAgentLocalID (int agentLocalID_h) |
virtual void | setAgentUniqueID (int agentUniqueID_h) |
virtual void | setComments (string comments_h) |
virtual void | setInitialResources (map< string, double > initialResources_h) |
virtual void | setLiquidity (double liquidity_h) |
virtual void | setNetProductionProfit (double netProductionProfit_h) |
virtual void | setGrossCoupledPremiums (double grossCoupledPremiums_h) |
virtual void | setGrossDecoupledPayment (double grossDecoupledPayment_h) |
virtual void | setNetTotalPremium (double netTotalPremium_h) |
void | addToSunkCostsPaid (double paid) |
Protected Attributes | |
string | comments |
string | category |
category of the agent (e.g. "farmer") | |
int | mouldLocalID |
only in the "factory" stage | |
int | mouldCoeff |
upscaling coefficient | |
int | agentLocalID |
only in the implementation | |
int | agentUniqueID |
only in the implementation | |
vector< ModelObject > | myObjects |
objects associated with each agent. Doesn't include spacial objects !! They are stored in the plots !!! | |
map< string, double > | initialResources |
initialResources | |
double | liquidity |
double | netProductionProfit |
production profit without coupled premiums | |
double | sunkCostsPaid |
out-of-MIP paid costs (e.g. rental prices) | |
double | liquidityShPrice |
shadow price of own liquidity (if any) | |
double | labourShPrice |
shadow price of family labour | |
Opt | OPT |
optimization problem | |
Manager_base * | manager |
pointer to the own manager | |
QMutex | mutex |
mutex object to protect multithreads-unsafe calls |
This is the base class for each derived agent:
Agent_base --> agent_nospacial --> ...
Agent_base --> agent_spaciallyExplicit --> ...
Definition at line 57 of file Agent_base.h.
Agent_base | ( | ThreadManager * | MTHREAD_h, | |
Manager_base * | manager_h | |||
) |
Constructor.
The constructor get the following pointers:
MTHREAD_h | pointer to the main thread |
Definition at line 32 of file Agent_base.cpp.
Agent_base | ( | ThreadManager * | MTHREAD_h, | |
int | uniqueID_h, | |||
Manager_base * | manager_h | |||
) |
~Agent_base | ( | ) | [virtual] |
Definition at line 53 of file Agent_base.cpp.
void acquireObject | ( | ModelObject | acquiredObject_h, | |
int | case_h = STAGE_NORMAL | |||
) | [virtual] |
Associate a new object to the agent.
case_h | stage (STAGE_INIT or STAGE_NORMAL) |
Definition at line 64 of file Agent_base.cpp.
Referenced by Agent_farmer::collectProductionEffects().
Here is the caller graph for this function:
virtual bool filterActivity | ( | matrixActivities * | ACT | ) | [pure virtual] |
This function will filter the activity for agent-specific parameters. E.g. subtract transport costs from the gm. A false return value means the activity has to be skipped.
Implemented in Agent_farmer.
Referenced by Opt::addPixel(), and Opt::updateActivities().
Here is the caller graph for this function:
virtual void payInitialYearCosts | ( | ) | [pure virtual] |
Pay the initial costs for the year coming (suckCosts: rental costs and maintainance costs).
Implemented in Agent_space.
void pay | ( | double | amount_h, | |
bool | updateResourceValues = true | |||
) | [virtual] |
Pay a money for whatsoever reason. Subtract liquidity and update the OPT problem.
Definition at line 356 of file Agent_base.cpp.
Referenced by Manager_farmers::assignPlot(), and Agent_space::payInitialYearCosts().
Here is the caller graph for this function:
virtual void update | ( | ) | [pure virtual] |
Implemented in Agent_space, and Agent_farmer.
virtual void produce | ( | ) | [pure virtual] |
Implemented in Agent_farmer.
void answerStats | ( | AgentSurvey & | SURVEY | ) |
Definition at line 218 of file Agent_base.cpp.
virtual int leaveActivity | ( | ) | [pure virtual] |
Implemented in Agent_farmer.
virtual void collectProductionEffects | ( | ) | [pure virtual] |
Implemented in Agent_farmer.
void withdraw | ( | ) |
Withdraw the money needed for living from the liquidity. Made by a fixed part plus a profit-variable one.
Definition at line 211 of file Agent_base.cpp.
void debugOptProblem | ( | string | debugMessage = "" , |
|
bool | useCallCounter = false | |||
) | [inline] |
Definition at line 76 of file Agent_base.h.
virtual int getMouldLocalID | ( | ) | [inline, virtual] |
Definition at line 78 of file Agent_base.h.
Referenced by answerStats(), Opt::debug(), and Output::printLeavingAgent().
Here is the caller graph for this function:
virtual int getMouldCoeff | ( | ) | [inline, virtual] |
Definition at line 79 of file Agent_base.h.
virtual int getAgentLocalID | ( | ) | [inline, virtual] |
Definition at line 80 of file Agent_base.h.
Referenced by Manager_farmers::assignPlot().
Here is the caller graph for this function:
virtual int getAgentUniqueID | ( | ) | [inline, virtual] |
Definition at line 81 of file Agent_base.h.
Referenced by answerStats(), Opt::debug(), Agent_farmer::getDecoupledPayments(), Agent_farmer::leaveActivity(), Output::printLeavingAgent(), Manager_farmers::removeFromModel(), and Opt::solveGlpk().
Here is the caller graph for this function:
virtual string getComments | ( | ) | [inline, virtual] |
Definition at line 82 of file Agent_base.h.
string getCategory | ( | ) | [inline] |
Definition at line 83 of file Agent_base.h.
Referenced by answerStats(), and Output::printLeavingAgent().
Here is the caller graph for this function:
double getResource | ( | string | resourceName_h | ) |
Definition at line 76 of file Agent_base.cpp.
Referenced by answerStats(), Agent_farmer::leaveActivity(), Opt::updateResourceValues(), and withdraw().
Here is the caller graph for this function:
virtual map<string,double> getInitialResources | ( | ) | [inline, virtual] |
Definition at line 85 of file Agent_base.h.
double getInitialResourceByName | ( | string | resourceName_h | ) | [virtual] |
Definition at line 99 of file Agent_base.cpp.
Referenced by getResource().
Here is the caller graph for this function:
double getCalculatedResourceByName | ( | string | resourceName_h | ) | [virtual] |
Definition at line 110 of file Agent_base.cpp.
Referenced by getResource().
Here is the caller graph for this function:
double getObjectResourceByName | ( | string | resourceName_h | ) | [virtual] |
Definition at line 128 of file Agent_base.cpp.
Referenced by getResource().
Here is the caller graph for this function:
virtual double getLiquidity | ( | ) | [inline, virtual] |
Definition at line 89 of file Agent_base.h.
Referenced by Output::printLeavingAgent().
Here is the caller graph for this function:
double getCapital | ( | bool | endOfYear = false |
) | [virtual] |
Return the capital of the agent.
endOfYear | Optional parameter to specify that the capital requested is those that the farm has at the end of the year |
Definition at line 138 of file Agent_base.cpp.
Referenced by answerStats(), Agent_farmer::leaveActivity(), and Output::printLeavingAgent().
Here is the caller graph for this function:
virtual double getLandCapital | ( | ) | [inline, virtual] |
Reimplemented in Agent_space.
Definition at line 92 of file Agent_base.h.
Referenced by getCapital().
Here is the caller graph for this function:
virtual double getLandShPrice | ( | ) | [inline, virtual] |
Reimplemented in Agent_space.
Definition at line 93 of file Agent_base.h.
Referenced by Output::printLeavingAgent().
Here is the caller graph for this function:
virtual int getNPlots | ( | int | ptype = PLOTS_ALL , |
|
int | landCode_h = 0 | |||
) | [inline, virtual] |
Reimplemented in Agent_space.
Definition at line 95 of file Agent_base.h.
Referenced by Output::printLeavingAgent().
Here is the caller graph for this function:
vector< ModelObject * > getOwnedObjects | ( | ) |
Return the owned plots, for financial analysis.
Definition at line 150 of file Agent_base.cpp.
Referenced by answerStats(), and getCapital().
Here is the caller graph for this function:
vector< ModelObject * > getAvailableObjects | ( | ) |
Return the available objects, for resource analysis.
Definition at line 183 of file Agent_base.cpp.
Referenced by answerStats(), and getObjectResourceByName().
Here is the caller graph for this function:
virtual int countMyObjects | ( | ) | [inline, virtual] |
double getZ | ( | ) | [inline] |
Definition at line 100 of file Agent_base.h.
virtual double getOverallProfit | ( | ) | [inline, virtual] |
netProductionProfit - sunkCostsPaid
Reimplemented in Agent_farmer.
Definition at line 102 of file Agent_base.h.
Referenced by withdraw().
Here is the caller graph for this function:
virtual double getNetProductionProfit | ( | ) | [inline, virtual] |
Definition at line 103 of file Agent_base.h.
Referenced by Output::printLeavingAgent().
Here is the caller graph for this function:
virtual double getGrossCoupledPremiums | ( | ) | [inline, virtual] |
Reimplemented in Agent_farmer.
Definition at line 104 of file Agent_base.h.
Referenced by answerStats(), and Output::printLeavingAgent().
Here is the caller graph for this function:
virtual double getGrossDecoupledPayment | ( | ) | [inline, virtual] |
Reimplemented in Agent_farmer.
Definition at line 105 of file Agent_base.h.
Referenced by answerStats(), and Output::printLeavingAgent().
Here is the caller graph for this function:
virtual double getNetTotalPremium | ( | ) | [inline, virtual] |
Reimplemented in Agent_farmer.
Definition at line 106 of file Agent_base.h.
Referenced by answerStats(), and Output::printLeavingAgent().
Here is the caller graph for this function:
double getSunkCostsPaid | ( | ) | [inline] |
Definition at line 107 of file Agent_base.h.
Referenced by Output::printLeavingAgent().
Here is the caller graph for this function:
double getLiquidityShPrice | ( | ) | [inline] |
Definition at line 108 of file Agent_base.h.
Referenced by Output::printLeavingAgent().
Here is the caller graph for this function:
double getLabourShPrice | ( | ) | [inline] |
Definition at line 109 of file Agent_base.h.
Referenced by Output::printLeavingAgent().
Here is the caller graph for this function:
virtual void setMouldLocalID | ( | int | mouldLocalID_h | ) | [inline, virtual] |
Definition at line 111 of file Agent_base.h.
void setCategory | ( | string | category_h | ) | [inline] |
Definition at line 112 of file Agent_base.h.
virtual void setMouldCoeff | ( | int | mouldCoeff_h | ) | [inline, virtual] |
Definition at line 113 of file Agent_base.h.
virtual void setAgentLocalID | ( | int | agentLocalID_h | ) | [inline, virtual] |
Definition at line 114 of file Agent_base.h.
virtual void setAgentUniqueID | ( | int | agentUniqueID_h | ) | [inline, virtual] |
Definition at line 115 of file Agent_base.h.
virtual void setComments | ( | string | comments_h | ) | [inline, virtual] |
Definition at line 116 of file Agent_base.h.
virtual void setInitialResources | ( | map< string, double > | initialResources_h | ) | [inline, virtual] |
Definition at line 117 of file Agent_base.h.
virtual void setLiquidity | ( | double | liquidity_h | ) | [inline, virtual] |
Definition at line 118 of file Agent_base.h.
virtual void setNetProductionProfit | ( | double | netProductionProfit_h | ) | [inline, virtual] |
Definition at line 119 of file Agent_base.h.
virtual void setGrossCoupledPremiums | ( | double | grossCoupledPremiums_h | ) | [inline, virtual] |
virtual void setGrossDecoupledPayment | ( | double | grossDecoupledPayment_h | ) | [inline, virtual] |
virtual void setNetTotalPremium | ( | double | netTotalPremium_h | ) | [inline, virtual] |
void addToSunkCostsPaid | ( | double | paid | ) | [inline] |
Definition at line 123 of file Agent_base.h.
Referenced by Manager_farmers::assignPlot().
Here is the caller graph for this function:
string comments [protected] |
string category [protected] |
category of the agent (e.g. "farmer")
Definition at line 128 of file Agent_base.h.
Referenced by getCategory(), and setCategory().
int mouldLocalID [protected] |
only in the "factory" stage
Definition at line 129 of file Agent_base.h.
Referenced by getMouldLocalID(), and setMouldLocalID().
int mouldCoeff [protected] |
upscaling coefficient
Definition at line 130 of file Agent_base.h.
Referenced by getMouldCoeff(), and setMouldCoeff().
int agentLocalID [protected] |
only in the implementation
Definition at line 131 of file Agent_base.h.
Referenced by getAgentLocalID(), and setAgentLocalID().
int agentUniqueID [protected] |
only in the implementation
Definition at line 132 of file Agent_base.h.
Referenced by Agent_base(), Agent_space::Agent_space(), getAgentUniqueID(), setAgentUniqueID(), and ~Agent_base().
vector<ModelObject> myObjects [protected] |
objects associated with each agent. Doesn't include spacial objects !! They are stored in the plots !!!
Definition at line 133 of file Agent_base.h.
Referenced by acquireObject(), Agent_space::countMyObjects(), countMyObjects(), getAvailableObjects(), getOwnedObjects(), and Agent_farmer::update().
map<string,double> initialResources [protected] |
initialResources
Definition at line 134 of file Agent_base.h.
Referenced by getInitialResourceByName(), getInitialResources(), and setInitialResources().
double liquidity [protected] |
Available liquidity. Liquidity is important at it is never created from scratch.
During the model run liquidity is increased or decreased according to the cash flow of the agent, but it is never reset. It can (and it is offen) negative in case of the presence of debs.
A short note: capital is dynamically created with getCapital(), it is not a propriety of the agent.
Definition at line 142 of file Agent_base.h.
Referenced by Agent_base(), answerStats(), Agent_farmer::collectProductionEffects(), getCalculatedResourceByName(), getCapital(), getLiquidity(), Agent_farmer::leaveActivity(), pay(), setLiquidity(), and withdraw().
double netProductionProfit [protected] |
production profit without coupled premiums
Definition at line 143 of file Agent_base.h.
Referenced by Agent_base(), answerStats(), Agent_farmer::collectProductionEffects(), getNetProductionProfit(), Agent_farmer::getOverallProfit(), getOverallProfit(), Agent_farmer::leaveActivity(), and setNetProductionProfit().
double sunkCostsPaid [protected] |
out-of-MIP paid costs (e.g. rental prices)
Definition at line 144 of file Agent_base.h.
Referenced by Agent_base(), answerStats(), Agent_farmer::getOverallProfit(), getOverallProfit(), getSunkCostsPaid(), Agent_farmer::leaveActivity(), and Agent_space::payInitialYearCosts().
double liquidityShPrice [protected] |
shadow price of own liquidity (if any)
Definition at line 145 of file Agent_base.h.
Referenced by getLiquidityShPrice(), and Agent_farmer::leaveActivity().
double labourShPrice [protected] |
shadow price of family labour
Definition at line 146 of file Agent_base.h.
Referenced by getLabourShPrice(), and Agent_farmer::leaveActivity().
optimization problem
Definition at line 147 of file Agent_base.h.
Referenced by Agent_space::addPlotToMIP(), answerStats(), Agent_farmer::collectProductionEffects(), debugOptProblem(), Agent_farmer::getShadowPrice(), getZ(), Agent_farmer::initMIP(), Agent_farmer::leaveActivity(), pay(), Agent_farmer::produce(), Agent_farmer::test(), and Agent_farmer::update().
Manager_base* manager [protected] |
pointer to the own manager
Definition at line 148 of file Agent_base.h.
Referenced by Agent_base(), answerStats(), and Agent_farmer::getDecoupledPayments().
QMutex mutex [protected] |