COBAM-f
Model was written in NetLogo 5.0.3
•
Viewed 316 times
•
Downloaded 32 times
•
Run 0 times
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 rules for how NTFPs grow or shrink ;; TODO improve rules for collection of NTFPs ;; TODO problem of traders getting stuck at edge of screen because prevented from stopping at fdest 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 [traders trader] breed [rivernodes rivernode] 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] undirected-link-breed [riverlinks riverlink] undirected-link-breed [tradelinks tradelink] patches-own [ partof ] farms-own [ size-xy area controller ;; 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 ] households-own [ hhtype head members clan ;; hhtype relates to the structure; clan is the ethnicity of origin association ;; which farming group location ;;hh-workforce ;; hh-workforce is a list, may or may not include children. total income from farm labour , migrant or mangrove work 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; pdest fdest ;; destination the village or patch of forestset mcol kcol ;; count of each NTFP collected this season ] 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 riverbank-distance ;; min distance from a farm node to river nodes - to improve display min-distance-forest 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 NTFPS ;; amount appearing each month of various forest products calendar ;; string definition for the calendar being used i.e. munshigonj croptypes ;; 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 ;; other features of the terrain hyp ;; track length primary-forest ;; patch set secondary-forest ;; village law buffer-distance ;; buffer zone around village where shrimp ponds are not allowed to be established ] 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 8 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 8 set forestsize-max 12 set number-households 36 ;; this should equal the number used in the create-structured-households method ;; string identifies the name of the product, digits indicate the months when it can appear (and the percentage chance) set NTFPS [] set NTFPS lput ["mangue" 0 0 0 0 10 5 1 1 0 0 0 0] NTFPS set NTFPS lput ["koko" 0 0 0 0 2 2 2 2 0 0 0 0] NTFPS set sprout-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 ;; 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 [14 6 6 4] ;; 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] ] 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 ] ] ;; create landscape ;; TODO gardens closer to village ;; 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" ;; create forest areas - choose a location away from any other forest area create-primarys 15 [ 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 )] ask forestset [set pcolor 2 set partof myself] hide-turtle ;;set label "PRIMARY" ] create-secondarys 15 [ 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 )] ;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] ;; TODO: other characteristics of forest areas ;; add markers ;; forest production rules : at times resources appear in patches and can be collected ;; define households main activity depending on their access to farm/forest (if it is above a threshold) ;; create groups - farmer associations. done using traders ;; allocate hh to a group. 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 ;; recueilleNTFPs to recueilleNTFPs let nearset patches in-radius walk-speed let nearNTFPs (turtle-set kokos-on nearset mangues-on nearset) let collected no-turtles if any? nearNTFPs [ let nnt min (list 3 (count nearNTFPs)) set collected n-of nnt nearNTFPs ] foreach sort collected [ if [breed] of ? = mangues [ set mcol mcol + 1] if [breed] of ? = kokos [ set kcol kcol + 1] ] ask collected [die] 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] ;; traders update their demands annually if month-id = 0 and the-period = 1 [ ask traders [update-demands] ] ifelse any? (turtle-set mangues kokos) [ foreach sort people [ 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 ;; 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 ;; 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 tries-paddys [ 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 fp [set pcolor 32] 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 controller 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 current ? set NTFPSID position current NTFPS let percent item (month-id + 1) current ;; percent chance the product will appear ;;if item (month-id + 1) current > 0 [ 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 ? [ if random 100 < percent [set sprout-set (patch-set sprout-set self)] ] select-case NTFPSID [ [ 0 "ask sprout-set [sprout-mangues 1 [set color 15 set-transparency 100 show-turtle]]"] [ 1 "ask sprout-set [sprout-kokos 1 [set color 45 set-transparency 100 show-turtle]]"] ] ] ] set sprout-set no-patches ;; ungathered NTFPs disappear if percent = 0 [ select-case NTFPSID [ [ 0 "ask mangues [die]"] [ 1 "ask kokos [die]"] ] ] ] 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 sfhere? 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 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" ;; 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 (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 11 years ago by Richard Taylor.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
COBAM-f.png | preview | screenshot | over 11 years ago, by Richard Taylor | Download |
This model does not have any ancestors.
This model does not have any descendants.