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 AGENTFARMER_H 00021 #define AGENTFARMER_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 // regmas headers... 00032 #include "Agent_space.h" 00033 #include "Manager_farmers.h" 00034 #include "Opt.h" 00035 00037 00044 class Agent_farmer: public Agent_space { 00045 00046 public: 00047 Agent_farmer(ThreadManager* MTHREAD_h, Manager_base* manager_h); 00048 Agent_farmer(ThreadManager* MTHREAD_h, int uniqueID_h, Manager_base* manager_h); 00049 ~Agent_farmer(); 00050 00051 virtual bool filterActivity(matrixActivities* ACT); 00052 double getShadowPrice(const Pixel* px_h, bool initSolve=false); 00053 double offerRentalPrice(const Pixel* px_h, bool initSolve=false); 00054 void update(); 00055 void produce(){OPT.update(); OPT.solve();}; // OPT update is needed otherwise I got slighly other results.. 00056 virtual int leaveActivity(); 00057 virtual void collectProductionEffects(); 00058 double applyModulation(double grossPremium); 00059 double getDecoupledPayments(); 00061 double getUAA(int ptype=PLOTS_ALL); 00062 double getAgrDistCost(const Pixel* px1); 00063 friend void Manager_farmers::setAgentMoulds(); 00064 void initMIP(); 00065 void test(); 00066 00067 string getFadnID(){return fadnID;}; 00068 string getFarmType(){return farmType;}; 00069 double getInitialDecPayment(){return initialDecPayment;}; 00070 int getAgrRegionNumber(){return agrRegionNumber;}; 00072 virtual double getOverallProfit(){return netProductionProfit+netTotalPremium-sunkCostsPaid;}; 00073 virtual double getGrossCoupledPremiums(){return grossCoupledPremiums;}; 00074 virtual double getGrossDecoupledPayment(){return grossDecoupledPayment;}; 00075 virtual double getNetTotalPremium(){return netTotalPremium;}; 00076 double getDecRightsByAct(int actMouldCounter, int policyPremiumCounter){return decRights.at(actMouldCounter).at(policyPremiumCounter);}; 00077 double getDecHaByActMould(int actMouldCounter, int policyPremiumCounter){return decHa.at(actMouldCounter).at(policyPremiumCounter);}; 00078 double getCachedOffer(){return cachedOffer;}; 00079 00080 00081 void setFadnID(string fadnID_h){fadnID =fadnID_h ;}; 00082 void setFarmType(string farmType_h){farmType = farmType_h;}; 00083 void setInitialDecPayment(double initialDecPayment_h){initialDecPayment = initialDecPayment_h;}; 00084 void setCachedOffer(double cachedOffer_h){cachedOffer = cachedOffer_h;}; 00085 virtual void setGrossCoupledPremiums(double grossCoupledPremiums_h){grossCoupledPremiums = grossCoupledPremiums_h;}; 00086 virtual void setGrossDecoupledPayment(double grossDecoupledPayment_h){grossDecoupledPayment = grossDecoupledPayment_h;}; 00087 virtual void setNetTotalPremium(double netTotalPremium_h){netTotalPremium = netTotalPremium_h;}; 00088 void setAgrRegionNumber(int agrRegionNumber_h){agrRegionNumber=agrRegionNumber_h;}; 00089 00090 double debugLandUse; 00091 volatile double cachedOffer; 00092 00093 private: 00094 string fadnID; 00095 string farmType; 00096 double initialDecPayment; 00097 int agrRegionNumber; 00098 00099 vector< vector<double> > decRights; 00100 vector< vector<int> > decYears; 00101 vector< vector<double> > decHa; 00102 00103 /*vector<double> decRights; ///< This is already the average by year of the coupled premiums got during the reference period - By act mould 00104 vector<int> decYears; ///< Counter of how many years the average "decYears" has been counted for - By act mould 00105 vector<double> decHa; ///< Counter of the average hectars generating the rights (reference area) - By act mould */ 00106 00107 double grossCoupledPremiums; 00108 double grossDecoupledPayment; 00109 double netTotalPremium; 00110 00111 00112 00113 00114 00115 }; 00116 00117 #endif