Agent_base.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006-2008 by Antonello Lobianco                         *
00003  *   http://regmas.org                                                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 3 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef AGENTBASE_H
00021 #define AGENTBASE_H
00022 
00023 // standard headers
00024 #include <string>
00025 #include <vector>
00026 #include <stdexcept>
00027 #include <iostream>
00028 #include <sstream>
00029 #include <map>
00030 
00031 // Qt headers..
00032 #include <QtCore>
00033 #include <QThread>
00034 
00035 // regmas headers..
00036 #include "BaseRegmas.h"
00037 #include "ModelObject.h"
00038 #include "Opt.h"
00039 
00040 class RegData;
00041 class Gis; // forward declaration
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