00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef AGENTBASE_H
00021 #define AGENTBASE_H
00022
00023
00024 #include <string>
00025 #include <vector>
00026 #include <stdexcept>
00027 #include <iostream>
00028 #include <sstream>
00029 #include <map>
00030
00031
00032 #include <QtCore>
00033 #include <QThread>
00034
00035
00036 #include "BaseRegmas.h"
00037 #include "ModelObject.h"
00038 #include "Opt.h"
00039
00040 class RegData;
00041 class Gis;
00042 struct AgentSurvey;
00043 class Manager_base;
00044
00046
00057 class Agent_base: public BaseRegmas{
00058
00059 public:
00060 Agent_base (ThreadManager* MTHREAD_h, Manager_base* manager_h);
00061 Agent_base (ThreadManager* MTHREAD_h, int uniqueID_h, Manager_base* manager_h);
00062 virtual ~Agent_base();
00063
00065 virtual void acquireObject(ModelObject acquiredObject_h, int case_h=STAGE_NORMAL);
00067 virtual bool filterActivity(matrixActivities* ACT)=0;
00068 virtual void payInitialYearCosts()=0;
00069 virtual void pay(double amount_h, bool updateResourceValues=true);
00070 virtual void update()=0;
00071 virtual void produce()=0;
00072 void answerStats(AgentSurvey &SURVEY);
00073 virtual int leaveActivity()=0;
00074 virtual void collectProductionEffects()=0;
00075 void withdraw();
00076 void debugOptProblem(string debugMessage="", bool useCallCounter=false){OPT.debug(debugMessage,useCallCounter);};
00077
00078 virtual int getMouldLocalID(){return mouldLocalID;};
00079 virtual int getMouldCoeff(){return mouldCoeff;};
00080 virtual int getAgentLocalID(){return agentLocalID;};
00081 virtual int getAgentUniqueID(){return agentUniqueID;};
00082 virtual string getComments(){return comments;};
00083 string getCategory(){return category;};
00084 double getResource(string resourceName_h);
00085 virtual map<string,double> getInitialResources(){return initialResources;};
00086 virtual double getInitialResourceByName(string resourceName_h);
00087 virtual double getCalculatedResourceByName(string resourceName_h);
00088 virtual double getObjectResourceByName(string resourceName_h);
00089 virtual double getLiquidity(){return liquidity;};
00091 virtual double getCapital(bool endOfYear=false);
00092 virtual double getLandCapital(){return 0;};
00093 virtual double getLandShPrice(){return 0;};
00094
00095 virtual int getNPlots(int ptype=PLOTS_ALL, int landCode_h = 0){int getRidCompWarning=ptype; getRidCompWarning=landCode_h;return 0;};
00096 vector <ModelObject*> getOwnedObjects();
00097 vector <ModelObject*> getAvailableObjects();
00098
00099 virtual int countMyObjects(){return myObjects.size();};
00100 double getZ(){return OPT.getZ();}
00102 virtual double getOverallProfit(){return netProductionProfit-sunkCostsPaid;};
00103 virtual double getNetProductionProfit(){return netProductionProfit;};
00104 virtual double getGrossCoupledPremiums(){return 0;};
00105 virtual double getGrossDecoupledPayment(){return 0;};
00106 virtual double getNetTotalPremium(){return 0;};
00107 double getSunkCostsPaid(){return sunkCostsPaid;};
00108 double getLiquidityShPrice(){return liquidityShPrice;};
00109 double getLabourShPrice(){return labourShPrice;};
00110
00111 virtual void setMouldLocalID(int mouldLocalID_h){mouldLocalID=mouldLocalID_h;};
00112 void setCategory(string category_h){category = category_h;};
00113 virtual void setMouldCoeff(int mouldCoeff_h){mouldCoeff=mouldCoeff_h;};
00114 virtual void setAgentLocalID(int agentLocalID_h){agentLocalID=agentLocalID_h;};
00115 virtual void setAgentUniqueID(int agentUniqueID_h){agentUniqueID=agentUniqueID_h;};
00116 virtual void setComments(string comments_h){comments=comments_h;};
00117 virtual void setInitialResources( map<string,double> initialResources_h){initialResources=initialResources_h;};
00118 virtual void setLiquidity(double liquidity_h){liquidity=liquidity_h;};
00119 virtual void setNetProductionProfit(double netProductionProfit_h){netProductionProfit = netProductionProfit_h;};
00120 virtual void setGrossCoupledPremiums(double grossCoupledPremiums_h){double temp = grossCoupledPremiums_h; temp++;};
00121 virtual void setGrossDecoupledPayment(double grossDecoupledPayment_h){double temp = grossDecoupledPayment_h; temp++;};
00122 virtual void setNetTotalPremium(double netTotalPremium_h){double temp = netTotalPremium_h; temp++;};
00123 void addToSunkCostsPaid(double paid){sunkCostsPaid += paid;};
00124
00125 protected:
00126
00127 string comments;
00128 string category;
00129 int mouldLocalID;
00130 int mouldCoeff;
00131 int agentLocalID;
00132 int agentUniqueID;
00133 vector <ModelObject> myObjects;
00134 map<string,double> initialResources;
00135
00142 double liquidity;
00143 double netProductionProfit;
00144 double sunkCostsPaid;
00145 double liquidityShPrice;
00146 double labourShPrice;
00147 Opt OPT;
00148 Manager_base* manager;
00149 QMutex mutex;
00150
00151 };
00152
00153 #endif