<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.6 of lundi 3 mars 2008 on mardi 5 juillet 2011 at 7:03:15</time-stamp>


<name-space>
<name>SimPolillaSimiatug_v02</name>
<environment>CormasNS.Models</environment>
<private>false</private>
<imports>
			private Smalltalk.*
			private CormasNS.Kernel.*
			</imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</name-space>


<class>
<name>Ag_Isolate_12</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_12</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_12</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_012_readAnswerMercy">Ag_Isolate_012_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_12_readAnswer">Ag_Isolate_12_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_12_readMsgHelpAndAnswer">Ag_Isolate_12_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_12_sendMsgHelp">Ag_Isolate_12_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_12_withCom">Ag_Isolate_12_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_12_withoutCom">Ag_Isolate_12_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_12</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=2]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality ifNil: [penality := 3]</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_12</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_12</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_12</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc|

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"7 to: 9 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_0', i printString) asSymbol) withinRange: 5)].
	10 to: 12 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_07 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 12.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_08 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 12.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_09 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 12.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_10 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 12.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_11 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 12.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_12 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 12.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 13 and:[m2 ag &gt; 6 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel]]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 13 and:[m2 ag &gt; 6 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart
"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"

self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 nivelAutre busy|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &gt;6 and:[m1 ag&lt;13 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 12.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=100/self  nivelFormation.] ifTrue:[seuil:=100].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>


<class>
<name>Ag_Isolate_17</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_17</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_17</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_017_readAnswerMercy">Ag_Isolate_017_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_17_readAnswer">Ag_Isolate_17_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_17_readMsgHelpAndAnswer">Ag_Isolate_17_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_17_sendMsgHelp">Ag_Isolate_17_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_17_withCom">Ag_Isolate_17_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_17_withoutCom">Ag_Isolate_17_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_17</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=2]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_17</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_17</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_17</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc|

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"13 to: 18 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_13 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 17.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_14 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 17.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_15 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 17.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_16 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 17.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_17 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 17.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_18 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 17.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &gt; 12 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel
]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &gt; 12 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage := self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 busy nivelAutre|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &gt;12 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 17.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=100/self  nivelFormation.] ifTrue:[seuil:=100].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>


<class>
<name>AgriTest01</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars>niveauFormation </class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AgriTest01 class</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="niveauFormation">niveauFormation
	"Getter accessor with default value = 1 "
	^niveauFormation ifNil:[niveauFormation := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="niveauFormation:">niveauFormation: anObject 
	niveauFormation := anObject</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AgriTest01</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AgriTest01</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="step">step
"En el campo :
	move   fumigar   ponerPapasMasProfundo   "
	self move.
	self fumigar.
	self ponerPapasMasProfundo.

 "En la bodega :
	fumigarBodega   limpiar   verificarPolillaYBotar   verificarPolillaYDestruir   "
self patch bodega=1 ifTrue:[
	self fumigarBodega.
	self limpiar.
	self verificarPolillaYBotar.
	self verificarPolillaYDestruir.
	].
"En el mercado/pueblo :
	comprarSemillas   comprarSemillasVerificar   venderPapas   venderPapasSanas"
self patch population&gt;0 ifTrue:[
	].</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AgriTest01</class-id> <category>alCampo</category>

<body package="SimPolillaSimiatug_v02" selector="fumigar">fumigar
|eficacidadTratamientoChimico seuil|

"Aqui se entran las caracteristicas del campesino"
eficacidadTratamientoChimico:=0.5.
seuil:=100/self class niveauFormation.

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*eficacidadTratamientoChimico].
self patch phthorimaea&gt;(seuil) ifTrue:[self patch phthorimaea: self patch phthorimaea*eficacidadTratamientoChimico].
self patch symmetrischemma&gt;(seuil) ifTrue:[self patch symmetrischemma: self patch symmetrischemma*eficacidadTratamientoChimico].</body>

<body package="SimPolillaSimiatug_v02" selector="move">move 
	self randomWalkConstrainedBy: [:c | c noOccupant].
</body>

<body package="SimPolillaSimiatug_v02" selector="moveAndThink">moveAndThink
 | teciaNeighbours | 

teciaNeighbours := self patch neighbourhood select: [:c | c patch = self patch bufferNumberTeciaFemale]. 

teciaNeighbours isEmpty
 	ifTrue: [self randomWalk]
 	ifFalse: [self leave. 
			self moveTo: (Cormas selectRandomlyFrom: teciaNeighbours)].
(self perception:15).</body>

<body package="SimPolillaSimiatug_v02" selector="ponerPapasMasProfundo">ponerPapasMasProfundo
|eficacidadTecnica|

eficacidadTecnica:=0.2.

self patch tecia: self patch tecia*eficacidadTecnica.
self patch phthorimaea: self patch phthorimaea*eficacidadTecnica.
self patch symmetrischemma: self patch symmetrischemma*eficacidadTecnica.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AgriTest01</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#AgriTest01.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AgriTest01</class-id> <category>alAlmacen</category>

<body package="SimPolillaSimiatug_v02" selector="fumigarBodega">fumigarBodega
</body>

<body package="SimPolillaSimiatug_v02" selector="limpiar">limpiar
"verificarPolillaYBotar   verificarPolillaYDestruir"</body>

<body package="SimPolillaSimiatug_v02" selector="verificarPolillaYBotar">verificarPolillaYBotar
"verificarPolillaYDestruir"</body>

<body package="SimPolillaSimiatug_v02" selector="verificarPolillaYDestruir">verificarPolillaYDestruir
</body>
</methods>


<class>
<name>Ag_Isolate_18</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_18</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_18</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_018_readAnswerMercy">Ag_Isolate_018_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_18_readAnswer">Ag_Isolate_18_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_18_readMsgHelpAndAnswer">Ag_Isolate_18_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_18_sendMsgHelp">Ag_Isolate_18_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_18_withCom">Ag_Isolate_18_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_18_withoutCom">Ag_Isolate_18_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_18</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=2]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_18</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_18</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_18</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc|

	stoPerc:=  (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"13 to: 18 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_13 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 18.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: 1.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_14 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 18.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_15 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 18.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_16 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 18.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_17 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 18.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_18 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 18.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &gt; 12 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel
]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &gt; 12 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage := self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 nivelAutre busy|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &gt;12 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 18.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo


	| eficacidadTratamientoChimico seuil |
	eficacidadTratamientoChimico := self nivelFormation * 0.2*((Cormas randomFrom:80 to:120)/100).
	self nivelFormation = 0 
		ifFalse: [seuil := 100 / self nivelFormation]
		ifTrue: [seuil := 100].
	self patch tecia &gt; seuil 
		ifTrue: 
			[self patch tecia: self patch tecia * (1 - eficacidadTratamientoChimico)]</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>


<class>
<name>AggregateTecia</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.SpatialEntityAggregate</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>agreTec </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AggregateTecia</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AggregateTecia</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov
^self size &gt; self agreTec
ifTrue: [#needHelp]
ifFalse: [#noHelpNeeded]</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AggregateTecia</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="agreTec">agreTec
	^agreTec ifNil:[agreTec := 10]</body>

<body package="SimPolillaSimiatug_v02" selector="agreTec:">agreTec: anObject
	agreTec := anObject</body>
</methods>


<class>
<name>Aggregate</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.SpatialEntityAggregate</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Aggregate</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Aggregate</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov
^self size &gt; 10
ifTrue: [#needHelp]
ifFalse: [#noHelpNeeded]</body>
</methods>


<class>
<name>MsgTecia</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.Msg</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>location </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.MsgTecia</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="location">location
	^location</body>

<body package="SimPolillaSimiatug_v02" selector="location:">location: anObject
	location := anObject</body>
</methods>


<class>
<name>AggregateSymmetrischema</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.SpatialEntityAggregate</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>agreSym </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AggregateSymmetrischema</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AggregateSymmetrischema</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="agreSym">agreSym
	^agreSym ifNil:[agreSym := 10]</body>

<body package="SimPolillaSimiatug_v02" selector="agreSym:">agreSym: anObject
	agreSym := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AggregateSymmetrischema</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov
^self size &gt; self agreSym
ifTrue: [#needHelp]
ifFalse: [#noHelpNeeded]</body>
</methods>


<class>
<name>Ag_Isolate_08</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_08</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_08</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_08_readAnswer">Ag_Isolate_08_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_08_readAnswerMercy">Ag_Isolate_08_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_08_readMsgHelpAndAnswer">Ag_Isolate_08_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_08_sendMsgHelp">Ag_Isolate_08_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_08_withCom">Ag_Isolate_08_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_08_withoutCom">Ag_Isolate_08_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_08</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=1]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_08</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_08</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_08</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc|

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"7 to: 9 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_0', i printString) asSymbol) withinRange: 5)].
	10 to: 12 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_07 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 8.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_08 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 8.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_09 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 8.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_10 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 8.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_11 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 8.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_12 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 8.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 13 and:[m2 ag &gt; 6 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel]]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 13 and:[m2 ag &gt; 6 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 busy nivelAutre |

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &gt;6 and:[m1 ag&lt;13 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 8.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=100/self  nivelFormation.] ifTrue:[seuil:=100].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>


<class>
<name>SimPolillaSimiatug_v02</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.CormasModel</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>theCells theAgriTest01s theAgri01s theAgri02s theAgri03s theAgri04s theAgri05s theAggregates theAggregateTecias theAggregatePhthorimaeas theAggregateSymmetrischemas theAg_Isolate_01s theAg_Isolate_02s theAg_Isolate_03s theAg_Isolate_04s theAg_Isolate_05s theAg_Isolate_06s theAg_Isolate_07s theAg_Isolate_08s theAg_Isolate_09s theAg_Isolate_10s theAg_Isolate_11s theAg_Isolate_12s theAg_Isolate_13s theAg_Isolate_14s theAg_Isolate_15s theAg_Isolate_16s theAg_Isolate_17s theAg_Isolate_18s decalage </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.SimPolillaSimiatug_v02 class</class-id> <category>description</category>

<body package="SimPolillaSimiatug_v02" selector="authors">authors
^ 'François Rebaudo
Olivier Dangles
'</body>

<body package="SimPolillaSimiatug_v02" selector="comments">comments
^ 'IRD-McKnight-PUCE-INIAP
Density dependent dispersion model of the threee invasive tuber moth species in the tropical Andes (Ecuador - Bolivar - Simiatug) : Tecia solanivora, Phthorimaea operculella and symmetrischemma tangolias.
This study received financial support from the McKnight fundation.'</body>

<body package="SimPolillaSimiatug_v02" selector="creationDate">creationDate
^ '8 nov 2007'	</body>

<body package="SimPolillaSimiatug_v02" selector="emails">emails
^ 'rebaudo@gmail.com

'	</body>

<body package="SimPolillaSimiatug_v02" selector="lastUpdate">lastUpdate
^ 'mardi 5 juillet 2011'	</body>

<body package="SimPolillaSimiatug_v02" selector="version">version
^ 'rebaudo_plos_comp_biol.st'	</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.SimPolillaSimiatug_v02</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="load_SMA_isolate">load_SMA_isolate
"ES = Para cargar los distintas capas que vienen de los SIG"
"US = To upload the different layers from GIS into the model"

self spaceModel loadEnvironmentFromFile: 'SMA-ind-tempPromedio.env' withPov:#povPTMteciaFemale.
self spaceModel addEnvironmentDataFromFile: 'SMA-ind-agro.env'.
self spaceModel addEnvironmentDataFromFile: 'SMA-ind-village.env'.
self spaceModel addEnvironmentDataFromFile: 'SMA-ind-village2.env'.
self spaceModel addEnvironmentDataFromFile: 'SMA-ind-population.env'.

self spaceModel addEnvironmentDataFromFile: 'SMA-ind-TECIA.env'.
self spaceModel addEnvironmentDataFromFile: 'SMA-ind-TECIA2.env'.

"ES = Para cortar el mapa en cuadros que representan las comunidades"
"US = To seperate the landscape into communities representing villages at different elevations"
self spaceModel addEnvironmentDataFromFile: 'SMA-ind-agroPart.env'.
self spaceModel addEnvironmentDataFromFile: 'SMA-ind-agroPartPart.env'.

	self initCells.
	self initAgentsIsolate.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.SimPolillaSimiatug_v02</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="decalage">decalage
	^decalage ifNil:[decalage:= 0].</body>

<body package="SimPolillaSimiatug_v02" selector="decalage:">decalage: anObject
	decalage := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="theAggregatePhthorimaeas">theAggregatePhthorimaeas
^theAggregatePhthorimaeas ifNil:[theAggregatePhthorimaeas := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAggregatePhthorimaeas:">theAggregatePhthorimaeas: x
theAggregatePhthorimaeas := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAggregates">theAggregates
^theAggregates ifNil:[theAggregates := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAggregates:">theAggregates: x
theAggregates := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAggregateSymmetrischemas">theAggregateSymmetrischemas
^theAggregateSymmetrischemas ifNil:[theAggregateSymmetrischemas := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAggregateSymmetrischemas:">theAggregateSymmetrischemas: x
theAggregateSymmetrischemas := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAggregateTecias">theAggregateTecias
^theAggregateTecias ifNil:[theAggregateTecias := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAggregateTecias:">theAggregateTecias: x
theAggregateTecias := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAgri01s">theAgri01s
^theAgri01s ifNil:[theAgri01s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAgri01s:">theAgri01s: x
theAgri01s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAgri02s">theAgri02s
^theAgri02s ifNil:[theAgri02s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAgri02s:">theAgri02s: x
theAgri02s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAgri03s">theAgri03s
^theAgri03s ifNil:[theAgri03s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAgri03s:">theAgri03s: x
theAgri03s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAgri04s">theAgri04s
^theAgri04s ifNil:[theAgri04s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAgri04s:">theAgri04s: x
theAgri04s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAgri05s">theAgri05s
^theAgri05s ifNil:[theAgri05s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAgri05s:">theAgri05s: x
theAgri05s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAgriTest01s">theAgriTest01s
^theAgriTest01s ifNil:[theAgriTest01s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAgriTest01s:">theAgriTest01s: x
theAgriTest01s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_01s">theAg_Isolate_01s
^theAg_Isolate_01s ifNil:[theAg_Isolate_01s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_01s:">theAg_Isolate_01s: x
theAg_Isolate_01s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_02s">theAg_Isolate_02s
^theAg_Isolate_02s ifNil:[theAg_Isolate_02s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_02s:">theAg_Isolate_02s: x
theAg_Isolate_02s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_03s">theAg_Isolate_03s
^theAg_Isolate_03s ifNil:[theAg_Isolate_03s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_03s:">theAg_Isolate_03s: x
theAg_Isolate_03s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_04s">theAg_Isolate_04s
^theAg_Isolate_04s ifNil:[theAg_Isolate_04s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_04s:">theAg_Isolate_04s: x
theAg_Isolate_04s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_05s">theAg_Isolate_05s
^theAg_Isolate_05s ifNil:[theAg_Isolate_05s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_05s:">theAg_Isolate_05s: x
theAg_Isolate_05s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_06s">theAg_Isolate_06s
^theAg_Isolate_06s ifNil:[theAg_Isolate_06s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_06s:">theAg_Isolate_06s: x
theAg_Isolate_06s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_07s">theAg_Isolate_07s
^theAg_Isolate_07s ifNil:[theAg_Isolate_07s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_07s:">theAg_Isolate_07s: x
theAg_Isolate_07s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_08s">theAg_Isolate_08s
^theAg_Isolate_08s ifNil:[theAg_Isolate_08s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_08s:">theAg_Isolate_08s: x
theAg_Isolate_08s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_09s">theAg_Isolate_09s
^theAg_Isolate_09s ifNil:[theAg_Isolate_09s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_09s:">theAg_Isolate_09s: x
theAg_Isolate_09s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_10s">theAg_Isolate_10s
^theAg_Isolate_10s ifNil:[theAg_Isolate_10s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_10s:">theAg_Isolate_10s: x
theAg_Isolate_10s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_11s">theAg_Isolate_11s
^theAg_Isolate_11s ifNil:[theAg_Isolate_11s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_11s:">theAg_Isolate_11s: x
theAg_Isolate_11s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_12s">theAg_Isolate_12s
^theAg_Isolate_12s ifNil:[theAg_Isolate_12s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_12s:">theAg_Isolate_12s: x
theAg_Isolate_12s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_13s">theAg_Isolate_13s
^theAg_Isolate_13s ifNil:[theAg_Isolate_13s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_13s:">theAg_Isolate_13s: x
theAg_Isolate_13s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_14s">theAg_Isolate_14s
^theAg_Isolate_14s ifNil:[theAg_Isolate_14s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_14s:">theAg_Isolate_14s: x
theAg_Isolate_14s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_15s">theAg_Isolate_15s
^theAg_Isolate_15s ifNil:[theAg_Isolate_15s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_15s:">theAg_Isolate_15s: x
theAg_Isolate_15s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_16s">theAg_Isolate_16s
^theAg_Isolate_16s ifNil:[theAg_Isolate_16s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_16s:">theAg_Isolate_16s: x
theAg_Isolate_16s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_17s">theAg_Isolate_17s
^theAg_Isolate_17s ifNil:[theAg_Isolate_17s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_17s:">theAg_Isolate_17s: x
theAg_Isolate_17s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_18s">theAg_Isolate_18s
^theAg_Isolate_18s ifNil:[theAg_Isolate_18s := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="theAg_Isolate_18s:">theAg_Isolate_18s: x
theAg_Isolate_18s := x</body>

<body package="SimPolillaSimiatug_v02" selector="theCells:">theCells: x
theCells := x</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.SimPolillaSimiatug_v02</class-id> <category>probes</category>

<body package="SimPolillaSimiatug_v02" selector="aa">aa
|env rec|
env:=self theAg_Isolate_02s inject:0 into:[:tot :f | tot + f nbrMailsRcp].
rec:=self theAg_Isolate_02s inject:0 into:[:tot :f | tot + f nbrMailsTrt].
^env-rec</body>

<body package="SimPolillaSimiatug_v02" selector="aaa">aaa
^self theAg_Isolate_02s inject:0 into:[:tot :f | tot + f nbrMailsTrt]</body>

<body package="SimPolillaSimiatug_v02" selector="aaaa">aaaa
^self theAg_Isolate_02s inject:0 into:[:tot :f | tot + f nbrMailsRcp]</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_1">agroPartPart_1
|com3 i|

i:=1.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_11">agroPartPart_11
|com3 i|

i:=7.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_12">agroPartPart_12
|com3 i|

i:=8.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_13">agroPartPart_13
|com3 i|

i:=9.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_14">agroPartPart_14
|com3 i|

i:=10.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_15">agroPartPart_15
|com3 i|

i:=11.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_16">agroPartPart_16
|com3 i|

i:=12.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_2">agroPartPart_2
|com3 i|

i:=2.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_21">agroPartPart_21
|com3 i|

i:=13.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_22">agroPartPart_22
|com3 i|

i:=14.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_23">agroPartPart_23
|com3 i|

i:=15.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_24">agroPartPart_24
|com3 i|

i:=16.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_25">agroPartPart_25
|com3 i|

i:=17.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_26">agroPartPart_26
|com3 i|

i:=18.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_3">agroPartPart_3
|com3 i|

i:=3.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_4">agroPartPart_4
|com3 i|

i:=4.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_5">agroPartPart_5
|com3 i|

i:=5.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart_6">agroPartPart_6
|com3 i|

i:=6.

	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ]).

	^(com3) size /6</body>

<body package="SimPolillaSimiatug_v02" selector="agroPart_1">agroPart_1
|com1 com2 com3 i|

i:=1.

	com1:= (self theCells select: [:g | g agroPart==i]).
	com2:= (self theCells select: [:f | f bufferNumberTeciaFemale&gt;1]).
	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPart==i] ]).

	^(com3) size /36</body>

<body package="SimPolillaSimiatug_v02" selector="agroPart_2">agroPart_2
|com3 i|
	i:=2.
	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPart==i] ]).
	^(com3) size /36</body>

<body package="SimPolillaSimiatug_v02" selector="agroPart_3">agroPart_3
|com3 i|
	i:=3.
	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPart==i] ]).
	^(com3) size /36</body>

<body package="SimPolillaSimiatug_v02" selector="difTempSP">difTempSP
|pro sto|

pro:=self theCells inject: 0 into: [:i :j | i +j tempStochastic].
sto:=self theCells inject: 0 into: [:i :j | i +j tempPromedio].

^sto - pro</body>

<body package="SimPolillaSimiatug_v02" selector="mailRECUS">mailRECUS
^self theAg_Isolate_02s inject:0 into:[:tot :f | tot + f nbrMailsRcp]</body>

<body package="SimPolillaSimiatug_v02" selector="mailRECU_TRT">mailRECU_TRT
|env rec|
env:=self theAg_Isolate_02s inject:0 into:[:tot :f | tot + f nbrMailsRcp].
rec:=self theAg_Isolate_02s inject:0 into:[:tot :f | tot + f nbrMailsTrt].
^env-rec</body>

<body package="SimPolillaSimiatug_v02" selector="mailTRT">mailTRT
^self theAg_Isolate_02s inject:0 into:[:tot :f | tot + f nbrMailsTrt]</body>

<body package="SimPolillaSimiatug_v02" selector="NBRmailSent">NBRmailSent
^self theAg_Isolate_02s inject:0 into:[:tot :f | tot + f mailSent]</body>

<body package="SimPolillaSimiatug_v02" selector="NBRmailSentRsp">NBRmailSentRsp
^self theAg_Isolate_02s inject:0 into:[:tot :f | tot + f mailSentRsp]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_01">nivel_is_01
^self theAg_Isolate_01s inject:0 into:[:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_02">nivel_is_02
^self theAg_Isolate_02s inject:0 into:[:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_03">nivel_is_03
^self theAg_Isolate_03s inject:0 into:[:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_04">nivel_is_04
^self theAg_Isolate_04s inject:0 into:[:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_05">nivel_is_05
^self theAg_Isolate_05s inject:0 into:[:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_06">nivel_is_06
^self theAg_Isolate_06s inject:0 into:[:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_07">nivel_is_07
^self theAg_Isolate_07s inject:0 into:[:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_08">nivel_is_08
	^self theAg_Isolate_08s inject: 0 into: [:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_09">nivel_is_09
	^self theAg_Isolate_09s inject: 0 into: [:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_10">nivel_is_10
	^self theAg_Isolate_10s inject: 0 into: [:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_11">nivel_is_11
	^self theAg_Isolate_11s inject: 0 into: [:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_12">nivel_is_12
	^self theAg_Isolate_12s inject: 0 into: [:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_13">nivel_is_13
	^self theAg_Isolate_13s inject: 0 into: [:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_14">nivel_is_14
	^self theAg_Isolate_14s inject: 0 into: [:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_15">nivel_is_15
	^self theAg_Isolate_15s inject: 0 into: [:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_16">nivel_is_16
	^self theAg_Isolate_16s inject: 0 into: [:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_17">nivel_is_17
	^self theAg_Isolate_17s inject: 0 into: [:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="nivel_is_18">nivel_is_18
	^self theAg_Isolate_18s inject: 0 into: [:tot :f | tot + f nivelFormation]</body>

<body package="SimPolillaSimiatug_v02" selector="PH">PH
	^self theCells inject: 0 into: [:i :j | i + j bufferNumberPhthorimaeaFemale].</body>

<body package="SimPolillaSimiatug_v02" selector="PHnumber1">PHnumber1
	^(self theCells select: [:f | f bufferNumberPhthorimaeaFemale&gt;1])size.</body>

<body package="SimPolillaSimiatug_v02" selector="PHnumber100">PHnumber100
	^(self theCells select: [:f | f bufferNumberPhthorimaeaFemale&gt;100])size.</body>

<body package="SimPolillaSimiatug_v02" selector="PHnumber200">PHnumber200
	^(self theCells select: [:f | f bufferNumberPhthorimaeaFemale&gt;200])size.</body>

<body package="SimPolillaSimiatug_v02" selector="prix_helped">prix_helped
|com1 com10 com100 comClean i j prix prixG prixG1 prixG2 prixG4 prixG5 prixG6 class1 class2 class3 class4|
	
	prixG:=0.
	class1:=1.
	class2:=0.8.
	class3:=0.5.
	class4:=0.2.
	j:=(Cormas randomFrom:1 to:96).
	prix:=Set new.
	prix := #(94 137 234 255 247 221 201 203 271 274 629 300 228 342 331 238 200 142 100 81 83 100 116 182 206 167 229 189 149 134 130 138 190 229 290 346 340 311 221 255 172 151 185 187 177 198 204 220 221 204 181 199 154 181 177 200 213 185 159 138 134 137 142 150 169 159 207 242 298 282 225 228 266 310 342 354 360 258 367 342 303 231 151 152 179 238 303 315 300 243 263 170 139 118 135 136 188 175 188 230 227 204 180 175).

	i:=1.
	com100:=1-((self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ])size /6).
	com10:=1-(((self theCells select: [:f | f bufferNumberTeciaFemale&gt;10 and: [f agroPartPart==i] ])size /6)-com100).
	com1:=1-(((self theCells select: [:f | f bufferNumberTeciaFemale&gt;1 and: [f agroPartPart==i] ])size /6)-com100 -com10).
	comClean:=1-((self theCells select: [:f | f bufferNumberTeciaFemale=0 and: [f agroPartPart==i] ])size /6).
	prixG1:= ((prix at:j) *comClean*class1) + ((prix at:j) *com1*class2) + ((prix at:j) *com10*class3) + ((prix at:j) *com100*class4) .
	i:=2.
	com100:=1-((self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ])size /6).
	com10:=1-(((self theCells select: [:f | f bufferNumberTeciaFemale&gt;10 and: [f agroPartPart==i] ])size /6)-com100).
	com1:=1-(((self theCells select: [:f | f bufferNumberTeciaFemale&gt;1 and: [f agroPartPart==i] ])size /6)-com100 -com10).
	comClean:=1-((self theCells select: [:f | f bufferNumberTeciaFemale=0 and: [f agroPartPart==i] ])size /6).
	prixG2:= ((prix at:j) *comClean*class1) + ((prix at:j) *com1*class2) + ((prix at:j) *com10*class3) + ((prix at:j) *com100*class4) .
	i:=4.
	com100:=1-((self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ])size /6).
	com10:=1-(((self theCells select: [:f | f bufferNumberTeciaFemale&gt;10 and: [f agroPartPart==i] ])size /6)-com100).
	com1:=1-(((self theCells select: [:f | f bufferNumberTeciaFemale&gt;1 and: [f agroPartPart==i] ])size /6)-com100 -com10).
	comClean:=1-((self theCells select: [:f | f bufferNumberTeciaFemale=0 and: [f agroPartPart==i] ])size /6).
	prixG4:= ((prix at:j) *comClean*class1) + ((prix at:j) *com1*class2) + ((prix at:j) *com10*class3) + ((prix at:j) *com100*class4) .
	i:=5.
	com100:=1-((self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ])size /6).
	com10:=1-(((self theCells select: [:f | f bufferNumberTeciaFemale&gt;10 and: [f agroPartPart==i] ])size /6)-com100).
	com1:=1-(((self theCells select: [:f | f bufferNumberTeciaFemale&gt;1 and: [f agroPartPart==i] ])size /6)-com100 -com10).
	comClean:=1-((self theCells select: [:f | f bufferNumberTeciaFemale=0 and: [f agroPartPart==i] ])size /6).
	prixG5:= ((prix at:j) *comClean*class1) + ((prix at:j) *com1*class2) + ((prix at:j) *com10*class3) + ((prix at:j) *com100*class4) .
	i:=6.
	com100:=1-((self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ])size /6).
	com10:=1-(((self theCells select: [:f | f bufferNumberTeciaFemale&gt;10 and: [f agroPartPart==i] ])size /6)-com100).
	com1:=1-(((self theCells select: [:f | f bufferNumberTeciaFemale&gt;1 and: [f agroPartPart==i] ])size /6)-com100 -com10).
	comClean:=1-((self theCells select: [:f | f bufferNumberTeciaFemale=0 and: [f agroPartPart==i] ])size /6).
	prixG6:= ((prix at:j) *comClean*class1) + ((prix at:j) *com1*class2) + ((prix at:j) *com10*class3) + ((prix at:j) *com100*class4) .

prixG:=(prixG1+prixG2+prixG4+prixG5+prixG6)/5.

	^prixG</body>

<body package="SimPolillaSimiatug_v02" selector="prix_helper">prix_helper
|com1 com10 com100 comClean i j prix prixG class1 class2 class3 class4|
	
	prixG:=0.
	i:=3.
	class1:=1.
	class2:=0.8.
	class3:=0.5.
	class4:=0.2.

	com100:=1-((self theCells select: [:f | f bufferNumberTeciaFemale&gt;100 and: [f agroPartPart==i] ])size /6).
	com10:=1-(((self theCells select: [:f | f bufferNumberTeciaFemale&gt;10 and: [f agroPartPart==i] ])size /6)-com100).
	com1:=1-(((self theCells select: [:f | f bufferNumberTeciaFemale&gt;1 and: [f agroPartPart==i] ])size /6)-com100 -com10).
	comClean:=1-((self theCells select: [:f | f bufferNumberTeciaFemale=0 and: [f agroPartPart==i] ])size /6).


	j:=(Cormas randomFrom:1 to:96).

	prix:=Set new.

	prix := #(94 137 234 255 247 221 201 203 271 274 629 300 228 342 331 238 200 142 100 81 83 100 116 182 206 167 229 189 149 134 130 138 190 229 290 346 340 311 221 255 172 151 185 187 177 198 204 220 221 204 181 199 154 181 177 200 213 185 159 138 134 137 142 150 169 159 207 242 298 282 225 228 266 310 342 354 360 258 367 342 303 231 151 152 179 238 303 315 300 243 263 170 139 118 135 136 188 175 188 230 227 204 180 175).

	prixG:= ((prix at:j) *comClean*class1) + ((prix at:j) *com1*class2) + ((prix at:j) *com10*class3) + ((prix at:j) *com100*class4) .

	^prixG</body>

<body package="SimPolillaSimiatug_v02" selector="prix_ref">prix_ref
| j prix prixG |
	
	prixG:=0.

	j:=(Cormas randomFrom:1 to:96).

	prix:=Set new.

	prix := #(94 137 234 255 247 221 201 203 271 274 629 300 228 342 331 238 200 142 100 81 83 100 116 182 206 167 229 189 149 134 130 138 190 229 290 346 340 311 221 255 172 151 185 187 177 198 204 220 221 204 181 199 154 181 177 200 213 185 159 138 134 137 142 150 169 159 207 242 298 282 225 228 266 310 342 354 360 258 367 342 303 231 151 152 179 238 303 315 300 243 263 170 139 118 135 136 188 175 188 230 227 204 180 175).

	prixG:= ((prix at:j) *6) .

	^prixG</body>

<body package="SimPolillaSimiatug_v02" selector="qualityHabitat">qualityHabitat
	^self theCells inject: 0 into: [:i :j | i/44 + j qualityHabitat].</body>

<body package="SimPolillaSimiatug_v02" selector="SMA_PH_nbr1_com1">SMA_PH_nbr1_com1
|com1 com2 com3|

	com1:= (self theCells select: [:g | g agroPart==1]).
	com2:= (self theCells select: [:f | f bufferNumberTeciaFemale&gt;1]).
	com3:=(self theCells select: [:f | f bufferNumberTeciaFemale&gt;1 and: [f agroPart==1]  ]).

	^(com3) size</body>

<body package="SimPolillaSimiatug_v02" selector="SY">SY
	^self theCells inject: 0 into: [:i :j | i + j bufferNumberSymmetrischemaFemale].</body>

<body package="SimPolillaSimiatug_v02" selector="SYnumber1">SYnumber1
	^(self theCells select: [:f | f bufferNumberSymmetrischemaFemale&gt;1])size.</body>

<body package="SimPolillaSimiatug_v02" selector="SYnumber100">SYnumber100
	^(self theCells select: [:f | f bufferNumberSymmetrischemaFemale&gt;100])size.</body>

<body package="SimPolillaSimiatug_v02" selector="SYnumber200">SYnumber200
	^(self theCells select: [:f | f bufferNumberSymmetrischemaFemale&gt;200])size.</body>

<body package="SimPolillaSimiatug_v02" selector="TE">TE
	^self theCells inject: 0 into: [:i :j | i + j bufferNumberTeciaFemale].</body>

<body package="SimPolillaSimiatug_v02" selector="TempStochastic">TempStochastic
	^self theCells inject: 0 into: [:i :j | i/80 +j tempStochastic]</body>

<body package="SimPolillaSimiatug_v02" selector="TEnumber1">TEnumber1
	^(self theCells select: [:f | f bufferNumberTeciaFemale&gt;1])size.</body>

<body package="SimPolillaSimiatug_v02" selector="TEnumber100">TEnumber100
	^(self theCells select: [:f | f bufferNumberTeciaFemale&gt;100])size.</body>

<body package="SimPolillaSimiatug_v02" selector="TEnumber200">TEnumber200
	^(self theCells select: [:f | f bufferNumberTeciaFemale&gt;200])size.</body>

<body package="SimPolillaSimiatug_v02" selector="theCells">theCells
^theCells ifNil:[theCells := IndexedSet new]</body>

<body package="SimPolillaSimiatug_v02" selector="ZProbe">ZProbe
	^self theCells inject: 0 into: [:i :j | i + j probe].</body>

<body package="SimPolillaSimiatug_v02" selector="ZstoPec">ZstoPec
	^self theCells inject: 0 into: [:i :j | i + j stoPec].</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.SimPolillaSimiatug_v02</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="stepSMA_isolate:">stepSMA_isolate: t

super stepEntities: self theCells.
self initAggregates. 
self initAggregatesTecia. 

"NON STAGE DEPENDENT---------------------------------------------------"
self theESE do: [:aCell | aCell initVariablesIsolate].
self theESE do: [:aCell | aCell constructAgroPart].
self theESE do: [:aCell | aCell updateTempStochastic].
self theESE do: [:aCell | aCell updateQualityHabitat].

"AGENT DEPENDENT-----------------------------------------------------------"
self theAg_Isolate_01s do: [:fm | fm Ag_Isolate_01_sendMsgHelp].
self theAg_Isolate_02s do: [:fm | fm Ag_Isolate_02_sendMsgHelp].
self theAg_Isolate_03s do: [:fm | fm Ag_Isolate_03_sendMsgHelp].
self theAg_Isolate_04s do: [:fm | fm Ag_Isolate_04_sendMsgHelp].
self theAg_Isolate_05s do: [:fm | fm Ag_Isolate_05_sendMsgHelp].
self theAg_Isolate_06s do: [:fm | fm Ag_Isolate_06_sendMsgHelp].
self theAg_Isolate_01s do: [:fm | fm Ag_Isolate_01_readMsgHelpAndAnswer].
self theAg_Isolate_02s do: [:fm | fm Ag_Isolate_02_readMsgHelpAndAnswer].
self theAg_Isolate_03s do: [:fm | fm Ag_Isolate_03_readMsgHelpAndAnswer].
self theAg_Isolate_04s do: [:fm | fm Ag_Isolate_04_readMsgHelpAndAnswer].
self theAg_Isolate_05s do: [:fm | fm Ag_Isolate_05_readMsgHelpAndAnswer].
self theAg_Isolate_06s do: [:fm | fm Ag_Isolate_06_readMsgHelpAndAnswer].
self theAg_Isolate_01s do: [:fm | fm Ag_Isolate_01_readAnswer].
self theAg_Isolate_02s do: [:fm | fm Ag_Isolate_02_readAnswer].
self theAg_Isolate_03s do: [:fm | fm Ag_Isolate_03_readAnswer].
self theAg_Isolate_04s do: [:fm | fm Ag_Isolate_04_readAnswer].
self theAg_Isolate_05s do: [:fm | fm Ag_Isolate_05_readAnswer].
self theAg_Isolate_06s do: [:fm | fm Ag_Isolate_06_readAnswer].
self theAg_Isolate_07s do: [:fm | fm Ag_Isolate_07_sendMsgHelp].
self theAg_Isolate_08s do: [:fm | fm Ag_Isolate_08_sendMsgHelp].
self theAg_Isolate_09s do: [:fm | fm Ag_Isolate_09_sendMsgHelp].
self theAg_Isolate_10s do: [:fm | fm Ag_Isolate_10_sendMsgHelp].
self theAg_Isolate_11s do: [:fm | fm Ag_Isolate_11_sendMsgHelp].
self theAg_Isolate_12s do: [:fm | fm Ag_Isolate_12_sendMsgHelp].
self theAg_Isolate_07s do: [:fm | fm Ag_Isolate_07_readMsgHelpAndAnswer].
self theAg_Isolate_08s do: [:fm | fm Ag_Isolate_08_readMsgHelpAndAnswer].
self theAg_Isolate_09s do: [:fm | fm Ag_Isolate_09_readMsgHelpAndAnswer].
self theAg_Isolate_10s do: [:fm | fm Ag_Isolate_10_readMsgHelpAndAnswer].
self theAg_Isolate_11s do: [:fm | fm Ag_Isolate_11_readMsgHelpAndAnswer].
self theAg_Isolate_12s do: [:fm | fm Ag_Isolate_12_readMsgHelpAndAnswer].
self theAg_Isolate_07s do: [:fm | fm Ag_Isolate_07_readAnswer].
self theAg_Isolate_08s do: [:fm | fm Ag_Isolate_08_readAnswer].
self theAg_Isolate_09s do: [:fm | fm Ag_Isolate_09_readAnswer].
self theAg_Isolate_10s do: [:fm | fm Ag_Isolate_10_readAnswer].
self theAg_Isolate_11s do: [:fm | fm Ag_Isolate_11_readAnswer].
self theAg_Isolate_12s do: [:fm | fm Ag_Isolate_12_readAnswer].
self theAg_Isolate_13s do: [:fm | fm Ag_Isolate_13_sendMsgHelp].
self theAg_Isolate_14s do: [:fm | fm Ag_Isolate_14_sendMsgHelp].
self theAg_Isolate_15s do: [:fm | fm Ag_Isolate_15_sendMsgHelp].
self theAg_Isolate_16s do: [:fm | fm Ag_Isolate_16_sendMsgHelp].
self theAg_Isolate_17s do: [:fm | fm Ag_Isolate_17_sendMsgHelp].
self theAg_Isolate_18s do: [:fm | fm Ag_Isolate_18_sendMsgHelp].
self theAg_Isolate_13s do: [:fm | fm Ag_Isolate_13_readMsgHelpAndAnswer].
self theAg_Isolate_14s do: [:fm | fm Ag_Isolate_14_readMsgHelpAndAnswer].
self theAg_Isolate_15s do: [:fm | fm Ag_Isolate_15_readMsgHelpAndAnswer].
self theAg_Isolate_16s do: [:fm | fm Ag_Isolate_16_readMsgHelpAndAnswer].
self theAg_Isolate_17s do: [:fm | fm Ag_Isolate_17_readMsgHelpAndAnswer].
self theAg_Isolate_18s do: [:fm | fm Ag_Isolate_18_readMsgHelpAndAnswer].
self theAg_Isolate_13s do: [:fm | fm Ag_Isolate_13_readAnswer].
self theAg_Isolate_14s do: [:fm | fm Ag_Isolate_14_readAnswer].
self theAg_Isolate_15s do: [:fm | fm Ag_Isolate_15_readAnswer].
self theAg_Isolate_16s do: [:fm | fm Ag_Isolate_16_readAnswer].
self theAg_Isolate_17s do: [:fm | fm Ag_Isolate_17_readAnswer].
self theAg_Isolate_18s do: [:fm | fm Ag_Isolate_18_readAnswer].

"RELATIVE TO JUVENILES---------------------------------------------------"
self theESE do: [:aCell | aCell updateSurvivalRateIsolate].
self theESE do: [:aCell | aCell diePTMJuveniles].

"RELATIVE TO ADULTS--------------------------------------------------------"
self theESE do: [:aCell | aCell diePTMAdults].
self theESE do: [:aCell | aCell movePTM_exp].	
self theESE do: [:aCell | aCell updatePTMdispersion].

"RELATIVE TO FEMALES------------------------------------------------------"
self theESE do: [:aCell | aCell updateRateLife].
self theESE do: [:aCell | aCell updateFecundityFemale].
self theESE do: [:aCell | aCell reproduceFemales].
self theESE do: [:aCell | aCell dieAllPTM].</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.SimPolillaSimiatug_v02</class-id> <category>instance-creation</category>

<body package="SimPolillaSimiatug_v02" selector="initAgents">initAgents 
|x1 x2 x3 x4 x5 i|
"US = One agent per land, 6 agents per community"

x1:=1.
x2:=1.
x3:=1.
x4:=1.
x5:=1.

	super initAgents. 

i:=1.
90 timesRepeat:[
self setRandomlyLocatedAgents: Agri01 n: x1 constrainedBy: [:f | f agroPart=i].
self setRandomlyLocatedAgents: Agri02 n: x2 constrainedBy: [:f | f agroPart=i].
self setRandomlyLocatedAgents: Agri03 n: x3 constrainedBy: [:f | f agroPart=i].
self setRandomlyLocatedAgents: Agri04 n: x4 constrainedBy: [:f | f agroPart=i].
self setRandomlyLocatedAgents: Agri05 n: x5 constrainedBy: [:f | f agroPart=i].
i:= i+1].

	self generateSymetricNetworkDensity: 1 forAgents: Agri01.
	self generateSymetricNetworkDensity: 1 forAgents: Agri02.
	self generateSymetricNetworkDensity: 1 forAgents: Agri03.
	self generateSymetricNetworkDensity: 1 forAgents: Agri04.
	self generateSymetricNetworkDensity: 1 forAgents: Agri05.</body>

<body package="SimPolillaSimiatug_v02" selector="initAgentsIsolate">initAgentsIsolate

	super initAgents. 

self setRandomlyLocatedAgents: Ag_Isolate_01 n: 1 constrainedBy: [:f | f agroPartPart=1].
self setRandomlyLocatedAgents: Ag_Isolate_02 n: 1 constrainedBy: [:f | f agroPartPart=2].
self setRandomlyLocatedAgents: Ag_Isolate_03 n: 1 constrainedBy: [:f | f agroPartPart=3].
self setRandomlyLocatedAgents: Ag_Isolate_04 n: 1 constrainedBy: [:f | f agroPartPart=4].
self setRandomlyLocatedAgents: Ag_Isolate_05 n: 1 constrainedBy: [:f | f agroPartPart=5].
self setRandomlyLocatedAgents: Ag_Isolate_06 n: 1 constrainedBy: [:f | f agroPartPart=6].
self setRandomlyLocatedAgents: Ag_Isolate_07 n: 1 constrainedBy: [:f | f agroPartPart=7].
self setRandomlyLocatedAgents: Ag_Isolate_08 n: 1 constrainedBy: [:f | f agroPartPart=8].
self setRandomlyLocatedAgents: Ag_Isolate_09 n: 1 constrainedBy: [:f | f agroPartPart=9].
self setRandomlyLocatedAgents: Ag_Isolate_10 n: 1 constrainedBy: [:f | f agroPartPart=10].
self setRandomlyLocatedAgents: Ag_Isolate_11 n: 1 constrainedBy: [:f | f agroPartPart=11].
self setRandomlyLocatedAgents: Ag_Isolate_12 n: 1 constrainedBy: [:f | f agroPartPart=12].
self setRandomlyLocatedAgents: Ag_Isolate_13 n: 1 constrainedBy: [:f | f agroPartPart=13].
self setRandomlyLocatedAgents: Ag_Isolate_14 n: 1 constrainedBy: [:f | f agroPartPart=14].
self setRandomlyLocatedAgents: Ag_Isolate_15 n: 1 constrainedBy: [:f | f agroPartPart=15].
self setRandomlyLocatedAgents: Ag_Isolate_16 n: 1 constrainedBy: [:f | f agroPartPart=16].
self setRandomlyLocatedAgents: Ag_Isolate_17 n: 1 constrainedBy: [:f | f agroPartPart=17].
self setRandomlyLocatedAgents: Ag_Isolate_18 n: 1 constrainedBy: [:f | f agroPartPart=18].

	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_01.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_02.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_03.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_04.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_05.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_06.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_07.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_08.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_09.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_10.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_11.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_12.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_13.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_14.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_15.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_16.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_17.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_18.
</body>

<body package="SimPolillaSimiatug_v02" selector="initAgentsIsolateSeul">initAgentsIsolateSeul

	super initAgents. 

self setRandomlyLocatedAgents: Ag_Isolate_01 n: 1 constrainedBy: [:f | f agroPartPart=1].
self setRandomlyLocatedAgents: Ag_Isolate_02 n: 1 constrainedBy: [:f | f agroPartPart=2].
self setRandomlyLocatedAgents: Ag_Isolate_03 n: 1 constrainedBy: [:f | f agroPartPart=3].
self setRandomlyLocatedAgents: Ag_Isolate_04 n: 1 constrainedBy: [:f | f agroPartPart=4].
self setRandomlyLocatedAgents: Ag_Isolate_05 n: 1 constrainedBy: [:f | f agroPartPart=5].
self setRandomlyLocatedAgents: Ag_Isolate_06 n: 1 constrainedBy: [:f | f agroPartPart=6].

	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_01.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_02.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_03.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_04.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_05.
	self generateSymetricNetworkDensity: 1 forAgents: Ag_Isolate_06.</body>

<body package="SimPolillaSimiatug_v02" selector="initAggregates">initAggregates
self spaceModel
setAggregates: Aggregate
from: Cell
verifying: [:f | f  bufferNumberTeciaFemale&gt;10 
	or: [ f bufferNumberPhthorimaeaFemale&gt;10
	or: [ f bufferNumberSymmetrischemaFemale&gt;10]]]</body>

<body package="SimPolillaSimiatug_v02" selector="initAggregatesPhthorimaea">initAggregatesPhthorimaea
self spaceModel
setAggregates: AggregatePhthorimaea
from: Cell
verifying: [:f | f  bufferNumberPhthorimaeaFemale&gt;10]</body>

<body package="SimPolillaSimiatug_v02" selector="initAggregatesSymmetrischema">initAggregatesSymmetrischema
self spaceModel
setAggregates: AggregateSymmetrischema
from: Cell
verifying: [:f | f  bufferNumberSymmetrischemaFemale&gt;10]</body>

<body package="SimPolillaSimiatug_v02" selector="initAggregatesTecia">initAggregatesTecia
self spaceModel
setAggregates: AggregateTecia
from: Cell
verifying: [:f | f  bufferNumberTeciaFemale&gt;10]</body>
</methods>


<class>
<name>Agri01</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation areaTotal riego maquinaria semillaPapa rotationVariedad aproFerti almacen listeAgent stockSend stockRead </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<comment>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri01</class-id>
<body>Agri01 representa a los agentes papicultores que tienen un nivel de capacitación o de conocimiento de uno, es decir lo mas bajo.

Instance Variables:
	almacen			&lt;SmallInteger&gt;		description of almacen
	aproFerti			&lt;SmallInteger&gt;		si=1 y no=0
	areaTotal			&lt;SmallInteger&gt;		description of areaTotal
	maquinaria			&lt;SmallInteger&gt;		si=1 y no=0
	nivelFormation		&lt;SmallInteger&gt;		nivel = 1
	riego				&lt;SmallInteger&gt;		description of riego
	rotationVariedad		&lt;SmallInteger&gt;		description of rotationVariedad
	semillaPapa			&lt;SmallInteger&gt;		description of semillaPapa

</body>
</comment>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri01</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
self listeAgent: OrderedCollection new.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri01</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>

<body package="SimPolillaSimiatug_v02" selector="step001">step001


			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.</body>

<body package="SimPolillaSimiatug_v02" selector="step01">step01

	self alarmCalling.
	self readMail.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.</body>

<body package="SimPolillaSimiatug_v02" selector="step01_Part">step01_Part


			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri01</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Agri01.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri01</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2.
seuil:=100/self  nivelFormation.

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].
self patch bufferNumberPhthorimaeaFemale&gt;(seuil) ifTrue:[self patch phthorimaea: self patch phthorimaea*(1-eficacidadTratamientoChimico)].
self patch symmetrischemma&gt;(seuil) ifTrue:[self patch symmetrischemma: self patch symmetrischemma*(1-eficacidadTratamientoChimico)].</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri01</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="almacen">almacen
	"Getter accessor with default value = 1 "
	^almacen ifNil:[almacen := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="almacen:">almacen: anObject 
	almacen := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="aproFerti">aproFerti
	"Getter accessor with default value = 1 "
	^aproFerti ifNil:[aproFerti := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="aproFerti:">aproFerti: anObject 
	aproFerti := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="areaTotal">areaTotal
	"Getter accessor with default value = 1 "
	^areaTotal ifNil:[areaTotal := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="areaTotal:">areaTotal: anObject 
	areaTotal := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="listeAgent">listeAgent
	^listeAgent</body>

<body package="SimPolillaSimiatug_v02" selector="listeAgent:">listeAgent: anObject
	listeAgent := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="maquinaria">maquinaria
	"Getter accessor with default value = 1 "
	^maquinaria ifNil:[maquinaria := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="maquinaria:">maquinaria: anObject 
	maquinaria := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	"Getter accessor with default value = 1 "
	^nivelFormation ifNil:[nivelFormation := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject 
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="riego">riego
	"Getter accessor with default value = 1 "
	^riego ifNil:[riego := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="riego:">riego: anObject 
	riego := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rotationVariedad">rotationVariedad
	"Getter accessor with default value = 1 "
	^rotationVariedad ifNil:[rotationVariedad := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="rotationVariedad:">rotationVariedad: anObject 
	rotationVariedad := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="semillaPapa">semillaPapa
	"Getter accessor with default value = 1 "
	^semillaPapa ifNil:[semillaPapa := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="semillaPapa:">semillaPapa: anObject 
	semillaPapa := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="stockRead">stockRead
	^stockRead</body>

<body package="SimPolillaSimiatug_v02" selector="stockRead:">stockRead: anObject
	stockRead := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="stockSend">stockSend
	^stockSend</body>

<body package="SimPolillaSimiatug_v02" selector="stockSend:">stockSend: anObject
	stockSend := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri01</class-id> <category>msg</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling

	| alarm teciaNeighbours phNeighbours symNeighbours bigNeighbours numCeldas agriOnMyCell|
	numCeldas := 2.

teciaNeighbours :=0.
phNeighbours :=0.
symNeighbours :=0.

	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (200 - (self nivelFormation * 20))].
	phNeighbours := self patch neighbourhood select: [:f | f bufferNumberPhthorimaeaFemale &gt; (200 - (self nivelFormation * 20))].
	symNeighbours := self patch neighbourhood select: [:f | f bufferNumberSymmetrischemaFemale &gt; (200 - (self nivelFormation * 20))].


	teciaNeighbours size &gt; phNeighbours size
		ifTrue: [teciaNeighbours size &gt; symNeighbours size
				ifTrue: [bigNeighbours := teciaNeighbours]
				ifFalse: [bigNeighbours := symNeighbours]]
		ifFalse: 	[phNeighbours size &gt; symNeighbours size
				ifTrue: [bigNeighbours := phNeighbours]
				ifFalse: [bigNeighbours := symNeighbours]].

	
agriOnMyCell := IndexedSet new.
	1 to: 5 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Agri0', i printString) asSymbol) withinRange: 5)].


	bigNeighbours size &gt; numCeldas 

		ifTrue: 
			[alarm := MsgHelp new.
			alarm sender: self.
			alarm symbol: #alarm.
			agriOnMyCell do: 
					[:x | 
					alarm location: (Cormas selectRandomlyFrom: bigNeighbours).
					alarm receiver: x.
					self sendMessageSynchronously: alarm]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmCallingAggregate">alarmCallingAggregate

| alarmT alarmP alarmS alarm teciaedCell phthedCell symedCell PTMCell aggregateT aggregateP aggregateS aggregateTOT numCellPTM tot|

numCellPTM:=5.
tot:=150.

teciaedCell := self patch neighbourhood detect: [:f | f  bufferNumberTeciaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].
phthedCell := self patch neighbourhood detect: [:f | f  bufferNumberPhthorimaeaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].
symedCell := self patch neighbourhood detect: [:f | f  bufferNumberSymmetrischemaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].
PTMCell := self patch neighbourhood detect: [:f | f  bufferNumberTeciaFemale&gt;(tot-(self nivelFormation*20))
	or: [f  bufferNumberPhthorimaeaFemale&gt;(tot-(self nivelFormation*20))
	or: [f  bufferNumberSymmetrischemaFemale&gt;(tot-(self nivelFormation*20))]]] ifNone: [^nil].

aggregateT := teciaedCell  theCSE at: #AggregateTecia.
aggregateP := phthedCell  theCSE at: #AggregatePhthorimaea.
aggregateS := symedCell  theCSE at: #AggregateSymmetrischema.
aggregateTOT   := PTMCell     theCSE at: #Aggregate.

aggregateTOT size &gt; numCellPTM
ifTrue:
	[alarm := MsgHelp new.
	alarm sender: self.
	alarm symbol: #alarm.
	self  acquaintances do: 
		[:x |
	alarm location: (Cormas selectRandomlyFrom: aggregateTOT components).
	alarm receiver: x.
	self sendMessageAsynchronously: alarm]].
</body>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling_v01">alarmCalling_v01
	

	| alarm teciaNeighbours phNeighbours symNeighbours bigNeighbours numCeldas emit|
	numCeldas := 2.

teciaNeighbours :=0.
phNeighbours :=0.
symNeighbours :=0.

	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (200 - (self nivelFormation * 20))].
	phNeighbours := self patch neighbourhood select: [:f | f bufferNumberPhthorimaeaFemale &gt; (200 - (self nivelFormation * 20))].
	symNeighbours := self patch neighbourhood select: [:f | f bufferNumberSymmetrischemaFemale &gt; (200 - (self nivelFormation * 20))].


	teciaNeighbours size &gt; phNeighbours size
		ifTrue: [teciaNeighbours size &gt; symNeighbours size
				ifTrue: [bigNeighbours := teciaNeighbours]
				ifFalse: [bigNeighbours := symNeighbours]]
		ifFalse: 	[phNeighbours size &gt; symNeighbours size
				ifTrue: [bigNeighbours := phNeighbours]
				ifFalse: [bigNeighbours := symNeighbours]].

	

	bigNeighbours size &gt; numCeldas 
		ifTrue: 
			[alarm := MsgHelp new.
			alarm sender: self.
			alarm symbol: #alarm.
			self acquaintances do: 
					[:x | 
					alarm location: (Cormas selectRandomlyFrom: bigNeighbours).
					alarm receiver: x.
					self sendMessageSynchronously: alarm].
		emit:=1.
		90 timesRepeat:[
			self patch agroPart = emit ifTrue:[self stockSend: emit]
			ifFalse:[emit:=emit+1]]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage := self nextMessage.

	aMessage notNil ifTrue:[
		self leave.
		self moveTo: aMessage location]
	ifFalse: [
		self moveIntoAgroPart]</body>

<body package="SimPolillaSimiatug_v02" selector="readMail_v01">readMail_v01
| aMessage recept|
aMessage := self nextMessage.

recept:=1.
90 timesRepeat:[
	self patch agroPart = recept ifTrue:[self stockRead: recept]
	ifFalse:[recept:=recept+1]].

self stockRead = self stockSend ifTrue:[
	aMessage notNil ifTrue:[
		self leave.
		self moveTo: aMessage location]
	ifFalse: [
		self moveIntoAgroPart]]</body>
</methods>


<class>
<name>Agri05</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation areaTotal riego maquinaria semillaPapa rotationVariedad aproFerti almacen </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<comment>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri05</class-id>
<body>Agri05 representa a los agentes papicultores que tienen un nivel de capacitación o de conocimiento de 5.

Instance Variables:
	almacen			&lt;SmallInteger&gt;		description of almacen
	aproFerti			&lt;SmallInteger&gt;		si=1 y no=0
	areaTotal			&lt;SmallInteger&gt;		description of areaTotal
	maquinaria			&lt;SmallInteger&gt;		si=1 y no=0
	nivelFormation		&lt;SmallInteger&gt;		nivel = 5
	riego				&lt;SmallInteger&gt;		description of riego
	rotationVariedad		&lt;SmallInteger&gt;		description of rotationVariedad
	semillaPapa			&lt;SmallInteger&gt;		description of semillaPapa

</body>
</comment>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri05</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri05</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>

<body package="SimPolillaSimiatug_v02" selector="step005">step005

			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.</body>

<body package="SimPolillaSimiatug_v02" selector="step05">step05
	self alarmCalling.
	self readMail.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.</body>

<body package="SimPolillaSimiatug_v02" selector="step05_Part">step05_Part


			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri05</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Agri05.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri05</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2.
seuil:=100/self  nivelFormation.

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].
self patch bufferNumberPhthorimaeaFemale&gt;(seuil) ifTrue:[self patch phthorimaea: self patch phthorimaea*(1-eficacidadTratamientoChimico)].
self patch symmetrischemma&gt;(seuil) ifTrue:[self patch symmetrischemma: self patch symmetrischemma*(1-eficacidadTratamientoChimico)].</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri05</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="almacen">almacen
	"Getter accessor with default value = 1 "
	^almacen ifNil:[almacen := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="almacen:">almacen: anObject 
	almacen := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="aproFerti">aproFerti
	"Getter accessor with default value = 1 "
	^aproFerti ifNil:[aproFerti := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="aproFerti:">aproFerti: anObject 
	aproFerti := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="areaTotal">areaTotal
	"Getter accessor with default value = 1 "
	^areaTotal ifNil:[areaTotal := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="areaTotal:">areaTotal: anObject 
	areaTotal := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="maquinaria">maquinaria
	"Getter accessor with default value = 1 "
	^maquinaria ifNil:[maquinaria := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="maquinaria:">maquinaria: anObject 
	maquinaria := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	"Getter accessor with default value = 5 "
	^nivelFormation ifNil:[nivelFormation := 5]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject 
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="riego">riego
	"Getter accessor with default value = 1 "
	^riego ifNil:[riego := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="riego:">riego: anObject 
	riego := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rotationVariedad">rotationVariedad
	"Getter accessor with default value = 1 "
	^rotationVariedad ifNil:[rotationVariedad := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="rotationVariedad:">rotationVariedad: anObject 
	rotationVariedad := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="semillaPapa">semillaPapa
	"Getter accessor with default value = 1 "
	^semillaPapa ifNil:[semillaPapa := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="semillaPapa:">semillaPapa: anObject 
	semillaPapa := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri05</class-id> <category>msg</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	

	| alarm teciaNeighbours phNeighbours symNeighbours bigNeighbours numCeldas agriOnMyCell|
	numCeldas := 2.

teciaNeighbours :=0.
phNeighbours :=0.
symNeighbours :=0.

	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (200 - (self nivelFormation * 20))].
	phNeighbours := self patch neighbourhood select: [:f | f bufferNumberPhthorimaeaFemale &gt; (200 - (self nivelFormation * 20))].
	symNeighbours := self patch neighbourhood select: [:f | f bufferNumberSymmetrischemaFemale &gt; (200 - (self nivelFormation * 20))].


	teciaNeighbours size &gt; phNeighbours size
		ifTrue: [teciaNeighbours size &gt; symNeighbours size
				ifTrue: [bigNeighbours := teciaNeighbours]
				ifFalse: [bigNeighbours := symNeighbours]]
		ifFalse: 	[phNeighbours size &gt; symNeighbours size
				ifTrue: [bigNeighbours := phNeighbours]
				ifFalse: [bigNeighbours := symNeighbours]].

	
agriOnMyCell := IndexedSet new.
	1 to: 5 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Agri0', i printString) asSymbol) withinRange: 5)].


	bigNeighbours size &gt; numCeldas 

		ifTrue: 
			[alarm := MsgHelp new.
			alarm sender: self.
			alarm symbol: #alarm.
			agriOnMyCell do: 
					[:x | 
					alarm location: (Cormas selectRandomlyFrom: bigNeighbours).
					alarm receiver: x.
					self sendMessageSynchronously: alarm]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmCallingAggregate">alarmCallingAggregate

| alarmT alarmP alarmS alarm teciaedCell phthedCell symedCell PTMCell aggregateT aggregateP aggregateS aggregate numCellPTM tot|

numCellPTM:=10.
tot:=150.

teciaedCell := self patch neighbourhood detect: [:f | f  bufferNumberTeciaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].
phthedCell := self patch neighbourhood detect: [:f | f  bufferNumberPhthorimaeaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].
symedCell := self patch neighbourhood detect: [:f | f  bufferNumberSymmetrischemaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].

PTMCell := self patch neighbourhood detect: [:f | f  bufferNumberTeciaFemale&gt;(tot-(self nivelFormation*20))
	or: [f  bufferNumberPhthorimaeaFemale&gt;(tot-(self nivelFormation*20))
	or: [f  bufferNumberSymmetrischemaFemale&gt;(tot-(self nivelFormation*20))]]] ifNone: [^nil].

aggregateT := teciaedCell theCSE at: #AggregateTecia.
aggregateP := phthedCell theCSE at: #AggregatePhthorimaea.
aggregateS := symedCell theCSE at: #AggregateSymmetrischema.

aggregate := PTMCell theCSE at: #Aggregate.

aggregate size &gt; numCellPTM
ifTrue:
	[alarm := MsgHelp new.
	alarm sender: self.
	alarm symbol: #alarm.
	self  acquaintances do:
		[:x |
	alarm location: (Cormas selectRandomlyFrom: aggregate components).
	alarm receiver: x.
	self sendMessageAsynchronously: alarm]].
</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage := self nextMessage.

	aMessage notNil ifTrue:[
		self leave.
		self moveTo: aMessage location]
	ifFalse: [
		self moveIntoAgroPart]</body>
</methods>


<class>
<name>MsgHelpAns</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.Msg</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>location nivel ag </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.MsgHelpAns</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="ag">ag
	^ag</body>

<body package="SimPolillaSimiatug_v02" selector="ag:">ag: anObject
	ag := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="location">location
	^location</body>

<body package="SimPolillaSimiatug_v02" selector="location:">location: anObject
	location := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivel">nivel
	^nivel</body>

<body package="SimPolillaSimiatug_v02" selector="nivel:">nivel: anObject
	nivel := anObject</body>
</methods>


<class>
<name>AggregatePhthorimaea</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.SpatialEntityAggregate</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>agrePht </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AggregatePhthorimaea</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AggregatePhthorimaea</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="agrePht">agrePht
	^agrePht ifNil:[agrePht := 10]</body>

<body package="SimPolillaSimiatug_v02" selector="agrePht:">agrePht: anObject
	agrePht := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.AggregatePhthorimaea</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov
^self size &gt; self agrePht
ifTrue: [#needHelp]
ifFalse: [#noHelpNeeded]</body>
</methods>


<class>
<name>Agri02</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation areaTotal riego maquinaria semillaPapa rotationVariedad aproFerti almacen </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<comment>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri02</class-id>
<body>Agri02 representa a los agentes papicultores que tienen un nivel de capacitación o de conocimiento de 2.

Instance Variables:
	almacen			&lt;SmallInteger&gt;		description of almacen
	aproFerti			&lt;SmallInteger&gt;		si=1 y no=0
	areaTotal			&lt;SmallInteger&gt;		description of areaTotal
	maquinaria			&lt;SmallInteger&gt;		si=1 y no=0
	nivelFormation		&lt;SmallInteger&gt;		nivel = 2
	riego				&lt;SmallInteger&gt;		description of riego
	rotationVariedad		&lt;SmallInteger&gt;		description of rotationVariedad
	semillaPapa			&lt;SmallInteger&gt;		description of semillaPapa

</body>
</comment>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri02</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri02</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>

<body package="SimPolillaSimiatug_v02" selector="step002">step002

			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.</body>

<body package="SimPolillaSimiatug_v02" selector="step02">step02
	self alarmCalling.
	self readMail.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.</body>

<body package="SimPolillaSimiatug_v02" selector="step02_Part">step02_Part


			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri02</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Agri02.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri02</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2.
seuil:=100/self  nivelFormation.

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].
self patch bufferNumberPhthorimaeaFemale&gt;(seuil) ifTrue:[self patch phthorimaea: self patch phthorimaea*(1-eficacidadTratamientoChimico)].
self patch symmetrischemma&gt;(seuil) ifTrue:[self patch symmetrischemma: self patch symmetrischemma*(1-eficacidadTratamientoChimico)].</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri02</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="almacen">almacen
	"Getter accessor with default value = 1 "
	^almacen ifNil:[almacen := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="almacen:">almacen: anObject 
	almacen := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="aproFerti">aproFerti
	"Getter accessor with default value = 1 "
	^aproFerti ifNil:[aproFerti := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="aproFerti:">aproFerti: anObject 
	aproFerti := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="areaTotal">areaTotal
	"Getter accessor with default value = 1 "
	^areaTotal ifNil:[areaTotal := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="areaTotal:">areaTotal: anObject 
	areaTotal := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="maquinaria">maquinaria
	"Getter accessor with default value = 1 "
	^maquinaria ifNil:[maquinaria := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="maquinaria:">maquinaria: anObject 
	maquinaria := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	"Getter accessor with default value = 2 "
	^nivelFormation ifNil:[nivelFormation := 2]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject 
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="riego">riego
	"Getter accessor with default value = 1 "
	^riego ifNil:[riego := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="riego:">riego: anObject 
	riego := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rotationVariedad">rotationVariedad
	"Getter accessor with default value = 1 "
	^rotationVariedad ifNil:[rotationVariedad := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="rotationVariedad:">rotationVariedad: anObject 
	rotationVariedad := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="semillaPapa">semillaPapa
	"Getter accessor with default value = 1 "
	^semillaPapa ifNil:[semillaPapa := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="semillaPapa:">semillaPapa: anObject 
	semillaPapa := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri02</class-id> <category>msg</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	

	| alarm teciaNeighbours phNeighbours symNeighbours bigNeighbours numCeldas agriOnMyCell|
	numCeldas := 2.

teciaNeighbours :=0.
phNeighbours :=0.
symNeighbours :=0.

	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (200 - (self nivelFormation * 20))].
	phNeighbours := self patch neighbourhood select: [:f | f bufferNumberPhthorimaeaFemale &gt; (200 - (self nivelFormation * 20))].
	symNeighbours := self patch neighbourhood select: [:f | f bufferNumberSymmetrischemaFemale &gt; (200 - (self nivelFormation * 20))].


	teciaNeighbours size &gt; phNeighbours size
		ifTrue: [teciaNeighbours size &gt; symNeighbours size
				ifTrue: [bigNeighbours := teciaNeighbours]
				ifFalse: [bigNeighbours := symNeighbours]]
		ifFalse: 	[phNeighbours size &gt; symNeighbours size
				ifTrue: [bigNeighbours := phNeighbours]
				ifFalse: [bigNeighbours := symNeighbours]].

	
agriOnMyCell := IndexedSet new.
	1 to: 5 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Agri0', i printString) asSymbol) withinRange: 5)].


	bigNeighbours size &gt; numCeldas 

		ifTrue: 
			[alarm := MsgHelp new.
			alarm sender: self.
			alarm symbol: #alarm.
			agriOnMyCell do: 
					[:x | 
					alarm location: (Cormas selectRandomlyFrom: bigNeighbours).
					alarm receiver: x.
					self sendMessageSynchronously: alarm]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmCallingAggregate">alarmCallingAggregate

| alarmT alarmP alarmS alarm teciaedCell phthedCell symedCell PTMCell aggregateT aggregateP aggregateS aggregate numCellPTM tot|

numCellPTM:=10.
tot:=150.

teciaedCell := self patch neighbourhood detect: [:f | f  bufferNumberTeciaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].
phthedCell := self patch neighbourhood detect: [:f | f  bufferNumberPhthorimaeaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].
symedCell := self patch neighbourhood detect: [:f | f  bufferNumberSymmetrischemaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].

PTMCell := self patch neighbourhood detect: [:f | f  bufferNumberTeciaFemale&gt;(tot-(self nivelFormation*20))
	or: [f  bufferNumberPhthorimaeaFemale&gt;(tot-(self nivelFormation*20))
	or: [f  bufferNumberSymmetrischemaFemale&gt;(tot-(self nivelFormation*20))]]] ifNone: [^nil].

aggregateT := teciaedCell theCSE at: #AggregateTecia.
aggregateP := phthedCell theCSE at: #AggregatePhthorimaea.
aggregateS := symedCell theCSE at: #AggregateSymmetrischema.

aggregate := PTMCell theCSE at: #Aggregate.

aggregate size &gt; numCellPTM
ifTrue:
	[alarm := MsgHelp new.
	alarm sender: self.
	alarm symbol: #alarm.
	self  acquaintances do:
		[:x |
	alarm location: (Cormas selectRandomlyFrom: aggregate components).
	alarm receiver: x.
	self sendMessageAsynchronously: alarm]].
</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage := self nextMessage.

	aMessage notNil ifTrue:[
		self leave.
		self moveTo: aMessage location]
	ifFalse: [
		self moveIntoAgroPart]</body>
</methods>


<class>
<name>Cell</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.SpatialEntityElement</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>altura pluvioAnual tempMini tempMaxi tempPromedio agro qualityHabitat tecia bufferTecia rateLifeTecia rateLifePhthorimaea rateLifeSymmetrischemma phthorimaea symmetrischemma bufferPhthorimaea bufferSymmetrischemma survivalRateTecia survivalRatePhthorimaea survivalRateSymmetrischemma fecundityTecia fecundityPhthorimaea fecunditySymmetrischemma stochastic roads bodega tempStochastic rain1 rain2 rain3 rain4 rain5 rain6 rain7 rain8 rain9 rain10 rain11 rain12 rainEffectJuveniles rainEffectAdults teciaAdults phthorimaeaAdults symmetrischemaAdults teciaFemale phthorimaeaFemale symmetrischemaFemale rT rP rS bufferNumberPhthorimaeaFemale moveT moveP moveS bufferNumberTeciaFemale bufferNumberSymmetrischemaFemale village village2 dispersalJumpv01 dispersalJumpv02 dispersalJumpv03 dispersalJumpv04 dispersalJumpv05 dispersalJumpv06 dispersalJumpv07 dispersalJumpv08 dispersalJumpv09 dispersalJumpv10 dispersalJumpv11 dispersalJumpv12 dispersalJumpv13 dispersalJumpv14 dispersalJumpv15 dispersalJumpv16 dispersalJumpv17 dispersalJumpv18 dispersalJumpv19 dispersalJumpv20 dispersalJumpv21 dispersalJumpv22 dispersalJumpv23 dispersalJumpv24 dispersalJumpv25 dispersalJumpv26 dispersalJumpv27 dispersalJumpv28 dispersalJumpv29 dispersalJumpv30 dispersalJumpv31 dispersalJumpv32 dispersalJumpv33 dispersalJumpv34 dispersalJumpp01 dispersalJumpp02 dispersalJumpp03 dispersalJumpp04 dispersalJumpp05 dispersalJumpp06 dispersalJumpp07 dispersalJumpp08 dispersalJumpp09 dispersalJumpp10 dispersalJumpp11 dispersalJumpp12 dispersalJumpp13 dispersalJumpp14 dispersalJumpp15 dispersalJumpp16 dispersalJumpp17 dispersalJumpp18 dispersalJumpp19 dispersalJumpp20 dispersalJumpp21 dispersalJumpp22 dispersalJumpp23 dispersalJumpp24 dispersalJumpp25 dispersalJumpp26 dispersalJumpp27 dispersalJumpp28 dispersalJumpp29 dispersalJumpp30 dispersalJumpp31 dispersalJumpp32 dispersalJumpp33 dispersalJumpp34 dispersalJumps01 dispersalJumps02 dispersalJumps03 dispersalJumps04 dispersalJumps05 dispersalJumps06 dispersalJumps07 dispersalJumps08 dispersalJumps09 dispersalJumps10 dispersalJumps11 dispersalJumps12 dispersalJumps13 dispersalJumps14 dispersalJumps15 dispersalJumps16 dispersalJumps17 dispersalJumps18 dispersalJumps19 dispersalJumps20 dispersalJumps21 dispersalJumps22 dispersalJumps23 dispersalJumps24 dispersalJumps25 dispersalJumps26 dispersalJumps27 dispersalJumps28 dispersalJumps29 dispersalJumps30 dispersalJumps31 dispersalJumps32 dispersalJumps33 dispersalJumps34 population probe agroPart agroPartPart bodegaDensityA bodegaDensityP stoPec stoPec2 </inst-vars>
<class-inst-vars>k r </class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Cell class</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="k">k
	"Getter accessor with default value = 1000 "
	^k ifNil:[k := 1000]</body>

<body package="SimPolillaSimiatug_v02" selector="k:">k: anObject 
	k := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="r">r
	"Getter accessor with default value = 0.2 "
	^r ifNil:[r := 0.2]</body>

<body package="SimPolillaSimiatug_v02" selector="r:">r: anObject 
	r := anObject</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Cell</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Cell</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="agro">agro
	"US = agro is a layer representing land use (1=crops, 0=other)"
	"ES = agro es una capa que representa el uso del suelo.
		cuando agro toma el valor 1, representa una zona donde hay un cultivo de ciclo corto
		cuando agro toma el valor 0, representa una zona con otro uso o sin uso (parámos, ciclo largo, ...)
	agro no es generado por el modelo sino que viene de un mapa SIG, adentro del archivo *.env que inicia una simulación"
	
	^agro ifNil:[agro := 0].
	"Si agro no tiene un valor (agro=Nil que significa nada), toma el valor 0"</body>

<body package="SimPolillaSimiatug_v02" selector="agro:">agro: anObject 
	agro := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="agroPart">agroPart
"US = layer to distinguish between the 3 communities of the initial model"
"ES = para representar las distintas comunidades de la zona"
	^agroPart ifNil:[agro := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="agroPart:">agroPart: anObject
	agroPart := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart">agroPartPart
	"Getter accessor without default value "
	^agroPartPart</body>

<body package="SimPolillaSimiatug_v02" selector="agroPartPart:">agroPartPart: anObject 
	agroPartPart := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="altura">altura
	"US = eleveation in m.a.s.l."
	"ES = altura es una capa que representa la altura en m.s.n.m..
	altura no es generado por el modelo sino que viene de un mapa SIG, adentro del archivo *.env que inicia una simulación"
	^altura ifNil:[altura := 0]
	"Si altura no tiene un valor (altura=Nil que significa nada), toma el valor 0"
</body>

<body package="SimPolillaSimiatug_v02" selector="altura:">altura: anObject 
	altura := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="bodega">bodega
	"US = representation of local storage facilities, not use in the model"
	"ES = bodega es una capa que representa si hay o no una bodega en el lugar considerado.
		cuando bodega toma el valor 1, representa una zona donde hay una bodega
		cuando bodega toma el valor 0, representa una zona donde no hay una bodega
	bodega no es generado por el modelo sino que viene de una capa hecha con Excel, teoricamente, adentro del archivo *.env que inicia una simulación"
	^bodega
	"Si bodega no tiene un valor (bodega=Nil que significa nada), toma el valor 0"</body>

<body package="SimPolillaSimiatug_v02" selector="bodega:">bodega: anObject 
	bodega := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="bodegaDensityA">bodegaDensityA
	^bodegaDensityA</body>

<body package="SimPolillaSimiatug_v02" selector="bodegaDensityA:">bodegaDensityA: anObject
	bodegaDensityA := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="bodegaDensityP">bodegaDensityP
	^bodegaDensityP</body>

<body package="SimPolillaSimiatug_v02" selector="bodegaDensityP:">bodegaDensityP: anObject
	bodegaDensityP := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="bufferNumberPhthorimaeaFemale">bufferNumberPhthorimaeaFemale
	"US = number of gravid females before reproduction: output of the pest model"
	"ES = Representa el numero de hembras al final de una generación, es decir antes que se mueren. 
	Sirve para hacer curvas y para representar las hembras en el modulo SPACE"
	^bufferNumberPhthorimaeaFemale ifNil:[bufferNumberPhthorimaeaFemale := 0]
</body>

<body package="SimPolillaSimiatug_v02" selector="bufferNumberPhthorimaeaFemale:">bufferNumberPhthorimaeaFemale: anObject 
	bufferNumberPhthorimaeaFemale := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="bufferNumberSymmetrischemaFemale">bufferNumberSymmetrischemaFemale
	"US = number of gravid females before reproduction: output of the pest model"
	"ES = Representa el numero de hembras al final de una generación, es decir antes que se mueren. 
	Sirve para hacer curvas y para representar las hembras en el modulo SPACE"
	^bufferNumberSymmetrischemaFemale ifNil:[bufferNumberSymmetrischemaFemale := 0]
</body>

<body package="SimPolillaSimiatug_v02" selector="bufferNumberSymmetrischemaFemale:">bufferNumberSymmetrischemaFemale: anObject 
	bufferNumberSymmetrischemaFemale := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="bufferNumberTeciaFemale">bufferNumberTeciaFemale
	"US = number of gravid females before reproduction: output of the pest model"
	"ES = Representa el numero de hembras al final de una generación, es decir antes que se mueren. 
	Sirve para hacer curvas y para representar las hembras en el modulo SPACE"
	^bufferNumberTeciaFemale ifNil:[bufferNumberTeciaFemale := 0]
</body>

<body package="SimPolillaSimiatug_v02" selector="bufferNumberTeciaFemale:">bufferNumberTeciaFemale: anObject 
	bufferNumberTeciaFemale := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="bufferPhthorimaea">bufferPhthorimaea
	"US = buffer layer to store pest diffusion"
	"ES = Representa una capa que guarda el numero de polillas que se mueven por difusión (hay dos tipos de dispersión, por difusión es decir por la distancia de vuelo de la polilla y por saltación, es decir por los movimientos de los humanos de un mercado a un campo)"
	^bufferPhthorimaea ifNil:[bufferPhthorimaea := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="bufferPhthorimaea:">bufferPhthorimaea: anObject 
	bufferPhthorimaea := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="bufferSymmetrischemma">bufferSymmetrischemma
	"US = buffer layer to store pest diffusion"
	"ES = Representa una capa que guarda el numero de polillas que se mueven por difusión (hay dos tipos de dispersión, por difusión es decir por la distancia de vuelo de la polilla y por saltación, es decir por los movimientos de los humanos de un mercado a un campo)"
	^bufferSymmetrischemma ifNil:[bufferSymmetrischemma := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="bufferSymmetrischemma:">bufferSymmetrischemma: anObject 
	bufferSymmetrischemma := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="bufferTecia">bufferTecia
	"US = buffer layer to store pest diffusion"
	"ES = Representa una capa que guarda el numero de polillas que se mueven por difusión (hay dos tipos de dispersión, por difusión es decir por la distancia de vuelo de la polilla y por saltación, es decir por los movimientos de los humanos de un mercado a un campo)"
	^bufferTecia ifNil:[bufferTecia := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="bufferTecia:">bufferTecia: anObject 
	bufferTecia := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp01">dispersalJumpp01
	"US = buffer layer to store pest dispersion"
	"ES = Representa una capa que guarda el numero de polillas que se mueven por saltación (hay dos tipos de dispersión, por difusión es decir por la distancia de vuelo de la polilla y por saltación, es decir por los movimientos de los humanos de un mercado a un campo)"
	^dispersalJumpp01 ifNil:[dispersalJumpp01 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp01:">dispersalJumpp01: anObject 
	dispersalJumpp01 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp02">dispersalJumpp02
	"Getter accessor with default value = 0 "
	^dispersalJumpp02 ifNil:[dispersalJumpp02 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp02:">dispersalJumpp02: anObject 
	dispersalJumpp02 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp03">dispersalJumpp03
	"Getter accessor with default value = 0 "
	^dispersalJumpp03 ifNil:[dispersalJumpp03 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp03:">dispersalJumpp03: anObject 
	dispersalJumpp03 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp04">dispersalJumpp04
	"Getter accessor with default value = 0 "
	^dispersalJumpp04 ifNil:[dispersalJumpp04 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp04:">dispersalJumpp04: anObject 
	dispersalJumpp04 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp05">dispersalJumpp05
	"Getter accessor with default value = 0 "
	^dispersalJumpp05 ifNil:[dispersalJumpp05 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp05:">dispersalJumpp05: anObject 
	dispersalJumpp05 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp06">dispersalJumpp06
	"Getter accessor with default value = 0 "
	^dispersalJumpp06 ifNil:[dispersalJumpp06 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp06:">dispersalJumpp06: anObject 
	dispersalJumpp06 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp07">dispersalJumpp07
	"Getter accessor with default value = 0 "
	^dispersalJumpp07 ifNil:[dispersalJumpp07 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp07:">dispersalJumpp07: anObject 
	dispersalJumpp07 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp08">dispersalJumpp08
	"Getter accessor with default value = 0 "
	^dispersalJumpp08 ifNil:[dispersalJumpp08 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp08:">dispersalJumpp08: anObject 
	dispersalJumpp08 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp09">dispersalJumpp09
	"Getter accessor with default value = 0 "
	^dispersalJumpp09 ifNil:[dispersalJumpp09 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp09:">dispersalJumpp09: anObject 
	dispersalJumpp09 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp10">dispersalJumpp10
	"Getter accessor with default value = 0 "
	^dispersalJumpp10 ifNil:[dispersalJumpp10 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp10:">dispersalJumpp10: anObject 
	dispersalJumpp10 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp11">dispersalJumpp11
	"Getter accessor with default value = 0 "
	^dispersalJumpp11 ifNil:[dispersalJumpp11 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp11:">dispersalJumpp11: anObject 
	dispersalJumpp11 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp12">dispersalJumpp12
	"Getter accessor with default value = 0 "
	^dispersalJumpp12 ifNil:[dispersalJumpp12 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp12:">dispersalJumpp12: anObject 
	dispersalJumpp12 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp13">dispersalJumpp13
	"Getter accessor with default value = 0 "
	^dispersalJumpp13 ifNil:[dispersalJumpp13 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp13:">dispersalJumpp13: anObject 
	dispersalJumpp13 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp14">dispersalJumpp14
	"Getter accessor with default value = 0 "
	^dispersalJumpp14 ifNil:[dispersalJumpp14 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp14:">dispersalJumpp14: anObject 
	dispersalJumpp14 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp15">dispersalJumpp15
	"Getter accessor with default value = 0 "
	^dispersalJumpp15 ifNil:[dispersalJumpp15 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp15:">dispersalJumpp15: anObject 
	dispersalJumpp15 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp16">dispersalJumpp16
	"Getter accessor with default value = 0 "
	^dispersalJumpp16 ifNil:[dispersalJumpp16 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp16:">dispersalJumpp16: anObject 
	dispersalJumpp16 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp17">dispersalJumpp17
	"Getter accessor with default value = 0 "
	^dispersalJumpp17 ifNil:[dispersalJumpp17 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp17:">dispersalJumpp17: anObject 
	dispersalJumpp17 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp18">dispersalJumpp18
	"Getter accessor with default value = 0 "
	^dispersalJumpp18 ifNil:[dispersalJumpp18 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp18:">dispersalJumpp18: anObject 
	dispersalJumpp18 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp19">dispersalJumpp19
	"Getter accessor with default value = 0 "
	^dispersalJumpp19 ifNil:[dispersalJumpp19 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp19:">dispersalJumpp19: anObject 
	dispersalJumpp19 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp20">dispersalJumpp20
	"Getter accessor with default value = 0 "
	^dispersalJumpp20 ifNil:[dispersalJumpp20 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp20:">dispersalJumpp20: anObject 
	dispersalJumpp20 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp21">dispersalJumpp21
	"Getter accessor with default value = 0 "
	^dispersalJumpp21 ifNil:[dispersalJumpp21 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp21:">dispersalJumpp21: anObject 
	dispersalJumpp21 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp22">dispersalJumpp22
	"Getter accessor with default value = 0 "
	^dispersalJumpp22 ifNil:[dispersalJumpp22 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp22:">dispersalJumpp22: anObject 
	dispersalJumpp22 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp23">dispersalJumpp23
	"Getter accessor with default value = 0 "
	^dispersalJumpp23 ifNil:[dispersalJumpp23 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp23:">dispersalJumpp23: anObject 
	dispersalJumpp23 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp24">dispersalJumpp24
	"Getter accessor with default value = 0 "
	^dispersalJumpp24 ifNil:[dispersalJumpp24 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp24:">dispersalJumpp24: anObject 
	dispersalJumpp24 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp25">dispersalJumpp25
	"Getter accessor with default value = 0 "
	^dispersalJumpp25 ifNil:[dispersalJumpp25 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp25:">dispersalJumpp25: anObject 
	dispersalJumpp25 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp26">dispersalJumpp26
	"Getter accessor with default value = 0 "
	^dispersalJumpp26 ifNil:[dispersalJumpp26 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp26:">dispersalJumpp26: anObject 
	dispersalJumpp26 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp27">dispersalJumpp27
	"Getter accessor with default value = 0 "
	^dispersalJumpp27 ifNil:[dispersalJumpp27 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp27:">dispersalJumpp27: anObject 
	dispersalJumpp27 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp28">dispersalJumpp28
	"Getter accessor with default value = 0 "
	^dispersalJumpp28 ifNil:[dispersalJumpp28 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp28:">dispersalJumpp28: anObject 
	dispersalJumpp28 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp29">dispersalJumpp29
	"Getter accessor with default value = 0 "
	^dispersalJumpp29 ifNil:[dispersalJumpp29 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp29:">dispersalJumpp29: anObject 
	dispersalJumpp29 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp30">dispersalJumpp30
	"Getter accessor with default value = 0 "
	^dispersalJumpp30 ifNil:[dispersalJumpp30 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp30:">dispersalJumpp30: anObject 
	dispersalJumpp30 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp31">dispersalJumpp31
	"Getter accessor with default value = 0 "
	^dispersalJumpp31 ifNil:[dispersalJumpp31 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp31:">dispersalJumpp31: anObject 
	dispersalJumpp31 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp32">dispersalJumpp32
	"Getter accessor with default value = 0 "
	^dispersalJumpp32 ifNil:[dispersalJumpp32 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp32:">dispersalJumpp32: anObject 
	dispersalJumpp32 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp33">dispersalJumpp33
	"Getter accessor with default value = 0 "
	^dispersalJumpp33 ifNil:[dispersalJumpp33 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp33:">dispersalJumpp33: anObject 
	dispersalJumpp33 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp34">dispersalJumpp34
	"Getter accessor with default value = 0 "
	^dispersalJumpp34 ifNil:[dispersalJumpp34 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpp34:">dispersalJumpp34: anObject 
	dispersalJumpp34 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps01">dispersalJumps01
	"Getter accessor with default value = 0 "
	^dispersalJumps01 ifNil:[dispersalJumps01 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps01:">dispersalJumps01: anObject 
	dispersalJumps01 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps02">dispersalJumps02
	"Getter accessor with default value = 0 "
	^dispersalJumps02 ifNil:[dispersalJumps02 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps02:">dispersalJumps02: anObject 
	dispersalJumps02 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps03">dispersalJumps03
	"Getter accessor with default value = 0 "
	^dispersalJumps03 ifNil:[dispersalJumps03 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps03:">dispersalJumps03: anObject 
	dispersalJumps03 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps04">dispersalJumps04
	"Getter accessor with default value = 0 "
	^dispersalJumps04 ifNil:[dispersalJumps04 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps04:">dispersalJumps04: anObject 
	dispersalJumps04 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps05">dispersalJumps05
	"Getter accessor with default value = 0 "
	^dispersalJumps05 ifNil:[dispersalJumps05 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps05:">dispersalJumps05: anObject 
	dispersalJumps05 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps06">dispersalJumps06
	"Getter accessor with default value = 0 "
	^dispersalJumps06 ifNil:[dispersalJumps06 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps06:">dispersalJumps06: anObject 
	dispersalJumps06 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps07">dispersalJumps07
	"Getter accessor with default value = 0 "
	^dispersalJumps07 ifNil:[dispersalJumps07 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps07:">dispersalJumps07: anObject 
	dispersalJumps07 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps08">dispersalJumps08
	"Getter accessor with default value = 0 "
	^dispersalJumps08 ifNil:[dispersalJumps08 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps08:">dispersalJumps08: anObject 
	dispersalJumps08 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps09">dispersalJumps09
	"Getter accessor with default value = 0 "
	^dispersalJumps09 ifNil:[dispersalJumps09 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps09:">dispersalJumps09: anObject 
	dispersalJumps09 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps10">dispersalJumps10
	"Getter accessor with default value = 0 "
	^dispersalJumps10 ifNil:[dispersalJumps10 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps10:">dispersalJumps10: anObject 
	dispersalJumps10 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps11">dispersalJumps11
	"Getter accessor with default value = 0 "
	^dispersalJumps11 ifNil:[dispersalJumps11 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps11:">dispersalJumps11: anObject 
	dispersalJumps11 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps12">dispersalJumps12
	"Getter accessor with default value = 0 "
	^dispersalJumps12 ifNil:[dispersalJumps12 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps12:">dispersalJumps12: anObject 
	dispersalJumps12 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps13">dispersalJumps13
	"Getter accessor with default value = 0 "
	^dispersalJumps13 ifNil:[dispersalJumps13 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps13:">dispersalJumps13: anObject 
	dispersalJumps13 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps14">dispersalJumps14
	"Getter accessor with default value = 0 "
	^dispersalJumps14 ifNil:[dispersalJumps14 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps14:">dispersalJumps14: anObject 
	dispersalJumps14 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps15">dispersalJumps15
	"Getter accessor with default value = 0 "
	^dispersalJumps15 ifNil:[dispersalJumps15 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps15:">dispersalJumps15: anObject 
	dispersalJumps15 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps16">dispersalJumps16
	"Getter accessor with default value = 0 "
	^dispersalJumps16 ifNil:[dispersalJumps16 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps16:">dispersalJumps16: anObject 
	dispersalJumps16 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps17">dispersalJumps17
	"Getter accessor with default value = 0 "
	^dispersalJumps17 ifNil:[dispersalJumps17 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps17:">dispersalJumps17: anObject 
	dispersalJumps17 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps18">dispersalJumps18
	"Getter accessor with default value = 0 "
	^dispersalJumps18 ifNil:[dispersalJumps18 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps18:">dispersalJumps18: anObject 
	dispersalJumps18 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps19">dispersalJumps19
	"Getter accessor with default value = 0 "
	^dispersalJumps19 ifNil:[dispersalJumps19 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps19:">dispersalJumps19: anObject 
	dispersalJumps19 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps20">dispersalJumps20
	"Getter accessor with default value = 0 "
	^dispersalJumps20 ifNil:[dispersalJumps20 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps20:">dispersalJumps20: anObject 
	dispersalJumps20 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps21">dispersalJumps21
	"Getter accessor with default value = 0 "
	^dispersalJumps21 ifNil:[dispersalJumps21 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps21:">dispersalJumps21: anObject 
	dispersalJumps21 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps22">dispersalJumps22
	"Getter accessor with default value = 0 "
	^dispersalJumps22 ifNil:[dispersalJumps22 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps22:">dispersalJumps22: anObject 
	dispersalJumps22 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps23">dispersalJumps23
	"Getter accessor with default value = 0 "
	^dispersalJumps23 ifNil:[dispersalJumps23 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps23:">dispersalJumps23: anObject 
	dispersalJumps23 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps24">dispersalJumps24
	"Getter accessor with default value = 0 "
	^dispersalJumps24 ifNil:[dispersalJumps24 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps24:">dispersalJumps24: anObject 
	dispersalJumps24 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps25">dispersalJumps25
	"Getter accessor with default value = 0 "
	^dispersalJumps25 ifNil:[dispersalJumps25 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps25:">dispersalJumps25: anObject 
	dispersalJumps25 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps26">dispersalJumps26
	"Getter accessor with default value = 0 "
	^dispersalJumps26 ifNil:[dispersalJumps26 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps26:">dispersalJumps26: anObject 
	dispersalJumps26 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps27">dispersalJumps27
	"Getter accessor with default value = 0 "
	^dispersalJumps27 ifNil:[dispersalJumps27 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps27:">dispersalJumps27: anObject 
	dispersalJumps27 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps28">dispersalJumps28
	"Getter accessor with default value = 0 "
	^dispersalJumps28 ifNil:[dispersalJumps28 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps28:">dispersalJumps28: anObject 
	dispersalJumps28 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps29">dispersalJumps29
	"Getter accessor with default value = 0 "
	^dispersalJumps29 ifNil:[dispersalJumps29 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps29:">dispersalJumps29: anObject 
	dispersalJumps29 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps30">dispersalJumps30
	"Getter accessor with default value = 0 "
	^dispersalJumps30 ifNil:[dispersalJumps30 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps30:">dispersalJumps30: anObject 
	dispersalJumps30 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps31">dispersalJumps31
	"Getter accessor with default value = 0 "
	^dispersalJumps31 ifNil:[dispersalJumps31 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps31:">dispersalJumps31: anObject 
	dispersalJumps31 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps32">dispersalJumps32
	"Getter accessor with default value = 0 "
	^dispersalJumps32 ifNil:[dispersalJumps32 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps32:">dispersalJumps32: anObject 
	dispersalJumps32 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps33">dispersalJumps33
	"Getter accessor with default value = 0 "
	^dispersalJumps33 ifNil:[dispersalJumps33 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps33:">dispersalJumps33: anObject 
	dispersalJumps33 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps34">dispersalJumps34
	"Getter accessor with default value = 0 "
	^dispersalJumps34 ifNil:[dispersalJumps34 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumps34:">dispersalJumps34: anObject 
	dispersalJumps34 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv01">dispersalJumpv01
	"Getter accessor with default value = 0 "
	^dispersalJumpv01 ifNil:[dispersalJumpv01 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv01:">dispersalJumpv01: anObject 
	dispersalJumpv01 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv02">dispersalJumpv02
	"Getter accessor with default value = 0 "
	^dispersalJumpv02 ifNil:[dispersalJumpv02 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv02:">dispersalJumpv02: anObject 
	dispersalJumpv02 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv03">dispersalJumpv03
	"Getter accessor with default value = 0 "
	^dispersalJumpv03 ifNil:[dispersalJumpv03 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv03:">dispersalJumpv03: anObject 
	dispersalJumpv03 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv04">dispersalJumpv04
	"Getter accessor with default value = 0 "
	^dispersalJumpv04 ifNil:[dispersalJumpv04 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv04:">dispersalJumpv04: anObject 
	dispersalJumpv04 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv05">dispersalJumpv05
	"Getter accessor with default value = 0 "
	^dispersalJumpv05 ifNil:[dispersalJumpv05 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv05:">dispersalJumpv05: anObject 
	dispersalJumpv05 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv06">dispersalJumpv06
	"Getter accessor with default value = 0 "
	^dispersalJumpv06 ifNil:[dispersalJumpv06 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv06:">dispersalJumpv06: anObject 
	dispersalJumpv06 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv07">dispersalJumpv07
	"Getter accessor with default value = 0 "
	^dispersalJumpv07 ifNil:[dispersalJumpv07 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv07:">dispersalJumpv07: anObject 
	dispersalJumpv07 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv08">dispersalJumpv08
	"Getter accessor with default value = 0 "
	^dispersalJumpv08 ifNil:[dispersalJumpv08 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv08:">dispersalJumpv08: anObject 
	dispersalJumpv08 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv09">dispersalJumpv09
	"Getter accessor with default value = 0 "
	^dispersalJumpv09 ifNil:[dispersalJumpv09 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv09:">dispersalJumpv09: anObject 
	dispersalJumpv09 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv10">dispersalJumpv10
	"Getter accessor with default value = 0 "
	^dispersalJumpv10 ifNil:[dispersalJumpv10 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv10:">dispersalJumpv10: anObject 
	dispersalJumpv10 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv11">dispersalJumpv11
	"Getter accessor with default value = 0 "
	^dispersalJumpv11 ifNil:[dispersalJumpv11 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv11:">dispersalJumpv11: anObject 
	dispersalJumpv11 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv12">dispersalJumpv12
	"Getter accessor with default value = 0 "
	^dispersalJumpv12 ifNil:[dispersalJumpv12 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv12:">dispersalJumpv12: anObject 
	dispersalJumpv12 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv13">dispersalJumpv13
	"Getter accessor with default value = 0 "
	^dispersalJumpv13 ifNil:[dispersalJumpv13 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv13:">dispersalJumpv13: anObject 
	dispersalJumpv13 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv14">dispersalJumpv14
	"Getter accessor with default value = 0 "
	^dispersalJumpv14 ifNil:[dispersalJumpv14 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv14:">dispersalJumpv14: anObject 
	dispersalJumpv14 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv15">dispersalJumpv15
	"Getter accessor with default value = 0 "
	^dispersalJumpv15 ifNil:[dispersalJumpv15 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv15:">dispersalJumpv15: anObject 
	dispersalJumpv15 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv16">dispersalJumpv16
	"Getter accessor with default value = 0 "
	^dispersalJumpv16 ifNil:[dispersalJumpv16 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv16:">dispersalJumpv16: anObject 
	dispersalJumpv16 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv17">dispersalJumpv17
	"Getter accessor with default value = 0 "
	^dispersalJumpv17 ifNil:[dispersalJumpv17 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv17:">dispersalJumpv17: anObject 
	dispersalJumpv17 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv18">dispersalJumpv18
	"Getter accessor with default value = 0 "
	^dispersalJumpv18 ifNil:[dispersalJumpv18 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv18:">dispersalJumpv18: anObject 
	dispersalJumpv18 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv19">dispersalJumpv19
	"Getter accessor with default value = 0 "
	^dispersalJumpv19 ifNil:[dispersalJumpv19 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv19:">dispersalJumpv19: anObject 
	dispersalJumpv19 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv20">dispersalJumpv20
	"Getter accessor with default value = 0 "
	^dispersalJumpv20 ifNil:[dispersalJumpv20 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv20:">dispersalJumpv20: anObject 
	dispersalJumpv20 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv21">dispersalJumpv21
	"Getter accessor with default value = 0 "
	^dispersalJumpv21 ifNil:[dispersalJumpv21 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv21:">dispersalJumpv21: anObject 
	dispersalJumpv21 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv22">dispersalJumpv22
	"Getter accessor with default value = 0 "
	^dispersalJumpv22 ifNil:[dispersalJumpv22 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv22:">dispersalJumpv22: anObject 
	dispersalJumpv22 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv23">dispersalJumpv23
	"Getter accessor with default value = 0 "
	^dispersalJumpv23 ifNil:[dispersalJumpv23 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv23:">dispersalJumpv23: anObject 
	dispersalJumpv23 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv24">dispersalJumpv24
	"Getter accessor with default value = 0 "
	^dispersalJumpv24 ifNil:[dispersalJumpv24 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv24:">dispersalJumpv24: anObject 
	dispersalJumpv24 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv25">dispersalJumpv25
	"Getter accessor with default value = 0 "
	^dispersalJumpv25 ifNil:[dispersalJumpv25 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv25:">dispersalJumpv25: anObject 
	dispersalJumpv25 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv26">dispersalJumpv26
	"Getter accessor with default value = 0 "
	^dispersalJumpv26 ifNil:[dispersalJumpv26 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv26:">dispersalJumpv26: anObject 
	dispersalJumpv26 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv27">dispersalJumpv27
	"Getter accessor with default value = 0 "
	^dispersalJumpv27 ifNil:[dispersalJumpv27 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv27:">dispersalJumpv27: anObject 
	dispersalJumpv27 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv28">dispersalJumpv28
	"Getter accessor with default value = 0 "
	^dispersalJumpv28 ifNil:[dispersalJumpv28 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv28:">dispersalJumpv28: anObject 
	dispersalJumpv28 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv29">dispersalJumpv29
	"Getter accessor with default value = 0 "
	^dispersalJumpv29 ifNil:[dispersalJumpv29 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv29:">dispersalJumpv29: anObject 
	dispersalJumpv29 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv30">dispersalJumpv30
	"Getter accessor with default value = 0 "
	^dispersalJumpv30 ifNil:[dispersalJumpv30 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv30:">dispersalJumpv30: anObject 
	dispersalJumpv30 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv31">dispersalJumpv31
	"Getter accessor with default value = 0 "
	^dispersalJumpv31 ifNil:[dispersalJumpv31 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv31:">dispersalJumpv31: anObject 
	dispersalJumpv31 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv32">dispersalJumpv32
	"Getter accessor with default value = 0 "
	^dispersalJumpv32 ifNil:[dispersalJumpv32 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv32:">dispersalJumpv32: anObject 
	dispersalJumpv32 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv33">dispersalJumpv33
	"Getter accessor with default value = 0 "
	^dispersalJumpv33 ifNil:[dispersalJumpv33 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv33:">dispersalJumpv33: anObject 
	dispersalJumpv33 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv34">dispersalJumpv34
	"Getter accessor with default value = 0 "
	^dispersalJumpv34 ifNil:[dispersalJumpv34 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="dispersalJumpv34:">dispersalJumpv34: anObject 
	dispersalJumpv34 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="fecundityPhthorimaea">fecundityPhthorimaea
	"US = fecundity layer"
	"ES = Representa a una capa que según la temperatura va a guardar el numero de huevos por hembra (ecuación de la publicación de Olivier Dangles)"
	^fecundityPhthorimaea ifNil:[fecundityPhthorimaea := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="fecundityPhthorimaea:">fecundityPhthorimaea: anObject 
	fecundityPhthorimaea := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="fecunditySymmetrischemma">fecunditySymmetrischemma
	"US = fecundity layer"
	"ES = Representa a una capa que según la temperatura va a guardar el numero de huevos por hembra (ecuación de la publicación de Olivier Dangles)"
	^fecunditySymmetrischemma ifNil:[fecunditySymmetrischemma := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="fecunditySymmetrischemma:">fecunditySymmetrischemma: anObject 
	fecunditySymmetrischemma := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="fecundityTecia">fecundityTecia
	"US = fecundity layer"
	"ES = Representa a una capa que según la temperatura va a guardar el numero de huevos por hembra (ecuación de la publicación de Olivier Dangles)"
^fecundityTecia ifNil:[fecundityTecia := 0].</body>

<body package="SimPolillaSimiatug_v02" selector="fecundityTecia:">fecundityTecia: anObject 
	fecundityTecia := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="moveP">moveP
	"US = buffer layer to store the pest diffusion cpabilities"
	"ES = Representa la capa de las polillas adultas que potencialmente pueden dispersarse por difusión"
	^moveP ifNil:[moveP := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="moveP:">moveP: anObject 
	moveP := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="moveS">moveS
	"US = buffer layer to store the pest diffusion cpabilities"
	"ES = Representa la capa de las polillas adultas que potencialmente pueden dispersarse por difusión"
	^moveS ifNil:[moveS := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="moveS:">moveS: anObject 
	moveS := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="moveT">moveT
	"US = buffer layer to store the pest diffusion cpabilities"
	"ES = Representa la capa de las polillas adultas que potencialmente pueden dispersarse por difusión"
	^moveT ifNil:[moveT := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="moveT:">moveT: anObject 
	moveT := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="phthorimaea">phthorimaea
	"US = juveniles' layer"
	"ES = Representa la capa de las polillas juveniles (del huevo a la larva)"
	^phthorimaea ifNil:[phthorimaea := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="phthorimaea:">phthorimaea: anObject 
	phthorimaea := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="phthorimaeaAdults">phthorimaeaAdults
	"US = adults' layer"
	"ES = Representa la capa de las polillas adultos"
	^phthorimaeaAdults ifNil:[phthorimaeaAdults := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="phthorimaeaAdults:">phthorimaeaAdults: anObject 
	phthorimaeaAdults := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="phthorimaeaFemale">phthorimaeaFemale
	"US = gravid females' layer"
	"ES = Representa la capa de las polillas hembras adultos"
	^phthorimaeaFemale ifNil:[phthorimaeaFemale := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="phthorimaeaFemale:">phthorimaeaFemale: anObject 
	phthorimaeaFemale := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="pluvioAnual">pluvioAnual
	"US = precipitations (not used in this model)"
	"ES = pluvioAnual es una capa que representa la precipitación anual promedia en mm.
	pluvioAnual no es generado por el modelo sino que viene de un mapa SIG, adentro del archivo *.env que inicia una simulación"
	^pluvioAnual ifNil:[pluvioAnual := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="pluvioAnual:">pluvioAnual: anObject 
	pluvioAnual := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="population">population
	"US = localisation of villages in the area studied (not used in this model)"
	"ES = population es una capa que representa la population en los 34 pueblos mas grande del mapa.
	population no es generado por el modelo sino que viene de un mapa SIG, adentro del archivo *.env que inicia una simulación"
	^population ifNil:[population := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="population:">population: anObject 
	population := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="probe">probe
	"US = %pest which can move per saltation (LDD)"
	"ES = Representa el porcentage de polillas que pueden hacer una dispersión por saltación"
	^probe ifNil:[probe := 0.01]</body>

<body package="SimPolillaSimiatug_v02" selector="probe:">probe: anObject 
	probe := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="qualityHabitat">qualityHabitat
	"US = representation of the habitat quality considering resources for the pest"
	"ES = Representa la capa de cuantidad de recurso tomando en cuenta el uso del suelo (agro) y la presencia de bodegas (bodega)"
	^qualityHabitat ifNil:[qualityHabitat := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="qualityHabitat:">qualityHabitat: anObject 
	qualityHabitat := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rain1">rain1
	"US = precipitations (not used in this model)"
	"ES = Precipitación promedia durante el mes 1=enero"
	^rain1 ifNil:[rain1 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rain10">rain10
	"US = precipitations (not used in this model)"
	"ES = Precipitación promedia durante el mes 10"
	^rain10 ifNil:[rain10 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rain10:">rain10: anObject 
	rain10 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rain11">rain11
	"US = precipitations (not used in this model)"
	"ES = Precipitación promedia durante el mes 11"
	^rain11 ifNil:[rain11 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rain11:">rain11: anObject 
	rain11 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rain12">rain12
	"US = precipitations (not used in this model)"
	"ES = Precipitación promedia durante el mes 12"
	^rain12 ifNil:[rain12 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rain12:">rain12: anObject 
	rain12 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rain1:">rain1: anObject 
	rain1 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rain2">rain2
	"US = precipitations (not used in this model)"
	"ES = Precipitación promedia durante el mes 2"
	^rain2 ifNil:[rain2 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rain2:">rain2: anObject 
	rain2 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rain3">rain3
	"US = precipitations (not used in this model)"
	"ES = Precipitación promedia durante el mes 3"
	^rain3 ifNil:[rain3 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rain3:">rain3: anObject 
	rain3 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rain4">rain4
	"US = precipitations (not used in this model)"
	"ES = Precipitación promedia durante el mes 4"
	^rain4 ifNil:[rain4 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rain4:">rain4: anObject 
	rain4 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rain5">rain5
	"US = precipitations (not used in this model)"
	"ES = Precipitación promedia durante el mes 5"
	^rain5 ifNil:[rain5 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rain5:">rain5: anObject 
	rain5 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rain6">rain6
	"US = precipitations (not used in this model)"
	"ES = Precipitación promedia durante el mes 6"
	^rain6 ifNil:[rain6 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rain6:">rain6: anObject 
	rain6 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rain7">rain7
	"US = precipitations (not used in this model)"
	"ES = Precipitación promedia durante el mes 7"
	^rain7 ifNil:[rain7 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rain7:">rain7: anObject 
	rain7 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rain8">rain8
	"US = precipitations (not used in this model)"
	"ES = Precipitación promedia durante el mes 8"
	^rain8 ifNil:[rain8 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rain8:">rain8: anObject 
	rain8 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rain9">rain9
	"US = precipitations (not used in this model)"
	"ES = Precipitación promedia durante el mes 9"
	^rain9 ifNil:[rain9 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rain9:">rain9: anObject 
	rain9 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rainEffectAdults">rainEffectAdults
	"US = precipitations (not used in this model)"
	"ES = Calcula el efecto de la precipitación en los adultos. Un mes aleatorio y el mes siguiente estan utilizados para que este factor cambia con cada generación, es decir que nunca va a ser el mismo efecto en las poblaciones de polilla. Las referencias utilisadas no son tan buenas y seria necesario añadir conocimiento gracias a bioensayos, pero resulta que este parámetro tiene muy poca incidencia en la dispersión y la supervivencia de las polillas. Resulta que no es necesario añadir mas conocimiento porque el nivel de precisión que tenemos con el modelo es suficiente en comparsión del uso que tenemos del modelo."
|x x2 r rEffect|

x := Cormas random.

x&gt;=0 ifTrue: [ x&lt;= 0.08333333 ifTrue: [x := 1]].
x&gt; 0.08333333 ifTrue: [ x&lt;=0.1666667 ifTrue: [x := 2]].
x&gt; 0.1666667 ifTrue: [ x&lt;=0.25 ifTrue: [x := 3]].
x&gt; 0.25 ifTrue: [ x&lt;=0.3333333 ifTrue: [x := 4]].
x&gt; 0.3333333 ifTrue: [ x&lt;=0.4166667 ifTrue: [x := 5]].
x&gt; 0.4166667 ifTrue: [ x&lt;=0.5 ifTrue: [x := 6]].
x&gt; 0.5 ifTrue: [ x&lt;=0.5833333 ifTrue: [x := 7]].
x&gt; 0.5833333 ifTrue: [ x&lt;=0.6666667 ifTrue: [x := 8]].
x&gt; 0.6666667 ifTrue: [ x&lt;=0.75 ifTrue: [x := 9]].
x&gt; 0.75 ifTrue: [ x&lt;=0.8333333 ifTrue: [x := 10]].
x&gt; 0.8333333 ifTrue: [ x&lt;=0.9166667 ifTrue: [x := 11]].
x&gt; 0.9166667 ifTrue: [ x&lt;=1 ifTrue: [x := 12]].

x2 := x + 1.
x2 = 13 ifTrue: [x2 := 1].

x = 1 ifTrue: [x :=rain1] 
	ifFalse: [x=2 ifTrue: [x :=rain2]
		ifFalse: [x=3 ifTrue: [x :=rain3]
			ifFalse: [x=4 ifTrue: [x :=rain4]
				ifFalse: [x=5 ifTrue: [x :=rain5]
					ifFalse: [x=6 ifTrue: [x :=rain6]
						ifFalse: [x=7 ifTrue: [x :=rain7]
							ifFalse: [x=8 ifTrue: [x :=rain8]
								ifFalse: [x=9 ifTrue: [x :=rain9]
									ifFalse: [x=10 ifTrue: [x :=rain10]
										ifFalse: [x=11 ifTrue: [x :=rain11]
											ifFalse: [x=12 ifTrue: [x :=rain12]
												ifFalse: [x isNil ifTrue: [x :=1]]     ]]]]]]]]]]].
x2 = 1 ifTrue: [x2 :=rain1] 
	ifFalse: [x2=2 ifTrue: [x2 :=rain2]
		ifFalse: [x2=3 ifTrue: [x2 :=rain3]
			ifFalse: [x2=4 ifTrue: [x2 :=rain4]
				ifFalse: [x2=5 ifTrue: [x2 :=rain5]
					ifFalse: [x2=6 ifTrue: [x2 :=rain6]
						ifFalse: [x2=7 ifTrue: [x2 :=rain7]
							ifFalse: [x2=8 ifTrue: [x2 :=rain8]
								ifFalse: [x2=9 ifTrue: [x2 :=rain9]
									ifFalse: [x2=10 ifTrue: [x2 :=rain10]
										ifFalse: [x2=11 ifTrue: [x2 :=rain11]
											ifFalse: [x2=12 ifTrue: [x2 :=rain12]
												ifFalse: [x isNil ifTrue: [x :=1]]     ]]]]]]]]]]].

x isNil ifTrue: [x :=1].
x2 isNil ifTrue: [x2 :=1].
r := (x + x2) * 6.
rEffect := (0-r)/40000000.
rEffect := rEffect * r.
rEffect := (rEffect)exp.

self rainEffectAdults: rEffect.

	^rainEffectAdults ifNil:[rainEffectAdults := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="rainEffectAdults:">rainEffectAdults: anObject 
	rainEffectAdults := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rainEffectJuveniles">rainEffectJuveniles
	"US = precipitations (not used in this model)"
	"ES = Calcula el efecto de la precipitación en los juveniles. Un mes aleatorio y el mes siguiente estan utilizados para que este factor cambia con cada generación, es decir que nunca va a ser el mismo efecto en las poblaciones de polilla. Las referencias utilisadas no son tan buenas y seria necesario añadir conocimiento gracias a bioensayos, pero resulta que este parámetro tiene muy poca incidencia en la dispersión y la supervivencia de las polillas. Resulta que no es necesario añadir mas conocimiento porque el nivel de precisión que tenemos con el modelo es suficiente en comparsión del uso que tenemos del modelo. El efecto de las precipitaciones es distinto para los juveniles y los adultos"
|x x2 r rEffect|

x := Cormas random.

x&gt;=0 ifTrue: [ x&lt;= 0.08333333 ifTrue: [x := 1]].
x&gt; 0.08333333 ifTrue: [ x&lt;=0.1666667 ifTrue: [x := 2]].
x&gt; 0.1666667 ifTrue: [ x&lt;=0.25 ifTrue: [x := 3]].
x&gt; 0.25 ifTrue: [ x&lt;=0.3333333 ifTrue: [x := 4]].
x&gt; 0.3333333 ifTrue: [ x&lt;=0.4166667 ifTrue: [x := 5]].
x&gt; 0.4166667 ifTrue: [ x&lt;=0.5 ifTrue: [x := 6]].
x&gt; 0.5 ifTrue: [ x&lt;=0.5833333 ifTrue: [x := 7]].
x&gt; 0.5833333 ifTrue: [ x&lt;=0.6666667 ifTrue: [x := 8]].
x&gt; 0.6666667 ifTrue: [ x&lt;=0.75 ifTrue: [x := 9]].
x&gt; 0.75 ifTrue: [ x&lt;=0.8333333 ifTrue: [x := 10]].
x&gt; 0.8333333 ifTrue: [ x&lt;=0.9166667 ifTrue: [x := 11]].
x&gt; 0.9166667 ifTrue: [ x&lt;=1 ifTrue: [x := 12]].

x2 := x + 1.
x2 = 13 ifTrue: [x2 := 1].

x = 1 ifTrue: [x :=self rain1] 
	ifFalse: [x=2 ifTrue: [x :=self rain2]
		ifFalse: [x=3 ifTrue: [x :=self rain3]
			ifFalse: [x=4 ifTrue: [x :=self rain4]
				ifFalse: [x=5 ifTrue: [x :=self rain5]
					ifFalse: [x=6 ifTrue: [x :=self rain6]
						ifFalse: [x=7 ifTrue: [x :=self rain7]
							ifFalse: [x=8 ifTrue: [x :=self rain8]
								ifFalse: [x=9 ifTrue: [x :=self rain9]
									ifFalse: [x=10 ifTrue: [x :=self rain10]
										ifFalse: [x=11 ifTrue: [x :=self rain11]
											ifFalse: [x=12 ifTrue: [x :=self rain12]
												ifFalse: [x isNil ifTrue: [x :=1]]     ]]]]]]]]]]].
x2 = 1 ifTrue: [x2 :=self rain1] 
	ifFalse: [x2=2 ifTrue: [x2 :=self rain2]
		ifFalse: [x2=3 ifTrue: [x2 :=self rain3]
			ifFalse: [x2=4 ifTrue: [x2 :=self rain4]
				ifFalse: [x2=5 ifTrue: [x2 :=self rain5]
					ifFalse: [x2=6 ifTrue: [x2 :=self rain6]
						ifFalse: [x2=7 ifTrue: [x2 :=self rain7]
							ifFalse: [x2=8 ifTrue: [x2 :=self rain8]
								ifFalse: [x2=9 ifTrue: [x2 :=self rain9]
									ifFalse: [x2=10 ifTrue: [x2 :=self rain10]
										ifFalse: [x2=11 ifTrue: [x2 :=self rain11]
											ifFalse: [x2=12 ifTrue: [x2 :=self rain12]
												ifFalse: [x isNil ifTrue: [x :=1]]     ]]]]]]]]]]].

x isNil ifTrue: [x :=1].
x2 isNil ifTrue: [x :=1].
r := (x + x2) * 6.
rEffect := (0-r)/40000000.
rEffect := rEffect * r.
rEffect := (rEffect)exp.

self rainEffectJuveniles: rEffect.


	^rainEffectJuveniles ifNil:[rainEffectJuveniles := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="rainEffectJuveniles:">rainEffectJuveniles: anObject 
	rainEffectJuveniles := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rateLifePhthorimaea">rateLifePhthorimaea
	"US = development time"
	"ES = Representa el tiempo de desarollo de las polillas, es decir cuanto tiempo desde el huevo hasta el adulto. Es necesario para ajustar la fecundidad según las diferencias entre polillas."
^rateLifePhthorimaea ifNil:[rateLifePhthorimaea := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rateLifePhthorimaea:">rateLifePhthorimaea: anObject 
	rateLifePhthorimaea := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rateLifeSymmetrischemma">rateLifeSymmetrischemma
	"US = development time"
	"ES = Representa el tiempo de desarollo de las polillas, es decir cuanto tiempo desde el huevo hasta el adulto. Es necesario para ajustar la fecundidad según las diferencias entre polillas."
^rateLifeSymmetrischemma ifNil:[rateLifeSymmetrischemma := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rateLifeSymmetrischemma:">rateLifeSymmetrischemma: anObject 
	rateLifeSymmetrischemma := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rateLifeTecia">rateLifeTecia
	"US = development time"
	"ES = Representa el tiempo de desarollo de las polillas, es decir cuanto tiempo desde el huevo hasta el adulto. Es necesario para ajustar la fecundidad según las diferencias entre polillas."
^rateLifeTecia ifNil:[rateLifeTecia := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="rateLifeTecia:">rateLifeTecia: anObject 
	rateLifeTecia := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="roads">roads
	"US = roads (not used)"
	"ES = Representa la capa de las carreteras, que por el momento no es utilizado..."
	^roads ifNil:[roads := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="roads:">roads: anObject 
	roads := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rP">rP
	"US = corrected fecundity"
	"ES = Representa la fecunidad (numero de huevos por hembra), con la corección del hecho que cada polilla tiene un tiempo de desarollo distinto según la temperatura."
	^rP ifNil:[rP := 0.2]</body>

<body package="SimPolillaSimiatug_v02" selector="rP:">rP: anObject 
	rP := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rS">rS
	"US = corrected fecundity"
	"ES = Representa la fecunidad (numero de huevos por hembra), con la corección del hecho que cada polilla tiene un tiempo de desarollo distinto según la temperatura."
	^rS ifNil:[rS := 0.2]</body>

<body package="SimPolillaSimiatug_v02" selector="rS:">rS: anObject 
	rS := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rT">rT
	"US = corrected fecundity"
	"ES = Representa la fecunidad (numero de huevos por hembra), con la corección del hecho que cada polilla tiene un tiempo de desarollo distinto según la temperatura."
	^rT ifNil:[rT := 0.2]</body>

<body package="SimPolillaSimiatug_v02" selector="rT:">rT: anObject 
	rT := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="stochastic">stochastic
	"US = stochastic adjustment of the temperature as sujested in the litterature"
	| x1 x2 y1 y2 w t|

x1 := (2 * (Cormas random)) - 1.
x2 := (2 * (Cormas random)) - 1.
w := (x1 * x1) + (x2 * x2).

w&lt;=1 ifTrue: [
	w := ( ((0-2) * ((w)ln)) /w )sqrt.
	y1 := x1 * w.
			t := 0 - 2.
			y1&lt;=t ifTrue: [y1 := t].
			y1&gt;=2 ifTrue: [y1 := 2].
	y2 := x2 * w.].

	self stochastic: y1.

	^stochastic ifNil: [stochastic := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="stochastic:">stochastic: anObject 
	stochastic := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="stoPec">stoPec
	^stoPec ifNil:[stoPec := 150]</body>

<body package="SimPolillaSimiatug_v02" selector="stoPec2">stoPec2
	^stoPec2 ifNil:[stoPec2 := 20]</body>

<body package="SimPolillaSimiatug_v02" selector="stoPec2:">stoPec2: anObject
	stoPec2 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="stoPec:">stoPec: anObject
	stoPec := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="survivalRatePhthorimaea">survivalRatePhthorimaea
	"US = pest survival"
	"ES = Representa la capa de supervivencia según la temperatura"
	^survivalRatePhthorimaea ifNil:[survivalRatePhthorimaea := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="survivalRatePhthorimaea:">survivalRatePhthorimaea: anObject 
	survivalRatePhthorimaea := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="survivalRateSymmetrischemma">survivalRateSymmetrischemma
	"US = pest survival"
	"ES = Representa la capa de supervivencia según la temperatura"
	^survivalRateSymmetrischemma ifNil:[survivalRateSymmetrischemma := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="survivalRateSymmetrischemma:">survivalRateSymmetrischemma: anObject 
	survivalRateSymmetrischemma := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="survivalRateTecia">survivalRateTecia
	"US = pest survival"
	"ES = Representa la capa de supervivencia según la temperatura"
^survivalRateTecia ifNil:[survivalRateTecia := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="survivalRateTecia:">survivalRateTecia: anObject 
	survivalRateTecia := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="symmetrischemaAdults">symmetrischemaAdults
	"US = pest adults"
	"ES = Representa la capa de las polillas adultos"
	^symmetrischemaAdults ifNil:[symmetrischemaAdults := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="symmetrischemaAdults:">symmetrischemaAdults: anObject 
	symmetrischemaAdults := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="symmetrischemaFemale">symmetrischemaFemale
	"US = pest gravid females"
	"ES = Representa la capa de las polillas hembras adultos"
	^symmetrischemaFemale ifNil:[symmetrischemaFemale := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="symmetrischemaFemale:">symmetrischemaFemale: anObject 
	symmetrischemaFemale := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="symmetrischemma">symmetrischemma
	"US = pest juveniles"
	"ES = Representa la capa de las polillas juveniles (del huevo a la larva)"
	^symmetrischemma ifNil:[symmetrischemma := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="symmetrischemma:">symmetrischemma: anObject 
	symmetrischemma := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="tecia">tecia
	"US = pest juveniles"
	"ES = Representa la capa de las polillas juveniles (del huevo a la larva)"
	^tecia ifNil:[tecia := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="tecia:">tecia: anObject 
	tecia := anObject.
	self	defineVisualState; show</body>

<body package="SimPolillaSimiatug_v02" selector="teciaAdults">teciaAdults
	"US = pest adults"
	"ES = Representa la capa de las polillas adultos"
	^teciaAdults ifNil:[teciaAdults := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="teciaAdults:">teciaAdults: anObject 
	teciaAdults := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="teciaFemale">teciaFemale
	"US = pest gravid females"
	"ES = Representa la capa de las polillas hembras adultos"
	^teciaFemale ifNil:[teciaFemale := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="teciaFemale:">teciaFemale: anObject 
	teciaFemale := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="tempMaxi">tempMaxi
	"US = max(Temperature)"
	"ES = tempMaxi es una capa que representa la temperatura promedia maxima en grados.
	tempMaxi no es generado por el modelo sino que viene de un mapa SIG, adentro del archivo *.env que inicia una simulación"
	^tempMaxi ifNil:[tempMaxi := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="tempMaxi:">tempMaxi: anObject 
	tempMaxi := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="tempMini">tempMini
	"US = min(Temperature)"
	"ES = tempMini es una capa que representa la temperatura promedia minima en grados.
	tempMini no es generado por el modelo sino que viene de un mapa SIG, adentro del archivo *.env que inicia una simulación"
	^tempMini ifNil:[tempMini := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="tempMini:">tempMini: anObject 
	tempMini := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="tempPromedio">tempPromedio
	"US = mean(Temperature)"
	"ES = tempPromedio es una capa que representa la temperatura promedia en grados.
	tempPromedio no es generado por el modelo sino que viene de un mapa SIG, adentro del archivo *.env que inicia una simulación"
	^tempPromedio ifNil:[tempPromedio := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="tempPromedio:">tempPromedio: anObject 
	tempPromedio := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="tempStochastic">tempStochastic
	"US = Temperature used in the model"
	"ES = Representa la temperatura utilizada en el modelo que esta hecha a partir de la capa tempPromedio y de la capa stochastic"
	^tempStochastic ifNil:[tempStochastic := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="tempStochastic:">tempStochastic: anObject 
	tempStochastic := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="village">village
	"US = villages (not used in this model)"
	"ES = Representa la capa de los pueblos, toma el valor 1 cuando hay un pueblo y 0 cuando no hay."
	^village ifNil:[village := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="village2">village2
	"US = villages (not used in this model)"
	"ES = Representa la capa de los pueblos, con un numero de 1 hasta 34 porque el modelo toma en cuenta los 34 mas grandes pueblos de la zona considerada."
	^village2 ifNil:[village2 := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="village2:">village2: anObject 
	village2 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="village:">village: anObject 
	village := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Cell</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="povAgro">povAgro
"GUI"
	"US = land use"
	"ES = Representamos en el mapa la capa agro. en verde tenemos las zonas de ciclo corto, es decir donde se puede que hay papas y en rojo las otras zonas como los parámos."
^super
	povAttribute: #agro
	minPalette:#(0 #red)
	maxPalette:#(1 #green)</body>

<body package="SimPolillaSimiatug_v02" selector="povAgroPart">povAgroPart
	^super 
		povAttribute: #agroPart
	min:1
	max:3
		color: ColorValue red</body>

<body package="SimPolillaSimiatug_v02" selector="povAgroPartPart">povAgroPartPart
	^super 
		povAttribute: #agroPartPart
	min:1
	max:18
		color: ColorValue red</body>

<body package="SimPolillaSimiatug_v02" selector="povAltura">povAltura
"GUI"
	"US = elevation"
	"ES = Representa la capa de altura desde 0 m.s.n.m hasta 5000 m.s.n.m.. Las partes mas altas estan en maron y las partes mas bajas en verde."
^super
	povAttribute: #altura
	minPalette:#(0 #green)
	maxPalette:#(5000 #brown)</body>

<body package="SimPolillaSimiatug_v02" selector="povBodegas">povBodegas
"GUI"
	"US = local stores"
	"ES = Representa la capa de las bodegas. Cuando hay una bodega el punto esta en rojo y cuando no hay en blanco."
^super
	povAttribute: #bodega
	minPalette:#(0 #white)
	maxPalette:#(1 #red)</body>

<body package="SimPolillaSimiatug_v02" selector="povPluvioAnual">povPluvioAnual
"GUI"
	"US = precipitaions"
	"ES = Representa la capa de las precipitaciones anuales. Los niveles se van desde 0 mm en blanco hasta 2500 mm en azul."
^super
	povAttribute: #pluvioAnual
	minPalette:#(0 #white)
	maxPalette:#(2500 #blue)</body>

<body package="SimPolillaSimiatug_v02" selector="povPopulation">povPopulation
"GUI"
	"US = populations (not used in this model)"
	"ES = Representa la capa de población. cuando no hay nadie la celda esta en blanca y se va hasta el marron cuando la población es alta. No hay diferencias para los pueblos de mas de 500 habitantes pero eso es unicamente visual."
^super
	povAttribute: #population
	minPalette:#(0 #white)
	maxPalette:#(500 #brown)</body>

<body package="SimPolillaSimiatug_v02" selector="povPTMPhthorimaeaAdults">povPTMPhthorimaeaAdults
"GUI"
	"US = %pest"
	"ES = Representa el numero relativo de polillas adultas."
^super
	povAttribute: #moveP
	min: 0
	max: 1000
	color: ColorValue red</body>

<body package="SimPolillaSimiatug_v02" selector="povPTMphthorimaeaFemale">povPTMphthorimaeaFemale
"GUI"
	"US = %pest"
	"ES = Representa el numero relativo de polillas hembras."
^super
	povAttribute: #bufferNumberPhthorimaeaFemale
	min: 0
	max: 1000
	color: ColorValue red</body>

<body package="SimPolillaSimiatug_v02" selector="povPTMSymmetrischemaAdults">povPTMSymmetrischemaAdults
"GUI"
	"US = %pest"
	"ES = Representa el numero relativo de polillas adultas."
^super
	povAttribute: #moveS
	min: 0
	max: 1000
	color: ColorValue blue</body>

<body package="SimPolillaSimiatug_v02" selector="povPTMsymmetrischemaFemale">povPTMsymmetrischemaFemale
"GUI"
	"US = %pest"
	"ES = Representa el numero relativo de polillas hembras."
^super
	povAttribute: #bufferNumberSymmetrischemaFemale
	min: 0
	max: 1000
	color: ColorValue blue</body>

<body package="SimPolillaSimiatug_v02" selector="povPTMTeciaAdults">povPTMTeciaAdults
"GUI"
	"US = %pest"
	"ES = Representa el numero relativo de polillas adultas."
^super
	povAttribute: #moveT
	min: 0
	max: 1000
	color: ColorValue green</body>

<body package="SimPolillaSimiatug_v02" selector="povPTMteciaFemale">povPTMteciaFemale
"GUI"
	"US = %pest"
	"ES = Representa el numero relativo de polillas hembras."
^super
	povAttribute: #bufferNumberTeciaFemale
	min: 0
	max: 1000
	color: ColorValue green</body>

<body package="SimPolillaSimiatug_v02" selector="povQualityHabitat">povQualityHabitat
"GUI"
	"US = habitat quality considering resources"
	"ES = Representa la cuantidad de recurso disponible en una celda."
^super
	povAttribute: #qualityHabitat
	minPalette:#(0 #red)
	maxPalette:#(1 #green)</body>

<body package="SimPolillaSimiatug_v02" selector="povRoads">povRoads
"GUI"
	"US = roads (not used)"
	"ES = Representa la capa de las carreteras...ahora no esta incluido en el modelo."
^super
	povAttribute: #roads
	minPalette:#(0 #black)
	maxPalette:#(1 #white)</body>

<body package="SimPolillaSimiatug_v02" selector="povStochastic">povStochastic
"GUI"
	"US = stochasticity over temperature"
	"ES = Representa la capa de estochasticidad del modelo. Para que funcionna la estochasticidad del modelo sobre la temperatura, ES NECESARIO QUE ESTA CAPA SEA VISIBLE EN ELMODULO SPACE... es un bug que no logro areglar hasta ahora..."
^super
	povAttribute: #stochastic
	minPalette:#(-10 #green)
	maxPalette:#(30 #red)</body>

<body package="SimPolillaSimiatug_v02" selector="povTempMaxi">povTempMaxi
"GUI"
	"US = Temperature"
	"ES = Representa la capa de temperatura maxima."
^super
	povAttribute: #tempMaxi
	minPalette:#(-2 #blue)
	maxPalette:#(25 #red)</body>

<body package="SimPolillaSimiatug_v02" selector="povTempMini">povTempMini
"GUI"
	"US = Temperature"
	"ES = Representa la capa de temperatura minima."
^super
	povAttribute: #tempMini
	minPalette:#(-2 #blue)
	maxPalette:#(25 #red)</body>

<body package="SimPolillaSimiatug_v02" selector="povTempPromedio">povTempPromedio
"GUI"
	"US = Temperature"
	"ES = Representa la capa de temperatura promedia."
^super
	povAttribute: #tempPromedio
	minPalette:#(-2 #blue)
	maxPalette:#(25 #red)</body>

<body package="SimPolillaSimiatug_v02" selector="povTempStochastic">povTempStochastic
"GUI"
	"US = Temperature"
	"ES = Representa la capa de temperatura promedia cambiada con el factor de estochasticidad (es decir la capa stochastic)."
^super
	povAttribute: #tempStochastic
	minPalette:#(-2 #blue)
	maxPalette:#(25 #red)</body>

<body package="SimPolillaSimiatug_v02" selector="povVillages">povVillages
"GUI"
	"US = villages"
	"ES = Representa la capa de los pueblos, con una celda azul si se encuentra un pueblo."
^super
	povAttribute: #village
	minPalette:#(0 #white)
	maxPalette:#(1 #blue)</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Cell</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="step">step
self updateTempStochastic.
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Cell</class-id> <category>modelIsolate</category>

<body package="SimPolillaSimiatug_v02" selector="initVariablesIsolate">initVariablesIsolate

self rainEffectAdults: 1.
self rainEffectJuveniles: 1.</body>

<body package="SimPolillaSimiatug_v02" selector="updateSurvivalRateIsolate">updateSurvivalRateIsolate
	"US = pest survival using Dangles et al. and Rebaudo et al."
	"ES = Regla para conocer la supervivencia de cada polilla según la temperatura"

| tempKelvinPromedio R aEgg bEgg cEgg dEgg eEgg fEgg aPupa bPupa cPupa dPupa ePupa fPupa aLarva bLarva cLarva dLarva eLarva fLarva survivalRateEggTecia survivalRateLarvaTecia survivalRatePupaTecia |
R := 1.987. "universal gas constant"

aEgg := 0.822.
bEgg := 0 - 758.5.
cEgg := 0 - 212100.
dEgg := 281.9.
eEgg := 405200.
fEgg := 303.8.
aLarva := 0.758.
bLarva := 0 - 180.2.
cLarva := 0 - 475700.
dLarva := 282.7.
eLarva := 1298000.
fLarva := 301.5.
aPupa := 0.9.
bPupa := 0 - 73.72.
cPupa := 0 - 1263000.
dPupa := 286.5.
ePupa := 1095000.
fPupa := 306.3.
tempKelvinPromedio := tempStochastic  + 273.5.

survivalRateEggTecia := (((aEgg * tempKelvinPromedio) /298.16) *((((bEgg * ((1/298.16) - (1/tempKelvinPromedio))))) exp)) / (((((((1/dEgg) - (1/tempKelvinPromedio)) * cEgg) / R) exp) + 1) + (((((1/fEgg) - (1/tempKelvinPromedio)) * eEgg) / R) exp)). 

survivalRateEggTecia &lt;=0 ifTrue:[survivalRateEggTecia:=0].

survivalRateLarvaTecia := (((aLarva * tempKelvinPromedio) /298.16) *((((bLarva * ((1/298.16) - (1/tempKelvinPromedio))))) exp)) / (((((((1/dLarva) - (1/tempKelvinPromedio)) * cLarva) / R) exp) + 1) + (((((1/fLarva) - (1/tempKelvinPromedio)) * eLarva) / R) exp)). 

survivalRateLarvaTecia &lt;=0 ifTrue:[survivalRateLarvaTecia:=0].

survivalRatePupaTecia isNil ifTrue:[survivalRatePupaTecia:=1].

self survivalRateTecia: survivalRatePupaTecia * survivalRateLarvaTecia * survivalRateEggTecia.

self survivalRateTecia &lt;0 ifTrue:[self survivalRateTecia: 0].</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Cell</class-id> <category>model</category>

<body package="SimPolillaSimiatug_v02" selector="bodegaEffect">bodegaEffect
"ES = Regla que pone una bodega mas donde hay un pueblo (1) y que modifica la temperatura según la presencia de bodega (2)"
"US = Rules which specify that if a village is present, therefore ther is at least one storage unit."

self altura&lt;1800 ifTrue:[self agro:0].

"(1)"
self village=1 ifTrue:[self bodega:1].

self bodegaDensityA:0.
self bodegaDensityP:0.

self agro=1 ifTrue:[
	self bodega isNil ifTrue:[
		Cormas random&lt;self bodegaDensityA ifTrue:[
			self bodega: 1
		]
		ifFalse:[
			self bodega: 0
		]
	]
].
self agro=0 ifTrue:[
	self bodega isNil ifTrue:[
		Cormas random&lt;self bodegaDensityP ifTrue:[
			self bodega: 1
		]
		ifFalse:[
			self bodega: 0
		]
	]
].
"(2)"
self bodega=1 ifTrue: 
	[self tempPromedio&gt;16 and: [Cormas random&lt;0.5 ifTrue:
			[self tempStochastic: 15]]].
self bodega=1 ifTrue: 
			[self tempPromedio&lt;14 ifTrue:
				[self tempStochastic: 15]].</body>

<body package="SimPolillaSimiatug_v02" selector="constructAgroPart">constructAgroPart

self agro=0 ifTrue:[self agroPart: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="dieAllPTM">dieAllPTM
"US = rules regarding the moth survival: at the end of a generation, old moths die"
"ES = Despues de una generación, todas las polillas deben de morir. Solo se queda huevos (juveniles), de la proxima generación."

"el numero maximo de juveniles es de 2000. Si hay mas, se queda a 2000."
self tecia&gt;2000 ifTrue:[self tecia: 2000].
self phthorimaea&gt;2000 ifTrue:[self phthorimaea: 2000].
self symmetrischemma&gt;2000 ifTrue:[self symmetrischemma: 2000].

"los adultos y/o hembras deben de morir"
self teciaAdults: 0.
self teciaFemale: 0.
self phthorimaeaAdults: 0.
self phthorimaeaFemale: 0.
self symmetrischemaAdults: 0.
self symmetrischemaFemale: 0.

"En las zonas donde no hay papas, hay poco recurso, añadimos este regla para que las polillas no pueden crusar un perimetro largo donde no hay papas (otro tipo de cultivo o paramo)"
self agro = 0 ifTrue:[self altura &gt; 3500 ifTrue:[self tecia: self tecia*0.1] ifFalse:[self tecia: self tecia*0.001]].
self agro = 0 ifTrue:[self altura &gt; 3500 ifTrue:[self phthorimaea: self phthorimaea*0.1] ifFalse:[self phthorimaea: self phthorimaea*0.001]].
self agro = 0 ifTrue:[self altura &gt; 3500 ifTrue:[self symmetrischemma: self symmetrischemma*0.1] ifFalse:[self symmetrischemma: self symmetrischemma*0.001]].</body>

<body package="SimPolillaSimiatug_v02" selector="diePTMAdults">diePTMAdults
"US = rules for the survival of the moths (adults)"
"ES = Regla que calcula la supervivencia de los adultos frente al nivel de predación, el efecto de las precipitaciones y el nivel de población de juveniles."
	| predLevel predationAdults predationAdultsT predationAdultsP predationAdultsS |

"nivel minimo =10, nivel maximo =0, si 0, 0% de supervivencia"
	predLevel := 10.
	predationAdults := (1) - (((0 - predLevel) / 20)  * predLevel)exp.

"adentro de una bodega no hay precipitaciones, entonces no hay efecto de la lluvia"
	self bodega = 1 ifTrue:[self rainEffectAdults: 1].

	"TECIA------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
	predationAdultsT := predationAdults.
	self teciaAdults: self teciaAdults * self rainEffectAdults * predationAdultsT.
	self moveT: self teciaAdults.
	"PHTHORIMAEA----------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
	predationAdultsP := predationAdults.
	self phthorimaeaAdults: self phthorimaeaAdults * self rainEffectAdults 	* predationAdultsP.
	self moveP: self phthorimaeaAdults.
	"SYMMETRISCHEMA---------------------------------------------------------------------------------------------------------------------------------------------------------------------"
	predationAdultsS := predationAdults.
	self symmetrischemaAdults: self symmetrischemaAdults * self rainEffectAdults * predationAdultsS.
	self moveS: self symmetrischemaAdults.
	"---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"</body>

<body package="SimPolillaSimiatug_v02" selector="diePTMJuveniles">diePTMJuveniles
"US = rules for the survival of the moths (juveniles)"
"ES = Regla para que la capa juveniles sea vacia cuando los juveniles estan adultos. Tambien aplicamos reglas de supervivencia."

|probaSurvival forceOfMortalityInnate forceOfMortalityDispersalRelated forceOfMortalityNaturalEnemies|

"adentro de una bodega no hay precipitaciones, entonces no hay efecto de la lluvia"
self bodega = 1 ifTrue:[self rainEffectJuveniles: 1].

"No utilisamos forceOfMortalityInnate porque tomamaos este parametro en cuenta dentro de la supervivencia de los adultos.
Los datos vienen de una publicación de Olivier Roux y Johann Baugärtner en Ecological Modelling, 1998 : Evaluation of mortality factors and risk analysis for the design of en integrated pest management system."
"TECIA------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
forceOfMortalityInnate:=0.016.
forceOfMortalityDispersalRelated:=0.060.
forceOfMortalityNaturalEnemies:=(0.129 + 0.162) / 2.

probaSurvival:= (0 - (("forceOfMortalityInnate + "forceOfMortalityDispersalRelated + forceOfMortalityNaturalEnemies)*5) ) exp.

self tecia ifNil:[self tecia: 0].

(self tecia: self tecia * probaSurvival * self survivalRateTecia * self rainEffectJuveniles).
(self teciaAdults: self tecia).

"PHTHORIMAEA----------------------------------------------------------------------------------------------------------------------------------------------------------------------------"

forceOfMortalityInnate:=0.016.
forceOfMortalityDispersalRelated:=0.060.
forceOfMortalityNaturalEnemies:=(0.129 + 0.162) / 2.

probaSurvival:= (0 - (("forceOfMortalityInnate + "forceOfMortalityDispersalRelated + forceOfMortalityNaturalEnemies)*5) ) exp.

self phthorimaea ifNil:[self phthorimaea: 0].

(self phthorimaea: self phthorimaea *probaSurvival * self survivalRatePhthorimaea * self rainEffectJuveniles).
(self phthorimaeaAdults: self phthorimaea).

"SYMMETRISCHEMA---------------------------------------------------------------------------------------------------------------------------------------------------------------------"

forceOfMortalityInnate:=0.016.
forceOfMortalityDispersalRelated:=0.060.
forceOfMortalityNaturalEnemies:=(0.129 + 0.162) / 2.

probaSurvival:= (0 - (("forceOfMortalityInnate + "forceOfMortalityDispersalRelated + forceOfMortalityNaturalEnemies)*5) ) exp.

self symmetrischemma ifNil:[self symmetrischemma: 0].

(self symmetrischemma: self symmetrischemma *probaSurvival * self survivalRateSymmetrischemma * self rainEffectJuveniles).
(self symmetrischemaAdults: self symmetrischemma).

"---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"</body>

<body package="SimPolillaSimiatug_v02" selector="DispersalJumpPforAnalysis">DispersalJumpPforAnalysis
"US = rules for the long distance dispersal (not used in the ABM at the scale considered)"
"ES = Reglas de dispersión por saltación"

|dispersalJumpRate value01 x numMigre|

"Proporción de la población de la celda de origen que se va a dispersar por saltación."
dispersalJumpRate := 0.3.

"valor de seguridad por razon de programación"
value01:=0.

"Area alrejedor de un pueblo que puede ser contaminada por saltación. Por ejemplo si el pueblo es de 1000 habitantes, la saltación puede ocurir en las 10 celdas alrejedor de este pueblo. Rounded es para que el numero sea un integer"
x:= (self population/100) rounded.

"Si la area es inferior o igual a cero, entonces pongamos 1"
x&lt;=0 ifTrue:[x := 1].

"Factor de división que hace morir una parte de la población que se dispersa."
numMigre := 2.

"si el pueblo es el pueblo numero 1, si un numero aleatorio entre 0 y 1 es mas pequeño que 0.1, si hay polillas, entonces guardamos en la capa dispersalJumpp01 la cuantidad de polilla que se puede dispersar por saltación. El numero de polillas en la celda es diminuido de las que se pueden ir. la capa dispersalJumpp01 corresponde a la area en la que se puede dispersar la polilla. Este numero es divido por NumMigre porque qlgunas se mueren durante el camino."
village2 = 1 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp01: self dispersalJumpp01 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp01: aCell dispersalJumpp01 + value01/numMigre].].].]. value01:=0.

village2 = 2 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp02: self dispersalJumpp02 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp02: aCell dispersalJumpp02 + value01/numMigre].].].]. value01:=0.
village2 = 3 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp03: self dispersalJumpp03 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp03: aCell dispersalJumpp03 + value01/numMigre].].].]. value01:=0.
village2 = 4 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp04: self dispersalJumpp04 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp04: aCell dispersalJumpp04 + value01/numMigre].].].]. value01:=0.
village2 = 5 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp05: self dispersalJumpp05 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp05: aCell dispersalJumpp05 + value01/numMigre].].].]. value01:=0.
village2 = 6 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp06: self dispersalJumpp06 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp06: aCell dispersalJumpp06 + value01/numMigre].].].]. value01:=0.
village2 = 7 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp07: self dispersalJumpp07 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp07: aCell dispersalJumpp07 + value01/numMigre].].].]. value01:=0.
village2 = 8 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp08: self dispersalJumpp08 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp08: aCell dispersalJumpp08 + value01/numMigre].].].]. value01:=0.
village2 = 9 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp09: self dispersalJumpp09 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp09: aCell dispersalJumpp09 + value01/numMigre].].].]. value01:=0.
village2 = 10 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp10: self dispersalJumpp10 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp10: aCell dispersalJumpp10 + value01/numMigre].].].]. value01:=0.
village2 = 11 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp11: self dispersalJumpp11 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp11: aCell dispersalJumpp11 + value01/numMigre].].].]. value01:=0.
village2 = 12 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp12: self dispersalJumpp12 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp12: aCell dispersalJumpp12 + value01/numMigre].].].]. value01:=0.
village2 = 13 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp13: self dispersalJumpp13 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp13: aCell dispersalJumpp13 + value01/numMigre].].].]. value01:=0.
village2 = 14 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp14: self dispersalJumpp14 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp14: aCell dispersalJumpp14 + value01/numMigre].].].]. value01:=0.
village2 = 15 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp15: self dispersalJumpp15 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp15: aCell dispersalJumpp15 + value01/numMigre].].].]. value01:=0.
village2 = 16 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp16: self dispersalJumpp16 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp16: aCell dispersalJumpp16 + value01/numMigre].].].]. value01:=0.
village2 = 17 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp17: self dispersalJumpp17 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp17: aCell dispersalJumpp17 + value01/numMigre].].].]. value01:=0.
village2 = 18 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp18: self dispersalJumpp18 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp18: aCell dispersalJumpp18 + value01/numMigre].].].]. value01:=0.
village2 = 19 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp19: self dispersalJumpp19 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp19: aCell dispersalJumpp19 + value01/numMigre].].].]. value01:=0.
village2 = 20 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp20: self dispersalJumpp20 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp20: aCell dispersalJumpp20 + value01/numMigre].].].]. value01:=0.
village2 = 21 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp21: self dispersalJumpp21 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp21: aCell dispersalJumpp21 + value01/numMigre].].].]. value01:=0.
village2 = 22 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp22: self dispersalJumpp22 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp22: aCell dispersalJumpp22 + value01/numMigre].].].]. value01:=0.
village2 = 23 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp23: self dispersalJumpp23 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp23: aCell dispersalJumpp23 + value01/numMigre].].].]. value01:=0.
village2 = 24 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp24: self dispersalJumpp24 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp24: aCell dispersalJumpp24 + value01/numMigre].].].]. value01:=0.
village2 = 25 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp25: self dispersalJumpp25 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp25: aCell dispersalJumpp25 + value01/numMigre].].].]. value01:=0.
village2 = 26 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp26: self dispersalJumpp26 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp26: aCell dispersalJumpp26 + value01/numMigre].].].]. value01:=0.
village2 = 27 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp27: self dispersalJumpp27 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp27: aCell dispersalJumpp27 + value01/numMigre].].].]. value01:=0.
village2 = 28 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp28: self dispersalJumpp28 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp28: aCell dispersalJumpp28 + value01/numMigre].].].]. value01:=0.
village2 = 29 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp29: self dispersalJumpp29 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp29: aCell dispersalJumpp29 + value01/numMigre].].].]. value01:=0.
village2 = 30 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp30: self dispersalJumpp30 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp30: aCell dispersalJumpp30 + value01/numMigre].].].]. value01:=0.
village2 = 31 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp31: self dispersalJumpp31 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp31: aCell dispersalJumpp31 + value01/numMigre].].].]. value01:=0.
village2 = 32 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp32: self dispersalJumpp32 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp32: aCell dispersalJumpp32 + value01/numMigre].].].]. value01:=0.
village2 = 33 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp33: self dispersalJumpp33 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp33: aCell dispersalJumpp33 + value01/numMigre].].].]. value01:=0.
village2 = 34 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self phthorimaeaAdults&gt;0 ifTrue: [self dispersalJumpp34: self dispersalJumpp34 - (phthorimaeaAdults * dispersalJumpRate). self phthorimaeaAdults: self phthorimaeaAdults - (phthorimaeaAdults * dispersalJumpRate). value01:= (phthorimaeaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpp34: aCell dispersalJumpp34 + value01/numMigre].].].]. value01:=0.</body>

<body package="SimPolillaSimiatug_v02" selector="DispersalJumpSforAnalysis">DispersalJumpSforAnalysis
"US = rules for the long distance dispersal (not used in the ABM at the scale considered)"

|dispersalJumpRate value01 x numMigre|
dispersalJumpRate := 0.3.
value01:=0.
x:= (self population/100) rounded.
x&lt;=0 ifTrue:[x := 1].
numMigre := 2.

village2 = 1 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps01: self dispersalJumps01 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps01: aCell dispersalJumps01 + value01/numMigre].].].]. value01:=0.
village2 = 2 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps02: self dispersalJumps02 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps02: aCell dispersalJumps02 + value01/numMigre].].].]. value01:=0.
village2 = 3 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps03: self dispersalJumps03 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps03: aCell dispersalJumps03 + value01/numMigre].].].]. value01:=0.
village2 = 4 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps04: self dispersalJumps04 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps04: aCell dispersalJumps04 + value01/numMigre].].].]. value01:=0.
village2 = 5 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps05: self dispersalJumps05 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps05: aCell dispersalJumps05 + value01/numMigre].].].]. value01:=0.
village2 = 6 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps06: self dispersalJumps06 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps06: aCell dispersalJumps06 + value01/numMigre].].].]. value01:=0.
village2 = 7 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps07: self dispersalJumps07 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps07: aCell dispersalJumps07 + value01/numMigre].].].]. value01:=0.
village2 = 8 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps08: self dispersalJumps08 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps08: aCell dispersalJumps08 + value01/numMigre].].].]. value01:=0.
village2 = 9 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps09: self dispersalJumps09 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps09: aCell dispersalJumps09 + value01/numMigre].].].]. value01:=0.
village2 = 10 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps10: self dispersalJumps10 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps10: aCell dispersalJumps10 + value01/numMigre].].].]. value01:=0.
village2 = 11 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps11: self dispersalJumps11 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps11: aCell dispersalJumps11 + value01/numMigre].].].]. value01:=0.
village2 = 12 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps12: self dispersalJumps12 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps12: aCell dispersalJumps12 + value01/numMigre].].].]. value01:=0.
village2 = 13 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps13: self dispersalJumps13 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps13: aCell dispersalJumps13 + value01/numMigre].].].]. value01:=0.
village2 = 14 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps14: self dispersalJumps14 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps14: aCell dispersalJumps14 + value01/numMigre].].].]. value01:=0.
village2 = 15 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps15: self dispersalJumps15 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps15: aCell dispersalJumps15 + value01/numMigre].].].]. value01:=0.
village2 = 16 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps16: self dispersalJumps16 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps16: aCell dispersalJumps16 + value01/numMigre].].].]. value01:=0.
village2 = 17 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps17: self dispersalJumps17 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps17: aCell dispersalJumps17 + value01/numMigre].].].]. value01:=0.
village2 = 18 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps18: self dispersalJumps18 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps18: aCell dispersalJumps18 + value01/numMigre].].].]. value01:=0.
village2 = 19 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps19: self dispersalJumps19 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps19: aCell dispersalJumps19 + value01/numMigre].].].]. value01:=0.
village2 = 20 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps20: self dispersalJumps20 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps20: aCell dispersalJumps20 + value01/numMigre].].].]. value01:=0.
village2 = 21 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps21: self dispersalJumps21 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps21: aCell dispersalJumps21 + value01/numMigre].].].]. value01:=0.
village2 = 22 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps22: self dispersalJumps22 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps22: aCell dispersalJumps22 + value01/numMigre].].].]. value01:=0.
village2 = 23 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps23: self dispersalJumps23 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps23: aCell dispersalJumps23 + value01/numMigre].].].]. value01:=0.
village2 = 24 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps24: self dispersalJumps24 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps24: aCell dispersalJumps24 + value01/numMigre].].].]. value01:=0.
village2 = 25 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps25: self dispersalJumps25 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps25: aCell dispersalJumps25 + value01/numMigre].].].]. value01:=0.
village2 = 26 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps26: self dispersalJumps26 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps26: aCell dispersalJumps26 + value01/numMigre].].].]. value01:=0.
village2 = 27 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps27: self dispersalJumps27 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps27: aCell dispersalJumps27 + value01/numMigre].].].]. value01:=0.
village2 = 28 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps28: self dispersalJumps28 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps28: aCell dispersalJumps28 + value01/numMigre].].].]. value01:=0.
village2 = 29 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps29: self dispersalJumps29 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps29: aCell dispersalJumps29 + value01/numMigre].].].]. value01:=0.
village2 = 30 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps30: self dispersalJumps30 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps30: aCell dispersalJumps30 + value01/numMigre].].].]. value01:=0.
village2 = 31 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps31: self dispersalJumps31 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps31: aCell dispersalJumps31 + value01/numMigre].].].]. value01:=0.
village2 = 32 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps32: self dispersalJumps32 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps32: aCell dispersalJumps32 + value01/numMigre].].].]. value01:=0.
village2 = 33 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps33: self dispersalJumps33 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps33: aCell dispersalJumps33 + value01/numMigre].].].]. value01:=0.
village2 = 34 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self symmetrischemaAdults&gt;0 ifTrue: [self dispersalJumps34: self dispersalJumps34 - (symmetrischemaAdults * dispersalJumpRate). self symmetrischemaAdults: self symmetrischemaAdults - (symmetrischemaAdults * dispersalJumpRate). value01:= (symmetrischemaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumps34: aCell dispersalJumps34 + value01/numMigre].].].]. value01:=0.</body>

<body package="SimPolillaSimiatug_v02" selector="DispersalJumpTforAnalysis">DispersalJumpTforAnalysis
"US = rules for the long distance dispersal (not used in the ABM at the scale considered)"

|dispersalJumpRate value01 x numMigre|
dispersalJumpRate := 0.3.
value01:=0.
x:= (self population/100) rounded.
x&lt;=0 ifTrue:[x := 1].
numMigre := 2.

village2 = 1 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv01: self dispersalJumpv01 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv01: aCell dispersalJumpv01 + value01/numMigre].].].]. value01:=0.
village2 = 2 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv02: self dispersalJumpv02 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv02: aCell dispersalJumpv02 + value01/numMigre].].].]. value01:=0.
village2 = 3 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv03: self dispersalJumpv03 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv03: aCell dispersalJumpv03 + value01/numMigre].].].]. value01:=0.
village2 = 4 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv04: self dispersalJumpv04 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv04: aCell dispersalJumpv04 + value01/numMigre].].].]. value01:=0.
village2 = 5 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv05: self dispersalJumpv05 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv05: aCell dispersalJumpv05 + value01/numMigre].].].]. value01:=0.
village2 = 6 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv06: self dispersalJumpv06 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv06: aCell dispersalJumpv06 + value01/numMigre].].].]. value01:=0.
village2 = 7 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv07: self dispersalJumpv07 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv07: aCell dispersalJumpv07 + value01/numMigre].].].]. value01:=0.
village2 = 8 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv08: self dispersalJumpv08 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv08: aCell dispersalJumpv08 + value01/numMigre].].].]. value01:=0.
village2 = 9 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv09: self dispersalJumpv09 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv09: aCell dispersalJumpv09 + value01/numMigre].].].]. value01:=0.
village2 = 10 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv10: self dispersalJumpv10 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv10: aCell dispersalJumpv10 + value01/numMigre].].].]. value01:=0.
village2 = 11 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv11: self dispersalJumpv11 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv11: aCell dispersalJumpv11 + value01/numMigre].].].]. value01:=0.
village2 = 12 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv12: self dispersalJumpv12 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv12: aCell dispersalJumpv12 + value01/numMigre].].].]. value01:=0.
village2 = 13 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv13: self dispersalJumpv13 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv13: aCell dispersalJumpv13 + value01/numMigre].].].]. value01:=0.
village2 = 14 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv14: self dispersalJumpv14 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv14: aCell dispersalJumpv14 + value01/numMigre].].].]. value01:=0.
village2 = 15 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv15: self dispersalJumpv15 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv15: aCell dispersalJumpv15 + value01/numMigre].].].]. value01:=0.
village2 = 16 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv16: self dispersalJumpv16 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv16: aCell dispersalJumpv16 + value01/numMigre].].].]. value01:=0.
village2 = 17 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv17: self dispersalJumpv17 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv17: aCell dispersalJumpv17 + value01/numMigre].].].]. value01:=0.
village2 = 18 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv18: self dispersalJumpv18 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv18: aCell dispersalJumpv18 + value01/numMigre].].].]. value01:=0.
village2 = 19 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv19: self dispersalJumpv19 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv19: aCell dispersalJumpv19 + value01/numMigre].].].]. value01:=0.
village2 = 20 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv20: self dispersalJumpv20 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv20: aCell dispersalJumpv20 + value01/numMigre].].].]. value01:=0.
village2 = 21 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv21: self dispersalJumpv21 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv21: aCell dispersalJumpv21 + value01/numMigre].].].]. value01:=0.
village2 = 22 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv22: self dispersalJumpv22 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv22: aCell dispersalJumpv22 + value01/numMigre].].].]. value01:=0.
village2 = 23 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv23: self dispersalJumpv23 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv23: aCell dispersalJumpv23 + value01/numMigre].].].]. value01:=0.
village2 = 24 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv24: self dispersalJumpv24 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv24: aCell dispersalJumpv24 + value01/numMigre].].].]. value01:=0.
village2 = 25 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv25: self dispersalJumpv25 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv25: aCell dispersalJumpv25 + value01/numMigre].].].]. value01:=0.
village2 = 26 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv26: self dispersalJumpv26 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv26: aCell dispersalJumpv26 + value01/numMigre].].].]. value01:=0.
village2 = 27 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv27: self dispersalJumpv27 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv27: aCell dispersalJumpv27 + value01/numMigre].].].]. value01:=0.
village2 = 28 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv28: self dispersalJumpv28 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv28: aCell dispersalJumpv28 + value01/numMigre].].].]. value01:=0.
village2 = 29 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv29: self dispersalJumpv29 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv29: aCell dispersalJumpv29 + value01/numMigre].].].]. value01:=0.
village2 = 30 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv30: self dispersalJumpv30 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv30: aCell dispersalJumpv30 + value01/numMigre].].].]. value01:=0.
village2 = 31 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv31: self dispersalJumpv31 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv31: aCell dispersalJumpv31 + value01/numMigre].].].]. value01:=0.
village2 = 32 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv32: self dispersalJumpv32 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv32: aCell dispersalJumpv32 + value01/numMigre].].].]. value01:=0.
village2 = 33 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv33: self dispersalJumpv33 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv33: aCell dispersalJumpv33 + value01/numMigre].].].]. value01:=0.
village2 = 34 ifTrue: [(Cormas randomFrom: 0 to: self population) &lt; (self population*0.1) ifTrue: [self teciaAdults&gt;0 ifTrue: [self dispersalJumpv34: self dispersalJumpv34 - (teciaAdults * dispersalJumpRate). self teciaAdults: self teciaAdults - (teciaAdults * dispersalJumpRate). value01:= (teciaAdults * dispersalJumpRate). (self recursiveNeighbourhood: x) do: [:aCell | aCell dispersalJumpv34: aCell dispersalJumpv34 + value01/numMigre].].].]. value01:=0.</body>

<body package="SimPolillaSimiatug_v02" selector="DispersalJumpUpdateP">DispersalJumpUpdateP
"US = rules for the long distance dispersal (not used in the ABM at the scale considered)"
"ES = Regla que finaliza la dispersión por saltación"

|SUMdispersalJumpp01 SUMdispersalJumpp02 SUMdispersalJumpp03 SUMdispersalJumpp04 SUMdispersalJumpp05 SUMdispersalJumpp06 SUMdispersalJumpp07 SUMdispersalJumpp08 SUMdispersalJumpp09 SUMdispersalJumpp10 SUMdispersalJumpp11 SUMdispersalJumpp12 SUMdispersalJumpp13 SUMdispersalJumpp14 SUMdispersalJumpp15 SUMdispersalJumpp16 SUMdispersalJumpp17 SUMdispersalJumpp18 SUMdispersalJumpp19 SUMdispersalJumpp20 SUMdispersalJumpp21 SUMdispersalJumpp22 SUMdispersalJumpp23 SUMdispersalJumpp24 SUMdispersalJumpp25 SUMdispersalJumpp26 SUMdispersalJumpp27 SUMdispersalJumpp28 SUMdispersalJumpp29 SUMdispersalJumpp30 SUMdispersalJumpp31 SUMdispersalJumpp32 SUMdispersalJumpp33 SUMdispersalJumpp34|

"Probabilidad de establecimiento de 1%"
"self probe: 0.01."

SUMdispersalJumpp01 := self dispersalJumpp01.
SUMdispersalJumpp02 := self dispersalJumpp02.
SUMdispersalJumpp03 := self dispersalJumpp03.
SUMdispersalJumpp04 := self dispersalJumpp04.
SUMdispersalJumpp05 := self dispersalJumpp05.
SUMdispersalJumpp06 := self dispersalJumpp06.
SUMdispersalJumpp07 := self dispersalJumpp07.
SUMdispersalJumpp08 := self dispersalJumpp08.
SUMdispersalJumpp09 := self dispersalJumpp09.
SUMdispersalJumpp10 := self dispersalJumpp10.
SUMdispersalJumpp11 := self dispersalJumpp11.
SUMdispersalJumpp12 := self dispersalJumpp12.
SUMdispersalJumpp13 := self dispersalJumpp13.
SUMdispersalJumpp14 := self dispersalJumpp14.
SUMdispersalJumpp15 := self dispersalJumpp15.
SUMdispersalJumpp16 := self dispersalJumpp16.
SUMdispersalJumpp17 := self dispersalJumpp17.
SUMdispersalJumpp18 := self dispersalJumpp18.
SUMdispersalJumpp19 := self dispersalJumpp19.
SUMdispersalJumpp20 := self dispersalJumpp20.
SUMdispersalJumpp21 := self dispersalJumpp21.
SUMdispersalJumpp22 := self dispersalJumpp22.
SUMdispersalJumpp23 := self dispersalJumpp23.
SUMdispersalJumpp24 := self dispersalJumpp24.
SUMdispersalJumpp25 := self dispersalJumpp25.
SUMdispersalJumpp26 := self dispersalJumpp26.
SUMdispersalJumpp27 := self dispersalJumpp27.
SUMdispersalJumpp28 := self dispersalJumpp28.
SUMdispersalJumpp29 := self dispersalJumpp29.
SUMdispersalJumpp30 := self dispersalJumpp30.
SUMdispersalJumpp31 := self dispersalJumpp31.
SUMdispersalJumpp32 := self dispersalJumpp32.
SUMdispersalJumpp33 := self dispersalJumpp33.
SUMdispersalJumpp34 := self dispersalJumpp34.

"Hay una probabilidad de establecimiento de probe% (ahora 1%), para cada celda de la area de saltación posible."
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp01. self dispersalJumpp01: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp02. self dispersalJumpp02: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp03. self dispersalJumpp03: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp04. self dispersalJumpp04: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp05. self dispersalJumpp05: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp06. self dispersalJumpp06: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp07. self dispersalJumpp07: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp08. self dispersalJumpp08: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp09. self dispersalJumpp09: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp10. self dispersalJumpp10: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp11. self dispersalJumpp11: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp12. self dispersalJumpp12: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp13. self dispersalJumpp13: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp14. self dispersalJumpp14: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp15. self dispersalJumpp15: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp16. self dispersalJumpp16: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp17. self dispersalJumpp17: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp18. self dispersalJumpp18: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp19. self dispersalJumpp19: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp20. self dispersalJumpp20: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp21. self dispersalJumpp21: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp22. self dispersalJumpp22: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp23. self dispersalJumpp23: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp24. self dispersalJumpp24: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp25. self dispersalJumpp25: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp26. self dispersalJumpp26: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp27. self dispersalJumpp27: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp28. self dispersalJumpp28: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp29. self dispersalJumpp29: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp30. self dispersalJumpp30: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp31. self dispersalJumpp31: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp32. self dispersalJumpp32: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp33. self dispersalJumpp33: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self phthorimaeaAdults: self phthorimaeaAdults + SUMdispersalJumpp34. self dispersalJumpp34: 0.].</body>

<body package="SimPolillaSimiatug_v02" selector="DispersalJumpUpdateS">DispersalJumpUpdateS
"US = rules for the long distance dispersal (not used in the ABM at the scale considered)"

|SUMdispersalJumps01 SUMdispersalJumps02 SUMdispersalJumps03 SUMdispersalJumps04 SUMdispersalJumps05 SUMdispersalJumps06 SUMdispersalJumps07 SUMdispersalJumps08 SUMdispersalJumps09 SUMdispersalJumps10 SUMdispersalJumps11 SUMdispersalJumps12 SUMdispersalJumps13 SUMdispersalJumps14 SUMdispersalJumps15 SUMdispersalJumps16 SUMdispersalJumps17 SUMdispersalJumps18 SUMdispersalJumps19 SUMdispersalJumps20 SUMdispersalJumps21 SUMdispersalJumps22 SUMdispersalJumps23 SUMdispersalJumps24 SUMdispersalJumps25 SUMdispersalJumps26 SUMdispersalJumps27 SUMdispersalJumps28 SUMdispersalJumps29 SUMdispersalJumps30 SUMdispersalJumps31 SUMdispersalJumps32 SUMdispersalJumps33 SUMdispersalJumps34|

"self probe:0.01."

SUMdispersalJumps01 := self dispersalJumps01.
SUMdispersalJumps02 := self dispersalJumps02.
SUMdispersalJumps03 := self dispersalJumps03.
SUMdispersalJumps04 := self dispersalJumps04.
SUMdispersalJumps05 := self dispersalJumps05.
SUMdispersalJumps06 := self dispersalJumps06.
SUMdispersalJumps07 := self dispersalJumps07.
SUMdispersalJumps08 := self dispersalJumps08.
SUMdispersalJumps09 := self dispersalJumps09.
SUMdispersalJumps10 := self dispersalJumps10.
SUMdispersalJumps11 := self dispersalJumps11.
SUMdispersalJumps12 := self dispersalJumps12.
SUMdispersalJumps13 := self dispersalJumps13.
SUMdispersalJumps14 := self dispersalJumps14.
SUMdispersalJumps15 := self dispersalJumps15.
SUMdispersalJumps16 := self dispersalJumps16.
SUMdispersalJumps17 := self dispersalJumps17.
SUMdispersalJumps18 := self dispersalJumps18.
SUMdispersalJumps19 := self dispersalJumps19.
SUMdispersalJumps20 := self dispersalJumps20.
SUMdispersalJumps21 := self dispersalJumps21.
SUMdispersalJumps22 := self dispersalJumps22.
SUMdispersalJumps23 := self dispersalJumps23.
SUMdispersalJumps24 := self dispersalJumps24.
SUMdispersalJumps25 := self dispersalJumps25.
SUMdispersalJumps26 := self dispersalJumps26.
SUMdispersalJumps27 := self dispersalJumps27.
SUMdispersalJumps28 := self dispersalJumps28.
SUMdispersalJumps29 := self dispersalJumps29.
SUMdispersalJumps30 := self dispersalJumps30.
SUMdispersalJumps31 := self dispersalJumps31.
SUMdispersalJumps32 := self dispersalJumps32.
SUMdispersalJumps33 := self dispersalJumps33.
SUMdispersalJumps34 := self dispersalJumps34.

(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps01. self dispersalJumps01: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps02. self dispersalJumps02: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps03. self dispersalJumps03: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps04. self dispersalJumps04: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps05. self dispersalJumps05: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps06. self dispersalJumps06: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps07. self dispersalJumps07: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps08. self dispersalJumps08: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps09. self dispersalJumps09: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps10. self dispersalJumps10: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps11. self dispersalJumps11: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps12. self dispersalJumps12: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps13. self dispersalJumps13: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps14. self dispersalJumps14: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps15. self dispersalJumps15: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps16. self dispersalJumps16: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps17. self dispersalJumps17: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps18. self dispersalJumps18: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps19. self dispersalJumps19: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps20. self dispersalJumps20: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps21. self dispersalJumps21: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps22. self dispersalJumps22: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps23. self dispersalJumps23: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps24. self dispersalJumps24: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps25. self dispersalJumps25: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps26. self dispersalJumps26: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps27. self dispersalJumps27: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps28. self dispersalJumps28: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps29. self dispersalJumps29: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps30. self dispersalJumps30: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps31. self dispersalJumps31: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps32. self dispersalJumps32: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps33. self dispersalJumps33: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population*self probe) ifTrue: [self symmetrischemaAdults: self symmetrischemaAdults + SUMdispersalJumps34. self dispersalJumps34: 0.].</body>

<body package="SimPolillaSimiatug_v02" selector="DispersalJumpUpdateT">DispersalJumpUpdateT
"US = rules for the long distance dispersal (not used in the ABM at the scale considered)"

|SUMdispersalJumpv01 SUMdispersalJumpv02 SUMdispersalJumpv03 SUMdispersalJumpv04 SUMdispersalJumpv05 SUMdispersalJumpv06 SUMdispersalJumpv07 SUMdispersalJumpv08 SUMdispersalJumpv09 SUMdispersalJumpv10 SUMdispersalJumpv11 SUMdispersalJumpv12 SUMdispersalJumpv13 SUMdispersalJumpv14 SUMdispersalJumpv15 SUMdispersalJumpv16 SUMdispersalJumpv17 SUMdispersalJumpv18 SUMdispersalJumpv19 SUMdispersalJumpv20 SUMdispersalJumpv21 SUMdispersalJumpv22 SUMdispersalJumpv23 SUMdispersalJumpv24 SUMdispersalJumpv25 SUMdispersalJumpv26 SUMdispersalJumpv27 SUMdispersalJumpv28 SUMdispersalJumpv29 SUMdispersalJumpv30 SUMdispersalJumpv31 SUMdispersalJumpv32 SUMdispersalJumpv33 SUMdispersalJumpv34 |

 "self probe:0.01."

SUMdispersalJumpv01 := self dispersalJumpv01.
SUMdispersalJumpv02 := self dispersalJumpv02.
SUMdispersalJumpv03 := self dispersalJumpv03.
SUMdispersalJumpv04 := self dispersalJumpv04.
SUMdispersalJumpv05 := self dispersalJumpv05.
SUMdispersalJumpv06 := self dispersalJumpv06.
SUMdispersalJumpv07 := self dispersalJumpv07.
SUMdispersalJumpv08 := self dispersalJumpv08.
SUMdispersalJumpv09 := self dispersalJumpv09.
SUMdispersalJumpv10 := self dispersalJumpv10.
SUMdispersalJumpv11 := self dispersalJumpv11.
SUMdispersalJumpv12 := self dispersalJumpv12.
SUMdispersalJumpv13 := self dispersalJumpv13.
SUMdispersalJumpv14 := self dispersalJumpv14.
SUMdispersalJumpv15 := self dispersalJumpv15.
SUMdispersalJumpv16 := self dispersalJumpv16.
SUMdispersalJumpv17 := self dispersalJumpv17.
SUMdispersalJumpv18 := self dispersalJumpv18.
SUMdispersalJumpv19 := self dispersalJumpv19.
SUMdispersalJumpv20 := self dispersalJumpv20.
SUMdispersalJumpv21 := self dispersalJumpv21.
SUMdispersalJumpv22 := self dispersalJumpv22.
SUMdispersalJumpv23 := self dispersalJumpv23.
SUMdispersalJumpv24 := self dispersalJumpv24.
SUMdispersalJumpv25 := self dispersalJumpv25.
SUMdispersalJumpv26 := self dispersalJumpv26.
SUMdispersalJumpv27 := self dispersalJumpv27.
SUMdispersalJumpv28 := self dispersalJumpv28.
SUMdispersalJumpv29 := self dispersalJumpv29.
SUMdispersalJumpv30 := self dispersalJumpv30.
SUMdispersalJumpv31 := self dispersalJumpv31.
SUMdispersalJumpv32 := self dispersalJumpv32.
SUMdispersalJumpv33 := self dispersalJumpv33.
SUMdispersalJumpv34 := self dispersalJumpv34.

(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv01. self dispersalJumpv01: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv02. self dispersalJumpv02: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv03. self dispersalJumpv03: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv04. self dispersalJumpv04: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv05. self dispersalJumpv05: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv06. self dispersalJumpv06: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv07. self dispersalJumpv07: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv08. self dispersalJumpv08: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv09. self dispersalJumpv09: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv10. self dispersalJumpv10: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv11. self dispersalJumpv11: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv12. self dispersalJumpv12: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv13. self dispersalJumpv13: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv14. self dispersalJumpv14: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv15. self dispersalJumpv15: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv16. self dispersalJumpv16: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv17. self dispersalJumpv17: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv18. self dispersalJumpv18: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv19. self dispersalJumpv19: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv20. self dispersalJumpv20: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv21. self dispersalJumpv21: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv22. self dispersalJumpv22: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv23. self dispersalJumpv23: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv24. self dispersalJumpv24: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv25. self dispersalJumpv25: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv26. self dispersalJumpv26: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv27. self dispersalJumpv27: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv28. self dispersalJumpv28: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv29. self dispersalJumpv29: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv30. self dispersalJumpv30: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv31. self dispersalJumpv31: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv32. self dispersalJumpv32: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv33. self dispersalJumpv33: 0.].
(Cormas randomFrom: 0 to: self population) &lt; (self population* self probe) ifTrue: [self teciaAdults: self teciaAdults + SUMdispersalJumpv34. self dispersalJumpv34: 0.].</body>

<body package="SimPolillaSimiatug_v02" selector="initVariables">initVariables

self rainEffectAdults isNil ifTrue:[self rainEffectAdults: 1].
self rainEffectJuveniles isNil ifTrue:[self rainEffectJuveniles: 1].</body>

<body package="SimPolillaSimiatug_v02" selector="movePTM_exp">movePTM_exp
"US = rules for the dispersion of the moth by diffusion"
"ES = Regla de dispersión por difusión (distancia de vuelo)"

| yd distance ye numMigre longCell yeReal surface  dispersal yeReal500 yeReal200 yeReal150 yeReal100 yeReal75 yeReal50 yeReal25 yeReal10 yeReal5 yeReal1 K a|

"Factor de la curva de distancia de vuelo"	
	a:=0.015.

"Probabilidad de dispersión según el numero de individuos y la cuantidad de recurso"
	K :=1000.
	ye := (0.4/(1 + 0.1 * ((   (0- 0.005) * (self moveT-(K-200))  )exp)    ))* (1-qualityHabitat).
"Numero de individuos que se van a dispersar por difusión"
	numMigre := ye * self moveT.
"Datos de una celda (que hace 500 * 500 m)"
	longCell := 500.
	surface := longCell * longCell.

"Porcentage de la población que se va de 250m hasta 499m"
	distance := (Cormas randomFrom: 250 to: 499).
	yd := ((0 - a) * distance) exp.
"Probabilidad de irse de una celda con este rango de distancia (en este caso dicemos 100% porque suponemos que la polilla se va recto y que elige el camino mas corto para salir de una celda)"
	yeReal := 1.
"Parte de la población que finalmente se va a dispersar por difusión afuera de su celda con este distancia"
	yeReal500 := yd * yeReal.

	distance := (Cormas randomFrom: 200 to: 249).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal200 := yd * yeReal.

	distance := (Cormas randomFrom: 150 to: 199).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal150 := yd * yeReal.

	distance := (Cormas randomFrom: 100 to: 149).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal100 := yd * yeReal.

	distance := (Cormas randomFrom: 75 to: 99).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal75 := yd * yeReal.

	distance := (Cormas randomFrom: 50 to: 74).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal50 := yd * yeReal.

	distance := (Cormas randomFrom: 25 to: 49).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal25 := yd * yeReal.

	distance := (Cormas randomFrom: 10 to: 24).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal10 := yd * yeReal.

	distance := (Cormas randomFrom: 5 to: 9).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal5 := yd * yeReal.

	distance := 1.
	yd := 1. "we assume that each PTM is moving in a 1 m² square"
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal1 := yd * yeReal.

"Cuantidad de polillas que se dispersen por difusión afuera de su celda"
dispersal := (yeReal500 + yeReal200 + yeReal150 + yeReal100 + yeReal75 + yeReal50 + yeReal25 + yeReal10 + yeReal5 + yeReal1) *  numMigre.
"Eliminamos de la celda inicial las polillas ques se van"
self bufferTecia: self bufferTecia - dispersal.
"Repartimos las polillas que se van en las 4 celdas alrejedor de la celda inicial (en una capa aparte aue utilizamos despues para la actualización)"
self neighbourhood do: [:aCell | aCell bufferTecia: aCell bufferTecia + (dispersal / self neighbourhood size)].
"----------------------------------------------------------------------------------------------------------------------------------------------------------"

	ye := (0.4/(1 + 0.1 * ((   (0- 0.005) * (self moveP-(K-200))  )exp)    ))* (1-qualityHabitat).
	numMigre := ye * self moveP.

	distance := (Cormas randomFrom: 250 to: 499).
	yd := ((0 - a) * distance) exp.
	yeReal := 1.
	yeReal500 := yd * yeReal.

	distance := (Cormas randomFrom: 200 to: 249).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal200 := yd * yeReal.

	distance := (Cormas randomFrom: 150 to: 199).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal150 := yd * yeReal.

	distance := (Cormas randomFrom: 100 to: 149).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal100 := yd * yeReal.

	distance := (Cormas randomFrom: 75 to: 99).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal75 := yd * yeReal.

	distance := (Cormas randomFrom: 50 to: 74).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal50 := yd * yeReal.

	distance := (Cormas randomFrom: 25 to: 49).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal25 := yd * yeReal.

	distance := (Cormas randomFrom: 10 to: 24).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal10 := yd * yeReal.

	distance := (Cormas randomFrom: 5 to: 9).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal5 := yd * yeReal.

	distance := 1.
	yd := 1. "we assume that each PTM is moving in a 1 m² square"
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal1 := yd * yeReal.

dispersal := (yeReal500 +yeReal200 + yeReal150 + yeReal100 + yeReal75 + yeReal50 + yeReal25 + yeReal10 + yeReal5 + yeReal1) *  numMigre.
self bufferPhthorimaea: self bufferPhthorimaea - dispersal.
self neighbourhood do: [:aCell | aCell bufferPhthorimaea: aCell bufferPhthorimaea + (dispersal / self neighbourhood size)].
"----------------------------------------------------------------------------------------------------------------------------------------------------------"

	ye := (0.4/(1 + 0.1 * ((   (0- 0.005) * (self moveS-(K-200))  )exp)    ))* (1-qualityHabitat).
	numMigre := ye * self moveS.

	distance := (Cormas randomFrom: 250 to: 499).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal500 := yd * yeReal.

	distance := (Cormas randomFrom: 200 to: 249).
	yd := ((0 - a) * distance) exp.
	yeReal :=1.
	yeReal200 := yd * yeReal.

	distance := (Cormas randomFrom: 150 to: 199).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal150 := yd * yeReal.

	distance := (Cormas randomFrom: 100 to: 149).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal100 := yd * yeReal.

	distance := (Cormas randomFrom: 75 to: 99).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal75 := yd * yeReal.

	distance := (Cormas randomFrom: 50 to: 74).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal50 := yd * yeReal.

	distance := (Cormas randomFrom: 25 to: 49).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal25 := yd * yeReal.

	distance := (Cormas randomFrom: 10 to: 24).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal10 := yd * yeReal.

	distance := (Cormas randomFrom: 5 to: 9).
	yd := ((0 - a) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal5 := yd * yeReal.

	distance := 1.
	yd := 1. "we assume that each PTM is moving in a 1 m² square"
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal1 := yd * yeReal.

dispersal := (yeReal500 +yeReal200 + yeReal150 + yeReal100 + yeReal75 + yeReal50 + yeReal25 + yeReal10 + yeReal5 + yeReal1) *  numMigre.
self bufferSymmetrischemma: self bufferSymmetrischemma - dispersal.
self neighbourhood do: [:aCell | aCell bufferSymmetrischemma: aCell bufferSymmetrischemma + (dispersal / self neighbourhood size)].</body>

<body package="SimPolillaSimiatug_v02" selector="movePTM_NORMAL_200">movePTM_NORMAL_200
"US = rules for the dispersion of the moth by diffusion used for testing other dispersal capabilities"

| yd distance ye numMigre longCell yeReal surface  dispersal yeReal200 yeReal150 yeReal100 yeReal75 yeReal50 yeReal25 yeReal10 yeReal5 yeReal1 K|

	K :=1000.
	ye := (0.4/(1 + 0.1 * ((   (0- 0.005) * (self moveT-(K-200))  )exp)    ))* (1-qualityHabitat).
	numMigre := ye * self moveT.
	longCell := 500.
	surface := longCell * longCell.

	distance := 200.
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal200 := yd * yeReal.

	distance := (Cormas randomFrom: 150 to: 199).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal150 := yd * yeReal.

	distance := (Cormas randomFrom: 100 to: 149).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal100 := yd * yeReal.

	distance := (Cormas randomFrom: 75 to: 99).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal75 := yd * yeReal.

	distance := (Cormas randomFrom: 50 to: 74).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal50 := yd * yeReal.

	distance := (Cormas randomFrom: 25 to: 49).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal25 := yd * yeReal.

	distance := (Cormas randomFrom: 10 to: 24).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal10 := yd * yeReal.

	distance := (Cormas randomFrom: 5 to: 9).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal5 := yd * yeReal.

	distance := 1.
	yd := 1. "we assume that each PTM is moving in a 1 m² square"
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal1 := yd * yeReal.

dispersal := (yeReal200 + yeReal150 + yeReal100 + yeReal75 + yeReal50 + yeReal25 + yeReal10 + yeReal5 + yeReal1) *  numMigre.
self bufferTecia: self bufferTecia - dispersal.
self neighbourhood do: [:aCell | aCell bufferTecia: aCell bufferTecia + (dispersal / self neighbourhood size)].
"----------------------------------------------------------------------------------------------------------------------------------------------------------"

	ye := (0.4/(1 + 0.1 * ((   (0- 0.005) * (self moveP-(K-200))  )exp)    ))* (1-qualityHabitat).
	numMigre := ye * self moveP.

	distance := 200.
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal200 := yd * yeReal.

	distance := (Cormas randomFrom: 150 to: 199).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal150 := yd * yeReal.

	distance := (Cormas randomFrom: 100 to: 149).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal100 := yd * yeReal.

	distance := (Cormas randomFrom: 75 to: 99).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal75 := yd * yeReal.

	distance := (Cormas randomFrom: 50 to: 74).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal50 := yd * yeReal.

	distance := (Cormas randomFrom: 25 to: 49).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal25 := yd * yeReal.

	distance := (Cormas randomFrom: 10 to: 24).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal10 := yd * yeReal.

	distance := (Cormas randomFrom: 5 to: 9).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal5 := yd * yeReal.

	distance := 1.
	yd := 1. "we assume that each PTM is moving in a 1 m² square"
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal1 := yd * yeReal.

dispersal := (yeReal200 + yeReal150 + yeReal100 + yeReal75 + yeReal50 + yeReal25 + yeReal10 + yeReal5 + yeReal1) *  numMigre.
self bufferPhthorimaea: self bufferPhthorimaea - dispersal.
self neighbourhood do: [:aCell | aCell bufferPhthorimaea: aCell bufferPhthorimaea + (dispersal / self neighbourhood size)].
"----------------------------------------------------------------------------------------------------------------------------------------------------------"

	ye := (0.4/(1 + 0.1 * ((   (0- 0.005) * (self moveS-(K-200))  )exp)    ))* (1-qualityHabitat).
	numMigre := ye * self moveS.

	distance := 200.
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal200 := yd * yeReal.

	distance := (Cormas randomFrom: 150 to: 199).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal150 := yd * yeReal.

	distance := (Cormas randomFrom: 100 to: 149).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal100 := yd * yeReal.

	distance := (Cormas randomFrom: 75 to: 99).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal75 := yd * yeReal.

	distance := (Cormas randomFrom: 50 to: 74).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal50 := yd * yeReal.

	distance := (Cormas randomFrom: 25 to: 49).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal25 := yd * yeReal.

	distance := (Cormas randomFrom: 10 to: 24).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal10 := yd * yeReal.

	distance := (Cormas randomFrom: 5 to: 9).
	yd := ((0 - 0.015) * distance) exp.
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal5 := yd * yeReal.

	distance := 1.
	yd := 1. "we assume that each PTM is moving in a 1 m² square"
	yeReal := (surface - ((longCell - (distance * 2))**2))/surface.
	yeReal1 := yd * yeReal.

dispersal := (yeReal200 + yeReal150 + yeReal100 + yeReal75 + yeReal50 + yeReal25 + yeReal10 + yeReal5 + yeReal1) *  numMigre.
self bufferSymmetrischemma: self bufferSymmetrischemma - dispersal.
self neighbourhood do: [:aCell | aCell bufferSymmetrischemma: aCell bufferSymmetrischemma + (dispersal / self neighbourhood size)].</body>

<body package="SimPolillaSimiatug_v02" selector="reproduceFemales">reproduceFemales
"US = reproduction rules for the moths"
"ES = Regla de reproducción de las hembras"

	| sexRatio matingRateT matingRateP matingRateS corT corP corS|

	sexRatio := 0.5.
	matingRateT := 1.
	matingRateP := 1.
	matingRateS := 1.

	self teciaFemale: self teciaAdults * sexRatio * matingRateT.
	self phthorimaeaFemale: self phthorimaeaAdults * sexRatio * matingRateP.
	self symmetrischemaFemale: self symmetrischemaAdults * sexRatio * matingRateS.

"corección debido a que todas las polillas no tienen el mismo tiempo de desarollo"
corT := 0.
corP := (rateLifePhthorimaea - rateLifeTecia) / rateLifeTecia.
corS := (rateLifeSymmetrischemma - rateLifeTecia) / rateLifeTecia.

"fitness correction * fecundity/(max(fecundity))"
self rT: self fecundityTecia.
self rP: self fecundityPhthorimaea + ( self fecundityPhthorimaea * corP).
self rS: self fecunditySymmetrischemma + ( self fecunditySymmetrischemma * corS).

"for probes and pov"
self bufferNumberTeciaFemale: self teciaFemale.
self bufferNumberPhthorimaeaFemale: self phthorimaeaFemale.
self bufferNumberSymmetrischemaFemale: self symmetrischemaFemale.

"REPRODUCTION"
self tecia: self teciaFemale * self rT.
self phthorimaea: self phthorimaeaFemale * self rP.
self symmetrischemma: self symmetrischemaFemale * self rS.

"correciones de fecundidad para que los numeros no sean demasiado grandes en relación con el K de nuestro modelo"
	self tecia &lt; 0 ifTrue: [self tecia: 0].
	self phthorimaea &lt; 0 ifTrue: [self phthorimaea: 0].
	self symmetrischemma &lt; 0 ifTrue: [self symmetrischemma: 0].

	self tecia &gt; 100000 ifTrue: [self tecia: 100000].
	self phthorimaea &gt; 100000 ifTrue: [self phthorimaea: 100000].
	self symmetrischemma &gt; 100000 ifTrue: [self symmetrischemma: 100000].</body>

<body package="SimPolillaSimiatug_v02" selector="updateFecundityFemale">updateFecundityFemale
"US = rules to update offsrping"

"eq := a+b*EXP(-((( tempPromedio -c)/d)+((e-1)/e)^(1/e))^e+((e-1)/e))*((e-1)/e)^(-((e-1)/e))*((( tempPromedio -c)/d)+((e-1)/e)^(1/e))^(e-1)"

"TECIA------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
|a b c d e f eq1 eq2 eq3 eq4 x|	

a := 0 - 30.11838694327944.
b := 343.2811048339828.
c := 18.75284501202404.
d := 17.10856111462315.
e := 3.299843838878276.

x := tempStochastic.

eq1 := x - c.
eq1 := eq1 / d.
eq2 := e - 1.
eq2 := eq2 / e.
eq2 := eq2 ** (1 / e).
eq1 := eq1 + eq2.

eq1 := eq1 ** e.
eq1 := 0 - eq1.

eq2 := e - 1.
eq2 := eq2 / e.
eq1 := eq1 + eq2.
eq1 := eq1 exp.
eq1 := b * eq1.

eq2 := x - c.
eq2 := eq2 / d.
eq3 := e - 1.
eq3 := eq3 / e.
eq3 := eq3 ** (1/e).
eq2 := eq2 + eq3.
eq2 := eq2 ** (e-1).

eq3 := e - 1.
eq3 := eq3 / e.
eq4 := e - 1.
eq4 := eq4 / e.
eq4 := 0 - eq4.
eq3 := eq3 ** eq4.

eq1 := eq1 * eq3 * eq2.
eq1 := a + eq1.
                                          

eq1 &lt; 0 ifTrue:[ eq1 := 0].
self fecundityTecia: eq1.

"PHTHORIMAEA------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"

a := 0 - 3468.925524381997.
b := 3606.259209047108.
c := 21.07236736926119.
d := 220.9979571820878.
e := 4.705734323803844.

x := tempStochastic.

eq1 := x - c.
eq1 := eq1 / d.
eq2 := e - 1.
eq2 := eq2 / e.
eq2 := eq2 ** (1 / e).
eq1 := eq1 + eq2.

eq1 := eq1 ** e.
eq1 := 0 - eq1.

eq2 := e - 1.
eq2 := eq2 / e.
eq1 := eq1 + eq2.
eq1 := eq1 exp.
eq1 := b * eq1.

eq2 := x - c.
eq2 := eq2 / d.
eq3 := e - 1.
eq3 := eq3 / e.
eq3 := eq3 ** (1/e).
eq2 := eq2 + eq3.
eq2 := eq2 ** (e-1).

eq3 := e - 1.
eq3 := eq3 / e.
eq4 := e - 1.
eq4 := eq4 / e.
eq4 := 0 - eq4.
eq3 := eq3 ** eq4.

eq1 := eq1 * eq3 * eq2.
eq1 := a + eq1.

eq1 &lt; 0 ifTrue:[ eq1 := 0].
self fecundityPhthorimaea: eq1.

"SYMMETRISCHEMA---------------------------------------------------------------------------------------------------------------------------------------------------------------------"

a := 0 - 2.061525357320953e-12.
b := 218.4559081941613.
c := 15.10830693327336.
d := 19.48393797288984.
e := 2.571556160851190.
f := 4.309180129635479.

x := tempStochastic.

eq1 := x - c.
eq1 := eq1 / d.
eq2 := e - 1.
eq2 := eq2 / e.
eq2 := eq2 ** (1 / e).
eq1 := eq1 + eq2.
eq1 := eq1 ** e.
eq1 := 0 - eq1.
eq2 := e - 1.
eq2 := eq2 / e.
eq1 := eq1 + eq2.
eq1 := eq1 exp.
eq1 := b * eq1.
eq2 := x - c.
eq2 := eq2 / d.
eq3 := e - 1.
eq3 := eq3 / e.
eq3 := eq3 ** (1/e).
eq2 := eq2 + eq3.
eq2 := eq2 ** (e-1).
eq3 := e - 1.
eq3 := eq3 / e.
eq4 := e - 1.
eq4 := eq4 / e.
eq4 := 0 - eq4.
eq3 := eq3 ** eq4.

eq1 := eq1 * eq3 * eq2.
eq1 := a + eq1.


eq1 &lt; 0 ifTrue:[ eq1 := 0].
self fecunditySymmetrischemma: eq1.</body>

<body package="SimPolillaSimiatug_v02" selector="updateHOMOGENEQualityHabitat">updateHOMOGENEQualityHabitat
"US = resources availabiblity"
"ES = Regla para determinar según el uso de la zona, la cuantidad de recurso disponible"

	self qualityHabitat: (Cormas randomFrom: 0.1 to: 0.9).
</body>

<body package="SimPolillaSimiatug_v02" selector="updateHOMOGENETempStochastic">updateHOMOGENETempStochastic
"US = stochasticity over temperature"
"ES = Regla para modificar la temperatura promedia según la capa de estochasticidad"


self tempStochastic: 20.</body>

<body package="SimPolillaSimiatug_v02" selector="updatePTMdispersion">updatePTMdispersion
"US = neighborhood of a given location"
"ES = Regla para poner las polillas alrejedor de una celda considerada"

  self teciaAdults: self teciaAdults + self bufferTecia.
  self bufferTecia: 0.

  self phthorimaeaAdults: self phthorimaeaAdults + self bufferPhthorimaea.
  self bufferPhthorimaea: 0.

  self symmetrischemaAdults: self symmetrischemaAdults + self bufferSymmetrischemma.
  self bufferSymmetrischemma: 0.</body>

<body package="SimPolillaSimiatug_v02" selector="updateQualityHabitat">updateQualityHabitat
"US = quality habitat"
"ES = Regla para determinar según el uso de la zona, la cuantidad de recurso disponible"

	self qualityHabitat: (Cormas randomFrom: 0.3 to: 0.9).
	self agro = 0 ifTrue:[self qualityHabitat: (Cormas randomFrom: 0 to: 0.3)].
	self bodega = 1 ifTrue:[self qualityHabitat: (Cormas randomFrom: 0.9 to: 1)].</body>

<body package="SimPolillaSimiatug_v02" selector="updateRateLife">updateRateLife
"US = correction over fitness to take into account the fact that the different moth species does not have the same developmental time as a function of temperature"
"ES = Regla para conocer el tiempo de desarollo de cada polilla"

| rateLifeEgg rateLifeLarva rateLifePupa devRateEgg devRateLarva devRatePupa tDemiLEgg tDemiLLarva tDemiLPupa deltaHAEgg deltaHALarva deltaHAPupa deltaHLEgg deltaHLLarva deltaHLPupa deltaHHEgg deltaHHLarva deltaHHPupa tDemiHEgg tDemiHLarva tDemiHPupa tempKelvinPromedio R|

"TECIA------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"

devRateEgg := 0.179.
devRateLarva := 0.076.
devRatePupa := 0.187.
deltaHAEgg := 17250.
deltaHALarva := 11000.
deltaHAPupa :=11500.
deltaHLEgg := 0 - 48000.
deltaHLLarva := 0 - 50000.
deltaHLPupa := 0 -35000.
tDemiLEgg := 265.2.
tDemiLLarva := 283.1.
tDemiLPupa := 290.0.
deltaHHEgg := 121830.
deltaHHLarva := 275000.
deltaHHPupa := 125000.
tDemiHEgg := 304.2.
tDemiHLarva := 302.1.
tDemiHPupa := 299.5.

"----------------------------------------------------------------------------------"
tempKelvinPromedio := tempStochastic  + 273.5.
"----------------------------------------------------------------------------------"

R := 1.987. "universal gas constant"

rateLifeEgg := (1/298.16) - (1/tempKelvinPromedio).
rateLifeEgg := (deltaHAEgg * rateLifeEgg).
rateLifeEgg := (rateLifeEgg) exp.
rateLifeEgg := ((devRateEgg * tempKelvinPromedio) /298.16) *rateLifeEgg.
rateLifeEgg := rateLifeEgg / (((((((1/tDemiLEgg) - (1/tempKelvinPromedio)) * deltaHLEgg) / R) exp) + 1) + (((((1/tDemiHEgg) - (1/tempKelvinPromedio)) * deltaHHEgg) / R) exp)). 

rateLifeLarva := (1/298.16) - (1/tempKelvinPromedio).
rateLifeLarva := (deltaHALarva * rateLifeLarva).
rateLifeLarva := (rateLifeLarva) exp.
rateLifeLarva := ((devRateLarva * tempKelvinPromedio) /298.16) *rateLifeLarva.
rateLifeLarva := rateLifeLarva / (((((((1/tDemiLLarva) - (1/tempKelvinPromedio)) * deltaHLLarva) / R) exp) + 1) + (((((1/tDemiHLarva) - (1/tempKelvinPromedio)) * deltaHHLarva) / R) exp)). 

rateLifePupa := (1/298.16) - (1/tempKelvinPromedio).
rateLifePupa := (deltaHAPupa * rateLifePupa).
rateLifePupa := (rateLifePupa) exp.
rateLifePupa := ((devRatePupa * tempKelvinPromedio) /298.16) *rateLifePupa.
rateLifePupa := rateLifePupa / (((((((1/tDemiLPupa) - (1/tempKelvinPromedio)) * deltaHLPupa) / R) exp) + 1) + (((((1/tDemiHPupa) - (1/tempKelvinPromedio)) * deltaHHPupa) / R) exp)). 

self rateLifeTecia:  ((21*rateLifeEgg) + (47*rateLifeLarva) + (32*rateLifePupa))/100.
self rateLifeTecia &lt;=0 ifTrue:[self rateLifeTecia: 0].
"PHTHORIMAEA------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"

devRateEgg := 0.190.
devRateLarva := 0.070.
devRatePupa := 0.119.
deltaHAEgg := 17250.
deltaHALarva := 11000.
deltaHAPupa :=11500.
deltaHLEgg := 0 - 48000.
deltaHLLarva := 0 - 50000.
deltaHLPupa := 0 -35000.
tDemiLEgg := 278.1.
tDemiLLarva := 287.5.
tDemiLPupa := 285.5.
deltaHHEgg := 121830.
deltaHHLarva := 275000.
deltaHHPupa := 125000.
tDemiHEgg := 309.4.
tDemiHLarva := 309.2.
tDemiHPupa := 312.3.

"----------------------------------------------------------------------------------"
tempKelvinPromedio := tempStochastic  + 273.5.
"----------------------------------------------------------------------------------"

R := 1.987. "universal gaz constant"

rateLifeEgg := (1/298.16) - (1/tempKelvinPromedio).
rateLifeEgg := (deltaHAEgg * rateLifeEgg).
rateLifeEgg := (rateLifeEgg) exp.
rateLifeEgg := ((devRateEgg * tempKelvinPromedio) /298.16) *rateLifeEgg.
rateLifeEgg := rateLifeEgg / (((((((1/tDemiLEgg) - (1/tempKelvinPromedio)) * deltaHLEgg) / R) exp) + 1) + (((((1/tDemiHEgg) - (1/tempKelvinPromedio)) * deltaHHEgg) / R) exp)). 

rateLifeLarva := (1/298.16) - (1/tempKelvinPromedio).
rateLifeLarva := (deltaHALarva * rateLifeLarva).
rateLifeLarva := (rateLifeLarva) exp.
rateLifeLarva := ((devRateLarva * tempKelvinPromedio) /298.16) *rateLifeLarva.
rateLifeLarva := rateLifeLarva / (((((((1/tDemiLLarva) - (1/tempKelvinPromedio)) * deltaHLLarva) / R) exp) + 1) + (((((1/tDemiHLarva) - (1/tempKelvinPromedio)) * deltaHHLarva) / R) exp)). 

rateLifePupa := (1/298.16) - (1/tempKelvinPromedio).
rateLifePupa := (deltaHAPupa * rateLifePupa).
rateLifePupa := (rateLifePupa) exp.
rateLifePupa := ((devRatePupa * tempKelvinPromedio) /298.16) *rateLifePupa.
rateLifePupa := rateLifePupa / (((((((1/tDemiLPupa) - (1/tempKelvinPromedio)) * deltaHLPupa) / R) exp) + 1) + (((((1/tDemiHPupa) - (1/tempKelvinPromedio)) * deltaHHPupa) / R) exp)). 

self rateLifePhthorimaea:  ((16*rateLifeEgg) + (56*rateLifeLarva) + (29*rateLifePupa))/100.
self rateLifePhthorimaea &lt;=0 ifTrue:[self rateLifePhthorimaea: 0].
"SYMMETRISCHEMA------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"

devRateEgg := 0.185.
devRateLarva := 0.050.
devRatePupa := 0.094.
deltaHAEgg := 17250.
deltaHALarva := 11000.
deltaHAPupa :=11500.
deltaHLEgg := 0 - 48000.
deltaHLLarva := 0 - 50000.
deltaHLPupa := 0 -35000.
tDemiLEgg := 280.0.
tDemiLLarva := 282.1.
tDemiLPupa := 283.2.
deltaHHEgg := 121830.
deltaHHLarva := 275000.
deltaHHPupa := 125000.
tDemiHEgg := 303.5.
tDemiHLarva := 305.1.
tDemiHPupa := 302.2.

"----------------------------------------------------------------------------------"
tempKelvinPromedio := tempStochastic  + 273.5.
"----------------------------------------------------------------------------------"

R := 1.987.

rateLifeEgg := (1/298.16) - (1/tempKelvinPromedio).
rateLifeEgg := (deltaHAEgg * rateLifeEgg).
rateLifeEgg := (rateLifeEgg) exp.
rateLifeEgg := ((devRateEgg * tempKelvinPromedio) /298.16) *rateLifeEgg.
rateLifeEgg := rateLifeEgg / (((((((1/tDemiLEgg) - (1/tempKelvinPromedio)) * deltaHLEgg) / R) exp) + 1) + (((((1/tDemiHEgg) - (1/tempKelvinPromedio)) * deltaHHEgg) / R) exp)). 

rateLifeLarva := (1/298.16) - (1/tempKelvinPromedio).
rateLifeLarva := (deltaHALarva * rateLifeLarva).
rateLifeLarva := (rateLifeLarva) exp.
rateLifeLarva := ((devRateLarva * tempKelvinPromedio) /298.16) *rateLifeLarva.
rateLifeLarva := rateLifeLarva / (((((((1/tDemiLLarva) - (1/tempKelvinPromedio)) * deltaHLLarva) / R) exp) + 1) + (((((1/tDemiHLarva) - (1/tempKelvinPromedio)) * deltaHHLarva) / R) exp)). 

rateLifePupa := (1/298.16) - (1/tempKelvinPromedio).
rateLifePupa := (deltaHAPupa * rateLifePupa).
rateLifePupa := (rateLifePupa) exp.
rateLifePupa := ((devRatePupa * tempKelvinPromedio) /298.16) *rateLifePupa.
rateLifePupa := rateLifePupa / (((((((1/tDemiLPupa) - (1/tempKelvinPromedio)) * deltaHLPupa) / R) exp) + 1) + (((((1/tDemiHPupa) - (1/tempKelvinPromedio)) * deltaHHPupa) / R) exp)). 

self rateLifeSymmetrischemma:  ((17*rateLifeEgg) + (51*rateLifeLarva) + (32*rateLifePupa))/100.
self rateLifeSymmetrischemma &lt;=0 ifTrue:[self rateLifeSymmetrischemma: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateSurvivalRate">updateSurvivalRate
"US = rules for the moth survival"
"ES = Regla para conocer la supervivencia de cada polilla según la temperatura"

|  tempKelvinPromedio R aEgg bEgg cEgg dEgg eEgg fEgg aPupa bPupa cPupa dPupa ePupa fPupa aLarva bLarva cLarva dLarva eLarva fLarva survivalRateEggTecia survivalRateEggPhthorimaea survivalRateEggSymmetrischemma survivalRateLarvaTecia survivalRateLarvaPhthorimaea survivalRateLarvaSymmetrischemma survivalRatePupaTecia survivalRatePupaPhthorimaea survivalRatePupaSymmetrischemma|
R := 1.987. "universal gas constant"

"TECIA------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
aEgg := 0.822.
bEgg := 0 - 758.5.
cEgg := 0 - 212100.
dEgg := 281.9.
eEgg := 405200.
fEgg := 303.8.
aLarva := 0.758.
bLarva := 0 - 180.2.
cLarva := 0 - 475700.
dLarva := 282.7.
eLarva := 1298000.
fLarva := 301.5.
aPupa := 0.9.
bPupa := 0 - 73.72.
cPupa := 0 - 1263000.
dPupa := 286.5.
ePupa := 1095000.
fPupa := 306.3.

"------------------------------------------------------------------------"
tempKelvinPromedio := tempStochastic  + 273.5.
"------------------------------------------------------------------------"

survivalRateEggTecia := (1/298.16) - (1/tempKelvinPromedio).
survivalRateEggTecia := (bEgg * survivalRateEggTecia).
survivalRateEggTecia := (survivalRateEggTecia) exp.
survivalRateEggTecia := ((aEgg * tempKelvinPromedio) /298.16) *survivalRateEggTecia.
survivalRateEggTecia := survivalRateEggTecia / (((((((1/dEgg) - (1/tempKelvinPromedio)) * cEgg) / R) exp) + 1) + (((((1/fEgg) - (1/tempKelvinPromedio)) * eEgg) / R) exp)). 

survivalRateEggTecia &lt;=0 ifTrue:[survivalRateEggTecia:=0].

survivalRateLarvaTecia := (1/298.16) - (1/tempKelvinPromedio).
survivalRateLarvaTecia := (bLarva * survivalRateLarvaTecia).
survivalRateLarvaTecia := (survivalRateLarvaTecia) exp.
survivalRateLarvaTecia := ((aLarva * tempKelvinPromedio) /298.16) *survivalRateLarvaTecia.
survivalRateLarvaTecia := survivalRateLarvaTecia / (((((((1/dLarva) - (1/tempKelvinPromedio)) * cLarva) / R) exp) + 1) + (((((1/fLarva) - (1/tempKelvinPromedio)) * eLarva) / R) exp)). 

survivalRateLarvaTecia &lt;=0 ifTrue:[survivalRateLarvaTecia:=0].

survivalRatePupaTecia := (1/298.16) - (1/tempKelvinPromedio).
survivalRatePupaTecia := (bPupa * survivalRatePupaTecia).
survivalRatePupaTecia := (survivalRatePupaTecia) exp.
survivalRatePupaTecia := ((aPupa * tempKelvinPromedio) /298.16) *survivalRatePupaTecia.
survivalRatePupaTecia := survivalRatePupaTecia / (((((((1/dPupa) - (1/tempKelvinPromedio)) * cPupa) / R) exp) + 1) + (((((1/fPupa) - (1/tempKelvinPromedio)) * ePupa) / R) exp)). 

survivalRatePupaTecia &lt;=0 ifTrue:[survivalRatePupaTecia:=0].

self survivalRateTecia: survivalRatePupaTecia * survivalRateLarvaTecia * survivalRateEggTecia.
self survivalRateTecia &lt;0 ifTrue:[self survivalRateTecia: 0].

"PHTHORIMAEA------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
aEgg := 0.917.
bEgg := 50.
cEgg := 0 - 200000.
dEgg := 283.3.
eEgg := 400000.
fEgg := 310.1.
aLarva := 0.950.
bLarva := 0 - 150.
cLarva := 0 - 400000.
dLarva := 284.4.
eLarva := 900000.
fLarva := 310.
aPupa := 0.96.
bPupa := 50.
cPupa := 0 - 800000.
dPupa := 283.1.
ePupa := 700000.
fPupa := 312.2.

"----------------------------------------------------------------------------------"
tempKelvinPromedio := tempStochastic  + 273.5.
"----------------------------------------------------------------------------------"

survivalRateEggPhthorimaea := (1/298.16) - (1/tempKelvinPromedio).
survivalRateEggPhthorimaea := (bEgg * survivalRateEggPhthorimaea).
survivalRateEggPhthorimaea := (survivalRateEggPhthorimaea) exp.
survivalRateEggPhthorimaea := ((aEgg * tempKelvinPromedio) /298.16) *survivalRateEggPhthorimaea.
survivalRateEggPhthorimaea := survivalRateEggPhthorimaea / (((((((1/dEgg) - (1/tempKelvinPromedio)) * cEgg) / R) exp) + 1) + (((((1/fEgg) - (1/tempKelvinPromedio)) * eEgg) / R) exp)). 

survivalRateEggPhthorimaea &lt;=0 ifTrue:[survivalRateEggPhthorimaea:=0].

survivalRateLarvaPhthorimaea := (1/298.16) - (1/tempKelvinPromedio).
survivalRateLarvaPhthorimaea := (bLarva * survivalRateLarvaPhthorimaea).
survivalRateLarvaPhthorimaea := (survivalRateLarvaPhthorimaea) exp.
survivalRateLarvaPhthorimaea := ((aLarva * tempKelvinPromedio) /298.16) *survivalRateLarvaPhthorimaea.
survivalRateLarvaPhthorimaea := survivalRateLarvaPhthorimaea / (((((((1/dLarva) - (1/tempKelvinPromedio)) * cLarva) / R) exp) + 1) + (((((1/fLarva) - (1/tempKelvinPromedio)) * eLarva) / R) exp)). 

survivalRateLarvaPhthorimaea &lt;=0 ifTrue:[survivalRateLarvaPhthorimaea:=0].

survivalRatePupaPhthorimaea := (1/298.16) - (1/tempKelvinPromedio).
survivalRatePupaPhthorimaea := (bPupa * survivalRatePupaPhthorimaea).
survivalRatePupaPhthorimaea := (survivalRatePupaPhthorimaea) exp.
survivalRatePupaPhthorimaea := ((aPupa * tempKelvinPromedio) /298.16) *survivalRatePupaPhthorimaea.
survivalRatePupaPhthorimaea := survivalRatePupaPhthorimaea / (((((((1/dPupa) - (1/tempKelvinPromedio)) * cPupa) / R) exp) + 1) + (((((1/fPupa) - (1/tempKelvinPromedio)) * ePupa) / R) exp)). 

survivalRatePupaPhthorimaea &lt;=0 ifTrue:[survivalRatePupaPhthorimaea:=0].

self survivalRatePhthorimaea: survivalRatePupaPhthorimaea*survivalRateLarvaPhthorimaea*survivalRateEggPhthorimaea.
self survivalRatePhthorimaea &lt;0 ifTrue:[self survivalRatePhthorimaea: 0].
"SYMMETRISCHEMA------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"

	R := 1.987.	"universal gas constant"
	aEgg := 0.834.
	bEgg := 10.94.
	cEgg := 0 - 234000.
	dEgg := 282.4.
	eEgg := 616600.
	fEgg := 304.1.
	aLarva := 0.694.
	bLarva := 0 - 236.3.
	cLarva := 0 - 420300.
	dLarva := 283.1.
	eLarva := 1551000.
	fLarva := 305.6.
	aPupa := 0.882.
	bPupa := 39.93.
	cPupa := 0 - 992700.
	dPupa := 282.9.
	ePupa := 1110000.
	fPupa := 304.7.

	"----------------------------------------------------------------------------------"
	tempKelvinPromedio := tempStochastic + 273.5.
	"----------------------------------------------------------------------------------"
	survivalRateEggSymmetrischemma := 1 / 298.16 - (1 / tempKelvinPromedio).
	survivalRateEggSymmetrischemma := bEgg * survivalRateEggSymmetrischemma.
	survivalRateEggSymmetrischemma := survivalRateEggSymmetrischemma exp.
	survivalRateEggSymmetrischemma := aEgg * tempKelvinPromedio / 298.16 
				* survivalRateEggSymmetrischemma.
	survivalRateEggSymmetrischemma := survivalRateEggSymmetrischemma 
				/ (((1 / dEgg - (1 / tempKelvinPromedio)) * cEgg / R) exp + 1 
						+ ((1 / fEgg - (1 / tempKelvinPromedio)) * eEgg / R) exp).

survivalRateEggSymmetrischemma &lt;=0 ifTrue:[survivalRateEggSymmetrischemma:=0].	

survivalRateLarvaSymmetrischemma := 1 / 298.16 - (1 / tempKelvinPromedio).
	survivalRateLarvaSymmetrischemma := bLarva 
				* survivalRateLarvaSymmetrischemma.
	survivalRateLarvaSymmetrischemma := survivalRateLarvaSymmetrischemma exp.
	survivalRateLarvaSymmetrischemma := aLarva * tempKelvinPromedio / 298.16 
				* survivalRateLarvaSymmetrischemma.
	survivalRateLarvaSymmetrischemma := survivalRateLarvaSymmetrischemma 
				/ (((1 / dLarva - (1 / tempKelvinPromedio)) * cLarva / R) exp + 1 
						+ ((1 / fLarva - (1 / tempKelvinPromedio)) * eLarva / R) exp).

survivalRateLarvaSymmetrischemma &lt;=0 ifTrue:[survivalRateLarvaSymmetrischemma:=0].	

	survivalRatePupaSymmetrischemma := 1 / 298.16 - (1 / tempKelvinPromedio).
	survivalRatePupaSymmetrischemma := bPupa * survivalRatePupaSymmetrischemma.
	survivalRatePupaSymmetrischemma := survivalRatePupaSymmetrischemma exp.
	survivalRatePupaSymmetrischemma := aPupa * tempKelvinPromedio / 298.16 
				* survivalRatePupaSymmetrischemma.
	survivalRatePupaSymmetrischemma := survivalRatePupaSymmetrischemma 
				/ (((1 / dPupa - (1 / tempKelvinPromedio)) * cPupa / R) exp + 1 
						+ ((1 / fPupa - (1 / tempKelvinPromedio)) * ePupa / R) exp).

survivalRatePupaSymmetrischemma &lt;=0 ifTrue:[survivalRatePupaSymmetrischemma:=0].	

self survivalRateSymmetrischemma: survivalRatePupaSymmetrischemma*survivalRateLarvaSymmetrischemma*survivalRateEggSymmetrischemma.
self survivalRateSymmetrischemma &lt;0 ifTrue:[self survivalRateSymmetrischemma: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateTempStochastic">updateTempStochastic
"US = to put stochasticity into temperature so that it takes into account uncertainties"
"ES = Regla para modificar la temperatura promedia según la capa de estochasticidad"
|ratioP|
ratioP := (self tempPromedio*0.653)/8.

self tempStochastic: self  tempPromedio + (ratioP* self stochastic).</body>
</methods>


<class>
<name>MsgHelp</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.Msg</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>location nivel ag </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.MsgHelp</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="ag">ag
	^ag</body>

<body package="SimPolillaSimiatug_v02" selector="ag:">ag: anObject
	ag := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="location">location
	^location</body>

<body package="SimPolillaSimiatug_v02" selector="location:">location: anObject
	location := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivel">nivel
	^nivel</body>

<body package="SimPolillaSimiatug_v02" selector="nivel:">nivel: anObject
	nivel := anObject</body>
</methods>


<class>
<name>Ag_Isolate_04</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_04</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_04</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_04_readAnswer">Ag_Isolate_04_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_04_readAnswerMercy">Ag_Isolate_04_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_04_readMsgHelpAndAnswer">Ag_Isolate_04_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_04_sendMsgHelp">Ag_Isolate_04_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_04_withCom">Ag_Isolate_04_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_04_withoutCom">Ag_Isolate_04_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_04</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=1]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_04</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc dist|

dist:=5.

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"1 to: 6 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_0', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_01 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 4.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_02 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 4.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_03 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 4.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_04 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 4.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_05 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 4.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_06 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 4.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 7 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 7 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 busy nivelAutre|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &lt;7 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 4.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil multip seuilVariable|

multip:=0.2.

seuilVariable:=100.

eficacidadTratamientoChimico:= self nivelFormation*multip*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=seuilVariable/self  nivelFormation.] ifTrue:[seuil:=seuilVariable].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].

self patch tecia&lt;0 ifTrue:[self patch tecia:0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_04</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_04</body>
</methods>


<class>
<name>Ag_Isolate_14</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_14</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_14</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_014_readAnswerMercy">Ag_Isolate_014_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_14_readAnswer">Ag_Isolate_14_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_14_readMsgHelpAndAnswer">Ag_Isolate_14_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_14_sendMsgHelp">Ag_Isolate_14_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_14_withCom">Ag_Isolate_14_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_14_withoutCom">Ag_Isolate_14_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_14</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=1]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil: [numActions := 5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_14</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_14</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_14</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc|

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"13 to: 18 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_13 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 14.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_14 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 14.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_15 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 14.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_16 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 14.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_17 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 14.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_18 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 14.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &gt; 12 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel
]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &gt; 12 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 busy nivelAutre|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &gt;12 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 14.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=100/self  nivelFormation.] ifTrue:[seuil:=100].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>


<class>
<name>Ag_Isolate_05</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_05</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_05</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_05_readAnswer">Ag_Isolate_05_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_05_readAnswerMercy">Ag_Isolate_05_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_05_readMsgHelpAndAnswer">Ag_Isolate_05_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_05_sendMsgHelp">Ag_Isolate_05_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_05_withCom">Ag_Isolate_05_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_05_withoutCom">Ag_Isolate_05_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_05</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=2]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_05</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc dist|

dist:=5.

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"1 to: 6 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_0', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_01 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 5.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_02 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 5.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_03 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 5.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_04 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 5.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_05 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 5.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_06 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 5.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 7 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 7 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 busy nivelAutre|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &lt;7 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 5.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil multip seuilVariable|

multip:=0.2.

seuilVariable:=100.

eficacidadTratamientoChimico:= self nivelFormation*multip*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=seuilVariable/self  nivelFormation.] ifTrue:[seuil:=seuilVariable].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].

self patch tecia&lt;0 ifTrue:[self patch tecia:0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_05</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_05</body>
</methods>


<class>
<name>Ag_Isolate_15</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_15</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_15</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_015_readAnswerMercy">Ag_Isolate_015_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_15_readAnswer">Ag_Isolate_15_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_15_readMsgHelpAndAnswer">Ag_Isolate_15_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_15_sendMsgHelp">Ag_Isolate_15_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_15_withCom">Ag_Isolate_15_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_15_withoutCom">Ag_Isolate_15_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_15</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_15</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_15</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_15</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc|

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"13 to: 18 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_13 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 15.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_14 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 15.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_15 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 15.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_16 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 15.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_17 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 15.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_18 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 15.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &gt; 12 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel
]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &gt; 12 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage := self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 busy nivelAutre|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &gt;12 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 15.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=100/self  nivelFormation.] ifTrue:[seuil:=100].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>


<class>
<name>MsgPhthorimaea</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.Msg</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>location </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.MsgPhthorimaea</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="location">location
	^location</body>

<body package="SimPolillaSimiatug_v02" selector="location:">location: anObject
	location := anObject</body>
</methods>


<class>
<name>Ag_Isolate_10</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_10</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_10</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_010_readAnswerMercy">Ag_Isolate_010_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_10_readAnswer">Ag_Isolate_10_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_10_readMsgHelpAndAnswer">Ag_Isolate_10_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_10_sendMsgHelp">Ag_Isolate_10_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_10_withCom">Ag_Isolate_10_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_10_withoutCom">Ag_Isolate_10_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_10</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_10</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_10</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=1]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_10</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc|

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"7 to: 9 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_0', i printString) asSymbol) withinRange: 5)].
	10 to: 12 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_07 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 10.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_08 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 10.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_09 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 10.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_10 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 10.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_11 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 10.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_12 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 10.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 13 and:[m2 ag &gt; 6 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel]]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 13 and:[m2 ag &gt; 6 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 busy nivelAutre|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &gt;6 and:[m1 ag&lt;13 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 10.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=100/self  nivelFormation.] ifTrue:[seuil:=100].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>


<class>
<name>Ag_Isolate_06</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_06</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_06</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_06_readAnswer">Ag_Isolate_06_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_06_readAnswerMercy">Ag_Isolate_06_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_06_readMsgHelpAndAnswer">Ag_Isolate_06_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_06_sendMsgHelp">Ag_Isolate_06_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_06_withCom">Ag_Isolate_06_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_06_withoutCom">Ag_Isolate_06_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_06</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=2]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_06</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_06</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_06</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc dist|

dist:=5.

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"1 to: 6 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_0', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_01 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 6.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_02 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 6.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_03 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 6.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_04 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 6.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_05 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 6.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_06 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 6.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 7 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 7 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 busy nivelAutre |

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &lt;7 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 6.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil multip seuilVariable|

multip:=0.2.

seuilVariable:=100.

eficacidadTratamientoChimico:= self nivelFormation*multip*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=seuilVariable/self  nivelFormation.] ifTrue:[seuil:=seuilVariable].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].

self patch tecia&lt;0 ifTrue:[self patch tecia:0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>


<class>
<name>Ag_Isolate_11</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_11</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_11</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_011_readAnswerMercy">Ag_Isolate_011_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_11_readAnswer">Ag_Isolate_11_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_11_readMsgHelpAndAnswer">Ag_Isolate_11_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_11_sendMsgHelp">Ag_Isolate_11_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_11_withCom">Ag_Isolate_11_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_11_withoutCom">Ag_Isolate_11_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_11</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=2]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_11</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_11</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_11</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc|

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"7 to: 9 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_0', i printString) asSymbol) withinRange: 5)].
	10 to: 12 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_07 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 11.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_08 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 11.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_09 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 11.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_10 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 11.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_11 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 11.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_12 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 11.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 13 and:[m2 ag &gt; 6 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel]]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 13 and:[m2 ag &gt; 6 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 busy nivelAutre|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &gt;6 and:[m1 ag&lt;13 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 11.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=100/self  nivelFormation.] ifTrue:[seuil:=100].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>


<class>
<name>Ag_Isolate_01</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_01</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_01</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_01_readAnswer">Ag_Isolate_01_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_01_readAnswerMercy">Ag_Isolate_01_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_01_readMsgHelpAndAnswer">Ag_Isolate_01_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_01_sendMsgHelp">Ag_Isolate_01_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_01_withCom">Ag_Isolate_01_withCom

"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

"Para comunicar"
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_01_withoutCom">Ag_Isolate_01_withoutCom

"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions=5.

	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_01</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc dist|

dist:=5.

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"1 to: 6 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_0', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_01 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 1.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_02 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 1.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_03 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 1.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_04 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 1.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_05 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 1.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_06 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 1.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 7 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel
]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 7 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart
"US = to constrain agents' movements into their field and communities"

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="msgPutAnEnd">msgPutAnEnd

self mailBox removeAll: (self mailBox select:[:k | k symbol = #pleaseHelp]).
self mailBox removeAll: (self mailBox select:[:k | k symbol = #ok]).

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 nbrMails nivelAutre busy|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &lt; 7 ifTrue:[busy = 1 ifFalse:[

				nbrMails:= (m1 symbol = #pleaseHelp) size.
				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."
					m2:=MsgHelpAns new.
					m2 sender: self.
					m2 receiver: (m1) sender.
					m2 symbol: #ok.
					m2 ag: 1.
					m2 nivel: self nivelFormation.
					self sendMessageSynchronously: m2.
					self numActions: self penality.
					"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil multip seuilVariable|

multip:=0.2.

seuilVariable:=100.

eficacidadTratamientoChimico:= self nivelFormation*multip*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=seuilVariable/self  nivelFormation.] ifTrue:[seuil:=seuilVariable].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].

self patch tecia&lt;0 ifTrue:[self patch tecia:0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_01</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]

</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_01</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_01.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_01</class-id> <category>archive</category>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

	aMessage notNil ifTrue:[
		aMessage object &lt; self nivelFormation ifTrue:[ 
	"	reply:= "
		self numActions: 1]].</body>
</methods>


<class>
<name>Ag_Isolate_09</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_09</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_09</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_09_readAnswer">Ag_Isolate_09_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_09_readAnswerMercy">Ag_Isolate_09_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_09_readMsgHelpAndAnswer">Ag_Isolate_09_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_09_sendMsgHelp">Ag_Isolate_09_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_09_withCom">Ag_Isolate_09_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_09_withoutCom">Ag_Isolate_09_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_09</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_09</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_09</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_09</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc|

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"7 to: 9 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_0', i printString) asSymbol) withinRange: 5)].
	10 to: 12 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_07 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 9.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_08 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 9.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_09 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 9.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_10 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 9.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_11 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 9.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_12 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 9.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 13 and:[m2 ag &gt; 6 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel]]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 13 and:[m2 ag &gt; 6 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 busy nivelAutre|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &gt;6 and:[m1 ag&lt;13 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 9.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=100/self  nivelFormation.] ifTrue:[seuil:=100].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>


<class>
<name>Agri04</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation areaTotal riego maquinaria semillaPapa rotationVariedad aproFerti almacen </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<comment>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri04</class-id>
<body>Agri04 representa a los agentes papicultores que tienen un nivel de capacitación o de conocimiento de 4.

Instance Variables:
	almacen			&lt;SmallInteger&gt;		description of almacen
	aproFerti			&lt;SmallInteger&gt;		si=1 y no=0
	areaTotal			&lt;SmallInteger&gt;		description of areaTotal
	maquinaria			&lt;SmallInteger&gt;		si=1 y no=0
	nivelFormation		&lt;SmallInteger&gt;		nivel = 4
	riego				&lt;SmallInteger&gt;		description of riego
	rotationVariedad		&lt;SmallInteger&gt;		description of rotationVariedad
	semillaPapa			&lt;SmallInteger&gt;		description of semillaPapa

</body>
</comment>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri04</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri04</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>

<body package="SimPolillaSimiatug_v02" selector="step004">step004

			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.</body>

<body package="SimPolillaSimiatug_v02" selector="step04">step04
	self alarmCalling.
	self readMail.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.</body>

<body package="SimPolillaSimiatug_v02" selector="step04_Part">step04_Part

	self moveIntoAgroPartPart.
	self testManejo.
	self moveIntoAgroPartPart.
	self testManejo.
	self moveIntoAgroPartPart.
	self testManejo.
	self moveIntoAgroPartPart.
	self testManejo.
	self moveIntoAgroPartPart.
	self testManejo</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri04</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Agri04.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri04</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2.
seuil:=100/self  nivelFormation.

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].
self patch bufferNumberPhthorimaeaFemale&gt;(seuil) ifTrue:[self patch phthorimaea: self patch phthorimaea*(1-eficacidadTratamientoChimico)].
self patch symmetrischemma&gt;(seuil) ifTrue:[self patch symmetrischemma: self patch symmetrischemma*(1-eficacidadTratamientoChimico)].</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri04</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="almacen">almacen
	"Getter accessor with default value = 1 "
	^almacen ifNil:[almacen := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="almacen:">almacen: anObject 
	almacen := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="aproFerti">aproFerti
	"Getter accessor with default value = 1 "
	^aproFerti ifNil:[aproFerti := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="aproFerti:">aproFerti: anObject 
	aproFerti := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="areaTotal">areaTotal
	"Getter accessor with default value = 1 "
	^areaTotal ifNil:[areaTotal := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="areaTotal:">areaTotal: anObject 
	areaTotal := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="maquinaria">maquinaria
	"Getter accessor with default value = 1 "
	^maquinaria ifNil:[maquinaria := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="maquinaria:">maquinaria: anObject 
	maquinaria := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	"Getter accessor with default value = 4 "
	^nivelFormation ifNil:[nivelFormation := 4]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject 
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="riego">riego
	"Getter accessor with default value = 1 "
	^riego ifNil:[riego := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="riego:">riego: anObject 
	riego := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rotationVariedad">rotationVariedad
	"Getter accessor with default value = 1 "
	^rotationVariedad ifNil:[rotationVariedad := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="rotationVariedad:">rotationVariedad: anObject 
	rotationVariedad := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="semillaPapa">semillaPapa
	"Getter accessor with default value = 1 "
	^semillaPapa ifNil:[semillaPapa := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="semillaPapa:">semillaPapa: anObject 
	semillaPapa := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri04</class-id> <category>msg</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	"para enviar un mensage a los demas si la polilla mas abundante acerca de un agente es mas alta que una valor dependiente del nivel de percepción de un agente"

	| alarm teciaNeighbours phNeighbours symNeighbours bigNeighbours numCeldas agriOnMyCell|
	numCeldas := 2.

teciaNeighbours :=0.
phNeighbours :=0.
symNeighbours :=0.

	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (200 - (self nivelFormation * 20))].
	phNeighbours := self patch neighbourhood select: [:f | f bufferNumberPhthorimaeaFemale &gt; (200 - (self nivelFormation * 20))].
	symNeighbours := self patch neighbourhood select: [:f | f bufferNumberSymmetrischemaFemale &gt; (200 - (self nivelFormation * 20))].


	teciaNeighbours size &gt; phNeighbours size
		ifTrue: [teciaNeighbours size &gt; symNeighbours size
				ifTrue: [bigNeighbours := teciaNeighbours]
				ifFalse: [bigNeighbours := symNeighbours]]
		ifFalse: 	[phNeighbours size &gt; symNeighbours size
				ifTrue: [bigNeighbours := phNeighbours]
				ifFalse: [bigNeighbours := symNeighbours]].

	"el mensage es enviado si hay mas de numCeldas celdas alrejedor de un agente"
agriOnMyCell := IndexedSet new.
	1 to: 5 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Agri0', i printString) asSymbol) withinRange: 5)].


	bigNeighbours size &gt; numCeldas 

		ifTrue: 
			[alarm := MsgHelp new.
			alarm sender: self.
			alarm symbol: #alarm.
			agriOnMyCell do: 
					[:x | 
					alarm location: (Cormas selectRandomlyFrom: bigNeighbours).
					alarm receiver: x.
					self sendMessageSynchronously: alarm]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmCallingAggregate">alarmCallingAggregate

| alarmT alarmP alarmS alarm teciaedCell phthedCell symedCell PTMCell aggregateT aggregateP aggregateS aggregate numCellPTM tot|

numCellPTM:=10.
tot:=150.

teciaedCell := self patch neighbourhood detect: [:f | f  bufferNumberTeciaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].
phthedCell := self patch neighbourhood detect: [:f | f  bufferNumberPhthorimaeaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].
symedCell := self patch neighbourhood detect: [:f | f  bufferNumberSymmetrischemaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].

PTMCell := self patch neighbourhood detect: [:f | f  bufferNumberTeciaFemale&gt;(tot-(self nivelFormation*20))
	or: [f  bufferNumberPhthorimaeaFemale&gt;(tot-(self nivelFormation*20))
	or: [f  bufferNumberSymmetrischemaFemale&gt;(tot-(self nivelFormation*20))]]] ifNone: [^nil].

aggregateT := teciaedCell theCSE at: #AggregateTecia.
aggregateP := phthedCell theCSE at: #AggregatePhthorimaea.
aggregateS := symedCell theCSE at: #AggregateSymmetrischema.

aggregate := PTMCell theCSE at: #Aggregate.

aggregate size &gt; numCellPTM
ifTrue:
	[alarm := MsgHelp new.
	alarm sender: self.
	alarm symbol: #alarm.
	self  acquaintances do:
		[:x |
	alarm location: (Cormas selectRandomlyFrom: aggregate components).
	alarm receiver: x.
	self sendMessageAsynchronously: alarm]].
</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage := self nextMessage.

	aMessage notNil ifTrue:[
		self leave.
		self moveTo: aMessage location]
	ifFalse: [
		self moveIntoAgroPart]</body>
</methods>


<class>
<name>Ag_Isolate_16</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_16</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_16</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_016_readAnswerMercy">Ag_Isolate_016_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_16_readAnswer">Ag_Isolate_16_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_16_readMsgHelpAndAnswer">Ag_Isolate_16_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_16_sendMsgHelp">Ag_Isolate_16_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_16_withCom">Ag_Isolate_16_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_16_withoutCom">Ag_Isolate_16_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_16</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=1]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_16</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_16</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_16</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc|

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"13 to: 18 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_13 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 16.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_14 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 16.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_15 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 16.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_16 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 16.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_17 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 16.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_18 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 16.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &gt; 12 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel
]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &gt; 12 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage := self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 nivelAutre busy|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &gt;12 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 16.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=100/self  nivelFormation.] ifTrue:[seuil:=100].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>


<class>
<name>Ag_Isolate_02</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions nbrMailsRcp nbrMailsTrt top penality forAchange mailSent mailSentRsp probaDe3 </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_02</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_02</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_02_readAnswer">Ag_Isolate_02_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_02_readAnswerMercy">Ag_Isolate_02_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_02_readMsgHelpAndAnswer">Ag_Isolate_02_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_02_sendMsgHelp">Ag_Isolate_02_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_02_withCom">Ag_Isolate_02_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_02_withoutCom">Ag_Isolate_02_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_02</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="mailSent">mailSent
	^mailSent ifNil: [mailSent := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="mailSent:">mailSent: anObject
	mailSent := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="mailSentRsp">mailSentRsp
	^mailSentRsp ifNil: [mailSentRsp := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="mailSentRsp:">mailSentRsp: anObject
	mailSentRsp := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nbrMailsRcp">nbrMailsRcp
	^nbrMailsRcp ifNil: [nbrMailsRcp := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="nbrMailsRcp:">nbrMailsRcp: anObject
	nbrMailsRcp := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nbrMailsTrt">nbrMailsTrt
	^nbrMailsTrt ifNil: [nbrMailsTrt := 0]</body>

<body package="SimPolillaSimiatug_v02" selector="nbrMailsTrt:">nbrMailsTrt: anObject
	nbrMailsTrt := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=1]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="probaDe3">probaDe3
	^probaDe3 ifNil:[probaDe3:=0.75]</body>

<body package="SimPolillaSimiatug_v02" selector="probaDe3:">probaDe3: anObject
	probaDe3 := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_02</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc dist|

dist:=5.

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.

	numCeldas := 2.

	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"1 to: 6 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_0', i printString) asSymbol) withinRange: 5)]. NE MARCHE PAS... RAISON INCONNUE..."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_01 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					self mailSent: (self mailSent+1).
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 2.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_02 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					self mailSent: (self mailSent+1).
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 2.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_03 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					self mailSent: (self mailSent+1).
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 2.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_04 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					self mailSent: (self mailSent+1).
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 2.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_05 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					self mailSent: (self mailSent+1).
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 2.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_06 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					self mailSent: (self mailSent+1).
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 2.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 7 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel
]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 7 ifTrue:[
			self mailSentRsp: (self mailSentRsp+1).
			proba&gt;self probaDe3 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;(1-self probaDe3) 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 nivelAutre busy|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &lt;7 ifTrue:[
					
					busy = 1 ifFalse:[
					self nbrMailsRcp: (self nbrMailsRcp+1).
				
				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					
					"busy:= 1."
					self nbrMailsTrt: (self nbrMailsTrt+1).

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 2.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil multip seuilVariable|

multip:=0.2.

seuilVariable:=100.

eficacidadTratamientoChimico:= self nivelFormation*multip*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=seuilVariable/self  nivelFormation.] ifTrue:[seuil:=seuilVariable].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].

self patch tecia&lt;0 ifTrue:[self patch tecia:0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_02</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_02</body>
</methods>


<class>
<name>Ag_Isolate_03</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_03</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_03</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_03_readAnswer">Ag_Isolate_03_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_03_readAnswerMercy">Ag_Isolate_03_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_03_readMsgHelpAndAnswer">Ag_Isolate_03_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_03_sendMsgHelp">Ag_Isolate_03_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_03_withCom">Ag_Isolate_03_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_03_withoutCom">Ag_Isolate_03_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_03</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_03</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc dist|

dist:=5.

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"1 to: 6 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_0', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_01 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 3.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_02 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 3.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_03 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 3.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_04 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 3.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_05 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 3.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_06 withinRange: dist).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 3.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 7 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel
]]]].
mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 7 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2  nivelAutre busy|

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &lt;7 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 3.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil multip seuilVariable|

multip:=0.2.

seuilVariable:=100.

eficacidadTratamientoChimico:= self nivelFormation*multip*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=seuilVariable/self  nivelFormation.] ifTrue:[seuil:=seuilVariable].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].

self patch tecia&lt;0 ifTrue:[self patch tecia:0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_03</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_03</body>
</methods>


<class>
<name>Ag_Isolate_07</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_07</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_07</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_07_readAnswer">Ag_Isolate_07_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_07_readAnswerMercy">Ag_Isolate_07_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_07_readMsgHelpAndAnswer">Ag_Isolate_07_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_07_sendMsgHelp">Ag_Isolate_07_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_07_withCom">Ag_Isolate_07_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_07_withoutCom">Ag_Isolate_07_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_07</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_07</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_07</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_07</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc|

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"7 to: 9 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_0', i printString) asSymbol) withinRange: 5)].
	10 to: 12 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_07 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 7.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_08 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 7.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_09 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 7.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_10 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 7.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_11 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 7.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_12 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 7.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 13 and:[m2 ag &gt; 6 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel]]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &lt; 13 and:[m2 ag &gt; 6 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 busy nivelAutre |

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &gt;6 and:[m1 ag&lt;13 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 7.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				"self mailBox removeAll:(self mailBox select:[:m |m symbol=#pleaseHelp])."
]]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=100/self  nivelFormation.] ifTrue:[seuil:=100].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>


<class>
<name>MsgSymmetrischema</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.Msg</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>location </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.MsgSymmetrischema</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="location">location
	^location</body>

<body package="SimPolillaSimiatug_v02" selector="location:">location: anObject
	location := anObject</body>
</methods>


<class>
<name>Agri03</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation areaTotal riego maquinaria semillaPapa rotationVariedad aproFerti almacen </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<comment>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri03</class-id>
<body>Agri03 representa a los agentes papicultores que tienen un nivel de capacitación o de conocimiento de 3.

Instance Variables:
	almacen			&lt;SmallInteger&gt;		description of almacen
	aproFerti			&lt;SmallInteger&gt;		si=1 y no=0
	areaTotal			&lt;SmallInteger&gt;		description of areaTotal
	maquinaria			&lt;SmallInteger&gt;		si=1 y no=0
	nivelFormation		&lt;SmallInteger&gt;		nivel = 3
	riego				&lt;SmallInteger&gt;		description of riego
	rotationVariedad		&lt;SmallInteger&gt;		description of rotationVariedad
	semillaPapa			&lt;SmallInteger&gt;		description of semillaPapa

</body>
</comment>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri03</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri03</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>

<body package="SimPolillaSimiatug_v02" selector="step003">step003

			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.</body>

<body package="SimPolillaSimiatug_v02" selector="step03">step03
	self alarmCalling.
	self readMail.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.
			self moveIntoAgroPart.
			self testManejo.</body>

<body package="SimPolillaSimiatug_v02" selector="step03_Part">step03_Part


			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.
			self moveIntoAgroPartPart.
			self testManejo.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri03</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Agri03.</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri03</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2.
seuil:=100/self  nivelFormation.

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].
self patch bufferNumberPhthorimaeaFemale&gt;(seuil) ifTrue:[self patch phthorimaea: self patch phthorimaea*(1-eficacidadTratamientoChimico)].
self patch symmetrischemma&gt;(seuil) ifTrue:[self patch symmetrischemma: self patch symmetrischemma*(1-eficacidadTratamientoChimico)].</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri03</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="almacen">almacen
	"Getter accessor with default value = 1 "
	^almacen ifNil:[almacen := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="almacen:">almacen: anObject 
	almacen := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="aproFerti">aproFerti
	"Getter accessor with default value = 1 "
	^aproFerti ifNil:[aproFerti := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="aproFerti:">aproFerti: anObject 
	aproFerti := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="areaTotal">areaTotal
	"Getter accessor with default value = 1 "
	^areaTotal ifNil:[areaTotal := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="areaTotal:">areaTotal: anObject 
	areaTotal := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="maquinaria">maquinaria
	"Getter accessor with default value = 1 "
	^maquinaria ifNil:[maquinaria := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="maquinaria:">maquinaria: anObject 
	maquinaria := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	"Getter accessor with default value = 3 "
	^nivelFormation ifNil:[nivelFormation := 3]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject 
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="riego">riego
	"Getter accessor with default value = 1 "
	^riego ifNil:[riego := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="riego:">riego: anObject 
	riego := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="rotationVariedad">rotationVariedad
	"Getter accessor with default value = 1 "
	^rotationVariedad ifNil:[rotationVariedad := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="rotationVariedad:">rotationVariedad: anObject 
	rotationVariedad := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="semillaPapa">semillaPapa
	"Getter accessor with default value = 1 "
	^semillaPapa ifNil:[semillaPapa := 1]</body>

<body package="SimPolillaSimiatug_v02" selector="semillaPapa:">semillaPapa: anObject 
	semillaPapa := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Agri03</class-id> <category>msg</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	"para enviar un mensage a los demas si la polilla mas abundante acerca de un agente es mas alta que una valor dependiente del nivel de percepción de un agente"

	| alarm teciaNeighbours phNeighbours symNeighbours bigNeighbours numCeldas agriOnMyCell|
	numCeldas := 2.

teciaNeighbours :=0.
phNeighbours :=0.
symNeighbours :=0.

	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (200 - (self nivelFormation * 20))].
	phNeighbours := self patch neighbourhood select: [:f | f bufferNumberPhthorimaeaFemale &gt; (200 - (self nivelFormation * 20))].
	symNeighbours := self patch neighbourhood select: [:f | f bufferNumberSymmetrischemaFemale &gt; (200 - (self nivelFormation * 20))].


	teciaNeighbours size &gt; phNeighbours size
		ifTrue: [teciaNeighbours size &gt; symNeighbours size
				ifTrue: [bigNeighbours := teciaNeighbours]
				ifFalse: [bigNeighbours := symNeighbours]]
		ifFalse: 	[phNeighbours size &gt; symNeighbours size
				ifTrue: [bigNeighbours := phNeighbours]
				ifFalse: [bigNeighbours := symNeighbours]].


agriOnMyCell := IndexedSet new.
	1 to: 5 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Agri0', i printString) asSymbol) withinRange: 5)].


	bigNeighbours size &gt; numCeldas 

		ifTrue: 
			[alarm := MsgHelp new.
			alarm sender: self.
			alarm symbol: #alarm.
			agriOnMyCell do: 
					[:x | 
					alarm location: (Cormas selectRandomlyFrom: bigNeighbours).
					alarm receiver: x.
					self sendMessageSynchronously: alarm]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmCallingAggregate">alarmCallingAggregate

| alarmT alarmP alarmS alarm teciaedCell phthedCell symedCell PTMCell aggregateT aggregateP aggregateS aggregate numCellPTM tot|

numCellPTM:=10.
tot:=150.

teciaedCell := self patch neighbourhood detect: [:f | f  bufferNumberTeciaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].
phthedCell := self patch neighbourhood detect: [:f | f  bufferNumberPhthorimaeaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].
symedCell := self patch neighbourhood detect: [:f | f  bufferNumberSymmetrischemaFemale&gt;(tot-(self nivelFormation*20))] ifNone: [^nil].

PTMCell := self patch neighbourhood detect: [:f | f  bufferNumberTeciaFemale&gt;(tot-(self nivelFormation*20))
	or: [f  bufferNumberPhthorimaeaFemale&gt;(tot-(self nivelFormation*20))
	or: [f  bufferNumberSymmetrischemaFemale&gt;(tot-(self nivelFormation*20))]]] ifNone: [^nil].

aggregateT := teciaedCell theCSE at: #AggregateTecia.
aggregateP := phthedCell theCSE at: #AggregatePhthorimaea.
aggregateS := symedCell theCSE at: #AggregateSymmetrischema.

aggregate := PTMCell theCSE at: #Aggregate.

aggregate size &gt; numCellPTM
ifTrue:
	[alarm := MsgHelp new.
	alarm sender: self.
	alarm symbol: #alarm.
	self  acquaintances do:
		[:x |
	alarm location: (Cormas selectRandomlyFrom: aggregate components).
	alarm receiver: x.
	self sendMessageAsynchronously: alarm]].
</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage := self nextMessage.

	aMessage notNil ifTrue:[
		self leave.
		self moveTo: aMessage location]
	ifFalse: [
		self moveIntoAgroPart]</body>
</methods>


<class>
<name>Ag_Isolate_13</name>
<environment>CormasNS.Models.SimPolillaSimiatug_v02</environment>
<super>CormasNS.Kernel.GroupCommLocation</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nivelFormation learnFromOthers sendMsg getMsg numActions top penality forAchange </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SimPolillaSimiatug_v02Category</category>
<attributes>
<package>SimPolillaSimiatug_v02</package>
</attributes>
</class>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_13</class-id> <category>init</category>

<body package="SimPolillaSimiatug_v02" selector="init">init
	"to be completed. The inherited attributes should have been already initialized"
</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_13</class-id> <category>control</category>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_013_readAnswerMercy">Ag_Isolate_013_readAnswerMercy

	self alarmReadingResponseMercy.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_13_readAnswer">Ag_Isolate_13_readAnswer

	self alarmReadingResponse.

"ES = Para conocer el nivel de conocimiento" "US = To know the IPM knowledge"
	self updateLearnFromOthers.
	self defineNivelFormation.

"ES = Actiones durante una generacion" "US = Process overview"
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_13_readMsgHelpAndAnswer">Ag_Isolate_13_readMsgHelpAndAnswer

self readMailAlarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_13_sendMsgHelp">Ag_Isolate_13_sendMsgHelp
"ES = Para afectar el nivel de formation de cada agente" "US = To affect the IPM knowledge to each agent" 
	self defineNivelFormation.
	self updateNumActions.

	self alarmCalling.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_13_withCom">Ag_Isolate_13_withCom
	self defineNivelFormation.
	self updateNumActions.
	self alarmCalling.
	self readMailAlarmCalling.
	self alarmReadingResponse.
	self updateLearnFromOthers.
	self defineNivelFormation.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.].
	self moveIntoAgroPartPart.</body>

<body package="SimPolillaSimiatug_v02" selector="Ag_Isolate_13_withoutCom">Ag_Isolate_13_withoutCom
	self defineNivelFormation.
	self numActions=5.
	self numActions timesRepeat:[
		self moveIntoAgroPartPart.
		self testManejo.]</body>

<body package="SimPolillaSimiatug_v02" selector="step">step
	"to be completed"</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_13</class-id> <category>accessing</category>

<body package="SimPolillaSimiatug_v02" selector="forAchange">forAchange
	^forAchange</body>

<body package="SimPolillaSimiatug_v02" selector="forAchange:">forAchange: anObject
	forAchange := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg">getMsg
	^getMsg</body>

<body package="SimPolillaSimiatug_v02" selector="getMsg:">getMsg: anObject
	getMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers">learnFromOthers
	^learnFromOthers ifNil:[learnFromOthers:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="learnFromOthers:">learnFromOthers: anObject
	learnFromOthers := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation">nivelFormation
	^nivelFormation ifNil:[nivelFormation:=0]</body>

<body package="SimPolillaSimiatug_v02" selector="nivelFormation:">nivelFormation: anObject
	nivelFormation := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="numActions">numActions
	^numActions ifNil:[numActions:=5]</body>

<body package="SimPolillaSimiatug_v02" selector="numActions:">numActions: anObject
	numActions := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="penality">penality
	^penality  ifNil:[penality:= 3].</body>

<body package="SimPolillaSimiatug_v02" selector="penality:">penality: anObject
	penality := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg">sendMsg
	^sendMsg</body>

<body package="SimPolillaSimiatug_v02" selector="sendMsg:">sendMsg: anObject
	sendMsg := anObject</body>

<body package="SimPolillaSimiatug_v02" selector="top">top
	^top</body>

<body package="SimPolillaSimiatug_v02" selector="top:">top: anObject
	top := anObject</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_13</class-id> <category>pov</category>

<body package="SimPolillaSimiatug_v02" selector="pov">pov

^#Ag_Isolate_13</body>
</methods>

<methods>
<class-id>CormasNS.Models.SimPolillaSimiatug_v02.Ag_Isolate_13</class-id> <category>rules</category>

<body package="SimPolillaSimiatug_v02" selector="alarmCalling">alarmCalling
	| teciaNeighbours numCeldas agriOnMyCell m1 stoPerc|

	stoPerc:= (self patch stoPec)*(Cormas randomFrom:80 to:120)/100.
	numCeldas := 2.
	teciaNeighbours :=0.
	teciaNeighbours := self patch neighbourhood 	select: [:f | f bufferNumberTeciaFemale &gt; (stoPerc - (self nivelFormation * self patch stoPec2))].

agriOnMyCell := IndexedSet new.
	"13 to: 18 do:[ :i | agriOnMyCell addAll: (self perceivedEntities: (('Ag_Isolate_', i printString) asSymbol) withinRange: 5)]."
	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_13 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 13.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_14 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 13.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_15 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 13.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_16 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 13.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_17 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 13.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].

	agriOnMyCell:= (self perceivedEntities: #Ag_Isolate_18 withinRange: 5).
	teciaNeighbours size &gt; numCeldas and:[self nivelFormation&lt;5 ifTrue:[
			m1 := MsgHelp new.
			agriOnMyCell do: 
					[:x | 
					m1 sender: self.
					m1	receiver: x.
					m1 symbol: #pleaseHelp.
					m1 nivel: self nivelFormation.	
					m1 ag: 13.
					m1 location: (Cormas selectRandomlyFrom: teciaNeighbours).
					self sendMessageSynchronously: m1].
			self numActions: self penality.]].</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponse">alarmReadingResponse

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &gt; 12 ifTrue:[
			self learnFromOthers: (self learnFromOthers + 1).

			self top: m2 nivel
]]]].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="alarmReadingResponseMercy">alarmReadingResponseMercy
|proba |

proba:=Cormas random.
Cormas random.

mailBox isEmpty ifFalse:[
	self mailBox do:[:m2 | m2 symbol = #ok and: [m2 ag &gt; 12 ifTrue:[
			proba&gt;0.75 
				ifTrue:[self learnFromOthers: (self learnFromOthers + 3)]
				ifFalse:[proba&gt;0.25 
					ifTrue:[self learnFromOthers: self learnFromOthers + (Cormas randomFrom: 1 to: 2)]
					ifFalse:[self learnFromOthers: (self learnFromOthers + 0)] ].
			self top: m2 nivel
] ] ] ].

mailBox:=OrderedCollection new.</body>

<body package="SimPolillaSimiatug_v02" selector="defineNivelFormation">defineNivelFormation
self top isNil ifTrue:[self top:5].
self nivelFormation&gt;5 ifTrue:[self nivelFormation: 5].
self nivelFormation&gt;self top ifTrue:[self nivelFormation: self top].</body>

<body package="SimPolillaSimiatug_v02" selector="moveIntoAgroPartPart">moveIntoAgroPartPart

"ES = Este modulo permitte que los agentes se mueven unicamente al interior del perimetro donde hay cultivos de ciclo corto y adentro de su comunidad." "US = to constrain agents' movements into their territory"
self patch agro=0 ifTrue: 
		[self randomWalk].

self patch agroPartPart=1 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=1]].
self patch agroPartPart=2 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=2]].
self patch agroPartPart=3 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=3]].
self patch agroPartPart=4 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=4]].
self patch agroPartPart=5 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=5]].
self patch agroPartPart=6 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=6]].
self patch agroPartPart=7 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=7]].
self patch agroPartPart=8 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=8]].
self patch agroPartPart=9 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=9]].
self patch agroPartPart=10 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=10]].
self patch agroPartPart=11 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=11]].
self patch agroPartPart=12 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=12]].
self patch agroPartPart=13 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=13]].
self patch agroPartPart=14 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=14]].
self patch agroPartPart=15 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=15]].
self patch agroPartPart=16 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=16]].
self patch agroPartPart=17 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=17]].
self patch agroPartPart=18 ifTrue: [self randomWalkConstrainedBy: [:f | f agroPartPart=18]].</body>

<body package="SimPolillaSimiatug_v02" selector="readMail">readMail
| aMessage |
aMessage:= self nextMessage.

self getMsg: self nivelFormation.

"self sendMsg &lt; self getMsg ifTrue:["
	aMessage notNil ifTrue:[
		self numActions: 2]
	ifFalse: [  ]"]"</body>

<body package="SimPolillaSimiatug_v02" selector="readMailAlarmCalling">readMailAlarmCalling
|m2 busy nivelAutre |

mailBox isEmpty ifFalse:[
	self mailBox do:[
		:m1 | m1 symbol = #pleaseHelp and:[ m1 ag &gt;12 ifTrue:[busy = 1 ifFalse:[

				nivelAutre:=m1 nivel.
				nivelAutre&lt;self nivelFormation ifTrue:[
					"busy:= 1."

				m2:=MsgHelpAns new.
				m2 sender: self.
				m2 receiver: (m1) sender.
				m2 symbol: #ok.
				m2 ag: 13.
				m2 nivel: self nivelFormation.
				self sendMessageSynchronously: m2.
				self numActions: self penality.
				
]]]]]]</body>

<body package="SimPolillaSimiatug_v02" selector="testManejo">testManejo

|eficacidadTratamientoChimico seuil|

eficacidadTratamientoChimico:= self nivelFormation*0.2*((Cormas randomFrom:80 to:120)/100).
self nivelFormation=0 ifFalse:[seuil:=100/self  nivelFormation.] ifTrue:[seuil:=100].

self patch tecia&gt;(seuil) ifTrue:[self patch tecia: self patch tecia*(1-eficacidadTratamientoChimico)].</body>

<body package="SimPolillaSimiatug_v02" selector="updateLearnFromOthers">updateLearnFromOthers

self forAchange ifNil:[self forAchange: 2].

self learnFromOthers &gt;=self forAchange ifTrue:[self nivelFormation: (self nivelFormation + 1).
	self learnFromOthers: 0].

self learnFromOthers &gt;=((self forAchange)*2) ifTrue:[self nivelFormation: (self nivelFormation + 2).
	self learnFromOthers: 0].</body>

<body package="SimPolillaSimiatug_v02" selector="updateNumActions">updateNumActions
	self numActions: 5</body>
</methods>



</st-source>