COBAM-3

COBAM-3 preview image

3 collaborators

Default-person Richard Taylor (Author)
Sukaina Bharwani (Team member)
Michael Fischer (Team member)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 307 times • Downloaded 14 times • Run 0 times
Download the 'COBAM-3' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;; 21st April
;; cobam model for Cameroon TNS

;; TODO
;; 1. health status attributes for forest (patch variable) land fertility, forest cover
;; 2. health status attributes for subsistence plots - fertility only

;; update rules for health status :
;; how does the NTFP depletion work?
;; 3. Actors sometimes turn black/get black cloud above them when entering forest and they start to cause damage
;; 4. annual farming strategy: expand (if labour, if low productivity etc- using KnETs rule) -
;; -- this (partial) clearing may involve a change in forest cover (depending on specific cashcrop)
;; -- with cocoa expansion in first years they grow other crop (what?) - can be illustrated as plain area
;; 5. annual subsistence farming strategy - (part of?) the strategy is to decide how much fallow/ level of intensification
;; -- Knets suggest reduced rotation (meaning intensification of production/less fallow time) 
;; 6 . monthly decision-making step - (based on KnETs rule ?)
;; -- first priority is Men and women do farming
;; -- when they have time available they do NTFPs collection - based on preferences - high val and low val NTFPS
;; -- includes poor and rich, male and female farmers/collectors

;; add other transition rules :
;; 7. cocoa survives how long - possible transition to agricultural /subsistence field  or abandonment if infertile?
;; -- recovery of fertility and tree cover. old fallows revert to secondary forest after an (estimated) number of seasons
;; -- or use tree recruitment and dispersal model
;; 8. agricultural land becomes infertile - depending on specific practices. use of fallows vs. intensification vs. training

;; 9. monitor the health of forest (land fertility, forest cover) and the health of farmland (land fertility), as well as collection of NTFPS
;; -- this will allow illustrate NTFPs getting further away and reducing CPU effort of NTFP collection
;; 10 add the other NTFPS - collection in recueilleNTFPs
;; -- Add NTFPs according to the latest calendar we got.
;; -- improve rules for collection of NTFPs - their animation
;; -- fix problem of traders getting stuck at edge of screen because prevented from stopping at fdest

;; 
;; introduce health/forest cover status attribute for each forest patch (part of farm) based on productive use - ie different types of farms (coffee?/cocoa/cassava/palm)


;; CLIMATE AND POLICY SCENARIOS
;; create climate scenarios
;; create policy scenario - training - and the new behaviour this enables e.g. reduced rotation and sustainable land fertility
;; NTFPs are 'wild' ie. only the gathering that needs to be considered - but some say they would consider cultivation if gathering failed

;; AREAS OF UNCERTAINTY (for modelling) -  many areas not informed by knets or other fieldwork
;; how crops and activities respond to weather (among other factors) from one period to the next and over several years


;; OTHER IDEAS
;; community forest CF (5000 ha)
;; Note: a household would not control a whole ha unless very rich
;; Further - include GIS file showing boundaries of the CF, location of villages, markets, roads, rivers, forests etc 
;; add multiple villages along the road. We may want to allocate forest areas to villages rather than to clans if clans are not as relevant for forest land access rights.
;; create groups - farmer associations. done using traders and allocate hh to a group.  
;; household structure and labour availability (for fixed hh sizes)


;; Notes
;; I have added two further NTFPs (others can easily be added but I will be keeping it simple for the moment) 
;; I have given them a seasonal cycle. This controls how quickly the NTFPs appear at different times of year.
;; For the seasonal ones I am assuming that they disappear when they get out of season, but Koko and mempa don't disappear
;; I have restricted it so that only one type of resource can appear at each location.
;; For this resource I have also quantified the amount of resource at each location. 
;; However tt may keep on growing infinitely until someone comes and harvests it...

;; NTFP harvesters will usually collect several NTFP types during one trip. Some (men) may concentrate on high-value NTFP types not collecting others - depending on preferences
;; Sometimes it is not the season of a certain NTFP but may be available anyway.


 ;; Monica: 
;; 20.1 I think we should add more than 2 NTFPs. Koko and Mempa are usually available all year throughout 
;; but the others such as mangue sauvage, Assa'a, Dogote, Talala, Mtondo, Djansang and Djembe differ in seasonality over a year. 
;; 20.3  what are your thoughts behind the seggregation of groups?
;; I thought it might be important for access to resources. if we don't have information on it we can leave it out
;; 20.3 it is important to distinguish the Baka (in terms of interactions with the communities during times of crisis, for example), also the CAR people who come to buy products
;; 20.4 if the model could capture and seggregate men and women actions/roles, 
;; - yes also seggergate rich and poor strategies
;; 20.5 village gardens, meaning the fields in the fallow land (jachere), but it can be quite far away from the village as well. 
;; 20.6 include the subsistence farming plots in the jachere as well
;; 20.7 a way to kind of show in the model that when we have the cacao season, men are going to town (money is spent on leisure/lost)
;; m1 Expansion of fallow agriculture land for subsistence is usually considered under tougher conditions (combinations of unfavorable drivers)

;; sb1 the indicators of interest could be related to income and carbon saving
;; sb2 show detail such as gender aspects as well as more large scale dynamics with several villages
;; sb3 NTFPS getting farther away than previously, planting nearby if poss

;; sb4 create groups for collection and sale of NTFP (here there is value in modelling different NTFP collected by better-off versus poor women, who seemed to focus on
;; more high-value NTFPs such as Assa and Dogote - don’t know if there is enough empirical evidence for this but seemed to come out of the game results)
;; sb5 training on agricultural practises - reduced rotation (meaning intensification of production/less fallow time) composting, use of demo plots and set up of tree nurseries).
;; sb6 extensification and land expansion trend
;; sb7 adaptive strategies driven by lack of land (esp. poorer hh lack access) and quantity of harvest
;; sb8 crop choices that vary in the degree to which they provide co-benefits. eg. crops that require forest cover or little or no clearing of trees are good from a mitigation perspective.
;; This means that cocoa, which requires shade to grow well, will encourage forest cover to be preserved. However, cassava and palm oil require more sunlight and forest to be cleared .
;; sb9 drivers triggering serious cascade effects for forest conservation 
;; sb10 mining (employment for better off HH) where agriculture is not possible or ag. constraints such as inappropriate weather conditions, lack of labor, lack of tools and lack of access to markets.
;; sb11 elites opportunistic interaction with villagers
;; sb12 Hunting is also more prominent among the poor households than the better-off, as the latter would buy their meat from the poorer households.
;; cultivation of crops near the water sources (e.g. rivers),
;; there is value in modelling different NTFP collected by better-off versus poor women, who seemed to focus on more high-value NTFPs such as Assa and Dogote 
;;let x neighbors with [any? turtles-here with [ member? breed (list as bs ) ]]
extensions [gis]

breed [households household]
breed [people person]
breed [farms farm]
breed [trees tree]
breed [roads road]
breed [GICs GIC]
breed [mangues mangue]
breed [kokos koko]
breed [mempas mempa]
breed [assas assa]
;;breed [NTFPs NTFP]
breed [traders trader]
breed [rivernodes rivernode]
breed [roadnodes roadnode]
breed [villages village]   
breed [spinners spinner]                     ;; clock face which shows the month 
breed [primarys primary]                     ;; forest areas are represented as agents somewhat artificially here
breed [secondarys secondary]
breed [boundarys boundary]
breed [gardens garden]                       ;; garden is a collection of fallow and productive jachere patches - a plot used for subsistence farming 
                                             ;; mixed/subsistence crop ; meaning the fields in the jachere, also along river

breed [river-labels river-label]
breed [village-labels village-label]

undirected-link-breed [riverlinks riverlink]
undirected-link-breed [roadlinks roadlink]
undirected-link-breed [tradelinks tradelink]


patches-own [
  partof     ;; part of forest or jachere - macro area
  partfarm   ;; part of gardens or plantation - productive farm unit in the forest or jachere
  quantity   ;; quantity of NTFP resource here - can only have one type 
]
farms-own [                               
  size-xy area
  farmer                  ;; who controls access - management entity or hh head
  ;; health 
  harvest   
  landuse                     ;; landuse is current use
  total-cost      ;; farm accounting variables
  farm-income farm-profit annual-profit
]   
primarys-own [
  forestset ;; patchset
  size-xy
  clan
  state
  ;;adult-count juvenile-count           ;; includes fishy variables here
  ;;shoal-size                           ;; there is only one shoal
]
secondarys-own [
  forestset ;; patch set
  size-xy
  clan
  state
] 
gardens-own [
 size-xy
 gardener 
 gardenset
]

households-own [
  hhtype head members clan             ;; hhtype relates to the structure; clan is the ethnicity of origin
  association                          ;; which farming group
  hhgarden                               ;; garden is an agent and collection of patches (gardenset)
  wealth                               ;; true and false - better off and poor households
  labour                               ;; labour is a boolean - whether or not additional labour is available - important driver of expansion 
  income profit                        ;; variables for the current tick. assume that profit (or loss) accrues to savings of the hh head
  hh-annual-profit
  nutrition                    ;; nutrition is a number between 0 and 4 signifying availability of different foods to household.
  food-cost annual-food-cost
] 
people-own [
  clan hh status            ;; status is the present activity; 
  strategy                  ;; strategy eg. on of NTFPtypes
  pdest fdest               ;; destination the village or patch of forestset
  mcol kcol mpcol acol      ;; count of each NTFP collected this season
  gender-male               ;; male (true) or female (false)
  
]
villages-own [salinity health]           ;; health depends only on salinity: see health-homestead reporter

traders-own [
  croptype  ;; each trader is only interested in one croptype at any moment
  demand
  destination               ;; forest that the agent is currently headed for
]
globals
[
  ;; the following are fixed, user-defined global variables chosen or input by the user
  ;;number-people             ;; overall number of people, set before they are assigned into networks, occupations, households etc
  number-households         ;; hh vary in terms of structure and assets (may be landless)
  ClanHHCensus              ;; a list of number of hh of each clan
  ClanList
  tries-paddys              ;; a maximum number. number-paddys is also constrained by min-distance
  
  farmsize-min farmsize-max ;; minimum and maximum (acres)
  forestsize-min forestsize-max
  min-distance              ;; min distance between any two agents              
  max-distance              ;; maximum for there to be a connection (not used?)
  riverbank-distance        ;; min distance from a farm node to river nodes - to improve display
  min-distance-forest       ;; min distance between two forest areas.(Also of forest to village - forest lies outside of jachere?)
  min-distance-gardens
  ticks-per-month           ;; allow for time-level below the month
  walk-speed
  ;; non-fixed variables
  number-paddys             ;; count of number
  the-month                 ;; string variable in bengali
  month-id                  ;; integer from 0 to 11 incl.
  the-period                ;; integer - time level below month
  year-id                   ;; integer initial value of 0
  ;;climate                 ;; string variable can take value monsoon or dry
  price-cacao               ;; price for sale to exporter
  price-rice                ;; market price
  price-fish                ;; market price
  sprout-set                ;; current set of patches generating NTFPS
  grow-set                  ;; patches where further NTFPS growing
  NTFPS                     ;; amount appearing each month of various forest products
  calendar                  ;; string definition for the calendar being used i.e. munshigonj
  croptypes
  NTFPtypes          
  ;; agentsets
  ;;headset                 ;; turtleset of all household heads, set in set-livelihoods
  workforce                 ;; all individuals not allocated to jobs yet
  all-locations             ;; farms, mangrove, village
  livelihoods               ;; occupations that are done over the course of one or more months
  chance-labour             ;; at start of year, there is a chance any hh accumulates additional labour (eg . 5% random)
  
  ;; other features of the terrain
  hyp                       ;; track length
  primary-forest            ;; patch set
  secondary-forest
  jachere                   ;; all jachere has an owner/manager while it is part of a rotation or plantation
                    ;; eg. at most 2km from road, 3km from village 
  jachere-rd
  jachere-vill
  gardensize-min gardensize-max ;; minimum and maximum (acres)
  
  ;; GIS globals
  villages-dataset
  rivers-dataset
  
  ;; village law
  buffer-distance           ;; buffer zone around village where shrimp ponds are not allowed to be established

]        

;; need an expert to write/check these

to write-climate-scenarios
  ;; open a connection to a further file
end 

to setup

  clear-all              ;; resets all global variables to zero, and calls reset-ticks, clear-turtles, clear-patches, clear-drawing, clear-all-plots, and clear-output.
  ;;set calendar "munshigonj"
  set ticks-per-month 8  ;; assume a number of ticks per month - this allows an animation of the activities, recueilleNTFPs etc
  ;; timelevel below the  month
  set the-period 0
  set month-id 0
  ;; parameters needed before agent creation
  ;; world-width and world-height set in view (default is -16 to +16)
  set min-distance 5         ;; distances between two farms
  set max-distance 10
  set tries-paddys 40
  set riverbank-distance 1.2
  set min-distance-forest 12  ;; distance between two forest units
  set min-distance-gardens 2 ;;???
  set walk-speed 2
  ;; these parameters would be set depending on the location and calendar 
  ;; TODO put in setup munshigonj method
  set farmsize-min 1
  set farmsize-max 5
  set forestsize-min 12
  set forestsize-max 20
  set gardensize-min 2
  set gardensize-max 3
  set number-households 34    ;; this should equal the number used in the create-structured-households method
  set chance-labour 5         
  set NTFPS []
  set NTFPtypes (list mangues kokos mempas assas)  ;; list of breeds therefore use plural
  ;; mangues kokos mempas assas dogote, Talala, Mtondo, Djansang and Djembe
  ;; digits indicate the months when it can appear (and the percentage chance) 
  ;; set NTFPS lput [0 0 0 0 0 3 3 3 0 0 0 0] NTFPS ;; mangues  - data from table 9
  set NTFPS lput [0 0 0 0 0 0 0 3 3 0 0 0] NTFPS ;; mangues  - aug - sep Monica
  ;; Koko and Mempa are usually available all year throughout
  set NTFPS lput [3 3 3 3 3 3 3 3 3 3 3 3] NTFPS ;; kokos - data from table 9
  set NTFPS lput [2 2 2 2 2 2 2 2 2 2 2 2] NTFPS ;; "mempas" 
  ;; others such as mangue sauvage, Assa'a, Dogote, Talala, Mtondo, Djansang and Djembe differ in seasonality over a year
  set NTFPS lput [1 1 1 2 2 2 2 2 1 1 1 1] NTFPS ;; "assas"  - assas all year - monica
  ;; include further NTFPS will make the model more complex
  ;set NTFPS lput [0 0 1 2 2 2 2 2 1 1 1 0] NTFPS ;; "dogotes" no information

  ;set NTFPS lput ["talalas" 1 1 1 2 0 0 0 1 1 1 1 1] NTFPS ;; jan-apr, aug -dec
  ;set NTFPS lput ["mtondos" 1 1 1 1 0 1 1 1 1 1 1 1] NTFPS ;; jan-apr jun-dec  
  ;set NTFPS lput ["djansangs" 1 0 0 0 0 1 1 1 1 1 1 1] NTFPS ;; jan and june-dec
  ;set NTFPS lput ["djembes" 0 0 0 0 0 0 0 2 2 0 0 0] NTFPS ;; August – September Monica (Mang) 
 
  print (word "NTFPtypes are: " NTFPtypes)
  set sprout-set no-patches
  set grow-set no-patches

  ;; define cash crops. TODO there could be subtypes/varieties with different names and characteristics
  set croptypes []
  set croptypes lput ["coffee"] croptypes ;; only characteristic so far is the name
  set croptypes lput ["cocoa"] croptypes
  
  ;; create the village in the centre of the window
  create-villages 1
  [ 
    set xcor 0 set ycor 0
    set shape "house"
    set color brown
  ]
  ask patches [set pcolor grey]
  ;; settlement and road
  ;; add river through village
  position-river
  
  ;; If using GIS information will need to change size of grid
  ;; setup-gis  
  
  ;; households and social infrastructure
  ;; generate a set of points for locating households (10 by 10 grid around origin) with separation of 0.1
  let points []
  let vals n-values 10 [?]  
  foreach vals [
    let x ((? - 5) / 10) 
    foreach vals [
      let y ((? - 5) / 10) 
      set points lput list x y points
    ]
  ]
  let HHID 0 
  let ClanID 0
  ;; TODO these are broad ethnicities rather than clans - should be about 12
  set ClanList ["Mpiemo" "Baka" "Muslim" "CAF"] ;; order of appearance 
  ;; define what fraction of HH are from each clan
  ;; define approx. what fraction of owned land belongs to each clan
  set ClanHHCensus [12 10 8 4]                ;; number of HH of each clan 
  let ClanForestAreas [7 4 3 2]               ;; number of areas for each clan
  print (word "Starting model with " length ClanList " Clans, " sum ClanHHCensus " households, ..") 
  create-households sum ClanHHCensus [
    ;; first hh are ones with 100% access
    set clan item ClanID ClanList
    let close []
    ;; select a location with distance of nearest turtle < 0.15
    ;; do not allow multiple hh occupying the same spot ie distance > 0 .05
    foreach points [
      let px item 0 ?
      let py item 1 ?
      let nn min-one-of other (turtle-set villages households)  [distancexy item 0 ? item 1 ?]
      ask nn [if distancexy px py < 0.15 and distancexy px py > 0.05 [set close lput list px py close] ]
    ]
    let point one-of close
    setxy item 0 point item 1 point
    ;; increase the HHID index by one unit and set the ClanID for next HH
    set HHID HHID + 1
    if HHID >= item 0 ClanHHCensus [set ClanID 1]
    if HHID >= item 0 ClanHHCensus + item 1 ClanHHCensus  [set ClanID 2]
    if HHID >= item 0 ClanHHCensus + item 1 ClanHHCensus + item 2 ClanHHCensus [set ClanID 3]  
    
    ;; other HH attributes
    set labour false
    set wealth HHID mod 2  = 0   ;; true and false signify the better off and poorer households
  ]

  ;; ask households [show (word "HH-" who " has labour:" labour ", has wealth:" wealth)]
  foreach sort households [
    create-people 1 [
      set clan [clan] of ?
      set hh ?
      setxy [xcor] of ? [ycor] of ? 
      ;set pdest "village-0"
      set pdest one-of villages  ;; no-patches ?
      set fdest no-turtles
      ;hide-turtle
      set gender-male member? ([who] of ? mod 6)  [0 1 2]
    ]
  ]
  
  ;;ask people [
  ;;  show (word "Person-" who " is male :" gender-male)
  ;;  ask [hh] of self [show (word "HH-" who " has labour:" labour ", has wealth:" wealth)]
  ;;]
  
  ;; create landscape
  ;; create jachere close to village, road, river etc.
  set jachere patches with [min [distance myself] of rivernodes < 7.5 and distance village 0 < 10 and partof = 0]
  ask jachere [
    set pcolor 4
    ;; set partof ;; jachere is not an agent 
  ]
  show (word "Jachere area of " count jachere " ha.")
  

  
  ;;show count households
   
  ;; TODO create some coffee plantations in jachere also ? 
   
  ;; TODO farm creation should be dynamic and agricultural groups construction
  set-default-shape trees "tree"
  set-default-shape farms "plant"

  ;; village land residence and garden
  set-default-shape boundarys "line"
  ;; forest product shapes
  set-default-shape mangues "x"
  set-default-shape kokos "triangle"
  set-default-shape mempas "star"
  set-default-shape assas "dot"
  
  ;; create forest areas - choose a location away from any other forest area
  create-primarys 8
  [
    set size-xy (list (forestsize-min + random-float (forestsize-max - forestsize-min)) (forestsize-min + random-float (forestsize-max - forestsize-min)))  
    position-forest-area
    set forestset patches with [abs (pxcor - [xcor] of myself) < ( item 0 [size-xy] of myself / 2 ) and abs (pycor - [ycor] of myself) < ( item 0 [size-xy] of myself / 2 )]
    set forestset forestset with [partof = 0 and member? self jachere = false]  ;; make sure patches in forest set lie outside of jachere
    ask forestset [set pcolor 2 set partof myself]
    hide-turtle
    ;;set label "PRIMARY"
  ]
  create-secondarys 8
  [
    set size-xy (list (forestsize-min + random-float (forestsize-max - forestsize-min)) (forestsize-min + random-float (forestsize-max - forestsize-min)))
    position-forest-area
    set forestset patches with [abs (pxcor - [xcor] of myself) < ( item 0 [size-xy] of myself / 2 ) and abs (pycor - [ycor] of myself) < ( item 0 [size-xy] of myself / 2 )]
    set forestset forestset with [partof = 0 and member? self jachere = false]  ;; make sure patches in forest set lie outside of jachere
    ;; let fp patches with [abs (pxcor - [xcor] of myself) < (forest-size / 2 ) and abs (pycor - [ycor] of myself) < (forest-size / 2 )]
    ask forestset [set pcolor 12 set partof myself]
    hide-turtle
    ;;set label "SECONDARY"
  ]
  ;; set forestset after all forests have been created (each patch can only be in one set)
  ask (turtle-set primarys secondarys) [ 
    set forestset patches with [partof = myself]
    let thisforest self
    let mycolorid 0
    ifelse breed = primarys 
    [set mycolorid one-of (list 33 34 35)]
    [set mycolorid one-of (list 53 54 55)]
    ask forestset [set pcolor mycolorid]
    ;; ask patches on edges of forest area to recolour
    ask forestset [if count neighbors with [partof = thisforest] < 8 [set pcolor 36] ]   
    ;; TODO add lines to demark the patch sets ?
    ;;create-boundaries
  ]
 
  show (word "Creating " count (turtle-set primarys secondarys)  " forest areas, controlled by 4 clans")
  ;; other logging concessionary areas are outside of model 
  ;; distribution of patches into forest
  let sforests reverse sort-on [count patches with [partof = myself]] (turtle-set secondarys primarys)
  ;; foreach sforests [show count patches with [partof = ?]]

  set ClanID 0
  let forestID 0
  ;; allocate forests to clans
  ask (turtle-set primarys secondarys) [ 
    set clan item ClanID ClanList
    set forestID forestID + 1
    ;; TODO use case when more than 4 clans
    if forestID >= item 0 ClanForestAreas [set ClanID 1]
    if forestID >= item 0 ClanForestAreas + item 1 ClanForestAreas  [set ClanID 2]
    if forestID >= item 0 ClanForestAreas + item 1 ClanForestAreas + item 2 ClanForestAreas [set ClanID 3]    
  ]
  ;;ask (turtle-set primarys secondarys) [ show clan]

  
  
  create-spinner
  ;; set display properties
  set-default-shape households "house"
  ask households [set size 1]
  ask households [set color brown]
  
  ;; other setup
  set-default-shape traders "person"
  set-default-shape people "person"
  reset-ticks
end 

;; this should be used for reading the gis shapefiles

to setup-gis
  ;; coordinate system
  let projection "rivers"
  gis:load-coordinate-system (word "data/" projection ".prj")
  ;;; load GIS datasets
  set villages-dataset gis:load-dataset "data/villagers_and_towns.shp"
  set rivers-dataset gis:load-dataset "data/rivers.shp"
  ;; set the world envelope to the union of all our dataset's envelopes
  gis:set-world-envelope (gis:envelope-union-of (gis:envelope-of villages-dataset) (gis:envelope-of rivers-dataset))
  
  ;; TODO try a transformation between GIS and netlogo coordinates
  ;;show gis:envelope-of villages-dataset
  ;;observer: [1158854.3745999997 1219490.25 370405.9997000005 402526.56350000016]
  gis:set-transformation (list 1175000 1200000 376000 380000) (list min-pxcor max-pxcor min-pycor max-pycor)
  ;; gis:set-transformation (list 15.28 15.29 3.28 3.29) (list min-pxcor max-pxcor min-pycor max-pycor)
end 

to initial-gardens
  ;; create gardens close to village, inside jachere
  ;; garden is a collection of fallow and productive jachere patches - if it stays fallow for too long it will become old fallows
  ;; householder prefers nearby gardens
  create-gardens number-households
   [
    set size-xy (list (gardensize-min + random-float (gardensize-max - gardensize-min)) (gardensize-min + random-float (gardensize-max - gardensize-min)))  
    position-garden-area
    set gardenset patches with [abs (pxcor - [xcor] of myself) < ( item 0 [size-xy] of myself / 2 ) and abs (pycor - [ycor] of myself) < ( item 0 [size-xy] of myself / 2 )]
    set gardenset gardenset with [partof = 0 and partfarm = 0 and member? self jachere = true] ;; patch must be in jachere but not in forest or already part of garden
    let mycolorid one-of (list 23 24 25)
    ask gardenset [set pcolor mycolorid set partfarm myself]
    hide-turtle  
    ;; set label "GARDENS"
  ] 
  ;; hhgarden is an attribute of household, it is equal to the garden agent
  let gs sort gardens
  let index 0
  foreach sort households [
    ask ? [set hhgarden item index gs]
    set index index + 1
  ]
end 

;; reposition people who were already created in setup

to initialize-people
  ;; send men to the gardens
  ask people with [gender-male] [move-to one-of [gardenset] of [hhgarden] of hh]
  ;;ask people with [not gender-male] [move-to one-of [gardenset] of [hhgarden] of hh]
end 

;; mangues kokos mempas assas dogote, Talala, Mtondo, Djansang and Djembe  

to recueilleNTFPs
  let nearset patches in-radius walk-speed
  let nearturtles turtles-on nearset
  let nearNTFPs nearturtles with [member? breed NTFPtypes ]
  ;; line below also seems to work now that NTFPtypes list is created correctly (i.e not using strings)
  ;; set nearNTFPs turtle-set filter [member? [breed] of ? NTFPtypes] sort nearturtles
  let collected no-turtles
  if any? nearNTFPs [
    let nnt min (list 3 (count nearNTFPs)) 
    set collected n-of nnt nearNTFPs
  ]          
  foreach sort collected [  
    let quant [quantity] of patch-here          
    if [breed] of ? = mangues [ set mcol mcol + quant]
    if [breed] of ? = kokos [ set kcol kcol + quant]
    if [breed] of ? = mempas [ set mpcol mpcol + quant]
    if [breed] of ? = assas [ set acol acol + quant]
    ;if is-dogote? ? 
    ;if is-talala? ?  
    ;if is-mtondo? ?
    ;if is-djanssang ? 
    ;if is-djembe? ?
    ;; clear patch quantities at locations of collected
    ask patch-here [set quantity 0] 
  ]
  
  ask collected [die]
end 

;; high val and low val NTFPS
;; mangues kokos mempas assas dogote, Talala, Mtondo, Djansang and Djembe

to-report NTFP-high-value [name]
  show name
  if is-mangue? name [report false] ;; all year round but fluctuates from year to year, aug and sept - LV see monica's NTFPs table
  if is-koko? name [report false] ;; all year round - LV see monica's NTFPs table
  if is-mempa? name [report false] ;; LV? 
  if is-assa? name [report false] ;; LV? all year round
  ;if is-dogote? name [report true] ;; HV sylvie
  ;if is-talala? name [report false] ;; LV no market
  ;if is-mtondo? name [report false]  ;; LV sylvie
  ;if is-djanssang name [report true] ;; all year round - now just aug and sept - HV see monica's NTFPs table
  ;if is-djembe? name [report true] ;; aug and sept - HV see monica's NTFPs table
end 

;; drawing polyline data from shapefile 

to display-rivers
  gis:draw rivers-dataset 1
  ;; loading data into turtles
  foreach gis:feature-list-of rivers-dataset
  [ 
    let centroid gis:location-of gis:centroid-of ?
    if not empty? centroid
    [
      
      create-river-labels 1
      [
        set xcor item 0 centroid
        set ycor item 1 centroid
        set size 0
        ;;set label gis:property-value ? "OBJECTID"
      ]
    ]
  ]
end 

;; drawing polyline data from shapefile 

to display-villages
  gis:draw villages-dataset 1
  ;; loading data into turtles
  foreach gis:feature-list-of villages-dataset
  [ 
    let centroid gis:location-of gis:centroid-of ?
    if not empty? centroid
    [
      
      create-village-labels 1
      [
        set xcor item 0 centroid
        set ycor item 1 centroid
        set size 0
        set label gis:property-value ? "ANNOTXT"
      ]
    ]
  ]
end 

;; nice animation of village activities

to ramble
  ;; short random walk
  set heading random 360
  fd 0.5
  ;; sleeping etc
end 

to go
  reset-tick
  ifelse (the-period = ticks-per-month)
  [set the-period 1 ]                   ;; new month has started
  [set the-period the-period + 1]
  if the-period = 1 [ 
    reset-month
    set-month        ;; set the month (string and id) 
  ]
  
  if the-period = 1 [NTFP-growth]
  
  ;; simulation events at start of annual step
  if month-id = 0 and the-period = 1 [
    
    ask traders [update-demands]              ;; traders update their demands 
    ask households [update-labour]            ;; some likelihood that labour boolean may be flipped from false to true
    
    ask households [set-gardening-strategy]   ;; female agents ? subsistence and small local sales
    ask households [set-farming-strategy]     ;; male agents ? cocoa and coffee, GIC opportunities, expansion opportunities
    ask households [set-collecting-strategy]  
   
    ;; after gardening, collecting, farming land productivity may go down
    
   
  ]
  
  let availabletypes filter [any? turtles with [breed = ?]] NTFPtypes
  ;; print (word "available NTFPs are: " availabletypes)
  
  ;; update agent strategy (from knets rules) 
  ;; differently for poor/rich and men/women
  ;; "best" strategy given expected return
  foreach sort people [ 
    ;; TODO selection of NTFP would be based on distance to travel to collect and therefore amount harvested per unit effort 
    ;; question. do they concentrate on one NTFP type or will collect several during one trip?
   
    ;; other strategies / activities farming cocoa/coffee
    ;;set strategy one-of availabletypes
    ;;ifelse any? (turtle-set mangues kokos) [
    
    
      let thisp ?
      let pclan [clan] of ?
      ;; if person is at village when NTFPS present - setting off for forest
      ifelse [pdest] of ? = village 0 [
        ;;print "set off" 
        let fordest one-of (turtle-set primarys secondarys) with [clan = pclan]
        ask thisp [
          set fdest fordest
          set status "collecting"
          set pdest one-of [forestset] of fdest
          set heading towards pdest
        ]
        ;; or choose other activity (farming etc.)
      ]
      ;; otherwise continue forward (at walkspeed)
      [
        ;; if I am at my destination, collect any NTFPs within walking distance, and change destination to another within forest set
        ;; TODO if I am at my forest destination collect any. only change patch destination when I reach near there
        ask ? [
          ifelse member? pdest patches in-radius walk-speed
          [ 
            ;; collect and account for NTFPs         
            recueilleNTFPs
            set pdest one-of [forestset] of fdest
            set heading towards pdest 
          ]
          ;; otherwise, continue walking towards destination
          [
            fd walk-speed
          ]      
        ]
      ]
    ]
 ;;] 
;  [  
;    foreach sort people [
;      ask ? [ 
;        set status "waiting"
;        set pdest village 0
;        set heading towards pdest
;        ;; either ramble around at destination or stay at destination
;        ifelse member? pdest turtles-on patches in-radius walk-speed
;        ;;if not member? pdest turtles-on [neighbors] of patch-here
;        [
;          ramble
;        ]
;        [
;          fd walk-speed
;        ]
;      ]
;    ]
;  ]
  ;; after a certain number of months/years a trader appears
  if month-id = 2 and the-period = 1 [
    create-traders 1 [
      setxy random-pxcor random-pycor
      set croptype item 0 one-of croptypes
      ;; turtle moves to the center of a random patch
      print (word "New " croptype " trader has appeared at " xcor ", " ycor)
      set demand random 100
      set color black
      set destination one-of (turtle-set primarys secondarys) 
      set heading towards destination
    ]
  ]
  ask traders [
    fd walk-speed
    ;; if arrived at destination and if no people nearby change destination
    if [partof] of patch-here = destination and not any? people in-radius walk-speed [
      ;;print "changing direction"
      set destination one-of (turtle-set primarys secondarys) 
      set heading towards destination
    ]
    if any? people in-radius walk-speed [
      create-tradelinks-with people in-radius walk-speed
    ]
    
  ] 

    
  ;;**** 1. climate and farm activity ********
  update-spinner                         ;; report the climate regime, track the climate and the current month
  tick
end 

;; women agents of the household decide production rules - eg. how much land to leave empty(15% jachere)

to set-gardening-strategy
end 

;; male agents of the household decide production rules - eg. whether to expand, whether to abandon unproductive land, which crop

to set-farming-strategy
end 

to set-collecting-strategy  
    ;; TODO something about obtaining NTFPs, targetting high or low val
    ;; let ntnt (turtle-set assas mangues mempas)
    ;;if any? ntnt [show NTFP-high-value one-of ntnt]
end 

;; shifting demand patterns for crop and amount to be supplied

to update-demands
  set croptype item 0 one-of croptypes
  set demand random 100
end 

;; chance of change of state of hh labour eg. 5 percent chance

to update-labour
  if not labour [set labour random 100 < chance-labour]
end 

;; it generates a new type of crop

to-report cropchooser
end 

;; this is controlled by a button

to initial-plantations
  let FarmID 0
  create-farms number-households [
    set harvest 0
    set annual-profit 0
    set size-xy (list (farmsize-min + random-float (farmsize-max - farmsize-min)) (farmsize-min + random-float (farmsize-max - farmsize-min)))
    position-paddy
    let xc xcor
    let yc ycor
    set area (item 0 size-xy) * (item 1 size-xy)
    let fp patches with [abs (pxcor - xc) < ( item 0 [size-xy] of myself / 2 ) and abs (pycor - yc) < ( item 1 [size-xy] of myself / 2)] 
    ;; ask patches to set partfarm to the current farm
    let farm self
    ask fp [set partfarm farm]
    set landuse "paddy"
    set color green
    ;; make them look like planations using transparency
    ask fp [sprout-trees 1 [set color 32 set-transparency 150]]
    ;; create lines around them?
    if FarmID < item 0 ClanHHCensus [set farmer item 0 ClanList]
    set FarmID FarmID + 1
  ]
  show (word "Creating " count farms  " farms")
end 

;; done at beginning of month

to NTFP-growth  
  let NTFPSID 0
  foreach NTFPS [
    let currentcal item NTFPSID NTFPS  ;; calendar for current NTFP
    let currentbreed item NTFPSID NTFPtypes
    ;; print (word "checking item " NTFPSID " which is " currentbreed)
    let percent item month-id currentcal ;; percent chance the product will appear
   
    if percent > 0 [
      ;;print (word item 0 current " is ready to harvest")
      ;;let sprout-set no-patches
      foreach sort (turtle-set primarys secondarys) [
        ;;ask [forestset] of ? [
        let current ?
        ;; forest patches not part of plantation / cash crop farm
        ask patch-set filter [[partfarm] of ? = 0] sort [forestset] of current [
          ifelse not any? turtles-here with [member? breed NTFPtypes ]
          [ 
            if random 100 < percent [set sprout-set (patch-set sprout-set self)]  
          ]
          [
            ;; adjust quantity of resource (no more than one NTFP agent per patch otherwise simlation will get too slow) 
            if random 100 < percent [set grow-set (patch-set grow-set self)] 
          ]
        ]
        ;;show sprout-set
      ]
      ;; do the actual sprouting for this type of NTFP for all forest areas 
      select-case NTFPSID [
        [ 0 "ask sprout-set [sprout-mangues 1 [set color 15 set-transparency 100 set heading 0 show-turtle]]"]
        [ 1 "ask sprout-set [sprout-kokos 1 [set color 45 set-transparency 100 set heading 0 show-turtle]]"]
        [ 2 "ask sprout-set [sprout-mempas 1 [set color 125 set-transparency 100 set heading 0 show-turtle]]"]
        [ 3 "ask sprout-set [sprout-assas 1 [set color 105 set size 2 set-transparency 100 set heading 0 show-turtle]]"]
      ]
      ask sprout-set [set quantity 1] ;; patch variable
      ask grow-set [set quantity quantity + 1]
      ;; clear sprout set and grow-sets  for this type of NTFP
      set sprout-set no-patches 
      set grow-set no-patches
    ]
    
    ;; ungathered NTFPs disappear
    ;; this will not effect those year round NTFPS
    if percent = 0 [
      
      ;; clear patch quantities at locations where NTFPs disappear
      ;;ask patch-here [set quantity 0]
      ask currentbreed [
        ask patch-here [set quantity 0] 
        die] 
    ]
    set NTFPSID NTFPSID + 1 ;; add one to the index
  ]
end 
  
;; resetting of different variables at start of tick

to reset-tick
  set sprout-set no-patches
  ask people [set mcol 0 set kcol 0]
end 

;; things that need to be done at end of a month

to reset-month
  ask traders [ask tradelinks[die]]
end 

;; timelevels are the-month (numeric month-id) and the timelevel below the-month, the-period 

to set-month
  ;; month is calculated from the value of tick
  
  let period-of-year ticks mod (ticks-per-month * 12) ;; "period" is timelevel below "month" timelevel
  set month-id floor (period-of-year / ticks-per-month)
  
  ;; these variables could be useful
  set year-id floor (ticks / (ticks-per-month * 12))
 
  ;; select the correct string for current month (* - not permitted to resalinise)
  select-case month-id [
    [ 0 "set the-month \"Janvier\""]   ;;  sf harvest pre monsoon
    [ 1 "set the-month \"Fevrier\""]   ;; * MAY-JUNE  add sf harvest here? pre-monsoon
    [ 2 "set the-month \"Mars\""]     ;; * monsoon-saltrinse add sf harvest here? monsoon
    [ 3 "set the-month \"Avril\""]    ;; * JULY-AUG aman start? add desalinisation law? monsoon
    [ 4 "set the-month \"Mai\""]    ;; * CHANGE sf harvest -> rice culivation  add desalinisation law? monsoon
    [ 5 "set the-month \"Juin\""]    ;; paddy harvest add desalinisation law? post monsoon
    [ 6 "set the-month \"Juillet\""]     ;; add sf  here? OCT - NOV aman harvest? post monsoon
    [ 7 "set the-month \"Aout\""]
    [ 8 "set the-month \"Septembre\""]       ;; one-cycle shrimp (dec-june )
    [ 9 "set the-month \"Octobre\""]        ;; CHANGE sf harvest -> sf cultivation JAN-FEB
    [ 10 "set the-month \"Novembre\""]
    [ 11 "set the-month \"Decembre\""]   ;; add sf harvest here? 
  ]
    ;; calculate climate - now using climate-regime reporter  
end 

to-report month
  report the-month
end 
;; useful switch/case procedure
;; Agent runs a command task or a string containing commands.

to select-case [ value cases ]
foreach cases
[ 
  if first ? = value [ run last ? stop ]
]
end  


;; place a river node at each point along x=0 axis
;; river links are directed from top most point of grid (where y= max value)
;; todo set as directed

to position-river
  let river-x 1
  ;; start at top where y takes maximum value (+16)
  let intlist n-values (max-pycor + 1 ) [?]
  foreach intlist [
    create-rivernodes 1 [
      set xcor river-x
      set ycor ?
    ]
  ]
  set intlist n-values max-pycor [?]
  foreach intlist [
    create-rivernodes 1 [
      set xcor river-x
      set ycor 0 - (1 + ?)
    ]
  ]
  ask rivernodes [
    let mywho who
    ;;create-riverlinks-to rivernodes with [who = mywho + 1] 
    create-riverlinks-with rivernodes with [who = mywho + 1] 
    hide-turtle
  ]
  ask riverlinks [
    set color blue
    set thickness 0.1
  ]
end 

;; paddy context

to position-paddy
  let exit false
  let tries 0
  while [exit = false] [
    ;;print "stuck in while"
     ;; report a random floating point number from the allowable range of turtle coordinates along the given axis, x or y.  
     let rfx random-xcor 
     let rfy random-ycor
     set xcor rfx
     set ycor rfy
     ;; distancexy reports distance from this agent to the point (xcor, ycor) and distance reports distance from this agent to another
     ;; paddys not allowed too close to other paddy or the village or mangrove
     ;; myself here refers to the current paddy that we are positioning
     ;;show distance min-one-of rivernodes [distance myself] ;;< riverbank-distance  
     ifelse any? other farms with [distance myself < min-distance] or distance one-of villages < min-distance or (distance min-one-of rivernodes [distance myself]) <  riverbank-distance
     [
       set tries tries + 1
       if tries > 20 
       [  die 
          set exit true
       ] ;; limit the number of paddy agents
     ]
     [ 
       let river-distance distance min-one-of rivernodes [distance myself]
       
       set exit true
     ]
  ] 
end 

;; position the garden somewhere in the jachere

to position-garden-area
 
  let exit false
  let tries 0
  while [exit = false] [
    let spot one-of jachere with [partof = 0 and partfarm = 0]  
     let rfx [pxcor] of spot 
     let rfy [pycor] of spot 
     set xcor rfx
     set ycor rfy
     
     
     ifelse any? other (turtle-set gardens farms) with [distance myself < min-distance-gardens] or distance one-of villages < min-distance-gardens or (distance min-one-of rivernodes [distance myself]) <  riverbank-distance
     [
       set tries tries + 1
       if tries > 20 
       [  
         ;; show tries
         die 
         
         set exit true
       ] ;; limit the number of paddy agents
     ]
     [ 
       let river-distance distance min-one-of rivernodes [distance myself]
       
       set exit true
     ]
  ] 
end 


;; position primarys or secondarys
;; note that a farm can be located in a forest area 

to position-forest-area
  let exit false
  let tries 0
  while [exit = false] [
    ;;print "stuck in while"
    let spot one-of patches with [not member? self jachere]
     let rfx [pxcor] of spot 
     let rfy [pycor] of spot 
     set xcor rfx
     set ycor rfy
     ;; distancexy reports distance from this agent to the point (xcor, ycor) and distance reports distance from this agent to another
     ;; paddys not allowed too close to other paddy or the village or mangrove
     ;; myself here refers to the current paddy that we are positioning
     ;;show distance min-one-of rivernodes [distance myself] ;;< riverbank-distance  
     ifelse any? other (turtle-set primarys secondarys) with [distance myself < min-distance-forest] or distance one-of villages < min-distance-forest or (distance min-one-of rivernodes [distance myself]) <  riverbank-distance
     [
       set tries tries + 1
       if tries > 20 
       [  die 
          set exit true
       ] ;; limit the number of paddy agents
     ]
     [ 
       let river-distance distance min-one-of rivernodes [distance myself]
       
       set exit true
     ]
  ] 
end 

to create-boundaries
 ;; draw 4 lines around edge of this forestset
 print "entered create-boundaries"
 let halfwidth item 0 size-xy / 2 
 let halfheight item 1 size-xy / 2
 let myx xcor
 let myy ycor
 hatch-boundarys 1 [
   set xcor myx - halfwidth
   ;; set xcor myx
   set ycor myy
  set heading 0
 ]
 hatch-boundarys 1 [
   set xcor myx
   set ycor myy - halfheight
   set heading 90
 ]
 hatch-boundarys 1 [
   set xcor myx + halfwidth
   set ycor myy
   set heading 0
 ]
 hatch-boundarys 1 [
   set xcor myx
   set ycor myy + halfheight
   set heading 90
 ]
  ask boundarys [
   set color white
   set size 3
   show-turtle
  ]
end 

;; make the spinner for the upper right hand corner

to create-spinner
  create-spinners 1
  [ set shape "clock"
    setxy (min-pxcor + 1.5) (max-pycor - 1.5)
    ;; place it near top left corner, but not on top of a paddy
    if any? other turtles with [distancexy (min-pxcor + 1.5) (max-pycor - 1.5) < 1.8]
    [
      let tow towards min-one-of other turtles [distance myself]
      ;;print (word "found turtle at " tow)
      ifelse tow < 90 or tow > 270
      [
        setxy (min-pxcor + 1.5)(max-pycor - 3) ;; move it down
      ]
      [
        ifelse tow > 180
        [
         setxy (min-pxcor + 3) (max-pycor - 1.5) ;; move it right
        ]
        [
          setxy (min-pxcor + 1) (max-pycor - 1) ;; move it slightly up and left      
        ]
      ]
    ]  
    set color gray - 1.5
    set size 2.5
    set heading 0]
    ;;set label 0 ]
end 

;; move the hand on one unit (one hour)

to update-spinner
  ask spinners
  [ set heading month-id * 30
    ;;ifelse climate-regime = "Monsoon"
    ;;[set color blue]
    ;;[set color grey]]
  ]
end 

;;Note the inversion of the transparency value so that the larger the number the MORE transparent (can remove or adjust that as you please).

to set-transparency [new-transparency]
  ifelse is-list? color
     [ set color lput (255 - new-transparency) sublist color 0 3 ]
     [ set color lput (255 - new-transparency) extract-rgb color ]
end 

;In Mendoungué village, the right of access to the land is based on the clan. Each clan owns a space and the children inherit land from their parents.
; Baka have access to resources that are located around their camps. Rivers and fields and fallow land boundaries are. Access to land for a native of 
; the village seeking land outside those left by his parents is authorized by the owner of the neighboring land that he seeks. Swamps belong to families 
; whose plots are located all around.
;1. The alien does not have the right of access to land. Access to NTFPs can be done by purchasing this with the owner.
;2. The timber is the only resource available to the authorization of the native responsible for CF. If marketing, a sales contract is established between the head of HR and the client. This regulation has contributed to the resurgence of wild timber in the village.

There is only one version of this model, created over 5 years ago by Richard Taylor.

Attached files

File Type Description Last updated
COBAM-3.png preview Preview for 'COBAM-3' over 5 years ago, by Richard Taylor Download

This model does not have any ancestors.

This model does not have any descendants.