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 MANAGERFARMERS_H 00021 #define MANAGERFARMERS_H 00022 00023 #include <QtCore> 00024 //#include <QThread> 00025 #include <QString> 00026 #include <QRunnable> 00027 00028 00029 #include <Manager_space.h> 00030 00031 00032 00033 class Agent_farmer; 00034 00035 struct bidsEstimatedCoefficients; 00036 00037 00039 00045 class Manager_farmers : public Manager_space { 00046 00047 public: 00048 Manager_farmers(ThreadManager* MTHREAD_h, string name_h); 00049 ~Manager_farmers(); 00050 virtual void setAgentMoulds(); 00051 virtual void riseMyAgents(); 00052 virtual void locateMyAgents(); 00053 virtual void createBehaviours(); 00054 virtual void prepare(); 00055 virtual void landAllocation(); 00056 void calibrateLandValues(); 00057 double quotePlot(Pixel* plot); 00058 virtual void act(); 00059 virtual void update(); 00060 virtual void planNext(); 00061 virtual void removeFromModel(Agent_farmer* agent_h); 00062 virtual void endInit(); 00063 00065 virtual void assignPlot(Pixel* plot_h, Agent_space* agent_h, double rentalCost=0, int assignmentType=PLOTS_RENTED); 00066 double getAverageRightsByAct(int mouldCounter=-1); 00067 00068 protected: 00069 vector < vector<double> > sumOfRightsOfDeadAgents; // keep record of rights of dead agents, by each mould 00070 vector < vector<double> > sumOfHaOfDeadAgents; // keep record of surface giving rights of dead agents, by each mould 00071 00072 00073 }; 00074 /* 00075 class Manager_farmers_threads : public QThread { 00076 Q_OBJECT 00077 00078 public: 00079 Manager_farmers_threads(); 00080 void assignJob(Agent_space* agent_h, const Pixel*plot_h, QMutex* mutex_h); 00081 00082 protected: 00083 void run(); 00084 00085 private: 00086 volatile Agent_space* agent; 00087 const Pixel* plot; 00088 QMutex* mutex; 00089 00090 }; 00091 */ 00092 class Manager_farmers_threads : public QRunnable { 00093 00094 public: 00095 Manager_farmers_threads(); 00096 void assignJob(Agent_space* agent_h, const Pixel*plot_h); 00097 00098 protected: 00099 void run(); 00100 00101 private: 00102 volatile Agent_space* agent; 00103 const Pixel* plot; 00104 //QMutex* mutex; 00105 00106 }; 00107 00108 #endif