1 /*
2  *  cReactionProcess.h
3  *  Avida
4  *
5  *  Called "reaction_process.hh" prior to 12/5/05.
6  *  Copyright 1999-2011 Michigan State University. All rights reserved.
7  *  Copyright 1993-2004 California Institute of Technology.
8  *
9  *
10  *  This file is part of Avida.
11  *
12  *  Avida is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
13  *  as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
14  *
15  *  Avida is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
17  *
18  *  You should have received a copy of the GNU Lesser General Public License along with Avida.
19  *  If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef cReactionProcess_h
24 #define cReactionProcess_h
25 
26 #include "avida/Avida.h"
27 
28 #include "cString.h"
29 #include "nReaction.h"
30 
31 #include <iostream>
32 
33 using namespace std;
34 
35 class cResource;
36 
37 
38 
39 class cReactionProcess {
40 private:
41   cResource* resource;  // Resource consumed.
42   double value;          // Efficiency.
43   int type;              // Method of applying bonuses.
44   double max_number;     // Max quantity of resource usable.
45   double min_number;     // Minimum quantity of resource needed (otherwise 0)
46   double max_fraction;   // Max fraction of avaiable resources useable.
47   double k_sub_m;        // k sub m variable needed for enzyme reaction
48   cResource* product;    // Output resource.
49   double conversion;     // Conversion factor.
50   double lethal;		 // Lethality of reaction
51   bool sterilize; //!< Whether performance of this reaction sterilizes the organism.
52   double deme_fraction; //!< Fraction of process reward that is applied to the organism's deme.
53   bool is_germline;         // Apply reward to germline propensity instead of bonus?
54   cString match_string;	 // Bit string to match if this is a match string reaction
55   cString inst;           // Instruction to be triggered if reaction successful.
56   bool depletable;       // Does completing consume resource?
57                          // (This is not quite redundant with an infinite resource
58                          // because it allows the resource level to be sensed @JEB)
59   bool internal;
60   ePHENPLAST_BONUS_METHOD m_ppmethod;  //@MRR How does one handle phenotypically plastic tasks?
61 
62   // Resource detection
63   cResource * detect;    // Resource Measured
64   double detection_threshold; // Min quantity of resource to register present
65   double detection_error; // Var of Detection Event (as % of resource present)
66 
67 
68   cReactionProcess(const cReactionProcess&); // @not_implemented
69   cReactionProcess& operator=(const cReactionProcess&); // @not_implemented
70 
71 public:
cReactionProcess()72   cReactionProcess()
73     : resource(NULL)
74     , value(1.0)
75     , type(nReaction::PROCTYPE_ADD)
76     , max_number(1.0)
77     , min_number(0.0)
78     , max_fraction(1.0)
79     , k_sub_m(0.0)
80     , product(NULL)
81     , conversion(1.0)
82     , lethal(0)
83     , sterilize(false)
84     , deme_fraction(0.0)
85     , is_germline(false)
86     , depletable(true)
87     , internal(false)
88     , m_ppmethod(DEFAULT)
89     , detect(NULL)
90     , detection_threshold(0.0)
91     , detection_error(0.0)
92   {
93   }
~cReactionProcess()94   ~cReactionProcess() { ; }
95 
GetResource()96   cResource* GetResource() const { return resource; }
GetValue()97   double GetValue() const { return value; }
GetType()98   int GetType() const { return type; }
GetMaxNumber()99   double GetMaxNumber() const { return max_number; }
GetMinNumber()100   double GetMinNumber() const { return min_number; }
GetMaxFraction()101   double GetMaxFraction() const { return max_fraction; }
GetKsubM()102   double GetKsubM() const { return k_sub_m; }
GetProduct()103   cResource* GetProduct() const { return product; }
GetConversion()104   double GetConversion() const { return conversion; }
GetInst()105   const cString& GetInst() const { return inst; }
GetDepletable()106   bool GetDepletable() const { return depletable; }
GetLethal()107   double GetLethal() const { return lethal; }
GetSterilize()108   bool GetSterilize() const { return sterilize; }
GetDemeFraction()109   double GetDemeFraction() const { return deme_fraction; }
GetPhenPlastBonusMethod()110   ePHENPLAST_BONUS_METHOD GetPhenPlastBonusMethod() const { return m_ppmethod; }
GetIsGermline()111   bool GetIsGermline() const { return is_germline; }
GetDetect()112   cResource* GetDetect() const { return detect; }
GetDetectionThreshold()113   double GetDetectionThreshold() const { return detection_threshold; }
GetDetectionError()114   double GetDetectionError() const { return detection_error; }
GetMatchString()115   cString GetMatchString() const { return match_string; }
GetInternal()116   double GetInternal() const { return internal; }
117 
SetResource(cResource * _in)118   void SetResource(cResource* _in) { resource = _in; }
SetValue(double _in)119   void SetValue(double _in) { value = _in; }
SetType(int _in)120   void SetType(int _in) { type = _in; }
SetMaxNumber(double _in)121   void SetMaxNumber(double _in) { max_number = _in; }
SetMinNumber(double _in)122   void SetMinNumber(double _in) { min_number = _in; }
SetMaxFraction(double _in)123   void SetMaxFraction(double _in) { max_fraction = _in; }
SetKsubM(double _in)124   void SetKsubM(double _in) { k_sub_m = _in; }
SetProduct(cResource * _in)125   void SetProduct(cResource* _in) { product = _in; }
SetConversion(double _in)126   void SetConversion(double _in) { conversion = _in; }
SetInst(const cString & _in)127   void SetInst(const cString& _in) { inst = _in; }
SetDepletable(bool _in)128   void SetDepletable(bool _in) { depletable = _in; }
SetLethal(double _in)129   void SetLethal(double _in) { lethal = _in; }
SetSterile(int _in)130   void SetSterile(int _in) { sterilize = _in; }
SetDemeFraction(double _in)131   void SetDemeFraction(double _in) { assert(_in>=0.0); assert(_in<=1.0); deme_fraction = _in; }
SetIsGermline(bool _in)132   void SetIsGermline(bool _in) { is_germline = _in; }
SetPhenPlastBonusMethod(ePHENPLAST_BONUS_METHOD _in)133   void SetPhenPlastBonusMethod(ePHENPLAST_BONUS_METHOD _in) { m_ppmethod = _in; }
SetDetect(cResource * _in)134   void SetDetect(cResource* _in) { detect = _in; }
SetDetectionThreshold(double _in)135   void SetDetectionThreshold(double _in) { detection_threshold = _in; }
SetDetectionError(double _in)136   void SetDetectionError(double _in) { detection_error = _in; }
SetMatchString(cString _in)137   void SetMatchString(cString _in) { match_string = _in; }
SetInternal(bool _in)138   void SetInternal(bool _in) { internal = _in; }
139 };
140 
141 #endif
142