;; @author Nanda Wijermans
;; @acknowledgements - model design choices made together in the team: Maja Schlüter, Anja Klein & Tilman Herz;
;; @acknowledgements - research assistant support in coding a few utility functions by Luja von Köckritz
;; @acknolwedgements - research assitant support in model analysis stage by Berrio Martinez
;; @email nanda.wijermans@su.se

;------------------------------------------------- EXTENSIONS -------------------------------------------------
extensions [ csv profiler ]

;------------------------------------------------- IT BEGINS HERE -------------------------------------------------
;BeeCome is relation-based model - an experiment of what a model would look like if we were to embrace relation-based view on systems like fisheries

;; All elements are agents
breed [ humans human ]
breed [ fishs fish ]
breed [ moneys money ]
breed [ fuels fuel ]
breed [ permitGovs permitGov ]
breed [ vessels vessel ]
breed [ winds wind ]
breed [ orgas orga ] ;this is an agent type for selforganising assemblages
breed [ gofas gofa ] ;agent for the Going Out Fishing Assemblage
breed [ permits permit ]

;;Elements have relations that can be part of mobility, historyOfCoop and enskillment spaces
undirected-link-breed [ mobilityLinks mobilityLink ] ;reflection of relations between elements that provide access or hamper mobility
undirected-link-breed [ enskillmentLinks enskillmentLink ] ;reflection of relations that reflect embodied learning. TODO is this directed? like to the human/fish agent?
undirected-link-breed [ histOfCoopLinks histOfCoopLink ] ;reflects the bonds between elements (social animals) and how close they are (e.g. family, friends etc)


globals [
  autoSeed                 ; RandomSeed that is automatically generated for this run
  land sea regionA regionB ; patch-set variables that allow for focusing on the different regions in the simulation
  possibleHumanGroups      ; list of lists - combinations of fisher agents groups that are theoretically possible in the world
  goFassemblages           ; list of goingFishing assemblages, each goingFishing assemblage is a list of links that are part of that assemblage
  actualisedGOFAs          ; list of actualised goingFishing assemblages
  testing                  ; TODO still needed? @Luja, pls check. list of lists of constellations that I am testing
  fixedElementsOnLand
  mobileElementsOnLand
  mobileElementsAtSea
  elementsA
  elementsB
  fishingLinks             ; all the links between fish and humans
  fishers
  buyers
  big-boats
  small-boats
  COOPS
  PCS
  vessel-owners ;agentset with agents that own vessels
  vessel-owners-nonCoop ; vessel owners agent that are not a cooperative

  align-members
  align-vessels

  ;outcome variables
  total-catch              ;total catch of all vessels this tick
  accum-catch              ;accumulated catch of all vessels over time
  depleted                 ;amount of fishStocks that got depleted
  stockA stockB            ;stock size of A and B
  numPossibleGOFAs         ;the number of possible GOFAs this tick
  numActualisedGOFAs       ;the number of GOFAs that actualised
  gofaRatio
  num-vessels

  num-ORGAs
  num-changed-crews        ; num crews that changed in total
  perc-changed-crews       ; The percentage of crews that have changes (# changed crews / actualised GOFAS)

  avgGOFAcatch avgGOFAskill
  sdGOFAcatch sdGOFAskill
  avgCapital accumCapital

  orgas-died-today         ; counter of disappearing ORGAs
  ;verification variables
  coopPowerList            ;stores of all the possible groups the coopPower
  num-small-boats          ;keeping track of the number of small vessels in the system
  num-large-vessels        ;keeping track of the number of large vessels in the system

  ;CONSTANTS
  EFFORT-SVSSL EFFORT-LVSSL
]

patches-own [
  region   ; indicates which of the 3 region this patch belongs to. Land = "land"; Sea 1: "region A" ; Sea 2 : "region B"
  habitat
]

turtles-own []

fishs-own [
  myStock
  myStock_beginOfYear
  myGrowth-rate
  myCARCAP
  myRegion
  caught-this-tick       ;the amount of fish caught from my stock
  num-boats-this-tick    ;number of boats that were fishing in my stock
  perc-boats-this-tick   ;percentage of boats that were fishing in my stock
  num-L-boats-this-tick  ;number of large boats that were fishing in my stock
  who-visited ;list of boat ids that visited me
]

humans-own [
  fisherID      ; [0,1] identification with being a fisher
  buyerID       ; [0,1] identification with being a buyer
  timeToWork    ; the timebudget that I have for this tick, can be used for fishing or organisation activities
  coopMember    ; boolean indicating that this person is part of a cooperative
  orgaID        ; Id of the organisational form that the turtle belongs to (this is a number not an agent)
  myVesselID    ; holds the ID of the vessel this person owns a vessel otherwise - no-turtles

  ;TODO REMOVE accesToVessel ;TODO reconsider/remove bool whether this person owns a vessel or connects to someone that owns a vessel    #TODO Luja - is this value being set properly for all humans, check and fix if necessary

  earnings      ; what I earned this tick
  capital       ; my accumulated earnings
]

moneys-own [
  owner         ; person or organisation owning the money
]

fuels-own [
  fuel-owner    ; person or organisation owning the fuel
  fuel-amount   ; how many boats I offered my fuel
]


vessels-own [
  owner         ; owner of the vessel (fisher agent - and orgas? TODO reconsider)
  catch         ; amount of fish caught on a fishing trip
  vsize         ; vessel size (small or large)
  useable       ; indicating whether the vessel is operationable at this point in time
  fuelAccess    ; has access to fuel the moment possible GOFAs are being contructed
]

winds-own [
  ;wind-strength ;variable in the interface affecting the ability for fishers/vessels to find the fish/go out
]

links-own [
  i ; Variable that is used to see which nodes are connected to eachother
]

mobilityLinks-own [
  strength; [0,1] 0 means for a vessel-wind link that the vessel cannot go fishing, 1 means the vessel can go fishing
]

enskillmentLinks-own [
  skill ; [0,1] reflects the type of skillfulness in engaging with each other, e.g. fisher with handling a vessel/gear to catch fish
  wentFishing; boolean
]

histOfCoopLinks-own [
  coopHistory; INT -counter of collab between two human elements
  trust;
]

;Orga reflects an subassemblage that enables fishing (providing fuel, access to market and permit etc)
orgas-own [
  members  ;agent-set of elements that are members
  human-members ;agent-set of human member elements
  orgaType ;type of organisation : PC, COOP, OTHER ...?
  myBuyer  ; only for PCs, indicates the buyer that is the Patron in the PC
  myFuel   ; the fuel I own
  age      ;how many ticks since its creation

  orga-daycatches ; sum of catches of its vessels that day
  orga-daycatchA  ; sum of catches from fish stock A
  orga-daycatchB  ; sum of catches from fish stock B
  orga-price ; the price for which it can buy fish
  capital    ; accumulated earnings
  earnings   ; what has been earned this round
  orga-coopPower ; collective collaborative strenght - based on value coopHistory of all the relations between human elements
  orga-gofaCoopPower ;list with coopPower of each GOFA in this orga
  orga-gofaSkillsA  ; list with collective skill for each GOFA in this orga
  orga-gofaSkillsB  ; list with collective skill for each GOFA in this orga
  orga-gofaVesselsA ; list with IDs of vessels that went fishing in fishStock A
  orga-gofaVesselsB ;  list with IDs of vessels that went fishing in fishStock B
  orga-gofaSkills   ; combined list with collective skills for the GOFAs in this ORGA
  orga-gofaCrewsPrev ; the crews that the orgas had last round
  orga-gofaCrews     ; traces the crew that went out this round
  orga-changedCrew   ; Indicates how many of the ORGAs gofaCrews have changed since last round: 0, 1 or 2

  myVessels ; vessels that are part of the ORGA
  numBoatsInORGA ; number of boats part of the orga (whether they actualise or not)
  numLboatsInOrga  ; number of large boats part of the orga (whether they actualise or not)
  numVessels-Act   ; # vessels in the orga that actualised
  numLboats-Act    ; # large boats that actualised
]
;Orga reflects an subassemblage, a doing that goes out and fishes
gofas-own [
  members  ;agent-set of elements that are members
  core-members ; agent-set of specific elements that have to remain in the assemblage for the assemblage to excist
  age      ;how many ticks since its creation  (not relevant in this version)

  gofa-orga ; the organisational form it connects, i.e. that provided fuel

  gofa-vessel gofa-fish gofa-fuel gofa-captain gofa-crew1 gofa-crew2 ; assemblage elements that can be directly accessed using these variables
  gofa-crew ; all the humans in the gofa

  gofa-catch
  gofa-coopPower ; collective collaborative strenght - based on value coopHistory of all the relations between human elements
  gofa-fishSkill ; collective fishing skill - average of skill of all the enskillment links between human and fish elements
]

;###### creating the world #######

to setup
  ifelse (scenario = "manual")
    [ set-default-vars ]
    [ set-scenario-vars
      ifelse (scenario = "2-disappear")
      [ set manualSeed -760696631 ] ; dissapear scenario
      [ set manualSeed -142360862 ] ; maintain scenario
    ]
  clear-all
  reset-ticks
  set autoSeed new-seed
  ifelse (autoSeed?)
  [ random-seed autoSeed ]
  [ random-seed manualSeed ]
  set num-small-boats 0
  set num-large-vessels 0

  if (MSY-Fishing or noFishing) [   ;TESTING FUNCTIONS
    set num-coops 0
    set num-pcs 0
  ]
  set-default-shapes
  create-environment
  create-elements
  create-links
  init-moneys

  set fishingLinks (link-set (specific-links-between2 (fish 0) fishers ENSKILLMENT) (specific-links-between2 (fish 1) fishers ENSKILLMENT))

  ;set outcome variables
  set depleted 0
  set total-catch 0
  set accum-catch 0
  set coopPowerList []
  set numPossibleGOFAs 0
  set numActualisedGOFAs 0
  set num-ORGAs count orgas
  set num-changed-crews 0

  layout
end

to set-default-vars
  set init-capital "all-week"
  set FISH-PRICE 4.5
  set initStock 0.5
  set highCapital 1000
  set noFishing false
  set MSY-Fishing false
  set fixedFskills false
  set rndFuelPermit false
  set permitHolderRatio 1
  set moneyFuelAccessRatio 1.0
  set fskillDynamic false
  set trustDistr "high"
  set FSKILL-SD 0.1
  set CoopHistSD 0.5
end

;Scenario variables settings for both maintain and dissapear scenario
to set-scenario-vars
  set num-coops 5
  set num-vessels-in-coop 2
  set num-fishers-in-coop 6
   set num-pcs 0
  set num-vessels-in-pc 0
  set num-fishers-in-pc 0
  set wind-scenario "manual"
  set wind-strength 0
end


to set-default-shapes
  set-default-shape fuels "bottle"
  set-default-shape moneys "money eu"
  set-default-shape vessels "boat"
  set-default-shape humans "person"
  set-default-shape fishs "fish 2"
  set-default-shape orgas "orbit 5"
  set-default-shape permitGovs "building institution"
  set-default-shape winds "cloud"
  set-default-shape mobilityLinks "type0"
  set-default-shape enskillmentLinks "type0"
  set-default-shape histOfCoopLinks "type0"
end

to create-environment
  let landdepth 15

  ;;Two regions
  set regionA patches with [ pxcor >= (min-pxcor) and pxcor <= (round(max-pxcor - landdepth - 1) / 2) and pycor >= min-pycor and pycor <= max-pycor]
  set regionB patches with [ pxcor >= (round(max-pxcor - landdepth - 1) / 2) and pxcor <= (max-pxcor - landdepth - 1) and pycor >= min-pycor and pycor <= max-pycor ]
  set sea (patch-set regionA regionB)
  set land patches with [ (pxcor >= min-pxcor and pxcor <= max-pxcor and pycor >= min-pycor and pycor < landdepth ) or (pxcor >= max-pxcor - landdepth and pxcor <= max-pxcor) ]

  ask land [ set region "land"]
  ask regionA [ set region regA ]
  ask regionB [ set region regB ]
  colourRegions

  set align-members true
  set align-vessels true
end

to colourRegions
  ask land [ set pcolor brown ]
  ask regionA [ set pcolor cyan ]
  ask regionB [ set pcolor blue ]
end

;creates all the elements
to create-elements
  set vessel-owners no-turtles
  set vessel-owners-nonCoop no-turtles

  derive-vessel-effort   ; sets the effort (maxCatch) values for large and small vessels

  create-fishs INIT-NUM-FISH[  ; for now all the fish stocks are initialised the same
    set color green move-to CENTRE-PATCH-A
    set myCARCAP CARCAP
    set myStock round(initStock * myCARCAP) ; at MSY
    set myGrowth-rate GRROWTH-RATE2
    set myRegion regA
  ]
  let fishB max([who] of fishs)
  ;PAPER 1 version: ask n-of (round(num-fish / 2)) fishs [
  ask turtle fishB [
    move-to-B
    set myRegion regB ]

  create-winds ONE        [ set color white move-to patch 20 30 ] ;top of between sea and land
  create-permitGovs ONE   [ set color white move-to patch 25 28 ] ;top middle of land

  setup-orgas

  ; global agent-sets
  set fixedElementsOnLand turtles with [ shape = "cloud" OR shape = "building institution" ]
  set mobileElementsOnLand (turtle-set vessels humans)
  set mobileElementsAtSea (turtle-set vessels FISHERS)
  set elementsA turtles-on regionA
  set elementsB turtles-on regionB

  set fishers humans with [fisherID = 1]
  set buyers humans with [buyerID = 1]
  set big-boats vessels with [vsize = LARGE]
  ask big-boats [set size 1.5] ; make larger vessel visually larger
  set small-boats vessels with [vsize = SMALL]
  set COOPS orgas with [ orgaType = COOP-OTYPE ] ;cooperatives
  set PCs orgas with [ orgaType = PC-OTYPE  ]
end

;Initialises the world with organisational forms (coops and pcs) given the interface values
;Based on the amount of PCs and COOPs the correspnding vessels and number of fishers and traders are created
to setup-orgas
  ;let peecees num-pcs TODO REMOVE
  let cps num-coops

  set num-fishers-in-coop num-vessels-in-coop * CREW-SIZE
  set num-fishers-in-pc num-vessels-in-pc * CREW-SIZE
  set num-vessels (num-vessels-in-coop * num-coops)+ (num-vessels-in-pc * num-pcs)
  ;determine-num-vessels

  ;Creating the coops  ;TODO include the creation and link to permit, is missing now
  while [ cps > 0 ] [
    let memberSet no-turtles
    let grp no-turtles
    create-humans num-fishers-in-coop [ set fisherID 1 set buyerID 0 set coopMember false set myVesselID -1 set color magenta move-to one-of land
      set memberSet (turtle-set self memberSet) ]
    ;show (sentence "setup-orgas: members of brand new coop: " memberSet)
    let elementSet no-turtles
    let half-num-coop-boats floor(num-vessels-in-coop / 2)
    ;create-vessels num-vessels-in-coop [  #original
    ;Quick fix to control that each coop has the same amount of small and large vessels
    create-vessels half-num-coop-boats [
      let vesselID [ who ] of self ;
      set color white set vsize LARGE move-to one-of land set useable true set owner 0
      set elementSet (turtle-set self elementSet)
      set owner one-of memberSet with [ not member? self vessel-owners ]  ;link to one of the members, as a fisher owns/captains the vessels that is not already owning a vessel
      ask owner [ set myVesselID vesselID ]
      set vessel-owners (turtle-set vessel-owners owner)
      create-mobilityLinks-with fishs
    ]
    let other-half-coop-boats num-vessels-in-coop - half-num-coop-boats
    create-vessels other-half-coop-boats [
      let vesselID [ who ] of self ;
      set color white set vsize SMALL move-to one-of land set useable true set owner 0
      set elementSet (turtle-set self elementSet)
      set owner one-of memberSet with [ not member? self vessel-owners ]  ;link to one of the members, as a fisher owns/captains the vessels that is not already owning a vessel
      ask owner [ set myVesselID vesselID ]
      set vessel-owners (turtle-set vessel-owners owner)
      create-mobilityLinks-with fishs
    ]
    create-coop memberSet elementSet
    set cps cps - 1
  ]
  set COOPS orgas with [ orgaType = COOP-OTYPE ] ; update agent set

  ;for the remaining vessels
  ask vessels with [ owner = 0 ] [
    let myOwner one-of COOPS       ;TODO CHECK in the coops the other vessels are owned by an agent
    create-mobilityLink-with myOwner [ set strength 1 ]
    set owner myOwner
    set vessel-owners (turtle-set vessel-owners myOwner);
    move-close-to myOwner
  ]

  set fishers humans with [fisherID = 1]      ; update agent set
  set buyers humans with [buyerID = 1]        ; update agent set
  set PCs orgas with [ orgaType = PC-OTYPE  ] ; update agent set

  ask permitGovs [
    create-mobilityLinks-with orgas;
  ]
end

;Initialise links between the elements
;Basic reasoning is that everyting is connected to everything in theory, here we only include those links that have the ability to influence:
;Winds are connected with all vessels (their combination makes that some vessels cannot go out when wind is too strong
;Humans are connected to knowledge and willingness to spend time to obtain a permit, some even have a permit
to create-links
  ask winds [
    create-mobilityLinks-with vessels ; theoretically also to fish but haven't included any interaction effect of fish and wind on mobility in this model
    changeOrNot ; initialises the strenght of the wind
  ]

  ask permitGovs [
    ifelse (rndFuelPermit) [ ;random amount of human elements have access to a permit
      let numPermitLinks floor (permitHolderRatio * NUM-HUMANS)
      create-mobilityLinks-with n-of numPermitLinks humans;
    ]
    [ ;let numPermitLinks floor (permitHolderRatio * NUM-BUYERS)
      create-mobilityLinks-with buyers;
      ;getPermit ;Future work
    ]
  ]
  ;Create history of cooperation links
  ;show (sentence "In create links: num-connections per agent: " num-connections)
  ask humans [
    create-histOfCoopLinks-with other humans [
      ifelse (coopHistDistr = "normal") [
        set coopHistory round random-normal-in-bounds (coopHistMean * 365) (coopHistSD * 365) ZERO MAXCOOP ;ito years
      ] ;uniform distribution
      [ set coopHistory round (random ((coopHistMean * 365) + (2 * (coopHistSD * 365))))]  ;or MAXCOOP
      set trust get-randomTrust
    ]

    ; This code updates the trust in the cooperation links between agents of the same cooperation to set them to a randomly distributed higher value
    if (trustDistr = "highCoop")
      [let cooplinks no-links
       let coopmembers nobody
       ask COOPS [ set coopmembers human-members
          let selectedLinks specific-links-between coopmembers histOfCoopLinks
          set cooplinks (link-set coopLinks selectedLinks)]

        ask cooplinks  [ set trust random-normal-in-bounds TRUST-HIGH TRUST-SD ZERO ONE ]
      ]
      ;[show "Syst.err - No COOPS in system"]

    ; Create enskilment links
    create-enskillmentLinks-with fishs [
      set skill get-randomFishSkills
  ]]
end

;all organisations have money, fuel, and a permit initially
;only ratio of the fishers have money and thus fuel
to init-moneys
  ;connect the newly created moneys each to a buyer. Money only links to one element
  let tobeMoneyedSet orgas
  if (rndFuelPermit) [ ;random amount of human elements have access to money
    let x floor(moneyFuelAccessRatio * NUM-HUMANS)
    set tobeMoneyedSet turtle-set n-of x humans with [ not member? self tobeMoneyedSet]]

  let tobeMoneyed [ self ] of tobeMoneyedSet
  create-moneys length tobeMoneyed [ set color yellow  ] ;add the moneys for the cooperatives in case we initialise with them too
  let unconnectedMoneys moneys with [ not any? my-links ] ;gets the moneys that have no links yet (the ones we just created)
  ask unconnectedMoneys [
    beMobilise (first tobeMoneyed) self
    set toBeMoneyed remove-item 0 toBeMoneyed
  ]
    ;create-permits num-permits      [ set shape "check" set color white move-to patch 25 30 ] ; top middle of land
end

;Assemblage creation

;Function that creates an agent to reflect a cooperative (an organisationsal form)
to create-coop [ memberSet otherElements ]
  ;create a new cooperative agent, moblity link all the members, members variables coopMember == true to it and add enskillment links to the govInstitution , what to do with the indivudal links? keep or remove?
  let this-orga nobody
  create-orgas 1 [
    ;print (sentence "creating a coop with " memberList)
    set members (turtle-set memberSet otherElements) ;memberSet; and otherElements
    set human-members memberSet
    ;show (sentence "human members: " [ who ] of human-members)
    set myVessels otherElements
    set orgaType COOP-OTYPE
    set age 0
    set color violet move-to one-of land
    set capital my-init-capital num-vessels-in-coop
    create-histOfCoopLinks-with members ;TODO init trust and coop power
    create-mobilityLinks-with otherElements
    set this-orga self
    ask members with [breed = humans] [
      set coopMember true
      set orgaID [ who ] of this-orga  ;store ID of coop in each member
    ]
    coop-owns-vessels this-orga ;TODO double check - properly restored?
    set numBoatsInORGA count myVessels
    set numLboatsInORGA count myVessels with [ vsize = LARGE ]
  ]

  create-fuels 1 [
    set fuel-owner this-orga
    set fuel-amount 0
    create-mobilityLink-with fuel-owner
    set color black move-close-to fuel-owner
    ask fuel-owner [
      set myFuel myself
      set members (turtle-set members self)
  ]]
end

;Initialised the capital according to the settings in the interface
to-report my-init-capital [ numVessels ]
  if (init-capital = "all-oneDay") [ report numVessels * ((FUEL-COST-L + FUEL-COST-S) / 2) ]
  if (init-capital = "all-week") [ report numVessels * ((FUEL-COST-L + FUEL-COST-S) / 2) *  7]
   if (init-capital = "all-month") [ report numVessels * ((FUEL-COST-L + FUEL-COST-S) / 2) *  30 ]
   if (init-capital = "mixed-1-7days") [
    let rndm (random 7) + 1
    report numVessels * ((FUEL-COST-L + FUEL-COST-S) / 2) *  rndm ]
end

;######### Time starts - the world activates ########

to go
  reset
  actualise ; god mode -check whether their assemblages that actualise e.g. fishing happens
  maintain  ;agents themselves
  update    ;update the cooperationHistory
  if (ticks > 0)[ update-outcome-vars ]
  layout
  tick ; advance time
end

to go-once
  go
end
to go-one-month
  repeat 30 [ go ]
end
to go-1-year
  repeat 365 [ go ]
end


;Function that resets variables that require resetting every tick
to reset
  ask enskillmentLinks [ set wentFishing false ]
  ask vessels [ set catch 0 ]
  ask orgas [
    set numVessels-Act 0
    set numLboats-Act 0
    set orga-daycatches 0
    set orga-daycatchA 0
    set orga-daycatchB 0
    set orga-gofaCoopPower []
    set orga-gofaSkillsA []
    set orga-gofaSkillsB []
    set orga-gofaVesselsA []
    set orga-gofaVesselsB []
    set orga-gofaSkills []
    ifelse(ticks > 0)
    [ set orga-gofaCrewsPrev orga-gofaCrews ]
    [ set orga-gofaCrewsPrev []]
    set orga-gofaCrews []
    set orga-changedCrew 0
    set perc-changed-crews 0
  ]
  ask fishs [
    set caught-this-tick 0
    set num-boats-this-tick 0
    set perc-boats-this-tick 0
    set num-L-boats-this-tick 0
    set who-visited []
  ]
end

;Actualise is a function that triggers when possible (sub)assemblage to actualise
;organisingFishing: gettingPermit, gettingFuel
;goOutFish goFish
;buySell
to actualise
  go-enable-fishing     ; ORGAs in action
  find-goOutAssemblages ; GOFAs possibility space change
  go-out-and-fish       ; actualising the gofas (goOutFishing assemblages) and fish?
  go-sell
end

;Function that describes processes/behaviours of elements
to maintain
  ask fishs [
    let me who
    if (MSY-fishing) [
      let dailyHarvest round (daily-MSY-catch / 2)  ;#two fish stocks
      set myStock myStock - dailyHarvest
      if (myStock < 0) [ set myStock 0 ]
      ;show (sentence "In maintain. I am MSY fishing now. harvest is: " dailyHarvest " and new Stock " myStock)
    ]
    if((ticks mod DAYS-IN-YEAR) < 1)[
      ;show "In maintain: regenerating now!"
      regenerate ]    ; logistic growth based, once a year
    if myStock < 1 [
      set depleted depleted + 1
      die
      let fid 0
      if ( me = 0 ) [ set fid 1 ] ;to determine which fish stock is left
      set fishingLinks (specific-links-between2 (fish who) fishers ENSKILLMENT)
  ]]
  ask winds [ changeOrNot ] ; interface-based, random or seasonal

  ask enskillmentLinks [
    if not(wentfishing) and (fskillDynamic) [
      let reducedSkill skill - SKILL-DECAY
      set skill max (list reducedSkill 0)
    ]
  ]

 ; checke whether orgas will  continuing to exist - if not remove the connected fuels, and links
  set orgas-died-today 0
  ask orgas [
    if capital < 1 [
      ask mobilityLink-neighbors with [ breed = fuels ] [ die ]
      ask human-members [ set orgaID -1 ]
      set orgas-died-today orgas-died-today + 1
      if (orgaType = PC-OTYPE) [
        ask myBuyer [ die ]]
      die ]]
  set align-members true
  set align-vessels true
end

;Function that updates the outcome variables we are interested in
to update
  set total-catch sum [ catch ] of vessels
  set accum-catch accum-catch + total-catch
  ifelse (fish 0 != nobody) [ set stockA [ myStock ] of fish 0 ] [ set stockA 0 ]
  ifelse (fish 1 != nobody) [ set stockB [ myStock ] of fish 1 ] [ set stockB 0 ]
  ask fishs [ set perc-boats-this-tick (precision (num-boats-this-tick / num-vessels * 100) 1) ]
end

; #### ORGA ASSEMBLAGE FUNCTIONS

;ORGA doings: formation of ORGAS (cooperatives and PCs), provision of fuel
;Formation of COOP: is the obtaining of a permit with a group of humans and by that form a formal and social contract to sell to the cooperative. When the COOP is there this social contract is establised until the COOP ceizes to exist
;Formation of PCs: Any human that identifies as a buyer reflects a PC, however the moment that fuel is provided to a fisher, this seals the social contract to who you sell
;Any ORGA when it has enough capital can provide for fuel
to go-enable-fishing
 ; create the social contracts between ORGA and fishers -> provide fuel (symbol for loans, lunch etc what the fishers need to be able to go out)
  getFuel
end


;Checks for each orga whether they can provide fuel for those vessels in reach of their organisation
;The provision of fuel is done by creating an mobilityLink from a vessel to the fuel of the organisation
;when the organisation can pay for that fuel
;It simplifies but reflects the process where a vessel/fisher gets a loan to go out fishing for fuel
to getFuel
  ask orgas [
    let fcost 0
    let miFuel myFuel
    let cptl capital
    ask myVessels [
      if not(mobilityLink-neighbor? miFuel)[
        set fcost fcost + getFuelCost vsize
        if (cptl - fcost >= 0) [
          create-mobilityLink-with miFuel
      ]]
    ]
    create-mobilityLink-with myFuel
    set capital capital - fcost  ; this it the capital of the orga
  ]

  ask fuels [
    set fuel-amount count mobilityLink-neighbors ; only vessels are mobility links
    ;show (sentence "vessel connections (IDs):" [ who ] of mobilityLink-neighbors " Fuel amount: " fuel-amount)
  ]
end

; #### GO OUT FISHING ASSEMBLAGE FUNCTIONS

;to detect goOutFishing assemblages
; starts from the vessels, whether they are usable, then ask the owner whether it has access to fuel itself or through an organisation
; if so, it goes through all the combinations of connections to that could allow for making a crew.
; all these different contellations are then saved as potential GOF assemblages.
to find-goOutAssemblages
  set goFassemblages []
  blow-wind             ; wind does what it does, but if the wind is too strong small vessels are unable to go out

  if (any? vessels and any? fishs and any? humans and any? fuels) [  ;if agents of any of these types are missing, there are no GOFAs
  ask vessels with [ useable = true ] [
      ;show "in find-goOutAssemblages: I am usuable vessel"
      let constels []
      let vsslID [ who ] of self
      set fuelAccess any? mobilityLink-neighbors with [breed = fuels]
      if (fuelAccess) [
        let fuelID [ who ] of one-of mobilityLink-neighbors with [breed = fuels]
        ;show (sentence " In find-goOutAssemb: I have fuel access  - fuelLink ID: " link-with turtle fuelID)
        ;show (sentence " In find-goOutAssemb: I have fuel access  - fuelLink ID: " mobilityLink who fuelID)
        ask owner [
          ;show "in find-goOutAssemblages: vessel owner:"
          let myConnections []
          ifelse (breed = orgas) ;which is always a cooperative in this case
          [ ;show (sentence "find-GOFassems: orga members" human-members)
            set myConnections [ who ] of human-members ]
          [ set myConnections [ who ] of histOfCoopLink-neighbors with [ breed = humans and myVesselID = -1 ]] ;human owner connecting to anyone in its nework (that doesn't own a vessel)
            ;show (sentence "in find-GOF. My connections:" myConnections)
          let possibleCrew comb (CREW-SIZE - 1) myConnections
          ;show (sentence "in find-GOF. Now I have these crew options:" possibleCrew)
          ;show (sentence "in find-GOF. Tick: "ticks " Now I X crew options:" length possibleCrew)
          ;now form the subassemblage!
          foreach possibleCrew [ group ->
            ;show (sentence "In find-goOutAssemblages:" group)
            let grp fput ([who] of self) group       ;add owner id
            set grp fput fuelID grp                  ;add fuel to the assemblage
            let myFishID getMaxSkilled4Fish group    ;get to which fish
            set grp fput myFishID grp ;add fish - TODO1 fix this needs to be one of the fish that the total crew has most knowledge of
            set grp fput vsslID grp                  ;add vessel id
            set constels fput grp constels
            ;show (sentence "in find-GOF. Possible GOFA:" grp)
          ]
          ;show (sentence "in find-GOF. Constels:" constels)
        ]
        ifelse not(empty? constels)
        [ ;show "In find-goOutAssemb: adding my combinations to the possible gofas"
          set goFassemblages (sentence constels goFassemblages)]
        [ show "In find-goOutAssemb: i am a vessel with fuel access and not hindered by wind, but have no crew options"]]
  ]]
  ;show (sentence "in find-goOUtAssemblages, we now found the following possible GOFAs:" goFassemblages)
  set numPossibleGOFAs length goFassemblages
end

;Triggers the goingFishing subassemblages(GOFA) that are actualised to actualy do their thing (move close to the fish in the subassemblage)
;Randomly an potential assemblage actualises, those GOFAs that cannot actualise anymore are removed and the next one is chosen randomly until all assemblages are actualised that can actualise
to go-out-and-fish
  set align-members false
  set align-vessels false

  ;print "in goOut and fish"
  set actualisedGOFAs []
  ask gofas [ die ] ; all gofas ceize existing from last round, we chose not to trace these for this simulation
  ;here subassemblages are being actualised (visible possiblity space is changing)
  if not(empty? goFassemblages) [
    ;set gofaSET
    orderGOFAs
    ;show (sentence "In go-out-and-fish: ordered the GOFAs according to coopPower:" goFassemblages)
    let actualisedGoF first goFassemblages  ; by default you take the first possible gofa, as it has the highest coop power
    if (random 100 > 90) [ ; but sometimes (10%) you pick a random one to start with
      set actualisedGoF one-of goFassemblages
      if (randomActualisationInfo = true ) [
        ;show (sentence "tick: " ticks " actualising randomly this gofa-crew: [" item 3 actualisedGoF " (boat-owner)," item 4 actualisedGoF","item 5 actualisedGoF "]")
    ]]
    ;show (sentence "In go-out-and-fish: the first GOFA that is going to be actualised is:" actualisedGoF)

    set actualisedGOFAs fput actualisedGoF actualisedGOFAs
    ;let fuelAGOFA turtle (item 2 actualisedGoF)
    ;show (sentence "In go-out-and-fish: fuel-amount = " [fuel-amount] of fuelAGOFA)
    ;use-fuel fuelAGOFA actualisedGoF
    let gofs (remove-notActualisable-GOFAs actualisedGoF goFassemblages)
    ;show (sentence "In go-out-and-fish: just removed the GOFAs that cannot actualise anymore - these are my residu options:" gofs)
    while [ not(empty? gofs)][
      set actualisedGoF first gofs ; by default the next one is the one with the next highest coop power
      if (random 100 > 90) [ set actualisedGoF one-of gofs ]; but sometimes (10%) you pick another
      ;show (sentence "In go-out-and-fish: the next GOFA that is going to be actualised is:" actualisedGoF)
      set actualisedGOFAs fput actualisedGoF actualisedGOFAs
      set gofs remove-notActualisable-GOFAs actualisedGoF gofs
      ;show (sentence "In go-out-and-fish: just removed the GOFAs that cannot actualise anymore - these are my residue options:" gofs)
  ]]
  ;print (sentence "In go-out-and-fish: These are the gofas to be actualised:" actualisedGOFAs)
  ;now the subassemblage will emerge, i.e. a new agent is created

  foreach actualisedGOFAs [ gfoa ->
      create-GOFAs 1 [
      set members list2set (but-last gfoa)
      set gofa-vessel turtle (item 0 gfoa)
      set gofa-captain turtle (item 3 gfoa)
      set gofa-fish turtle (item 1 gfoa)
      set gofa-crew1 turtle (item 4 gfoa)
      set gofa-crew2 turtle (item 5 gfoa)
      set gofa-fuel turtle (item 2 gfoa)
      set core-members (turtle-set gofa-vessel gofa-captain gofa-fish) ;should this really include the fish-stock?  if they would switch fish stock, this subassemblage would ceize to exist...
      set gofa-catch 0
      set gofa-orga [ fuel-owner ] of gofa-fuel ;TODO should this be the one that provided the fuel? how can this be set up that connects directly to this orga, now the order in getting fuel is before the GOFA is created..
      set gofa-crew members with [ breed = humans ]
      set gofa-coopPower (last gfoa) ;(getCoopPower gofa-crew)
      let crewLinksFish specific-links-between2 gofa-fish gofa-crew ENSKILLMENT

      set gofa-fishSkill precision (mean [ skill ] of crewLinksFish ) 2
     ;show (sentence "testing specific-links-between2 in go-out-and-fish: crew fish skill" gofa-fishSkill)
      set gofa-crew1 turtle (item 4 gfoa)
      set gofa-crew2 turtle (item 5 gfoa)
      let crewLinksCollab specific-links-between2 gofa-captain (turtle-set gofa-crew1 gofa-crew2) HISTOFCOOP
      ask crewLinksCollab [ set coopHistory coopHistory + 1 ]
  ]
  ]
  ;show (sentence "In go-out-and-fish: gofas are going fishing" )
  ;show (sentence "GOFAs in the world are:  " [ who] of gofas)
  ;show (sentence "ORGAs in the world are: " [ who ] of orgas )
  ;type (sentence "In go-out-and-fish: gofa that just went out: ")
  ask gofas[
    ;sanityCheck-FuelLink
    go-out
    go-fish
    ;show (sentence "In go-out-and-fish. captain: " [ who ] of gofa-captain " crew members: "  [ who ] of gofa-crew1 " " [who] of gofa-crew2) ;tmp added to trace who goes out
    ;show [ who ] of gofa-crew  ;tmp added to trace who goes out
    ;type (sentence who ", ")
  ]

end

;Function describes how a GOFA (going out fishing assemblage) goes out (to fish) and uses fuel
to go-out
  let fishElement gofa-fish
  ask members with [ breed = humans OR breed = vessels ][
    face fishElement
    move-to fishElement
    fd random 5
  ]

; use the fuel
  let fuelID [ who ] of gofa-fuel
  let vesselID [ who ] of gofa-vessel
  ;show (sentence "In go-out: vessel ("vesselID") using my fuel ("[who ] of gofa-fuel")")
  ask mobilityLink fuelID vesselID [ die ]
end


; function that describes what happens when a subassemblage fishes
; Depending on their vessel (and crew) there will be a catch (stored on the vessel)
; in another actualise assemblage - selling/buying - this catch will be sold and money gets distributed over the crew
; after fishing, if the catch exceeds the expecation of a particular fisher, the skill increases, reflecting a learning experience in this team
to go-fish
  let effort 0
  let ctch 0
  let stock [ myStock ] of gofa-fish
  let boatSize [ vsize ] of gofa-vessel ;"none"
  let boatID [who] of gofa-vessel

  ;show (sentence "In go-fish: at tick: "ticks " vessel: "boatID " fishes stock " [ who ] of gofa-fish " in region " [ myRegion ] of gofa-fish)

  if (stock > 0)[  ;determine catch
    ask gofa-vessel [ set effort getEffort vsize ]
    let gofa-effort effort
    set ctch gofa-fishSkill * gofa-effort * stock
    ;show (sentence "go-fish: gofa-effort =" gofa-effort ", gofa-catch = " ctch)

    ;show (sentence "In go-fish: at tick: "ticks " catch = "ctch " gofa-effort = " gofa-effort " gofos-fishSkill = "gofa-fishSkill " stock: = " stock )
    if (ctch < 0) [ show "Syst.err catch is negative - shouldn't compute" ]
    if (stock < ctch ) [
      set ctch stock
      ;show (sentence "go-fish: current stock = " stock ", gofa-fishSkill =" gofa-fishSkill ", gofa-catch = " ctch)
    ]
  ]
  set gofa-catch ctch

  ask gofa-fish [
    if not(constantStock)[ set myStock myStock - ctch ] ; reduce the fish stock with the catch
    set caught-this-tick caught-this-tick + ctch
    set num-boats-this-tick num-boats-this-tick + 1
    if (boatSize = LARGE) [ set num-L-boats-this-tick num-L-boats-this-tick + 1 ]
    set who-visited fput boatID who-visited
    ;show (sentence "In gofa-fish: I am fish " who " in region "myRegion" fished by vessel: "boatID)
  ]

  ask gofa-vessel [ set catch ctch ]

  ;show (sentence "In go-fish: gofa-orga is: " [ who ] of gofa-orga)
  let myRgn [ myRegion ] of gofa-fish
  let collSkill gofa-fishSkill
  let team []
  set team fput [ who ] of gofa-captain team
  set team lput [ who ] of gofa-crew1 team
  set team lput [ who ] of gofa-crew2 team

  ;in order to track team changes | to create the same team but just different crew order - captain stays on the first spot)
  let teamMirror []
  set teamMirror fput (first team) teamMirror
  set teamMirror lput (last team) teamMirror
  set teamMirror lput [ who ] of gofa-crew1 teamMirror

  let cpPwr gofa-coopPower
  ask gofa-orga [
    set numVessels-Act numVessels-Act + 1  ; counter for the amount of vessels go out per ORGA
    if (boatSize = LARGE) [ set numLboats-Act numLboats-Act + 1 ]
    if (myRgn = regA)[
      set orga-gofaSkillsA fput collSkill orga-gofaSkillsA
      set orga-gofaVesselsA fput boatID orga-gofaVesselsA
      ;show (sentence "In gofa-fish: at tick:" ticks " adding " boatID "to region A")
    ]
    if (myRgn = regB)[
      set orga-gofaSkillsB fput collSkill orga-gofaSkillsB
      set orga-gofaVesselsB fput boatID orga-gofaVesselsB
      ;show (sentence "In gofa-fish: at tick: " ticks " adding boat " boatID "to region B")
    ]
    set orga-gofaSkills (sentence orga-gofaSkillsA orga-gofaSkillsB)
    set orga-gofaCrews fput team orga-gofaCrews
    set orga-gofaCoopPower fput cpPwr orga-gofaCoopPower
    ifelse (member? team orga-gofaCrewsPrev)
    [] ;nothing changed
    [ ifelse (member? teamMirror orga-gofaCrewsPrev)
      [] ;nothing changed
      [ set orga-changedCrew orga-changedCrew + 1 ]]
  ]
  if (fskillDynamic) [ ; increase fishing skill
  let fishedFish gofa-fish
    ask gofa-crew [
      ask enskillmentLink-with fishedFish [
        set wentfishing true ;bool used to not descrease the skill as it did actualise
        if (fskillDynamic = true) [ ;skills can change overtime
        let expected-catch effort * skill  ; expectation based on my own skill
        if (expected-catch < ctch) [ ; expected catch smaller than actual quatch
                                     ; increase enskilment skill
          set skill skill + SKILL-INCREASE
          if skill > 1 [ set skill 1 ]
        ]]
      ]
  ]]
end

;Function that orders the possible go-out-fishing assemblages given their cooperation power
;Thereby building in path dependency of the possible gofas to be actualised
to orderGOFAs
  ;first calculate the coopPower for each gofa and add it
  set coopPowerList []

  foreach goFassemblages [ gfoa ->
    let captain turtle (item 3 gfoa)
    let crew1 turtle (item 4 gfoa)
    let crew2 turtle (item 5 gfoa)
    let crew (turtle-set captain crew1 crew2)
    let indx position gfoa goFassemblages
    let gofa-cpPwr (getCoopPower captain (turtle-set crew1 crew2))
    let gfoaNew lput gofa-cpPwr gfoa
    set coopPowerList fput gofa-cpPwr coopPowerList
    set goFassemblages replace-item indx goFassemblages gfoaNew
    ;show (sentence "In orderGOFAs: last element in list (should be coopPower) =" last gfoaNew)
  ]
  let goFassemblagesSorted []
  ifelse (randomActualisation = true)
  [ set goFassemblagesSorted shuffle goFassemblages ] ;GOFAs are randomly ordered
  [ set goFassemblagesSorted sort-by [ [ list1 list2 ] -> last(list1) > last(list2)] goFassemblages ] ;sort the gofa based on the cooperation power of the gofas
  ;show (sentence "In orderGOFAs, Old gofaLIst: " first goFassemblages " and the sorted gofasList: " first goFassemblagesSorted)
  set goFassemblages goFassemblagesSorted
end

;reports the effort of the vessel based on its vesselsize
to-report getEffort [ vesselSize ]
  let ffrt 0
  if vesselSize = SMALL [ set ffrt EFFORT-SVSSL ]
  if vesselSize = LARGE [ set ffrt EFFORT-LVSSL ]
  report ffrt
end

;Function that removes any GOFA that cannot be actualised anymore since actGofas already actualises and reports the residue GOFAS
;remove any GOFA that has the same vessel, owner, crew or fuel as the actualised GOFA
;only consider fuel as an element that cannot exist in other assemblages when the fuel-amount is 0
;Reports a list of GOFAs that can potentially actualise
to-report remove-notActualisable-GOFAs [ actGofas gofasI ]
  let residue []
  let vssl item 0 actGOFAS  ; vessel id
  let feul item 2 actGOFAS  ; fuel id
  let ownr item 3 actGOFAS  ; vessel owner id
  let crw1 item 4 actGOFAS  ; crw1 id
  let crw2 item 5 actGOFAS  ; crw2 id

  ;let fuel-mnt [ fuel-amount ] of turtle feul

  ;ifelse (fuel-mnt > 0) ; this fuel can still be used in another assemblage
  foreach gofasI [ g ->
    ;show (sentence "in remove-notActualised-GOFAs: fuel amount is" [fuel-amount] of turtle feul)
    if ((not(member? vssl g)) and (not(member? ownr g)) and (not(member? crw1 g)) and (not(member? crw2 g)))
      [ set residue fput g residue
        ;Sanity checking due to an error where more GOFAs go out than possible:
        if ((member? vssl g) OR (member? ownr g) OR (member? crw1 g) OR (member? crw2 g))
        [ show "Syst.err In remove-notActualisable..: an element that already actualised is still on the tobe actualised combos"]
    ]
  ]
  report residue
end

; A function that creates a link between an organization and all vessels owned by the organizations members
to coop-owns-vessels [ this-orga ]
  let memberSet [ members ] of this-orga
   let coop-vessels nobody
   ask memberSet [
    ;print (sentence "searching vessels")
    let member-neighbors turtle-set mobilityLink-neighbors
    let new-vessels member-neighbors with [breed = vessels]
    set coop-vessels (turtle-set coop-vessels new-vessels)
  ]
  ;print (sentence "coop-vessels are " coop-vessels)

  ask coop-vessels [
     create-mobilityLink-with this-orga
  ]
end

to-report getMaxSkilled4Fish [ crew ]
  let fishIDs [ who ] of fishs
  let crw no-turtles

  foreach crew [ id ->
    set crw (turtle-set crw (turtle id))
  ]

  let skillA getFishingSkill (first fishIDs) crw    ;skills for fish 0
  let skillB getFishingSkill (last fishIDs) crw     ;skills for fish 1
  ;show (sentence "In getMaxSkilled4Fish: skillA = " skillA " skillB = " skillB)

  ifelse (skillA > skillB)
  [ report first fishIDs ]
  [ ifelse (skillB > skillA)
    [ report last fishIDs ]
    [ report one-of [ who ] of fishs ]]; item randmn fishIDs ]] ;just as skilled for both fish stock, then take a random fish stock
end

;Reports the collective fishing skill of a crew for a particular fish-stock
to-report getFishingSkill [ fID crew ]
  let fishing-links specific-links-between2 (fish fID) crew ENSKILLMENT
  ;show (sentence "In getFishingSkill: fishingLinks of crew (" [ who ] of crew ") : "  [ skill ] of fishing-links)
  let crewSkill mean [ skill ] of fishing-links
  ;show (sentence "In getFishingSkill: crewSkill " crewSkill)
  report crewSkill
end

; coopPower is a proxy for how well the group cooperates
; currently this is based on the coopHistory, the more this group has worked together in the past the higher the cooperation power
; assumes fishers_assembly to be an agentset
to-report getCoopPower [captain crew]
  let fishers_links specific-links-between2 captain crew HISTOFCOOP
  ;show (sentence " in getCoopPower: crew =" [ who ] of fishers_assembly "links between are: " [ who ] of fishers_links " and coophist = "[coopHistory ] of fishers_links)
  let cppwr sum[coopHistory] of fishers_links
  ;show (sentence " in getCoopPower: coopPower = " cppwr)
  report round cppwr
end

; Given a certain GOFA (going out fishing assembly) that just has been actualised the cooperationHistory is increased
; concerns the group of humans in the assembly working together. This will affect the likelihood they go out fishing again in the future as their cooperation power goes up
to update-coopHistory [fishing_assembly]
  ask fishing_assembly [
    let crewLinksCollab specific-links-between2 gofa-captain (turtle-set gofa-crew1 gofa-crew2) HISTOFCOOP
    ask crewLinksCollab [ set coopHistory coopHistory + 1 ]
  ]
end


; collective trust is a proxy for how trusting a group is in general, which is now random!
; this is used to influence whether a GOFA team is up cheating while selling or not
to-report getCollectiveTrust [crew]
  let collTrust random 100
  report collTrust
end

; Describes how vessels too small for the current wind strength are demobilized and become not useable
; Set strength of small vessels mobility links to zero and color the small vessels in black
to blow-wind
  let strngt 1
  let sails white
  let useBool true
  if (wind-strength > 0.5)
  [ set strngt 0 set sails black set useBool false ]

  ask winds [
    ask mobilityLink-neighbors with [ breed = vessels ] [
      if ( vsize = "small" )  ;Only small vessels change due to wind
      [ set color sails
        set useable useBool
        ask my-mobilityLinks [ set strength strngt]]
  ]]
end

;Reports the cost of fuel depending on the boatsize
to-report getFuelCost [ boatSize ]
  if(boatSize = SMALL) [ report FUEL-COST-S ]
  if(boatSize = LARGE) [ report FUEL-COST-L ]
  report (sentence "Syst.err boatSize is unfamiliar to me: " boatSize)
end

;### Both ORGA and GOFA assemblage functions

;Function that for every GOFA that actualised sells their catch and distributes the earnings
;Is this an interaction between subassemblages (or via elements?)
to go-sell
  let PROFIT_SHARE (1 / 4) ; 3 crewmembers + boat share
  ;let FISH-PRICE 1
  ask orgas [ set earnings 0 ]

  ask gofas [
    let price 0
    let oType 0
    let gofa-trust getCollectiveTrust gofa-crew
    let sellingTo gofa-orga
    let cheating? false
    ask sellingTo [
      set oType orgaType
    ]
    let ctch gofa-catch
    let fcost getFuelCost ([ vsize ] of gofa-vessel)
    let profit max(list 0 (ctch * FISH-PRICE - fcost)) ;no negative profit
    ;show (sentence "go-sell: catch = "ctch "profit = "profit " and a share is " (profit * PROFIT_SHARE))
    let fair-share profit * PROFIT_SHARE

    ask gofa-crew [ update-earnings fair-share ]
    let rgn [myRegion] of gofa-fish
    ask gofa-orga [
      set orga-daycatches orga-daycatches + ctch
      ;show (sentence "In go-sell: went fishing in region: " rgn)
      if (rgn = regA)[ set orga-daycatchA orga-daycatchA + ctch ]
      if (rgn = regB)[ set orga-daycatchB orga-daycatchB + ctch ]
      let capital-related-cost 0 ;% extra cost you have from running an orga, the more capital the higher the amount you pay - when capital is low it is 1%
       if capital > highCapital [ set capital-related-cost 0.1 ]   ;10% extra cost to run an ORGA when capital is high - what is HIGH capital is to be debated
        let my-earning fair-share * (1 - capital-related-cost)
        update-earnings my-earning ]
    ]

  foreach actualisedGOFAs [ gfoa ->
    let ctch[ catch ] of turtle (item 0 gfoa)
    ;let sellOrga myOrga ;#make this more complex to allow for cheating/getting a better deal with an other organisational form
  ]
end

;updates the recent earnings for this agent (crew, captain or orga)
to update-earnings [ my-earning ]
  set earnings earnings + my-earning
  set capital capital + my-earning
end

;Fish regenerating while there is minimum of fish present
;Updates the stock following a logistic growth function - standard discrete population dynamics model (Verhulst 1935 - Schaefer model)
;Stock_t+1 = stock_t + growth-rate(r) * stock_t *( 1 - stock / carrying-capacity(K) - harvesting)
to regenerate
  let spawningStock 0.3 * myCARCAP ; minimal stock needed to regenerate
  let yearsCatch myStock_beginOfYear - myStock

  if (myStock > spawningStock) [
    ifelse (myCARCAP > 0) [
      set myStock myStock_beginOfYear + (myStock_beginOfYear * myGrowth-rate * (1 - (myStock_beginOfYear / myCARCAP))) - yearsCatch
    ][ print "Syst.err regenerate: carcap is 0"
      set myStock 0 ]

   set myStock_beginOfYear myStock ;reset stock for the next year
  ]
  ;Made this to adapt growthrate cycles to any length. but now it is yearly
  ;let relative-grwth-rate (growth-rate / 365) * fish-update-freq ;  the growth rate is based on a yearly cyclus here we adapt it to the update frequency used in the model
end

to-report update-logistic-growth [ stock growth-rate crcp ]
  end

;Describes the changes in wind strength
to changeOrNot
  let windStrngt wind-strength * 10 ; (wind-scenario = "manual") multiplied by 10 for consistency with random and seasonal scenario
  ifelse(wind-scenario = "random")
  [ set windStrngt (random 10) ] ; A value between 0 and 9, including both 0 and 9 to be consistent with the seasonal scenario
  [ ifelse(wind-scenario = "noWind")
    [ set windStrngt 0 ]
    [ ifelse(wind-scenario = "windOn")
      [ set windStrngt 1 ]
      [ if (wind-scenario = "seasonal") ; => ;3 months high likeliness of strong winds, 3 months of medium and 6 months of low
        [ let time-of-year ticks mod 365 ; count days since January 1st of that year
          ifelse (time-of-year < 90) ; first 3 months
          [ set windStrngt random-normal 8 1] ; strong wind
          [ ifelse (time-of-year < 180) ; second 3 months
            [ set windStrngt random-normal 5 1 ] ; medium wind
            [ set windStrngt random-normal 2 1 ]] ; low wind - last 6 months
  ]]]]
  set wind-strength precision (windStrngt / 10) 1   ;update the wind-strength value in interface so there is feedback on what it is now
  ask my-out-mobilityLinks [ set strength windStrngt ]
end

; ###### Assemblage specifications & Assemblage utils ########


; Function that creates a mobility link between a person and a money or permit element
; moves that money/permit/fuel close to the person it connects to the person/organisation
; in case it concernts an organisational form, the fuel is also added as a member of the
to beMobilise [ person element ]
  ask element [
    move-to person face person set heading heading + 180 fd 1
    create-mobilityLink-with person [  set color green tie ]
    set owner person ;To indicated from what organisation/person created my existance
  ]
  ask person [
    if (breed = orgas) [ set members (turtle-set element members) ] ;make part of the orga
]
end


; A function to retrieve all links of a specific type between the agents within a group
; Get all links between a group of agents by looping through all agents in a group and getting the links by editing the parameter i as a marker.
to-report specific-links-between [ nodes link_type ]
  ask links [ set i 0 ]
  let elmnts no-links

  ask nodes [
    ;show (sentence "In specific-links-between. my links of" link_type ": " [ who ] of my-links with [ breed = link_type ])
    ask my-links with [breed = link_type]
    [ set i i + 1 ]]
  set elmnts (link-set links with [ i = 2 ] )  ;This ensures that the link is between two agents in the group at it is selected twice

  let elmntsList remove-duplicates (list elmnts)
  ;show (sentence "In specific-links-between. Number of links " length elmntsList " with link-type  : "  link_type)
  report link-set elmntsList
end


; describes a function that gives the specific link types between a set of elements that are connected to a specific element
; checks whether specficElement is connects with each of the elementset (combing from an assemblage)
; and then retrieves and reports the links between
; need it to get to the collective skill of a crew that is fishing a particular fish (stock)
to-report specific-links-between2 [ specificElement elementSet link_type ]
  let myLinks no-links

  ; now get to the link-type links between relevantConnections and specificElements
  ask elementSet [
    ifelse (link_type = MOBILITY)
    [ if mobilityLink-neighbor? specificElement [ set myLinks (link-set myLinks mobilityLink-with specificElement)]]
    [ ifelse(link_type = ENSKILLMENT)
      [ if enskillmentLink-neighbor? specificElement [ set myLinks (link-set myLinks enskillmentLink-with specificElement)]]
      [ ifelse (link_type = HISTOFCOOP)
        [ if histOfCoopLink-neighbor? specificElement [ set myLinks (link-set myLinks histOfCoopLink-with specificElement)]]
        [ show (sentence "Syst.err. in specific-links-between2: link_type unknown, pls check: " link_type) ]
  ]]]

  report myLinks
end


;checks whehter a vessel has access to fuel
;by checking whether there is mombility link with fuel on the other end
to-report access-to-fuel
  report mobilityLink-neighbors with [breed = fuels]
end


;Reports back an agent-set given a list of agent ids
to-report list2set [ lst ]
  let assem no-turtles
  foreach lst [ element ->
    set assem (turtle-set (turtle element) assem)
  ]
  report assem
end

; ###### Outcome variables ######

to update-outcome-vars
  ; numPossibleGOFAs is set in find-goOutAssemblages as this variable is reused to prune the changing possible GOFAs after activation of one/some
  if (ticks > 0) [
    set num-ORGAs count orgas
    set numActualisedGOFAs count GOFAs

    ifelse (numPossibleGOFAs != 0)
    [ set gofaRatio numActualisedGOFAs / numPossibleGOFAs]
    [ set gofaRatio 0 ]

    if (any? GOFAS)[
      set avgGOFAcatch mean [ gofa-catch ] of GOFAS
      set avgGOFAskill mean [ gofa-fishSkill ] of GOFAS
      if (count GOFAS > 1 )[
        set sdGOFAcatch standard-deviation [ gofa-catch ] of GOFAS
        set sdGOFAskill standard-deviation [ gofa-fishSkill ] of GOFAS
    ]]

    if (any? ORGAS)[
      set avgCapital mean [ capital ] of ORGAS
      set accumCapital sum [ capital ] of ORGAS
      set num-changed-crews sum [ orga-changedCrew ] of ORGAS
      if (numActualisedGOFAs > 0) [ set perc-changed-crews num-changed-crews / numActualisedGOFAs ]
    ]
  ]
end

;; Function calculates GINI of the contribution of the players that made the threshold, a measure of inequality of a distribution (Gini,1912),
;; 0 = equality; 1 + maximal inequality
;; Ratio of the areas on the Lorenz curve diagram (proportion of total S (e.g. income) corresponding the cumulative S of the x% of the population.
;; adapted the implementation at https://subversion.american.edu/aisaac/notes/netlogo-intro.xhtml#plotting-gini-coefficient-and-lorenz-curve
to-report GINI-orgaCapital
  if (not any? ORGAs) [ report 0 ]  ;with [ myGroupMadeThreshold = true])
  let numAgents count ORGAs ;with [ myGroupMadeThreshold = true ]
  let cumsum-sorted-val 0
  set cumsum-sorted-val partial-sums sort [ capital ] of ORGAs
  ;print (word "cumsum-sorted-val: " cumsum-sorted-val)
  let total-val last cumsum-sorted-val
  let normalized-val n-values numAgents [ 0 ]
  ifelse (total-val > 0 ) [
    set normalized-val map [ [x] -> x / total-val] cumsum-sorted-val
    ;print (word "normalized-contrib: " normalized-contrib)
    let gaps n-values numAgents [ [x] -> (((x + 1) / numAgents) - item x normalized-val)]
    report (2 * sum gaps / numAgents)                                  ;Gini = A/(A+B) = 2*A
    ;print (word "gaps: " gaps " gini: " precision gini 2)
  ][ report 0 ]
  ;print gini
end

; ###### Utils ########

;; adopted from https://subversion.american.edu/aisaac/notes/netlogo-intro.xhtml#plotting-gini-coefficient-and-lorenz-curve
;;Written by Seth Tisue
to-report partial-sums [nums]
  let total 0
  let result []
  foreach nums [ ?1 ->
    set total total + ?1
    set result lput total result
  ]
  report result
end

;A function to measure the runtime of the model
to profile
  ;setup                                          ;; set up the model
  profiler:start                                  ;; start profiling
  ;repeat 2 [ setup ]                               ;; run something you want to measure
  setup
  go-one-month
  profiler:stop                                  ;; stop profiling
  csv:to-file "profiler_data.csv" profiler:data  ;; save the results
  profiler:reset                                 ;; clear the data
end

;function that reports with a certain probability vessel size to be large or small
to-report getVesselSize
  let maxVessels round (0.5 * num-vessels)
  let ratio 0.5
  let rnd ((random 100) + 1)/ 100

  ifelse (num-small-boats < maxVessels) [
    ifelse (ratio > rnd)
    [ set num-large-vessels num-large-vessels + 1
      report LARGE
    ]
    [ set num-small-boats num-small-boats + 1
      report SMALL
  ]][ ; small vessels have been allocated
      set num-large-vessels num-large-vessels + 1
      report LARGE
  ]
end

; moves the caller close to the agent
; then randomly change direction and stap a bit away
to move-close-to [ agent ]
  if (agent != nobody)[
  move-to agent
  set heading random 360
  fd 2
  ]
end

;moves an agent to a spot in region A in a circle around the centre BUT not on other agents
to move-to-A
  ;set heading ((random 360) + 1)   ;random produces number greater than or equal to 0, but strictly less than 360
  move-to CENTRE-PATCH-A
  set myRegion regA
  ;while [ any? turtles-on patch-ahead 4 ]
  ;[ set heading ((random 360) + 1) ]
  ;fd 4
end

;moves an agent to a spot in region B in a circle around the centre BUT not on other agents
to move-to-B
  ;set heading ((random 360) + 1)   ;random produces number greater than or equal to 0, but strictly less than 360
  move-to CENTRE-PATCH-B
  set myRegion regB
  ;while [ any? turtles-on patch-ahead 4 ]
  ; [ set heading ((random 360) + 1) ]
  ;fd 4
end

;moves an agent to a spot in region B in a circle around the centre BUT not on other agents
to move-to-LAND
  set heading ((random 360) + 1)   ;random produces number greater than or equal to 0, but strictly less than 360
  move-to CENTRE-PATCH-LAND
  set myRegion "land"
  while [ any? turtles-on patch-ahead 4 ]
   [ set heading ((random 360) + 1) ]
  fd 4
end

;A random normal distribution in bounds without weird effects
;source: https://stackoverflow.com/questions/20230685/netlogo-how-to-make-sure-a-variable-stays-in-a-defined-range/20233830#20233830
;WISH Would like to have a function to have skewed normal distributions
to-report random-normal-in-bounds [mid dev mmin mmax]
  let result random-normal mid dev
  if result < mmin or result > mmax
    [ report random-normal-in-bounds mid dev mmin mmax ]
  report result
end

to-report skewed-random-normal-in-bounds [alpha loc scale mmin mmax]
end

;Reports a random-normal number between 0-1
to-report getRandomNormalNum
  let rnd random-normal-in-bounds 50 20 0 100     ;TODO SENSTIVITY ANALSYSIS/CALIBRATION
  report rnd / 100
end

;Reports a random number that is usually low, but 10% of the time high
to-report getRandomRareNum
  let rnd random 100 + 1
  let rnd2 random 50 + 1
  ifelse (rnd > 90)
  [ report (rnd2 + 50) / 100 ] ;rarely
  [ report rnd2 / 100] ;most/90% of the time
end

;reports a random fishing skill [0,1], with 2 decimals precision
;depending on UI setting the type of random distribution is chosen
to-report get-randomFishSkills
  let val precision ((random 10 + 1) / 10) 2  ;UNIFORM is DEFAULT for now
  ifelse (fixedFskills or fishingSkillDistr = "all-0.5") [ set val 0.5 ]
  [ ifelse (fishingSkillDistr = "all-1") [ set val 1 ]
    [ ifelse (fishingSkillDistr = "uniform")
    [ set val precision ((random 10 + 1) / 10) 2 ]
    [ ifelse (fishingSkillDistr = "normal")
      [ set val random-normal-in-bounds THEORETICAL-FSKILL FSKILL-SD ZERO ONE  ] ; TODO check if the values used for trust also hold for skill
      [ show "Syst.err - In get-randomFishSkills: I am using uniform now, the other distributions will be implemented soon" ]
  ]]]
  report val
end

;reports UI-based random trust [0,1] with 2 decimals precision
;depending on the UI setting (high, low, random, low/high for coop vs pcs) different distributions are be generated
to-report get-randomTrust
  let val precision ((random 10 + 1) / 10) 2  ;default is uniform now

  ifelse (trustDistr = "high")
  [ set val random-normal-in-bounds TRUST-HIGH TRUST-SD ZERO ONE ]
  [ ifelse (trustDistr = "low")
    [ set val random-normal-in-bounds TRUST-LOW TRUST-SD ZERO ONE ]
    [ ifelse (trustDistr = "random")
      [ set val precision ((random 10 + 1) / 10) 2 ]
      [ ifelse (trustDistr = "highCoop")
        [] ; This is updated afterwards, see code after calling this function
          [
        show "Syst.err - In get-randomTrust: I am using uniform now, the distribution you selected will be implemented soon"
      ]
  ]]]
  report val
end

;source: https://stackoverflow.com/questions/33815666/generating-permutations-of-a-list-in-netlogo
 to-report combinations [#lst] ;Return all combinations of `lst`
  let n length #lst
  if (n = 0) [report #lst]
  if (n = 1) [report []]
  if (n = 2) [report (list #lst)]

  let result []
  let frst first #lst
  let ndx range n

  foreach ndx [ ? ->
    let el item ? #lst
    set result lput (fput frst el) result

    let #lst2 remove-item ? #lst
    let n2 length #lst2
    let frst2 first #lst2
    let idxs range n2
    foreach idxs [ ?? ->
      let el2 item ? #lst2
      set result lput (fput el el2) result
      set result lput (fput el frst2) result
  ]]
  report result
end

to-report combinations2 [ #lst len ]
  let n length #lst
  if (n = 0) [report #lst]
  if (n = 1) [report []]
  if (n = 2) [report (list #lst)]

  if (len >= n) [
    let result []
    let firstPart sublist #lst 0 len
    let ndx (range (len - 1) n)
    foreach ndx [ ? ->
      let el item ? #lst
      set result lput (fput firstPart el) result
    ]
  ]
end

;Possible group combinations with groupsize len
to-report comb [len #lst]
  if (len = 0) [ report [[]] ]
  if (#lst = []) [ report [] ]
  let _rest butfirst #lst
  let _lista map [? -> fput item 0 #lst ?] comb (len - 1) _rest
  let _listb comb len _rest
  report (sentence _lista _listb)
end


;function that determines how many vessels per organisational there are
; based on the overal number of vessels in the systems
; distributes them evenly over the PCs and Coops
;Note that it could be that the total amount of vessels is lower due to rounding and not distributing 1 vessel over multiple coops
to determine-num-vessels
  let num-pot-coopVessels ((num-fishers-in-coop * num-coops) / CREW-SIZE)
  let num-pot-pcVessels round((num-fishers-in-pc * num-pcs) / CREW-SIZE)
  let sum-potVessels num-pot-coopVessels + num-pot-pcVessels
  let num-vessels-in-system count vessels
  show (sentence "In determine num vessels:  sum-potVessels" num-pot-coopVessels "and num-pot-coopVessels" num-pot-coopVessels)
  ifelse(sum-potVessels <= num-vessels-in-system) [
    set num-vessels-in-coop precision num-pot-coopVessels 0
    set num-vessels-in-pc precision num-pot-pcVessels 0
  ][ ;if they can have more vessels but there are less vessels in the system - distribute
    let vesselratio num-vessels-in-system / (num-pot-coopVessels + num-pot-pcVessels)
    ifelse (num-pcs > 0 and num-coops > 0) [
      set num-vessels-in-coop precision ((num-pot-coopVessels * vesselratio) / num-coops) 0
      set num-vessels-in-pc precision floor((num-vessels-in-system - (num-vessels-in-coop * num-coops)) / num-pcs) 0
      show (sentence "num-vessels-in-pc ( " floor((num-vessels-in-system - (num-vessels-in-coop * num-coops))/ num-pcs))
      ][ ifelse (num-pcs = 0 and num-coops > 0) [
        set num-vessels-in-coop precision floor(num-vessels-in-system / num-coops) 0
        set num-vessels-in-pc 0
        ][ ifelse (num-pcs > 0 and num-coops = 0) [
          set num-vessels-in-pc precision floor(num-vessels-in-system / num-pcs) 0
          set num-vessels-in-coop 0
        ][ ;num-pcs = 0 and num-coops = 0
          show "Syst.err in determine-num-vessels: both num-pcs and num-coops are 0, so I switch noFishing on"
          set noFishing true
  ]]]]
  ;verification of functioning:
  show (sentence "In determine-num-vessels: num-vessels-in-pc = " num-vessels-in-pc" and num-vessels-in-coop = " num-vessels-in-coop)
end

; ###### Layout functions ########

;Adapts the layout in the interface provided by the interface settings
;Visibility of (particular) links/relations
to layout
  alignOrgas
  with-local-randomness [ ask fuels [ move-close-to fuel-owner ]]
  with-local-randomness [ ask links [ hide-link ]]
  ifelse (show-relations = "all")
  [ with-local-randomness [ ask links [ show-link]]
    with-local-randomness [ ask mobilityLinks [ set color green ]]
    with-local-randomness [ ask enskillmentLinks [ set color violet ]]
    with-local-randomness [ ask histOfCoopLinks [ set color red ]]]
  [ ifelse (show-relations = "enskillmentLinks")
    [ with-local-randomness [ ask enskillmentLinks   [
      show-link set color violet
      ]]
    ]
    [ ifelse (show-relations = "mobilityLinks")
      [ with-local-randomness [ ask mobilityLinks [ show-link set color green ]]]
      [ ifelse (show-relations = "histOfCoopLinks")
        [ with-local-randomness [ ask histOfCoopLinks  [
            show-link set color red
          set thickness ((coopHistory * MAXPIXELS-LINK) / MAX-THIGHTNESS-COOP) ]]]
        [ if not(show-relations = "none") [ print ("Input.err in layout: none of the show-relations options were selected")]]
]]]
  if (align-members = true) [
  with-local-randomness [ ask orgas [
        let this-orga self
        with-local-randomness [ ask  members [
        move-to this-orga set heading heading + 180 fd 1.5
  ]]]]]
  with-local-randomness [ ask humans with [buyerid = 1] [
    move-to turtle orgaid ]]

  if (align-vessels = true) [
    with-local-randomness [ ask vessels [ move-close-to owner ]]
  ]

end

; this function aligns PC and coopertive organizations on two separate lines
to alignOrgas
  distribute orgas with [orgatype = PC-OTYPE ] 17
  distribute orgas with [orgatype = COOP-OTYPE] 25
end

; this function makes the individuals spread out on a specified vertical line
to distribute [individuals line]
  let height max-pycor - (max-pycor / 3)
  let counter count individuals
  if counter > 0
   [ let gap height / counter
     let half-gap gap / 2
     ask individuals
     [ set counter counter - 1
       set xcor line
       set ycor half-gap + gap * counter + (max-pycor / 3)
     ]
   ]
end

;######### GETTERS and SETTERS

to-report ELEMENTS
  report turtles
end

to-report NUM-HUMANS
  report count humans
  ;NUM-BUYERS + NUM-FISHERS
end

;Just 2 to get starting simple for now
to-report INIT-NUM-BUYERS
  report 2
end

;Just 2 to get starting simple for now
to-report INIT-NUM-FISH
  report 2
end

;Just 6 to get starting simple for now
to-report NUM-FISHERS
  report count humans with [ fisherID = 1]  ; TODO calibrate
end

;Maximum amount of permits granted in the system, i.e. number of relations/links to this permit agent
to-report MAX-PERMITS
  report 5;
end

;Number of fish (stock) elements in the system, not to be confused with the total amount of fishstock in the system
to-report NUM-FISH
  report count fishs
end

;Just 1 as the wind can affect them all, we choose not to nuance it that differnt types of wind go over the spatial area for simplicity sake and it is not that important
to-report NUM-WIND
  report 1
end

;; Returns the CARCAP given a certain metier for the a fish stock.
;; based on a capacity that allows for theoretically dealing with X vessels sustainably, while being at MSY-STOCK = 0.5 CARCAP
; Generic case = fishers are assumed to have a default fishing skill (=1), biomass density is assumed to be at CARCAP (density = 1),
; generic yearly harvest = max-catch * e(-(msyBiomassDensity * generic-catchability)) * numfishers-theoretical * mean-yearly-fishing-days
; = METIER-MAX-CATCH-GENERIC-ABC-SLN * 1 - e(-(50 * CATCHABILITY-MGC-NR) * NUM *VESSELS
to-report CARCAP
;  let biomassDens-MSY 0.5 ; 50%, biomass / carcap * 100
;  let generic-yearly-harvest (metier-max-catch * exp(- biomassDens-MSY * CATCHABILITY)) * THEORETICAL-NUM-VESSELS * DAYS-IN-YEAR
;  let generic-yearly-harvest metier-max-catch * THEORETICAL-NUM-VESSELS * DAYS-IN-YEAR  ;TODO check - my simple minded reasoning
;  report round (4 * generic-yearly-harvest / GRROWTH-RATE)
  report 100000
end

;Growthrate of the fish - for now just an arbitrary number used for the initialisation
to-report GRROWTH-RATE
 report 0.4
end

;Growthrate of the fish while regenerating - slighly lower thant the GRROWTH-RATE just to make sure to have a good basedline and demo scenario
to-report GRROWTH-RATE2
 report 0.38
end

;the cycles (after x days in the year) in which the fish is updated)
to-report fish-update-freq
  report 365
end

;Catchability - for now just an arbitrary number
to-report CATCHABILITY
  report 1
end

;Fishing skill used to intitialise and calibrate the fishery
;Reflects an average fishing skill (0 is min, 1 is max).
to-report THEORETICAL-FSKILL
  report 0.5
end

;The amount of vessels the system should theoretically sustain
to-report THEORETICAL-NUM-VESSELS
  report 5
end

; This functions derives the # fishing effort for a fisher with two 2 fish stocks each 10000 CARCAP,
; in which 5 large and 5 small vessels fish, where the large vessels can catch 2x as much as the small vessels.
; For this we use the logistic growth function for the fish population the total catch at MSY is carcap*growthrate/4
; catch-to-stay-at-msy= CARCAP * growthRate / 4  # or in more common fishery modelling terms: H_msy=K*r/4
to derive-vessel-effort
  let totalCarCap CARCAP * 2    ; 2 fish stocks
  let msyStock totalCarCap * 0.5
  let yearlyMSYcatch totalCarCap * GRROWTH-RATE / 4
  let msy-daily-catch yearlyMSYcatch / DAYS-IN-YEAR
  ;show (sentence "dailyMSYcatch: "msy-daily-catch " (totalCarCap: " totalCarCap")")

  ;total effort at MYS = E_msy = catch_msy / (fskill * msyStock)
  let dailyMSYeffort msy-daily-catch / (THEORETICAL-FSKILL * msyStock)

  let magic-nr1 1.5  ;constant derived from the fact that the effort needs to reflect that large vessel catch is twice that of the small vessel
  let magic-nr2 0.75

  set EFFORT-SVSSL dailyMSYeffort / (magic-nr1 * THEORETICAL-NUM-VESSELS)
  set EFFORT-LVSSL dailyMSYeffort / (magic-nr2 * THEORETICAL-NUM-VESSELS)

  ;show (sentence "In derive vessel effort: daily msy effort: " dailyMSYeffort "smallVessel effort: " (precision EFFORT-SVSSL 7) "largeVessel effort: " (precision EFFORT-LVSSL 7))
end

;Report the yearly catch to stay at MSY
;Follows the narrative of 10 vessels (5 small, 5 large), fishing everyday with small catching half of large vessels,
;all with an average fishing skill (0.5)
to-report daily-MSY-catch
  let currentStock sum [ myStock ] of fishs        ;
  ;show (sentence "Total stock" totalStock)

  let msy-catch THEORETICAL-FSKILL * (THEORETICAL-NUM-VESSELS / 2) * (EFFORT-SVSSL + EFFORT-LVSSL) * currentStock
  report msy-catch
  ;show (sentence "Total Harvest = " yearHarvest)
end

to-report DAYS-IN-YEAR
  report 365
end

;reports cost for fuel for a large vessel (twice the amount of a small vessel)
to-report FUEL-COST-L
report 2 * FUEL-COST-S
end

;reports cost for fuel for a small vessel
to-report FUEL-COST-S
report 3
end

;Fuel cost used in the scenarios - maintain and disappear with 2 boats (S and L) per orga
to-report FUEL-COST-ORGA
  report (FUEL-COST-S + FUEL-COST-L)
end

;reports the centre patch in region A
to-report CENTRE-PATCH-A
  ;report (patch 5 15)
  report (patch 5 15)
end
;reports the centre patch in region B
to-report CENTRE-PATCH-B
  ;report (patch 15 15)
  report (patch 10 15)
end

;reports the centre patch in land
to-report CENTRE-PATCH-LAND
  ;report (patch 25 15)
  report (patch 20 15)
end


;the maximum thickness that a link in the UI will reach
to-report MAXPIXELS-LINK
  report 0.4
end

;The maximum amount of resources an agent can invest in getting a permit (1 for knowledge and 1 for willingnes)
to-report MAX-PERMIT-RESOURCES
report 2 ;
end

; After this duraction of cooperation the link thickness will reach its maximum
;TODO calibrate this amount based on the duation of the simulation and the time relation with the real world of 1 tick. Maybe 10 years of collab?
to-report MAX-THIGHTNESS-COOP
report 100;
end

to-report ZERO
  report 0
end

to-report ONE
  report 1
end

;Max duration of cooperation to affect the max of coopPower
;set to 5 years
to-report MAXCOOP
  report 5 * DAYS-IN-YEAR
end

;Constant used to make distrubutions around a trust value - here high
to-report TRUST-HIGH
  report 0.8
end

;Constant used to make distrubutions around a trust value - here low
to-report TRUST-LOW
  report (1 - TRUST-HIGH)
end

;Standard deviation used to initalise a trust distributions
;TODO sensitivity analysis
to-report TRUST-SD
  report 0.1
end


;reports the size of a crew for a vessel - 3 agents
to-report CREW-SIZE
  report 3
end

to-report MOBILITY
  report "mobilityLinks"
end

to-report ENSKILLMENT
  report "enskillmentLinks"
end

to-report HISTOFCOOP
  report "histOfCoopLinks"
end

;everytime one has a positive experience fishing, skill increases with 0.01
;Fishing skill increase reflects that one can acquire a skill from 0-1 over the course of 15 years of daily fishing
to-report SKILL-INCREASE
  ifelse (fixedFskills)
  [ report 0 ]
  [ report 1 / (15 * DAYS-IN-YEAR) ]
end

;everytime a fisher doesn't go out fishing
;fishing skill decay rate reflects that one completely loses the skill by consecutively not fishing for 5 years
to-report SKILL-DECAY
  report 1 / (10 * DAYS-IN-YEAR)
end


to-report PC-OTYPE
  report "PC"
end

to-report COOP-OTYPE
  report "COOP"
end

to-report SMALL
  report "small"
end

to-report LARGE
  report "large"
end

to-report regA
  report "rgnA"
end

to-report regB
  report "rgnB"
end
@#$#@#$#@
GRAPHICS-WINDOW
1477
41
1933
498
-1
-1
14.452
1
10
1
1
1
0
0
0
1
0
30
0
30
1
1
1
ticks
30.0

BUTTON
21
55
113
89
NIL
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1

BUTTON
191
56
263
89
NIL
go
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
0

TEXTBOX
19
10
169
35
BeeCome
20
105.0
1

TEXTBOX
21
36
231
64
A relation-based model on fisheries
11
0.0
1

SLIDER
17
665
185
698
wind-strength
wind-strength
0
1
0.0
0.1
1
NIL
HORIZONTAL

TEXTBOX
1488
54
1544
86
regionA
13
0.0
1

TEXTBOX
1606
57
1658
75
regionB
13
0.0
1

CHOOSER
16
617
189
662
wind-scenario
wind-scenario
"manual" "random" "seasonal" "noWind" "windOn"
0

BUTTON
115
56
189
89
step
go\n
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1

PLOT
275
57
563
248
Fish stock
NIL
NIL
0.0
10.0
0.0
10.0
true
true
"" ";ask fishs [\n;  create-temporary-plot-pen (word who)\n;  set-plot-pen-color color\n;  plotxy ticks myStock\n;]"
PENS
"fishA" 1.0 0 -11221820 true "" "if (ticks > 0 and turtle 0 != nobody) [ plot [ myStock ] of fish 0 ]"
"fishB" 1.0 2 -13791810 true "" "if (ticks > 0 and turtle 1 != nobody )[ plot [ myStock ] of fish 1 ]"
"msy" 1.0 2 -4539718 true "" "plot 50000"

SLIDER
738
990
910
1023
permitHolderRatio
permitHolderRatio
0
1
1.0
0.1
1
NIL
HORIZONTAL

SLIDER
740
1033
913
1066
moneyFuelAccessRatio
moneyFuelAccessRatio
0
1
1.0
0.1
1
NIL
HORIZONTAL

CHOOSER
1780
506
1932
551
show-relations
show-relations
"none" "enskillmentLinks" "mobilityLinks" "histOfCoopLinks" "all"
0

BUTTON
1842
560
1916
593
redraw
layout
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1

SLIDER
18
1009
138
1042
CoopHistMean
CoopHistMean
0
15
5.0
5
1
NIL
HORIZONTAL

SLIDER
17
1046
137
1079
CoopHistSD
CoopHistSD
0
5
0.5
0.5
1
NIL
HORIZONTAL

TEXTBOX
20
988
212
1006
Human-Human/Orga relations
11
0.0
1

SWITCH
739
954
868
987
rndFuelPermit
rndFuelPermit
1
1
-1000

BUTTON
114
90
190
123
NIL
go-1-year
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1

SLIDER
19
481
164
514
num-coops
num-coops
0
10
5.0
1
1
NIL
HORIZONTAL

SLIDER
573
950
679
983
num-pcs
num-pcs
0
20
0.0
1
1
NIL
HORIZONTAL

SLIDER
572
1029
721
1062
num-fishers-in-PC
num-fishers-in-PC
1
6
0.0
1
1
NIL
HORIZONTAL

SLIDER
19
555
169
588
num-fishers-in-coop
num-fishers-in-coop
0
50
6.0
1
1
NIL
HORIZONTAL

PLOT
2198
367
2427
517
Fishery assemblage II
time
coopPower
0.0
10.0
0.0
100.0
true
true
"" ""
PENS
"GOFAs" 1.0 0 -2674135 true "" "if (any? gofas) [ plot mean [ gofa-coopPower ] of gofas ]"
"ORGAs" 1.0 0 -1184463 true "" "if (any? orgas) [ plot mean [ orga-coopPower ] of orgas ]"

CHOOSER
143
1008
264
1053
trustDistr
trustDistr
"high" "low" "random" "highCoop" "lowPCs-highCoop" "highPCs-lowCoop"
0

PLOT
1937
41
2192
209
GOFAs
NIL
NIL
0.0
10.0
0.0
1.0
true
true
"" ""
PENS
"minFskill" 1.0 0 -5204280 true "" "if (any? gofas) [ plot min [ gofa-fishSkill ] of gofas ]"
"maxFskill" 1.0 0 -8630108 true "" "if (any? gofas) [ plot max [ gofa-fishSkill ] of gofas ]"
"avgFskill" 1.0 0 -7500403 true "" "if (any? gofas) [ plot mean [ gofa-fishSkill ] of gofas ]"

MONITOR
515
214
578
259
fishStock
precision sum [ mystock ] of fishs 1
17
1
11

MONITOR
1320
475
1460
520
# GOFAs possiblity space
length goFassemblages
17
1
11

MONITOR
1321
521
1404
566
maxGOFAs
num-vessels
17
1
11

TEXTBOX
19
459
169
477
Settings for init-orgas
13
0.0
1

TEXTBOX
740
929
945
961
Settings no init-orgas (todo)
13
0.0
1

TEXTBOX
21
596
107
614
Externalities
13
0.0
1

TEXTBOX
22
214
183
232
Human-Fish relation init
13
0.0
1

CHOOSER
21
236
130
281
fishingSkillDistr
fishingSkillDistr
"all-0.5" "uniform" "normal"
1

PLOT
1037
427
1315
587
ORGA capital
NIL
NIL
0.0
10.0
0.0
10.0
true
true
"\n" ""
PENS
"Coop" 1.0 0 -5825686 true "" "if (ticks > 0 and any? COOPS) [ plot mean [ capital ] of COOPS]"
"trust" 1.0 0 -7500403 false "" ";plot 0"
"cheating" 1.0 0 -2674135 false "" ";plot 0 "
"coop+sd" 1.0 2 -865067 false "" "if (ticks > 0 and count COOPS > 1) [ plot mean [ capital ] of COOPS + (standard-deviation [ capital ] of COOPS)]"
"PC" 1.0 0 -6459832 true "" "if (ticks > 0 and any? pcs) [ plot mean [ capital ] of pcs ]"
"coop-sd" 1.0 2 -865067 true "" "if (ticks > 0 and count COOPS > 1) [ plot mean [ capital ] of orgas with [ orgaType = COOP-OTYPE ] - (standard-deviation [ capital ] of COOPS)]"
"pc-sd" 1.0 2 -3889007 true "" "if (ticks > 0 and count pcs > 1) [ plot mean [ capital ] of pcs - (standard-deviation [ capital ] of pcs)]"
"pc+sd" 1.0 2 -3889007 true "" "if (ticks > 0 and count pcs > 1) [ plot mean [ capital ] of orgas with [ orgaType = PC-OTYPE ] + (standard-deviation [ capital ] of orgas with [ orgaType = PC-OTYPE ])]"

BUTTON
21
91
111
125
NIL
go-one-month
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1

MONITOR
516
124
577
169
fishsA
precision [ myStock ] of fish 0 1
17
1
11

MONITOR
516
169
577
214
fishsB
precision [ myStock ] of fish 1 1
17
1
11

PLOT
2197
65
2428
208
fishSkill distribution
NIL
NIL
0.0
10.0
0.0
10.0
true
false
"" ""
PENS
"skill" 1.0 1 -16777216 true "" "if(any? fishingLinks) [ histogram [ skill * 10 ] of fishingLinks ]"

SWITCH
17
718
136
751
autoSeed?
autoSeed?
0
1
-1000

MONITOR
145
718
265
763
NIL
autoSeed
17
1
11

INPUTBOX
18
756
135
816
manualSeed
-7.60696631E8
1
0
Number

PLOT
1946
498
2175
642
coopPowerPossibleGOFAs
NIL
NIL
0.0
5000.0
0.0
10.0
true
false
"" ""
PENS
"default" 1.0 1 -16777216 true "" "if not (empty? coopPowerList) [ histogram coopPowerList ]"

PLOT
2198
214
2425
364
GOFA catch
NIL
NIL
0.0
5.0
0.0
10.0
true
false
"" ""
PENS
"default" 1.0 0 -16777216 true "" "if (ticks > 0 and any? GOFAS) [ plot mean [ gofa-catch ] of gofas ]"
"pen-1" 1.0 2 -7500403 true "" "if (ticks > 0 and any? GOFAS) [ plot mean [ gofa-catch ] of gofas + (standard-deviation [ gofa-catch ] of gofas)]"
"pen-2" 1.0 2 -7500403 true "" "if (ticks > 0 and any? GOFAS) [ plot mean [ gofa-catch ] of gofas - (standard-deviation [ gofa-catch ] of gofas)]"

SWITCH
312
975
430
1008
MSY-Fishing
MSY-Fishing
1
1
-1000

SWITCH
312
941
431
974
noFishing
noFishing
1
1
-1000

SLIDER
17
940
122
973
initStock
initStock
0
1
0.5
0.1
1
NIL
HORIZONTAL

MONITOR
274
10
327
55
year
precision (floor ticks / DAYS-IN-YEAR) 0
17
1
11

SLIDER
19
518
166
551
num-vessels-in-coop
num-vessels-in-coop
0
10
2.0
1
1
NIL
HORIZONTAL

SLIDER
573
989
718
1022
num-vessels-in-pc
num-vessels-in-pc
0
5
0.0
1
1
NIL
HORIZONTAL

TEXTBOX
175
530
273
601
num fishers are set according to num vessels and crew size
11
0.0
1

TEXTBOX
21
919
171
937
Sensitivity / Calibration
11
0.0
1

SLIDER
142
940
251
973
FSKILL-SD
FSKILL-SD
0
0.5
0.1
0.1
1
NIL
HORIZONTAL

SWITCH
313
1012
430
1045
fixedFskills
fixedFskills
1
1
-1000

PLOT
566
611
856
775
total catch
NIL
NIL
0.0
10.0
0.0
10.0
true
true
"" ""
PENS
"totalCatch" 1.0 0 -16777216 true "" "plot sum [ gofa-catch ] of GOFAS"
"Svessels" 1.0 0 -10141563 true "" "plot sum [ catch ] of vessels with [ vsize = \"small\" ] "
"Lvessels" 1.0 0 -14070903 true "" "plot sum [ catch ] of vessels with [ vsize = \"large\" ] "

MONITOR
2197
528
2269
573
gofaRatio
precision gofaRatio 2
17
1
11

BUTTON
190
90
264
123
go-5-years
repeat 5 [ go-1-year ]
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1

TEXTBOX
314
923
464
941
Testing 
11
0.0
1

TEXTBOX
734
907
884
927
TODO
16
0.0
1

PLOT
580
58
855
220
ORGA 12
NIL
NIL
0.0
10.0
0.0
1.0
true
true
"" ""
PENS
"2" 1.0 0 -3026479 false "" "plot 2"
"4" 1.0 0 -3026479 false "" "plot 4"
"6" 1.0 0 -3026479 false "" "plot 6"
"8" 1.0 0 -3026479 false "" "plot 8"
"#boatsOut" 1.0 0 -16777216 true "" "if (ticks > 0) [ ask turtle 12 [ plot numVessels-Act ]]"
"dayCatchB" 1.0 0 -13791810 true "" "if (ticks > 0 and plotCatchAB) [ ask turtle 12 [ plot orga-daycatchB ]]"
"dayCatchA" 1.0 0 -8990512 true "" "if (ticks > 0 and plotCatchAB) [ ask turtle 12 [ plot orga-daycatchA ]]"
"totCatch" 1.0 0 -14730904 true "" "if (ticks > 0 and not plotCatchAB) [ ask turtle 12 [ plot orga-daycatches ]] "
"fskill1" 1.0 0 -8630108 true "" "if (ticks > 0 and fskillsx10) [ ask turtle 12 [ plot first orga-gofaSkills * 10 ]]"
"fskill2" 1.0 0 -5204280 true "" "if (ticks > 0 and fskillsx10) [ ask turtle 12 [ plot last orga-gofaSkills * 10]]"

PLOT
1486
511
1713
677
% GOFAs (from max possible actualisable GOFAs)
NIL
NIL
0.0
100.0
0.0
10.0
true
false
"" ""
PENS
"default" 1.0 0 -16777216 true "" "if (ticks > 0 and any? GOFAS) [\nplot min list 100 (numActualisedGOFAs / num-vessels * 100)\n]"
"100%" 1.0 2 -8630108 true "" "plot 100;plot numPossibleGOFAs"

MONITOR
1715
588
1789
633
possibleGOFAs
numPossibleGOFAs
17
1
11

MONITOR
1404
521
1480
566
actlsGOFAs
numActualisedGOFAs
17
1
11

MONITOR
1715
633
1789
678
% GOFAs
;if (ticks > 0) [ (min list 100 (numActualisedGOFAs / num-vessels * 100)]\nmin list 100 (precision (numActualisedGOFAs / num-vessels * 100) 1)
17
1
11

CHOOSER
18
1102
136
1147
init-capital
init-capital
"all-oneDay" "all-week" "all-month" "mixed-1-7days"
1

PLOT
1937
214
2191
364
Catch distribution
NIL
NIL
0.0
10.0
0.0
10.0
true
false
"" ""
PENS
"default" 1.0 1 -16777216 true "" "if(any? vessels) [ histogram [ catch ] of vessels]"
"smallBoats" 1.0 1 -3844592 true "" "if(any? small-boats) [ histogram [ catch ] of small-boats]"

PLOT
274
609
563
772
ORGA capital 
NIL
NIL
0.0
10.0
0.0
10.0
true
true
"" ""
PENS
"default" 1.0 0 -16777216 false "" "if ticks > 0 [\n  ask ORGAS [\n    create-temporary-plot-pen (word who \" \" orgaType)\n    set-plot-pen-color who;(random 135)\n    plotxy ticks capital\n  ]\n]"

TEXTBOX
18
1083
165
1101
ORGA capital initialisation
11
0.0
1

MONITOR
1319
428
1416
473
NIL
orgas-died-today
17
1
11

SLIDER
17
1148
136
1181
FISH-PRICE
FISH-PRICE
1
10
4.5
0.5
1
NIL
HORIZONTAL

TEXTBOX
575
924
725
942
Currently not in use
11
0.0
1

SWITCH
136
237
258
270
fskillDynamic
fskillDynamic
1
1
-1000

PLOT
580
241
861
403
ORGA 22
NIL
NIL
0.0
10.0
0.0
10.0
true
true
"" ""
PENS
"2" 1.0 0 -3026479 false "" "plot 2"
"4" 1.0 0 -3026479 false "" "plot 4"
"6" 1.0 0 -3026479 false "" "plot 6"
"8" 1.0 0 -3026479 false "" "plot 8"
"#boatsOut" 1.0 0 -16777216 true "" "if (ticks > 0) [ ask turtle 22 [ plot numVessels-Act ]]"
"dayCatchB" 1.0 0 -13791810 true "" "if (ticks > 0 and plotCatchAB) [ ask turtle 22 [ plot orga-daycatchB ]]"
"dayCatchA" 1.0 0 -11221820 true "" "if (ticks > 0 and plotCatchAB) [ ask turtle 22 [ plot orga-daycatchA ]]"
"totCatch" 1.0 0 -14730904 true "" "if (ticks > 0 and not plotCatchAB) [ ask turtle 22 [ plot orga-daycatches ]]"
"fskill1" 1.0 0 -8630108 true "" "if (ticks > 0 and fskillsx10) [ ask turtle 22 [ plot first orga-gofaSkills * 10 ]]"
"fskill2" 1.0 0 -5204280 true "" "if (ticks > 0 and fskillsx10) [ ask turtle 22 [ plot last orga-gofaSkills * 10]]"

PLOT
582
427
863
590
ORGA 32
NIL
NIL
0.0
10.0
0.0
10.0
true
true
"" ""
PENS
"2" 1.0 0 -3026479 false "" "plot 2"
"4" 1.0 0 -3026479 false "" "plot 4"
"6" 1.0 0 -3026479 false "" "plot 6"
"8" 1.0 0 -3026479 false "" "plot 8"
"#boatsOut" 1.0 0 -16777216 true "" "if (ticks > 0) [ ask turtle 32 [ plot numVessels-Act ]]"
"dayCatchB" 1.0 0 -13791810 true "" "if (ticks > 0 and plotCatchAB) [ ask turtle 32 [ plot orga-daycatchB ]]"
"dayCatchA" 1.0 0 -8990512 true "" "if (ticks > 0 and plotCatchAB) [ ask turtle 32 [ plot orga-daycatchA ]]"
"totCatch" 1.0 0 -14070903 true "" "if (ticks > 0 and not plotCatchAB) [ ask turtle 32 [ plot orga-daycatches ]]"
"fskill1" 1.0 0 -8630108 true "" "if (ticks > 0 and fskillsx10) [ ask turtle 32 [ plot first orga-gofaSkills * 10 ]]"
"fskill2" 1.0 0 -5204280 true "" "if (ticks > 0 and fskillsx10) [ ask turtle 32 [ plot last orga-gofaSkills * 10]]"

PLOT
1028
57
1304
219
ORGA 42
NIL
NIL
0.0
10.0
0.0
10.0
true
false
"" ""
PENS
"2" 1.0 0 -3026479 false "" "plot 2"
"4" 1.0 0 -3026479 false "" "plot 4"
"6" 1.0 0 -3026479 false "" "plot 6"
"8" 1.0 0 -3026479 false "" "plot 8"
"#boatsOut" 1.0 0 -16777216 true "" "if (ticks > 0) [ ask turtle 42 [ plot numVessels-Act ]]"
"dayCatchB" 1.0 0 -13791810 true "" "if (ticks > 0 and plotCatchAB) [ ask turtle 42 [ plot orga-daycatchB ]]"
"dayCatchA" 1.0 0 -8990512 true "" "if (ticks > 0 and plotCatchAB) [ ask turtle 42 [ plot orga-daycatchA ]]"
"totCatch" 1.0 0 -14730904 true "" "if (ticks > 0 and not plotCatchAB) [ ask turtle 42 [ plot orga-daycatches ]]"
"fskill1" 1.0 0 -8630108 true "" "if (ticks > 0 and fskillsx10) [ ask turtle 42 [ plot first orga-gofaSkills * 10 ]]"
"fskill2" 1.0 0 -5204280 true "" "if (ticks > 0 and fskillsx10) [ ask turtle 42 [ plot last orga-gofaSkills * 10]]"

PLOT
1033
246
1308
407
ORGA 52
NIL
NIL
0.0
10.0
0.0
10.0
true
false
"" ""
PENS
"2" 1.0 0 -3026479 false "" "plot 2"
"4" 1.0 0 -3026479 false "" "plot 4"
"6" 1.0 0 -3026479 false "" "plot 6"
"8" 1.0 0 -3026479 true "" "plot 8"
"#boatsOut" 1.0 0 -16777216 true "" "if (ticks > 0) [ ask turtle 52 [ plot numVessels-Act ]]"
"dayCatchB" 1.0 0 -13791810 true "" "if (ticks > 0 and plotCatchAB) [ ask turtle 52 [ plot orga-daycatchB ]]"
"dayCatchA" 1.0 0 -11221820 true "" "if (ticks > 0 and plotCatchAB) [ ask turtle 52 [ plot orga-daycatchA ]]"
"totCatch" 1.0 0 -14730904 true "" "if (ticks > 0 and not plotCatchAB) [ ask turtle 52 [ plot orga-daycatches ]]"
"fskill1" 1.0 0 -8630108 true "" "if (ticks > 0 and fskillsx10) [ ask turtle 52 [ plot first orga-gofaSkills * 10 ]]"
"fskill2" 1.0 0 -5204280 true "" "if (ticks > 0 and fskillsx10) [ ask turtle 52 [ plot last orga-gofaSkills * 10]]"

MONITOR
858
186
912
231
cap12
round ([ capital ] of turtle 12)
17
1
11

MONITOR
864
372
915
417
cap22
round ([ capital ] of turtle 22)
17
1
11

MONITOR
865
557
918
602
cap32
round ([ capital ] of turtle 32)
17
1
11

MONITOR
1308
187
1359
232
cap42
round ([ capital ] of turtle 42)
17
1
11

MONITOR
1311
376
1362
421
cap52
round ([ capital ] of turtle 52)
17
1
11

SLIDER
141
1102
262
1135
highCapital
highCapital
0
1000
1000.0
5
1
NIL
HORIZONTAL

MONITOR
965
327
1021
372
profit22
precision [ earnings - FUEL-COST-ORGA ] of turtle 22 2\n;[ numVessels-Act ] of turtle 22\n;[ numLboats-Act ] of turtle 22
17
1
11

MONITOR
961
142
1012
187
profit12
precision [ earnings - FUEL-COST-ORGA ] of turtle 12 2\n;[ numVessels-Act ] of turtle 12\n;[ numLboats-Act ] of turtle 12
17
1
11

MONITOR
955
513
1010
558
proft32
precision [ earnings - FUEL-COST-ORGA ] of turtle 32 2\n;[ numVessels-Act ] of turtle 32\n;[ numLboats-Act ] of turtle 32
17
1
11

MONITOR
1359
188
1410
233
#btsOut42
[ numVessels-Act ] of turtle 42
17
1
11

MONITOR
1361
376
1412
421
#btsOut52
[ numVessels-Act ] of turtle 52
17
1
11

MONITOR
910
142
961
187
ctch11
precision ([ catch ] of turtle 11) 2
17
1
11

MONITOR
858
142
910
187
ctch10
precision ([ catch ] of turtle 10) 2
17
1
11

MONITOR
863
327
914
372
ctch20
precision [ catch] of turtle 20 2
17
1
11

MONITOR
914
327
965
372
ctch21
precision [catch] of turtle 21 2
17
1
11

MONITOR
865
513
917
558
ctch30
precision [catch] of turtle 30 2
17
1
11

MONITOR
904
513
955
558
ctch31
precision [catch] of turtle 31 2
17
1
11

MONITOR
1311
331
1362
376
ctch50
precision [catch] of turtle 50 2
17
1
11

MONITOR
1361
331
1412
376
ctch51
precision [catch] of turtle 51 2
17
1
11

MONITOR
1307
143
1358
188
ctch40
precision [catch] of turtle 40 2
17
1
11

MONITOR
1359
143
1410
188
ctch41
precision [catch] of turtle 41 2
17
1
11

TEXTBOX
54
135
247
153
RBM scenarios
14
0.0
1

SWITCH
597
16
719
49
plotCatchAB
plotCatchAB
1
1
-1000

MONITOR
858
53
937
98
fskillA_12
[ orga-gofaSkillsA ] of turtle 12
17
1
11

MONITOR
939
53
1018
98
fskillB_12
[ orga-gofaSkillsB ] of turtle 12
17
1
11

SWITCH
739
16
856
49
fskillsx10
fskillsx10
0
1
-1000

MONITOR
863
237
941
282
fskillA_22
[ orga-gofaSkillsA ] of turtle 22
17
1
11

MONITOR
941
237
1022
282
fskillB_22
[ orga-gofaSkillsB ] of turtle 22
17
1
11

MONITOR
865
424
942
469
fskillA_32
[ orga-gofaSkillsA ] of turtle 32
17
1
11

MONITOR
944
424
1023
469
fskillB_32
[ orga-gofaSkillsB ] of turtle 32
17
1
11

MONITOR
858
98
1003
143
gofaCrews_12
[ orga-gofaCrews ] of turtle 12
17
1
11

MONITOR
865
469
1001
514
gofaCrews_32
[ orga-gofaCrews ] of turtle 32
17
1
11

MONITOR
863
282
1011
327
gofaCrews_22
[ orga-gofaCrews ] of turtle 22
17
1
11

MONITOR
1306
53
1386
98
fskillA_42
[ orga-gofaSkillsA ] of turtle 42
17
1
11

MONITOR
1388
53
1468
98
fskillB_42
[ orga-gofaSkillsB ] of turtle 42
17
1
11

MONITOR
1310
241
1386
286
fskillA_52
[ orga-gofaSkillsA ] of turtle 52
17
1
11

MONITOR
1387
241
1464
286
fskillB_52
[ orga-gofaSkillsB ] of turtle 52
17
1
11

MONITOR
1306
98
1446
143
gofaCrews_42
[ orga-gofaCrews ] of turtle 42
17
1
11

MONITOR
1311
286
1448
331
gofaCrews_52
[ orga-gofaCrews ] of turtle 52
17
1
11

MONITOR
912
186
963
231
#btsOut12
[ numVessels-Act ] of turtle 12
17
1
11

MONITOR
963
187
1025
232
#LbOut12
[ numLboats-Act ] of turtle 12
17
1
11

MONITOR
914
372
965
417
#btsOut22
[ numVessels-Act ] of turtle 22
17
1
11

MONITOR
965
372
1028
417
#LbOut22
[ numLboats-Act ] of turtle 22
17
1
11

MONITOR
917
558
968
603
#btsOut32
[ numVessels-Act ] of turtle 32
17
1
11

MONITOR
967
559
1031
604
#LbOut32
[ numLboats-Act ] of turtle 32
17
1
11

MONITOR
1409
188
1469
233
#LbOut42
[ numLboats-Act ] of turtle 42
17
1
11

MONITOR
1411
376
1473
421
#LbOut52
[ numLboats-Act ] of turtle 52
17
1
11

MONITOR
1409
143
1466
188
profit42
precision [ earnings - FUEL-COST-ORGA ] of turtle 42 2\n;[ numVessels-Act ] of turtle 42\n;[ numLboats-Act ] of turtle 42
17
1
11

MONITOR
1411
331
1468
376
profit52
precision [ earnings - FUEL-COST-ORGA ] of turtle 52 2\n;[ numVessels-Act ] of turtle 52\n;[ numLboats-Act ] of turtle 52
17
1
11

MONITOR
736
186
856
231
gofaCoopPower_12
[ orga-gofaCoopPower ] of turtle 12
17
1
11

MONITOR
738
375
861
420
gofaCoopPower_22
[ orga-gofaCoopPower ] of turtle 22
17
1
11

MONITOR
724
556
858
601
gofaCoopPower_32
[ orga-gofaCoopPower ] of turtle 32
17
1
11

MONITOR
1170
183
1304
228
gofaCoopPower_42
[ orga-gofaCoopPower ] of turtle 42
17
1
11

MONITOR
1176
373
1310
418
gofaCoopPower_52
[ orga-gofaCoopPower ] of turtle 52
17
1
11

MONITOR
276
362
333
407
catchA
precision ([ caught-this-tick ] of turtle 0) 1
17
1
11

MONITOR
336
361
400
406
boatsInA
[ num-boats-this-tick ] of turtle 0
17
1
11

MONITOR
412
407
470
452
%boatsInB
[ perc-boats-this-tick ] of turtle 1
17
1
11

MONITOR
336
408
400
453
#LboatsA
[ num-L-boats-this-tick] of turtle 0
17
1
11

MONITOR
274
457
416
502
boatsIDsA
[ who-visited ] of turtle 0\n;[ who-visited ] of fish in region A
17
1
11

MONITOR
413
360
470
405
catchB
precision ([ caught-this-tick ] of turtle 1) 1
17
1
11

MONITOR
472
360
534
405
boatsInB
[ num-boats-this-tick ] of turtle 1
17
1
11

MONITOR
276
409
334
454
%boatsInA
[ perc-boats-this-tick ] of turtle 0
17
1
11

MONITOR
473
407
533
452
#LboatsB
[ num-L-boats-this-tick] of turtle 1
17
1
11

MONITOR
422
458
563
503
boatsIDsB
[ who-visited ] of turtle 1
17
1
11

SWITCH
315
1089
525
1122
randomActualisationInfo
randomActualisationInfo
0
1
-1000

SWITCH
314
1053
458
1086
constantStock
constantStock
1
1
-1000

MONITOR
277
504
342
549
vsslA_12
[ orga-gofaVesselsA ] of turtle 12
17
1
11

MONITOR
423
504
490
549
vsslsB_12
[ orga-gofaVesselsB ] of turtle 12
17
1
11

MONITOR
276
550
343
595
vsslA_22
[ orga-gofaVesselsA ] of turtle 22
17
1
11

MONITOR
278
597
342
642
vsslA_32
[ orga-gofaVesselsA ] of turtle 32
17
1
11

MONITOR
343
504
413
549
vsslA_42
[ orga-gofaVesselsA ] of turtle 42
17
1
11

MONITOR
344
550
412
595
vsslA_52
[ orga-gofaVesselsA ] of turtle 52
17
1
11

MONITOR
425
550
492
595
vsslB_22
[ orga-gofaVesselsB ] of turtle 22
17
1
11

MONITOR
425
597
492
642
vsslB_32
[ orga-gofaVesselsB ] of turtle 32
17
1
11

MONITOR
492
506
554
551
vsslB_42
[ orga-gofaVesselsB ] of turtle 42
17
1
11

MONITOR
494
552
554
597
vsslB_52
[ orga-gofaVesselsB ] of turtle 52
17
1
11

CHOOSER
24
157
131
202
scenario
scenario
"manual" "1-maintain" "2-disappear"
2

CHOOSER
22
284
130
329
coopHistDistr
coopHistDistr
"normal" "uniform"
0

PLOT
869
611
1131
775
Cooperation history distribution
NIL
NIL
1000.0
2000.0
0.0
10.0
true
false
"" ""
PENS
"coop" 1.0 1 -16777216 true "" "if(any? histOfCoopLinks) [ histogram [ coopHistory ] of histOfCoopLinks ]"

MONITOR
910
10
1003
55
crewChange?_12
[orga-changedCrew] of turtle 12
17
1
11

MONITOR
958
98
1053
143
prevCrew_12
[ orga-gofaCrewsPrev ] of turtle 12
17
1
11

MONITOR
276
269
330
314
GINI
precision GINI-orgaCapital 2
17
1
11

MONITOR
332
269
416
314
accumCapital
precision accumCapital 2
17
1
11

MONITOR
421
270
500
315
NIL
num-ORGAs
17
1
11

MONITOR
279
316
422
361
NIL
num-changed-crews
17
1
11

MONITOR
424
316
567
361
ratioCrewChange
precision perc-changed-crews 2
17
1
11

SWITCH
20
339
182
372
randomActualisation
randomActualisation
0
1
-1000

@#$#@#$#@
## WHAT IS IT?

BeeCome is a relation-based model (RBM),i.e. an agent-based model that attempts to embody a process relational philosopy/view. The approach takes the relations and doings as central, rather than and actor- and property-centred approach.

We apply this experimental approach of developing an RBM in the context of a Mexican Fishery and the creation of a simulation what allows of to explore the research question: (revisit) 
 
a. Why and how do different organizational forms emerge in the small-scale fisheries in Baja California? What are their social-ecological consequences? What in the organization and dynamics of an assemblage (i.e. its human or non-human elements, their relations, processes, and interactions with other assemblages) explains the emergence of different types of self-governance?
b. RBM: What human and non-human elements make up a fishing-trading assemblage? How does it assemble itself? Which processes stabilize/destabilize it? What emergent practices/capacities does it have? 

The RBM reflects an artificial fishery in which agents (elements) and their links (relations) engage in fishing, buying/selling, reproducing, enabling fishing are core doings that maintain the assemblage.

;NaN: revisit from here on:
It simulates the formation of social groups such as cooperatives and buyer-fisher connections as well as how they go fishing. 

In the model, fishers or cooperatives need experience and financial funds to obtain a fishing permit. This allows them to go out fishing. During the fishing, fishers gain experience in collaborating, which leads to a bigger cooperative power within the group. This makes the group more efficient and more likely to go out fishing together again.

## HOW IT WORKS


## HOW TO USE IT
 

## THINGS TO NOTICE
Unique to this model is the emphasis on relationships between elements of the model as well as the process-relational approach that is implemented here. The process-oriented philosophy emphasizes the constant change the fishing system goes through e.g. by not necesariliy reaching an equilibrium. The relational perspective is implemented as fishers not only have a link with government agencies, each other, and their sailing vessels but are also connected with the fish and the wind.

See also:
Mancilla García, M., Hertz, T., Schlüter, M., Preiser, R., & Woermann, M. (2020). Adopting process-relational perspectives to tackle the challenges of social-ecological systems research. Ecology and Society, 25(1).

Mancilla Garcia, M., Hertz, T., & Schlüter, M. (2020). Towards a Process Epistemology for the Analysis of Social-Ecological System. Environmental Values, 29(2), 221-239.

## THINGS TO TRY
To explore two scenarios described in the paper use the RBM scenarios 1 (maintain) and 2 (disappear) to get to get an impression. 

## EXTENDING THE MODEL


## RELATED MODELS


## NETLOGO FEATURES

## HOW TO CITE

If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:

* Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

## COPYRIGHT AND LICENSE

Copyright 2008 Uri Wilensky.

![CC BY-NC-SA 3.0](http://ccl.northwestern.edu/images/creativecommons/byncsa.png)

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.  To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.
@#$#@#$#@
default
true
0
Polygon -7500403 true true 150 5 40 250 150 205 260 250

airplane
true
0
Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15

arrow
true
0
Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150

boat
false
0
Polygon -1 true false 63 162 90 207 223 207 290 162
Rectangle -6459832 true false 150 32 157 162
Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49
Polygon -7500403 true true 158 33 230 157 182 150 169 151 157 156
Polygon -7500403 true true 149 55 88 143 103 139 111 136 117 139 126 145 130 147 139 147 146 146 149 55

boat top
true
0
Polygon -7500403 true true 150 1 137 18 123 46 110 87 102 150 106 208 114 258 123 286 175 287 183 258 193 209 198 150 191 87 178 46 163 17
Rectangle -16777216 false false 129 92 170 178
Rectangle -16777216 false false 120 63 180 93
Rectangle -7500403 true true 133 89 165 165
Polygon -11221820 true false 150 60 105 105 150 90 195 105
Polygon -16777216 false false 150 60 105 105 150 90 195 105
Rectangle -16777216 false false 135 178 165 262
Polygon -16777216 false false 134 262 144 286 158 286 166 262
Line -16777216 false 129 149 171 149
Line -16777216 false 166 262 188 252
Line -16777216 false 134 262 112 252
Line -16777216 false 150 2 149 62

bottle
false
0
Circle -7500403 true true 90 240 60
Rectangle -1 true false 135 8 165 31
Line -7500403 true 123 30 175 30
Circle -7500403 true true 150 240 60
Rectangle -7500403 true true 90 105 210 270
Rectangle -7500403 true true 120 270 180 300
Circle -7500403 true true 90 45 120
Rectangle -7500403 true true 135 27 165 51

box
false
0
Polygon -7500403 true true 150 285 285 225 285 75 150 135
Polygon -7500403 true true 150 135 15 75 150 15 285 75
Polygon -7500403 true true 15 75 15 225 150 285 150 135
Line -16777216 false 150 285 150 135
Line -16777216 false 150 135 15 75
Line -16777216 false 150 135 285 75

bug
true
0
Circle -7500403 true true 96 182 108
Circle -7500403 true true 110 127 80
Circle -7500403 true true 110 75 80
Line -7500403 true 150 100 80 30
Line -7500403 true 150 100 220 30

building institution
false
0
Rectangle -7500403 true true 0 60 300 270
Rectangle -16777216 true false 130 196 168 256
Rectangle -16777216 false false 0 255 300 270
Polygon -7500403 true true 0 60 150 15 300 60
Polygon -16777216 false false 0 60 150 15 300 60
Circle -1 true false 135 26 30
Circle -16777216 false false 135 25 30
Rectangle -16777216 false false 0 60 300 75
Rectangle -16777216 false false 218 75 255 90
Rectangle -16777216 false false 218 240 255 255
Rectangle -16777216 false false 224 90 249 240
Rectangle -16777216 false false 45 75 82 90
Rectangle -16777216 false false 45 240 82 255
Rectangle -16777216 false false 51 90 76 240
Rectangle -16777216 false false 90 240 127 255
Rectangle -16777216 false false 90 75 127 90
Rectangle -16777216 false false 96 90 121 240
Rectangle -16777216 false false 179 90 204 240
Rectangle -16777216 false false 173 75 210 90
Rectangle -16777216 false false 173 240 210 255
Rectangle -16777216 false false 269 90 294 240
Rectangle -16777216 false false 263 75 300 90
Rectangle -16777216 false false 263 240 300 255
Rectangle -16777216 false false 0 240 37 255
Rectangle -16777216 false false 6 90 31 240
Rectangle -16777216 false false 0 75 37 90
Line -16777216 false 112 260 184 260
Line -16777216 false 105 265 196 265

butterfly
true
0
Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240
Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240
Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163
Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165
Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225
Circle -16777216 true false 135 90 30
Line -16777216 false 150 105 195 60
Line -16777216 false 150 105 105 60

car
false
0
Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180
Circle -16777216 true false 180 180 90
Circle -16777216 true false 30 180 90
Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89
Circle -7500403 true true 47 195 58
Circle -7500403 true true 195 195 58

check
false
0
Polygon -7500403 true true 55 138 22 155 53 196 72 232 91 288 111 272 136 258 147 220 167 174 208 113 280 24 257 7 192 78 151 138 106 213 87 182

circle
false
0
Circle -7500403 true true 0 0 300

circle 2
false
0
Circle -7500403 true true 0 0 300
Circle -16777216 true false 30 30 240

cloud
false
0
Circle -7500403 true true 13 118 94
Circle -7500403 true true 86 101 127
Circle -7500403 true true 51 51 108
Circle -7500403 true true 118 43 95
Circle -7500403 true true 158 68 134

cow
false
0
Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167
Polygon -7500403 true true 73 210 86 251 62 249 48 208
Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123

cylinder
false
0
Circle -7500403 true true 0 0 300

dot
false
0
Circle -7500403 true true 90 90 120

face happy
false
0
Circle -7500403 true true 8 8 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240

face neutral
false
0
Circle -7500403 true true 8 7 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Rectangle -16777216 true false 60 195 240 225

face sad
false
0
Circle -7500403 true true 8 8 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183

fish
false
0
Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166
Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165
Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60
Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166
Circle -16777216 true false 215 106 30

fish 2
false
0
Polygon -1 true false 56 133 34 127 12 105 21 126 23 146 16 163 10 194 32 177 55 173
Polygon -7500403 true true 156 229 118 242 67 248 37 248 51 222 49 168
Polygon -7500403 true true 30 60 45 75 60 105 50 136 150 53 89 56
Polygon -7500403 true true 50 132 146 52 241 72 268 119 291 147 271 156 291 164 264 208 211 239 148 231 48 177
Circle -1 true false 237 116 30
Circle -16777216 true false 241 127 12
Polygon -1 true false 159 228 160 294 182 281 206 236
Polygon -7500403 true true 102 189 109 203
Polygon -1 true false 215 182 181 192 171 177 169 164 152 142 154 123 170 119 223 163
Line -16777216 false 240 77 162 71
Line -16777216 false 164 71 98 78
Line -16777216 false 96 79 62 105
Line -16777216 false 50 179 88 217
Line -16777216 false 88 217 149 230

fish 3
false
0
Polygon -7500403 true true 137 105 124 83 103 76 77 75 53 104 47 136
Polygon -7500403 true true 226 194 223 229 207 243 178 237 169 203 167 175
Polygon -7500403 true true 137 195 124 217 103 224 77 225 53 196 47 164
Polygon -7500403 true true 40 123 32 109 16 108 0 130 0 151 7 182 23 190 40 179 47 145
Polygon -7500403 true true 45 120 90 105 195 90 275 120 294 152 285 165 293 171 270 195 210 210 150 210 45 180
Circle -1184463 true false 244 128 26
Circle -16777216 true false 248 135 14
Line -16777216 false 48 121 133 96
Line -16777216 false 48 179 133 204
Polygon -7500403 true true 241 106 241 77 217 71 190 75 167 99 182 125
Line -16777216 false 226 102 158 95
Line -16777216 false 171 208 225 205
Polygon -1 true false 252 111 232 103 213 132 210 165 223 193 229 204 247 201 237 170 236 137
Polygon -1 true false 135 98 140 137 135 204 154 210 167 209 170 176 160 156 163 126 171 117 156 96
Polygon -16777216 true false 192 117 171 118 162 126 158 148 160 165 168 175 188 183 211 186 217 185 206 181 172 171 164 156 166 133 174 121
Polygon -1 true false 40 121 46 147 42 163 37 179 56 178 65 159 67 128 59 116

flag
false
0
Rectangle -7500403 true true 60 15 75 300
Polygon -7500403 true true 90 150 270 90 90 30
Line -7500403 true 75 135 90 135
Line -7500403 true 75 45 90 45

flower
false
0
Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135
Circle -7500403 true true 85 132 38
Circle -7500403 true true 130 147 38
Circle -7500403 true true 192 85 38
Circle -7500403 true true 85 40 38
Circle -7500403 true true 177 40 38
Circle -7500403 true true 177 132 38
Circle -7500403 true true 70 85 38
Circle -7500403 true true 130 25 38
Circle -7500403 true true 96 51 108
Circle -16777216 true false 113 68 74
Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218
Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240

house
false
0
Rectangle -7500403 true true 45 120 255 285
Rectangle -16777216 true false 120 210 180 285
Polygon -7500403 true true 15 120 150 15 285 120
Line -16777216 false 30 120 270 120

leaf
false
0
Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195
Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195

line
true
0
Line -7500403 true 150 0 150 300

line half
true
0
Line -7500403 true 150 0 150 150

money eu
true
0
Rectangle -7500403 false true 120 60 210 75
Line -7500403 true 120 75 105 90
Rectangle -7500403 false true 105 60 120 90
Rectangle -7500403 false true 90 75 105 105
Rectangle -7500403 false true 75 90 90 225
Rectangle -7500403 false true 90 210 105 240
Rectangle -7500403 false true 105 225 120 255
Rectangle -7500403 false true 120 240 210 255
Rectangle -7500403 false true 45 135 165 150
Rectangle -7500403 false true 45 165 165 180

orbit 5
true
0
Circle -7500403 true true 116 11 67
Circle -7500403 true true 13 89 67
Circle -7500403 true true 178 206 67
Circle -7500403 true true 53 204 67
Circle -7500403 true true 220 91 67
Circle -7500403 false true 45 45 210

pentagon
false
0
Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120

person
false
0
Circle -7500403 true true 110 5 80
Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90
Rectangle -7500403 true true 127 79 172 94
Polygon -7500403 true true 195 90 240 150 225 180 165 105
Polygon -7500403 true true 105 90 60 150 75 180 135 105

person business
false
0
Rectangle -1 true false 120 90 180 180
Polygon -13345367 true false 135 90 150 105 135 180 150 195 165 180 150 105 165 90
Polygon -7500403 true true 120 90 105 90 60 195 90 210 116 154 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 183 153 210 210 240 195 195 90 180 90 150 165
Circle -7500403 true true 110 5 80
Rectangle -7500403 true true 127 76 172 91
Line -16777216 false 172 90 161 94
Line -16777216 false 128 90 139 94
Polygon -13345367 true false 195 225 195 300 270 270 270 195
Rectangle -13791810 true false 180 225 195 300
Polygon -14835848 true false 180 226 195 226 270 196 255 196
Polygon -13345367 true false 209 202 209 216 244 202 243 188
Line -16777216 false 180 90 150 165
Line -16777216 false 120 90 150 165

plant
false
0
Rectangle -7500403 true true 135 90 165 300
Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285
Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285
Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210
Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135
Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135
Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60
Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90

sailboat side
false
0
Line -16777216 false 0 240 120 210
Polygon -7500403 true true 0 239 270 254 270 269 240 284 225 299 60 299 15 254
Polygon -1 true false 15 240 30 195 75 120 105 90 105 225
Polygon -1 true false 135 75 165 180 150 240 255 240 285 225 255 150 210 105
Line -16777216 false 105 90 120 60
Line -16777216 false 120 45 120 240
Line -16777216 false 150 240 120 240
Line -16777216 false 135 75 120 60
Polygon -7500403 true true 120 60 75 45 120 30
Polygon -16777216 false false 105 90 75 120 30 195 15 240 105 225
Polygon -16777216 false false 135 75 165 180 150 240 255 240 285 225 255 150 210 105
Polygon -16777216 false false 0 239 60 299 225 299 240 284 270 269 270 254

square
false
0
Rectangle -7500403 true true 30 30 270 270

square 2
false
0
Rectangle -7500403 true true 30 30 270 270
Rectangle -16777216 true false 60 60 240 240

star
false
0
Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108

target
false
0
Circle -7500403 true true 0 0 300
Circle -16777216 true false 30 30 240
Circle -7500403 true true 60 60 180
Circle -16777216 true false 90 90 120
Circle -7500403 true true 120 120 60

tree
false
0
Circle -7500403 true true 118 3 94
Rectangle -6459832 true false 120 195 180 300
Circle -7500403 true true 65 21 108
Circle -7500403 true true 116 41 127
Circle -7500403 true true 45 90 120
Circle -7500403 true true 104 74 152

triangle
false
0
Polygon -7500403 true true 150 30 15 255 285 255

triangle 2
false
0
Polygon -7500403 true true 150 30 15 255 285 255
Polygon -16777216 true false 151 99 225 223 75 224

truck
false
0
Rectangle -7500403 true true 4 45 195 187
Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194
Rectangle -1 true false 195 60 195 105
Polygon -16777216 true false 238 112 252 141 219 141 218 112
Circle -16777216 true false 234 174 42
Rectangle -7500403 true true 181 185 214 194
Circle -16777216 true false 144 174 42
Circle -16777216 true false 24 174 42
Circle -7500403 false true 24 174 42
Circle -7500403 false true 144 174 42
Circle -7500403 false true 234 174 42

turtle
true
0
Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210
Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105
Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105
Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87
Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210
Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99

wheel
false
0
Circle -7500403 true true 3 3 294
Circle -16777216 true false 30 30 240
Line -7500403 true 150 285 150 15
Line -7500403 true 15 150 285 150
Circle -7500403 true true 120 120 60
Line -7500403 true 216 40 79 269
Line -7500403 true 40 84 269 221
Line -7500403 true 40 216 269 79
Line -7500403 true 84 40 221 269

x
false
0
Polygon -7500403 true true 270 75 225 30 30 225 75 270
Polygon -7500403 true true 30 75 75 30 270 225 225 270
@#$#@#$#@
NetLogo 6.4.0
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
<experiments>
  <experiment name="huntingBreakingPoint" repetitions="10" runMetricsEveryStep="true">
    <setup>setup</setup>
    <go>go</go>
    <timeLimit steps="1825"/>
    <metric>stockA</metric>
    <metric>stockB</metric>
    <metric>accum-catch</metric>
    <metric>depleted</metric>
    <metric>gofaRatio</metric>
    <metric>avgGOFAcatch</metric>
    <metric>avgGOFAskill</metric>
    <metric>sdGOFAcatch</metric>
    <metric>sdGOFAskill</metric>
    <enumeratedValueSet variable="init-orgas?">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-coops">
      <value value="1"/>
    </enumeratedValueSet>
    <steppedValueSet variable="num-pcs" first="1" step="2" last="5"/>
    <enumeratedValueSet variable="num-vessels-in-coop">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-pc">
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="initStock">
      <value value="0.5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-strength">
      <value value="0"/>
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fishingSkillDistr">
      <value value="&quot;uniform&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="FSKILL-SD">
      <value value="0.1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="CoopHistMean">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="CoopHistSD">
      <value value="0.5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="trustDistr">
      <value value="&quot;high&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="autoSeed?">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="MSY-Fishing">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="noFishing">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fixedFskills">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="MSY-Fishing">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="noFishing">
      <value value="false"/>
    </enumeratedValueSet>
  </experiment>
  <experiment name="scenarioPaper" repetitions="50" runMetricsEveryStep="true">
    <setup>setup</setup>
    <go>go</go>
    <timeLimit steps="1825"/>
    <metric>autoSeed</metric>
    <metric>stockA</metric>
    <metric>stockB</metric>
    <metric>accum-catch</metric>
    <metric>depleted</metric>
    <metric>gofaRatio</metric>
    <metric>avgGOFAcatch</metric>
    <metric>avgGOFAskill</metric>
    <metric>sdGOFAcatch</metric>
    <metric>sdGOFAskill</metric>
    <enumeratedValueSet variable="init-orgas?">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-coops">
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-pcs">
      <value value="8"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-coop">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-pc">
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="initStock">
      <value value="0.5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-strength">
      <value value="0"/>
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fishingSkillDistr">
      <value value="&quot;uniform&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="FSKILL-SD">
      <value value="0.1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="CoopHistMean">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="CoopHistSD">
      <value value="0.5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="trustDistr">
      <value value="&quot;high&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="autoSeed?">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="MSY-Fishing">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="noFishing">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fixedFskills">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="MSY-Fishing">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="noFishing">
      <value value="false"/>
    </enumeratedValueSet>
  </experiment>
  <experiment name="New-SCEN2-Disappear_ALL" repetitions="1" runMetricsEveryStep="true">
    <setup>setup</setup>
    <go>go</go>
    <timeLimit steps="1825"/>
    <metric>precision sum [ mystock ] of fishs 1</metric>
    <metric>precision [ myStock ] of fish 0 1</metric>
    <metric>precision ([ caught-this-tick ] of turtle 0) 1</metric>
    <metric>[ num-boats-this-tick ] of turtle 0</metric>
    <metric>[ perc-boats-this-tick ] of turtle 0</metric>
    <metric>[ num-L-boats-this-tick] of turtle 0</metric>
    <metric>[ who-visited ] of turtle 0</metric>
    <metric>precision [ myStock ] of fish 1 1</metric>
    <metric>precision ([ caught-this-tick ] of turtle 1) 1</metric>
    <metric>[ num-boats-this-tick ] of turtle 1</metric>
    <metric>[ perc-boats-this-tick ] of turtle 1</metric>
    <metric>[ num-L-boats-this-tick] of turtle 1</metric>
    <metric>[ who-visited ] of turtle 1</metric>
    <metric>[ numVessels-Act ] of turtle 12</metric>
    <metric>[ numLboats-Act ] of turtle 12</metric>
    <metric>[ orga-gofaCrews ] of turtle 12</metric>
    <metric>round ([ capital ] of turtle 12)</metric>
    <metric>precision [ earnings - FUEL-COST-ORGA ] of turtle 12 2</metric>
    <metric>[ orga-gofaSkillsA ] of turtle 12</metric>
    <metric>[ orga-gofaSkillsB ] of turtle 12</metric>
    <metric>[ orga-daycatches ] of turtle 12</metric>
    <metric>precision ([ catch ] of turtle 10) 2</metric>
    <metric>precision ([ catch ] of turtle 11) 2</metric>
    <metric>[ orga-gofaCoopPower ] of turtle 12</metric>
    <metric>[ numVessels-Act ] of turtle 22</metric>
    <metric>[ numLboats-Act ] of turtle 22</metric>
    <metric>[ orga-gofaCrews ] of turtle 22</metric>
    <metric>round ([ capital ] of turtle 22)</metric>
    <metric>precision [ earnings - FUEL-COST-ORGA ] of turtle 22 2</metric>
    <metric>[ orga-gofaSkillsA ] of turtle 22</metric>
    <metric>[ orga-gofaSkillsB ] of turtle 22</metric>
    <metric>[ orga-daycatches ] of turtle 22</metric>
    <metric>precision ([ catch ] of turtle 20) 2</metric>
    <metric>precision ([ catch ] of turtle 21) 2</metric>
    <metric>[ orga-gofaCoopPower ] of turtle 22</metric>
    <metric>[ numVessels-Act ] of turtle 32</metric>
    <metric>[ numLboats-Act ] of turtle 32</metric>
    <metric>[ orga-gofaCrews ] of turtle 32</metric>
    <metric>round ([ capital ] of turtle 32)</metric>
    <metric>precision [ earnings - FUEL-COST-ORGA ] of turtle 32 2</metric>
    <metric>[ orga-gofaSkillsA ] of turtle 32</metric>
    <metric>[ orga-gofaSkillsB ] of turtle 32</metric>
    <metric>[ orga-daycatches ] of turtle 32</metric>
    <metric>precision ([ catch ] of turtle 30) 2</metric>
    <metric>precision ([ catch ] of turtle 31) 2</metric>
    <metric>[ orga-gofaCoopPower ] of turtle 32</metric>
    <metric>[ numVessels-Act ] of turtle 42</metric>
    <metric>[ numLboats-Act ] of turtle 42</metric>
    <metric>[ orga-gofaCrews ] of turtle 42</metric>
    <metric>round ([ capital ] of turtle 42)</metric>
    <metric>precision [ earnings - FUEL-COST-ORGA ] of turtle 42 2</metric>
    <metric>[ orga-gofaSkillsA ] of turtle 42</metric>
    <metric>[ orga-gofaSkillsB ] of turtle 42</metric>
    <metric>[ orga-daycatches ] of turtle 42</metric>
    <metric>precision ([ catch ] of turtle 40) 2</metric>
    <metric>precision ([ catch ] of turtle 41) 2</metric>
    <metric>[ orga-gofaCoopPower ] of turtle 42</metric>
    <metric>[ numVessels-Act ] of turtle 52</metric>
    <metric>[ numLboats-Act ] of turtle 52</metric>
    <metric>[ orga-gofaCrews ] of turtle 52</metric>
    <metric>round ([ capital ] of turtle 52)</metric>
    <metric>precision [ earnings - FUEL-COST-ORGA ] of turtle 52 2</metric>
    <metric>[ orga-gofaSkillsA ] of turtle 52</metric>
    <metric>[ orga-gofaSkillsB ] of turtle 52</metric>
    <metric>[ orga-daycatches ] of turtle 52</metric>
    <metric>precision ([ catch ] of turtle 50) 2</metric>
    <metric>precision ([ catch ] of turtle 51) 2</metric>
    <metric>[ orga-gofaCoopPower ] of turtle 52</metric>
    <enumeratedValueSet variable="CoopHistMean">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-coop">
      <value value="6"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="FSKILL-SD">
      <value value="0.1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="trustDistr">
      <value value="&quot;high&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="show-relations">
      <value value="&quot;none&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-pcs">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="autoSeed?">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="rndFuelPermit">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-coops">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="plotCatchAB">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="MSY-Fishing">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="noFishing">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-strength">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fishingSkillDistr">
      <value value="&quot;normal&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="initStock">
      <value value="0.5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="highCapital">
      <value value="1000"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="init-capital">
      <value value="&quot;all-week&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fskillsx10">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="CoopHistSD">
      <value value="0.5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-PC">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="permitHolderRatio">
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fixedFskills">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-coop">
      <value value="2"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="FISH-PRICE">
      <value value="4.5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fskillDynamic">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="manualSeed">
      <value value="-760696631"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="moneyFuelAccessRatio">
      <value value="1"/>
    </enumeratedValueSet>
  </experiment>
  <experiment name="New-SCEN1-Maintain_ALL" repetitions="1" runMetricsEveryStep="true">
    <setup>setup</setup>
    <go>go</go>
    <timeLimit steps="1825"/>
    <metric>precision sum [ mystock ] of fishs 1</metric>
    <metric>precision [ myStock ] of fish 0 1</metric>
    <metric>precision ([ caught-this-tick ] of turtle 0) 1</metric>
    <metric>[ num-boats-this-tick ] of turtle 0</metric>
    <metric>[ perc-boats-this-tick ] of turtle 0</metric>
    <metric>[ num-L-boats-this-tick] of turtle 0</metric>
    <metric>[ who-visited ] of turtle 0</metric>
    <metric>precision [ myStock ] of fish 1 1</metric>
    <metric>precision ([ caught-this-tick ] of turtle 1) 1</metric>
    <metric>[ num-boats-this-tick ] of turtle 1</metric>
    <metric>[ perc-boats-this-tick ] of turtle 1</metric>
    <metric>[ num-L-boats-this-tick] of turtle 1</metric>
    <metric>[ who-visited ] of turtle 1</metric>
    <metric>[ numVessels-Act ] of turtle 12</metric>
    <metric>[ numLboats-Act ] of turtle 12</metric>
    <metric>[ orga-gofaCrews ] of turtle 12</metric>
    <metric>round ([ capital ] of turtle 12)</metric>
    <metric>precision [ earnings - FUEL-COST-ORGA ] of turtle 12 2</metric>
    <metric>[ orga-gofaSkillsA ] of turtle 12</metric>
    <metric>[ orga-gofaSkillsB ] of turtle 12</metric>
    <metric>[ orga-daycatches ] of turtle 12</metric>
    <metric>precision ([ catch ] of turtle 10) 2</metric>
    <metric>precision ([ catch ] of turtle 11) 2</metric>
    <metric>[ orga-gofaCoopPower ] of turtle 12</metric>
    <metric>[ numVessels-Act ] of turtle 22</metric>
    <metric>[ numLboats-Act ] of turtle 22</metric>
    <metric>[ orga-gofaCrews ] of turtle 22</metric>
    <metric>round ([ capital ] of turtle 22)</metric>
    <metric>precision [ earnings - FUEL-COST-ORGA ] of turtle 22 2</metric>
    <metric>[ orga-gofaSkillsA ] of turtle 22</metric>
    <metric>[ orga-gofaSkillsB ] of turtle 22</metric>
    <metric>[ orga-daycatches ] of turtle 22</metric>
    <metric>precision ([ catch ] of turtle 20) 2</metric>
    <metric>precision ([ catch ] of turtle 21) 2</metric>
    <metric>[ orga-gofaCoopPower ] of turtle 22</metric>
    <metric>[ numVessels-Act ] of turtle 32</metric>
    <metric>[ numLboats-Act ] of turtle 32</metric>
    <metric>[ orga-gofaCrews ] of turtle 32</metric>
    <metric>round ([ capital ] of turtle 32)</metric>
    <metric>precision [ earnings - FUEL-COST-ORGA ] of turtle 32 2</metric>
    <metric>[ orga-gofaSkillsA ] of turtle 32</metric>
    <metric>[ orga-gofaSkillsB ] of turtle 32</metric>
    <metric>[ orga-daycatches ] of turtle 32</metric>
    <metric>precision ([ catch ] of turtle 30) 2</metric>
    <metric>precision ([ catch ] of turtle 31) 2</metric>
    <metric>[ orga-gofaCoopPower ] of turtle 32</metric>
    <metric>[ numVessels-Act ] of turtle 42</metric>
    <metric>[ numLboats-Act ] of turtle 42</metric>
    <metric>[ orga-gofaCrews ] of turtle 42</metric>
    <metric>round ([ capital ] of turtle 42)</metric>
    <metric>precision [ earnings - FUEL-COST-ORGA ] of turtle 42 2</metric>
    <metric>[ orga-gofaSkillsA ] of turtle 42</metric>
    <metric>[ orga-gofaSkillsB ] of turtle 42</metric>
    <metric>[ orga-daycatches ] of turtle 42</metric>
    <metric>precision ([ catch ] of turtle 40) 2</metric>
    <metric>precision ([ catch ] of turtle 41) 2</metric>
    <metric>[ orga-gofaCoopPower ] of turtle 42</metric>
    <metric>[ numVessels-Act ] of turtle 52</metric>
    <metric>[ numLboats-Act ] of turtle 52</metric>
    <metric>[ orga-gofaCrews ] of turtle 52</metric>
    <metric>round ([ capital ] of turtle 52)</metric>
    <metric>precision [ earnings - FUEL-COST-ORGA ] of turtle 52 2</metric>
    <metric>[ orga-gofaSkillsA ] of turtle 52</metric>
    <metric>[ orga-gofaSkillsB ] of turtle 52</metric>
    <metric>[ orga-daycatches ] of turtle 52</metric>
    <metric>precision ([ catch ] of turtle 50) 2</metric>
    <metric>precision ([ catch ] of turtle 51) 2</metric>
    <metric>[ orga-gofaCoopPower ] of turtle 52</metric>
    <enumeratedValueSet variable="CoopHistMean">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-coop">
      <value value="6"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="FSKILL-SD">
      <value value="0.1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="trustDistr">
      <value value="&quot;high&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="show-relations">
      <value value="&quot;none&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-pcs">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="autoSeed?">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="rndFuelPermit">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-coops">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="plotCatchAB">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="MSY-Fishing">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="noFishing">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-strength">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fishingSkillDistr">
      <value value="&quot;normal&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="initStock">
      <value value="0.5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="highCapital">
      <value value="1000"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="init-capital">
      <value value="&quot;all-week&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fskillsx10">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="CoopHistSD">
      <value value="0.5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-PC">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="permitHolderRatio">
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fixedFskills">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-coop">
      <value value="2"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="FISH-PRICE">
      <value value="4.5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fskillDynamic">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="manualSeed">
      <value value="-142360862"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="moneyFuelAccessRatio">
      <value value="1"/>
    </enumeratedValueSet>
  </experiment>
  <experiment name="ScenarioSanityCheck" repetitions="200" runMetricsEveryStep="true">
    <setup>setup</setup>
    <go>go</go>
    <timeLimit steps="1095"/>
    <metric>behaviorspace-run-number</metric>
    <metric>autoSeed</metric>
    <metric>num-orgas</metric>
    <metric>stockA</metric>
    <metric>stockB</metric>
    <metric>avgGOFAskill</metric>
    <metric>sdGOFAskill</metric>
    <metric>avgCapital</metric>
    <metric>accumCapital</metric>
    <metric>GINI-orgaCapital</metric>
    <metric>num-changed-crews</metric>
    <metric>perc-changed-crews</metric>
    <enumeratedValueSet variable="scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="autoSeed?">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="coopHistDistr">
      <value value="&quot;normal&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="CoopHistMean">
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fishingSkillDistr">
      <value value="&quot;normal&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-strength">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-coops">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-coop">
      <value value="2"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-coop">
      <value value="6"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-pcs">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
  </experiment>
  <experiment name="Sensitivity1-CoopHistMean" repetitions="100" runMetricsEveryStep="true">
    <setup>setup</setup>
    <go>go</go>
    <timeLimit steps="1095"/>
    <metric>behaviorspace-run-number</metric>
    <metric>autoSeed</metric>
    <metric>num-orgas</metric>
    <metric>stockA</metric>
    <metric>stockB</metric>
    <metric>avgGOFAskill</metric>
    <metric>sdGOFAskill</metric>
    <metric>avgCapital</metric>
    <metric>accumCapital</metric>
    <metric>GINI-orgaCapital</metric>
    <metric>num-changed-crews</metric>
    <metric>perc-changed-crews</metric>
    <enumeratedValueSet variable="scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="autoSeed?">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="coopHistDistr">
      <value value="&quot;normal&quot;"/>
    </enumeratedValueSet>
    <steppedValueSet variable="CoopHistMean" first="0" step="1" last="5"/>
    <enumeratedValueSet variable="fishingSkillDistr">
      <value value="&quot;normal&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-strength">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-coops">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-coop">
      <value value="2"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-coop">
      <value value="6"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-pcs">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
  </experiment>
  <experiment name="Sensitivity2-CoopHistDistr" repetitions="10" runMetricsEveryStep="true">
    <setup>setup</setup>
    <go>go</go>
    <timeLimit steps="1095"/>
    <metric>behaviorspace-run-number</metric>
    <metric>autoSeed</metric>
    <metric>num-orgas</metric>
    <metric>stockA</metric>
    <metric>stockB</metric>
    <metric>avgGOFAskill</metric>
    <metric>sdGOFAskill</metric>
    <metric>avgCapital</metric>
    <metric>accumCapital</metric>
    <metric>GINI-orgaCapital</metric>
    <metric>num-changed-crews</metric>
    <metric>perc-changed-crews</metric>
    <enumeratedValueSet variable="scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="autoSeed?">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="coopHistDistr">
      <value value="&quot;normal&quot;"/>
      <value value="&quot;uniform&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="CoopHistMean">
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fishingSkillDistr">
      <value value="&quot;normal&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-strength">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-coops">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-coop">
      <value value="2"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-coop">
      <value value="6"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-pcs">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
  </experiment>
  <experiment name="Sensitivity3-FishSkillsDistr" repetitions="1000" runMetricsEveryStep="true">
    <setup>setup</setup>
    <go>go</go>
    <timeLimit steps="1095"/>
    <metric>behaviorspace-run-number</metric>
    <metric>autoSeed</metric>
    <metric>num-orgas</metric>
    <metric>stockA</metric>
    <metric>stockB</metric>
    <metric>avgGOFAskill</metric>
    <metric>sdGOFAskill</metric>
    <metric>avgCapital</metric>
    <metric>accumCapital</metric>
    <metric>GINI-orgaCapital</metric>
    <metric>num-changed-crews</metric>
    <metric>perc-changed-crews</metric>
    <enumeratedValueSet variable="scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="autoSeed?">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fishingSkillDistr">
      <value value="&quot;normal&quot;"/>
      <value value="&quot;uniform&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="coopHistDistr">
      <value value="&quot;normal&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="CoopHistMean">
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-strength">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-coops">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-coop">
      <value value="2"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-coop">
      <value value="6"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-pcs">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
  </experiment>
  <experiment name="WindExploration" repetitions="200" runMetricsEveryStep="true">
    <setup>setup</setup>
    <go>go</go>
    <timeLimit steps="1095"/>
    <metric>behaviorspace-run-number</metric>
    <metric>autoSeed</metric>
    <metric>num-orgas</metric>
    <metric>stockA</metric>
    <metric>stockB</metric>
    <metric>avgGOFAskill</metric>
    <metric>sdGOFAskill</metric>
    <metric>avgCapital</metric>
    <metric>accumCapital</metric>
    <metric>GINI-orgaCapital</metric>
    <metric>num-changed-crews</metric>
    <metric>perc-changed-crews</metric>
    <enumeratedValueSet variable="scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="autoSeed?">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-scenario">
      <value value="&quot;noWind&quot;"/>
      <value value="&quot;windOn&quot;"/>
      <value value="&quot;seasonal&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fishingSkillDistr">
      <value value="&quot;normal&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="coopHistDistr">
      <value value="&quot;normal&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="CoopHistMean">
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-coops">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-coop">
      <value value="2"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-coop">
      <value value="6"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-pcs">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
  </experiment>
  <experiment name="Sensitivity4-CoopHistFishSkillsDistr" repetitions="10" runMetricsEveryStep="true">
    <setup>setup</setup>
    <go>go</go>
    <timeLimit steps="1095"/>
    <metric>behaviorspace-run-number</metric>
    <metric>autoSeed</metric>
    <metric>num-orgas</metric>
    <metric>stockA</metric>
    <metric>stockB</metric>
    <metric>avgGOFAskill</metric>
    <metric>sdGOFAskill</metric>
    <metric>avgCapital</metric>
    <metric>accumCapital</metric>
    <metric>GINI-orgaCapital</metric>
    <metric>num-changed-crews</metric>
    <metric>perc-changed-crews</metric>
    <enumeratedValueSet variable="scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="autoSeed?">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fishingSkillDistr">
      <value value="&quot;normal&quot;"/>
      <value value="&quot;uniform&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="coopHistDistr">
      <value value="&quot;normal&quot;"/>
      <value value="&quot;uniform&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="CoopHistMean">
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-strength">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-coops">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-coop">
      <value value="2"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-coop">
      <value value="6"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-pcs">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
  </experiment>
  <experiment name="numRepetitions" repetitions="1000" runMetricsEveryStep="true">
    <setup>setup</setup>
    <go>go</go>
    <timeLimit steps="1095"/>
    <metric>behaviorspace-run-number</metric>
    <metric>autoSeed</metric>
    <metric>num-orgas</metric>
    <metric>stockA</metric>
    <metric>stockB</metric>
    <metric>avgGOFAskill</metric>
    <metric>sdGOFAskill</metric>
    <metric>avgCapital</metric>
    <metric>accumCapital</metric>
    <metric>GINI-orgaCapital</metric>
    <metric>num-changed-crews</metric>
    <metric>perc-changed-crews</metric>
    <enumeratedValueSet variable="scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="autoSeed?">
      <value value="true"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="fishingSkillDistr">
      <value value="&quot;normal&quot;"/>
      <value value="&quot;uniform&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="coopHistDistr">
      <value value="&quot;normal&quot;"/>
      <value value="&quot;uniform&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="CoopHistMean">
      <value value="1"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="randomActualisation">
      <value value="false"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-scenario">
      <value value="&quot;manual&quot;"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="wind-strength">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-coops">
      <value value="5"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-coop">
      <value value="2"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-coop">
      <value value="6"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-pcs">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-vessels-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
    <enumeratedValueSet variable="num-fishers-in-pc">
      <value value="0"/>
    </enumeratedValueSet>
  </experiment>
</experiments>
@#$#@#$#@
@#$#@#$#@
default
0.0
-0.2 0 0.0 1.0
0.0 1 1.0 0.0
0.2 0 0.0 1.0
link direction
true
0
Line -7500403 true 150 150 90 180
Line -7500403 true 150 150 210 180

type0
0.5
-0.2 0 0.0 1.0
0.0 1 1.0 0.0
0.2 0 0.0 1.0
link direction
true
0
Line -7500403 true 150 150 90 180
Line -7500403 true 150 150 210 180

type1
0.2
-0.2 0 0.0 1.0
0.0 1 4.0 4.0
0.2 0 0.0 1.0
link direction
true
0
Line -7500403 true 150 150 90 180
Line -7500403 true 150 150 210 180

type2
0.2
-0.2 0 0.0 1.0
0.0 1 4.0 4.0 2.0 2.0
0.2 0 0.0 1.0
link direction
true
0
Line -7500403 true 150 150 90 180
Line -7500403 true 150 150 210 180
@#$#@#$#@
0
@#$#@#$#@
