This page was automatically generated by NetLogo 5.0.5.

The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.


In order for this to work, this file, your model file (Sudety.nlogo), and the files NetLogoLite.jar and NetLogoLite.jar.pack.gz must all be in the same directory. (You can copy NetLogoLite.jar and NetLogoLite.jar.pack.gz from the directory where you installed NetLogo.)

On some systems, you can test the applet locally on your computer before uploading it to a web server. It doesn't work on all systems, though, so if it doesn't work from your hard drive, please try uploading it to a web server.

You don't need to include everything in this file in your page. If you want, you can just take the HTML code beginning with <applet> and ending with </applet>, and paste it into any HTML file you want. It's even OK to put multiple <applet> tags on a single page.

If the NetLogoLite files and your model are in different directories, you must modify the archive= and value= lines in the HTML code to point to their actual locations. (For example, if you have multiple applets in different directories on the same web server, you may want to put a single copy of the NetLogoLite files in one central place and change the archive= lines of all the HTML files to point to that one central copy. This will save disk space for you and download time for your users.)

powered by NetLogo

view/download model file: Sudety.nlogo

WHAT IS IT?

(a general understanding of what the model is trying to show or explain)

HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab)

THINGS TO NOTICE

(suggested things for the user to notice while running the model)

THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

CREDITS AND REFERENCES

(a reference to the model’s URL on the web if it has one, as well as any other necessary credits, citations, and links)

CODE

globals
[
  ;; agent sets
  Liberec
  Usti
  Zatec
  VelkaMesta
  OtherPlaces
  Places
  Dice
  German
  Mix
  Czech
  Zlepsovaci
  Udrzovaci
  Salamisti
  Dosidlujici
  Ostatni
  IAmDifference
  VolneKat1 ;; je to agenset patchu, ktere maji volne bydleni kategorie 1
  VolneKat2 ;; je to agenset patchu, ktere maji volne bydleni kategorie 2
  VolneKat3 ;; je to agenset patchu, ktere maji volne bydleni kategorie 3
  TargetingCity ;; mesto, kam se rodina rozhodla prestehovat
  LeftCity ;; mesto, ze ktereho odchazi
  LeftKat  ;; kvalita objektu, ktery opousti
  CompareLiving ;; slouzi pro srovnani kvality bydleni rodiny s nabidkou ve vybranem meste
  CompareAttractivity ;; slouzi pro srovnani atraktivity soucasnehoho mista rodiny a vybraneho mesta
  
  
]

 
turtles-own
[  
  ;; turtles variables (turtle = family)
  members
  povaha
  DateOfMove
  LivingKat
  fIAm ;; index atraktivity soucasneho mista, ktery do sebe z dlazdice rodina "natahne"
] 
  

patches-own
[ 
  ;; patches variables (variable = village/town)
  inhabitants
  families
  dwellings
  ethnicity
  Obec ;; pokud jde o obec Obec = 1, pokud o osadu Obec = 0
  obydlenost
  kat1
  kat2
  kat3
  kat4
  kat1free
  kat2free
  kat3free
  kat1lived
  kat2lived
  kat3lived
  Hospody
  Obchody
  Doktori
  Posty
  LinkyVerejneDopravy
  Skoly
  Kina
  Farnosti
  Kulturaky
  Vybavenost
  BonusObydlenost
  BonusObec
  IAm ;; = index atraktivity mista
]


to setup
  clear-all
  reset-ticks
 
  ask patches
  [
    set pcolor yellow
    ;;if pxcor < 3 [set pcolor (11 + pxcor + pycor)]
  ]

  ifelse random-labels = true
  [
    ask patch random 3 random-pycor [set plabel "ZT"]
    ask patch random 3 random-pycor [set plabel "UL"]
    ask patch random 3 random-pycor [set plabel "LB"]
  ]
  [
    ask patch 1 13 [set plabel "ZT"]
    ask patch 1 8  [set plabel "UL"]
    ask patch 1 3  [set plabel "LB"]
  ]
  
  set Liberec patches with [plabel = "LB"]
  set Usti patches with [plabel = "UL"]
  set Zatec patches with [plabel = "ZT"]
  set Places patches with [pxcor < 3]
  set VelkaMesta patches with [plabel != ""]
  set OtherPlaces patches with [pxcor < 3 and plabel = ""]
      
  
  ask Liberec
  [
    set dwellings 33000
    set ethnicity "German"
  ]

    
  ask Usti
  [
    set dwellings 23000
    set ethnicity "German"
  ]

    
  ask Zatec
  [
    set dwellings 10000
    set ethnicity "German"
  ]
    
  
  ask OtherPlaces
  [
    set Dice (1 + random 100)
    ifelse Dice < podil-nemeckych-obci-strop
    [set ethnicity "German"]
    [
      ifelse Dice < podil-ceskych-obci-dno
      [set ethnicity "Mix"][set ethnicity "Czech"]
    ]
    set dwellings round(random-normal mean-size-obce (mean-size-obce * tail-length))
    while [dwellings < 100] [set dwellings round(random-normal 100 mean-size-obce)]
  ]

  
  set German patches with [ethnicity = "German"]
  set Mix patches with [ethnicity = "Mix"]
  set Czech patches with [ethnicity = "Czech"]

  ask German
  [set families round (dwellings * 0.1)]
  ask Mix
  [set families round (dwellings * 0.5)]
  ask Czech
  [set families round (dwellings * 0.9)]

      
  ask Places 
  [
    ifelse families < 34 [set Obec 1] [set Obec 0]
    set obydlenost round (families / dwellings * 100)
    set kat1 (1 + random dwellings)
    set kat1free kat1
    set kat2 (random (dwellings - kat1))
    set kat2free kat2
    set kat3 (dwellings - kat2 - kat1)
    set kat3free kat3
    set kat4 0
    set pcolor round (families / (max [families] of Places) * 9)
    ifelse kat1 > families 
    [
      set kat1lived families
      set kat1free (kat1 - families)
      sprout families
      [
        ifelse random 100 > obydlenost [set DateOfMove 0] [set DateOfMove (-55)]  ;; vychazim z predpokladu, ze cim vetsi je obydlenost obce tesne po valce, tim mensi sance je, ze mistni Cech ziskal svou nemovitost prestehovanim, naopak, cim je obydlenost mensi, tim je sance vetsi (Cech se ma kam stehovat...)
        set LivingKat 1
        set Dice (1 + random 100)
        ifelse Dice > sudety-salamisti-dno
        [set povaha "salamista" set color red]
        [ifelse Dice < sudety-zlepsovaci-strop 
          [set povaha "zlepsovac" set color blue] [set povaha "udrzovaci" set color yellow] 
        ] 
      ]
    ]
    [
      set kat1lived kat1
      set kat1free 0
      sprout kat1
      [
        ifelse random 100 > obydlenost [set DateOfMove 0] [set DateOfMove (-55)]  
        set LivingKat 1
        set Dice (1 + random 100)
        ifelse Dice > sudety-salamisti-dno
        [set povaha "salamista" set color red]
        [ifelse Dice < sudety-zlepsovaci-strop 
          [set povaha "zlepsovac" set color blue] [set povaha "udrzovaci" set color yellow] 
        ] 
      ]
      ifelse (kat1 + kat2) > families
      [
        set kat2lived (families - kat1)
        set kat2free (kat2 - kat2lived)
        sprout kat2lived
        [
          ifelse random 100 > obydlenost [set DateOfMove 0] [set DateOfMove (-55)]  
          set LivingKat 2
          set Dice (1 + random 100)
          ifelse Dice > sudety-salamisti-dno
          [set povaha "salamista" set color red]
          [ifelse Dice < sudety-zlepsovaci-strop 
          [set povaha "zlepsovac" set color blue] [set povaha "udrzovaci" set color yellow] 
        ] 
      ]
      ]
      [
        set kat2lived kat2
        set kat2free 0
        set kat3lived (families - kat1 - kat2)
        set kat3free  (kat3 - kat3lived)
        sprout kat2
        [
          ifelse random 100 > obydlenost [set DateOfMove 0] [set DateOfMove (-55)]  
          set LivingKat 2
          set Dice (1 + random 100)
          ifelse Dice > sudety-salamisti-dno
          [set povaha "salamista" set color red]
          [ifelse Dice < sudety-zlepsovaci-strop 
          [set povaha "zlepsovac" set color blue] [set povaha "udrzovaci" set color yellow] 
          ] 
        ]
        sprout kat3lived
        [
          ifelse random 100 > obydlenost [set DateOfMove 0] [set DateOfMove (-55)]  
          set LivingKat 3
          set Dice (1 + random 100)
          ifelse Dice > sudety-salamisti-dno
          [set povaha "salamista" set color red]
          [ifelse Dice < sudety-zlepsovaci-strop 
          [set povaha "zlepsovac" set color blue] [set povaha "udrzovaci" set color yellow] 
          ] 
         ]
       ]
     ]
  ]  
 

  ask patches
  [
    if pxcor = 4 
    [
      set pcolor green
      sprout turtles-at-patch-born 
      [
        set members 3
        set Dice (1 + random 100)
        ifelse Dice > dosidleni-salamisti-dno
        [set povaha "salamista" set color red]
        [ifelse Dice < dosidleni-zlepsovaci-strop 
        [set povaha "zlepsovac" set color blue] [set povaha "udrzovaci" set color yellow] 
        ]
      ]
    ]
  ]
 
  ask turtles 
  [
    set members 3
    set size 0.3
  ]  
  
  set Zlepsovaci turtles with [color = blue]
  set Udrzovaci turtles with [color = yellow]
  set Salamisti turtles with [color = red]
  set Dosidlujici turtles with [xcor = 4]
  set Ostatni turtles with [xcor < 3]
  
  ask Places
  [
    set inhabitants sum [members] of turtles-here
    set Hospody ceiling ((inhabitants - 29) / 300) 
    set Obchody ceiling ((inhabitants - 49) / 200) 
    set Doktori ceiling ((inhabitants - 799) / 2000) 
    set Posty ceiling ((inhabitants - 299) / 2500) 
    set LinkyVerejneDopravy ceiling ((inhabitants - 199) / 150) ;; u osad s malo obyvateli to nekdy vyjde -1, mohl bych to opravit ale necham to tam jako "penalizaci za spatne silnice"...
    set Skoly ceiling ((inhabitants - 499) / 1000) 
    set Kina ceiling ((inhabitants - 799) / 2000) 
    set Farnosti ceiling ((inhabitants - 29) / 6000) 
    set Kulturaky ceiling ((inhabitants - 999) / 3000) 
    set Vybavenost (Hospody + Obchody + Doktori + Posty + LinkyVerejneDopravy + Skoly + Kina + Farnosti + Kulturaky)
    set BonusObec (3 * Obec)
    set BonusObydlenost floor (Obydlenost / delitel-obydlenost)
    set IAm (Vybavenost + BonusObec + BonusObydlenost)
  ]
   
   
   ask Places
   [
     if any? neighbors with [plabel != ""] [set IAm (([IAm] of max-one-of neighbors with [plabel != ""] [IAm]) * 0.1 + IAm)]
   ]
  
  
  set IAmDifference (([IAm] of max-one-of Places [IAm]) - ([IAm] of min-one-of Places [IAm]))
  show IAmDifference
  
  
  ask Dosidlujici
  [
    set fIAm floor (random-normal (IAmDifference / 2) (IAmDifference / 6))
    if fIAm < 0 [set fIAm 0]
    set LivingKat ((random 3) + 2)   
  ]


  ask Ostatni
  [
    set fIAm ([IAm] of patch-here)
  ]

  ask turtles [set DateOfMove (random 51) - 52]
  
end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go
  set IAmDifference (([IAm] of max-one-of Places [IAm]) - ([IAm] of min-one-of Places [IAm]))
  ask turtles with [(DateOfMove + 51) < ticks] 
  [
    set CompareAttractivity fIAm
    set CompareLiving LivingKat 
    set LeftKat LivingKat
    set LeftCity patch-here
    GuessToMove
    if TargetingCity != 0 
    [
      ask LeftCity [RecountCityLeft]
      move-to TargetingCity
      set fIAm ([IAm] of patch-here)
      set LivingKat CompareLiving
      set DateOfMove ticks
    ]
  ]
  if (natural-downgrade  = True) 
  [
    show "under construction"
    ask patches with [pxcor < 3]
    [
     let zchatralo3 floor ((random-float sance-chatrani) * kat3free)
     set kat3free (kat3free - zchatralo3)
     set kat3 (kat3 - zchatralo3)
     set kat4 (kat4 + zchatralo3)
     let zchatralo2 floor ((random-float sance-chatrani) * kat2free)
     set kat2free (kat2free - zchatralo2)
     set kat2 (kat2 - zchatralo2)
     set kat3 (kat3 + zchatralo2)
     let zchatralo1 floor ((random-float sance-chatrani) * kat1free)
     set kat1free (kat1free - zchatralo1)
     set kat1 (kat1 - zchatralo1)
     set kat2 (kat2 + zchatralo1)
    ]
  ]
  ask Places [set families (count turtles-here)]
  ask Places [set pcolor (round (families / (max [families] of Places) * 9))]
  ask Places [set inhabitants sum [members] of turtles-here]
end


to GuessToMove
   StanoveniKategoriiBydleni
   if any? VolneKat1 
   [
     ask VolneKat1
     [
      if (CompareLiving > 1) and (IAm > CompareAttractivity) 
       [
        CheckFamilyAndCity1
        stop
       ]
      if (CompareLiving = 1) and ((random IAmDifference) < (IAm - CompareAttractivity))
       [
        CheckFamilyAndCity1
        stop
       ]
      if (CompareLiving > 1) and (IAm < CompareAttractivity) and ((random IAmDifference) > (CompareAttractivity - IAm))
       [
        CheckFamilyAndCity1
        stop
       ]
      ]
    ]

   if any? VolneKat2 
   [
     ask VolneKat2
     [
      if (CompareLiving > 2) and (IAm > CompareAttractivity)  
       [
        CheckFamilyAndCity2
        stop
       ]
      if (CompareLiving = 2) and ((random IAmDifference) < (IAm - CompareAttractivity))
       [
        CheckFamilyAndCity2
        stop
       ]
      if (CompareLiving = 1) and ((random IAmDifference) < ((IAm - CompareAttractivity) / 2))
       [
        CheckFamilyAndCity2
        stop
       ]
      if (CompareLiving > 2) and (IAm < CompareAttractivity) and ((random IAmDifference) > (CompareAttractivity - IAm))
       [
        CheckFamilyAndCity2
        stop
       ]
      ]
    ]
   
   if any? VolneKat3 
   [
     ask VolneKat3
     [
      if (CompareLiving > 3) and (IAm > CompareAttractivity)  
       [
        CheckFamilyAndCity3
        stop
       ]
      if (CompareLiving = 3) and ((random IAmDifference) < (IAm - CompareAttractivity))
       [
        CheckFamilyAndCity3
        stop
       ]
      if (CompareLiving < 3) and ((random IAmDifference) < ((IAm - CompareAttractivity) / 2))
       [
        CheckFamilyAndCity3
        stop
       ]
      if (CompareLiving > 3) and (IAm < CompareAttractivity) and ((random IAmDifference) > (CompareAttractivity - IAm))
       [
        CheckFamilyAndCity3
        stop
       ]
      ]
    ]
end 


to CheckFamilyAndCity1
        set kat1free (kat1free - 1)
        set kat1lived (kat1lived + 1)
        set CompareLiving 1
        RecountCity
end


to CheckFamilyAndCity2
        set kat2free (kat2free - 1)
        set kat2lived (kat2lived + 1)
        set CompareLiving 2
        RecountCity
end


to CheckFamilyAndCity3
        set kat3free (kat3free - 1)
        set kat3lived (kat3lived + 1)
        set CompareLiving 3
        RecountCity
end


to RecountCity
    set TargetingCity self
    set families (families + 1)
    if pxcor < 3 [set obydlenost round (families / dwellings * 100)]
    set inhabitants sum [members] of turtles-here
    if inhabitants  > 250 [set Obec 1]    
    if Hospody < ceiling ((inhabitants - (49 + 4.9 * (1 - Obec))) / 500 + 50 * (1 - Obec)) [set Hospody ceiling ((inhabitants - 49) / 500)] 
    ;; penalizaci za osadu p5ipo49t8v8m p5es n*(1-Obec), nekter8 infrastruktura se ale v mistech pod 450 obyvatel ani postavit neda, tak tam to tou penalizaci nekomplikuju
    ;; a dale abych to nekomplikoval, penalizaci uplatnuji jen pri rozhodovani, zda si to postavi, do 450  pak funguje vzorec stejne i bez penalizace, tak jsem to zase nekomplikoval... 
    if Obchody < ceiling ((inhabitants - (99 + 9.9 * (1 - Obec))) / 300 + 30 * (1 - Obec)) [set Obchody ceiling ((inhabitants - 99) / 300)] 
    if Doktori < ceiling ((inhabitants - 1199) / 3000) [set Doktori ceiling ((inhabitants - 1199) / 3000)]
    if Posty < ceiling ((inhabitants - 499) / 5000) [set Posty ceiling ((inhabitants - 499) / 5000)] 
    if LinkyVerejneDopravy < ceiling ((inhabitants - 299 + (29.9 * (1 - Obec)) / 200)) [set LinkyVerejneDopravy ceiling ((inhabitants - 299) / 200)] ;; u osad s malo obyvateli to nekdy vyjde -1, mohl bych to opravit ale necham to tam jako "penalizaci za spatne silnice"...
    if Skoly < ceiling ((inhabitants  - 799) / 1500) [set Skoly ceiling ((inhabitants - 799) / 1500)] 
    if Kina < ceiling ((inhabitants - 1999) / 20000) [set Kina ceiling ((inhabitants - 1999) / 20000)] 
    if Farnosti < ceiling ((inhabitants - 49 + (4.9 * (1 - Obec))) / 10000) [set Farnosti ceiling ((inhabitants - 49) / 10000)] 
    if Kulturaky < ceiling ((inhabitants - 2999) / 10000) [set Kulturaky ceiling ((inhabitants - 2999) / 10000)] 
    set Vybavenost (Hospody + Obchody + Doktori + Posty + LinkyVerejneDopravy + Skoly + Kina + Farnosti + Kulturaky)
    set BonusObec (3 * Obec)
    set BonusObydlenost floor (Obydlenost / delitel-obydlenost)
    set IAm (Vybavenost + BonusObec + BonusObydlenost)
    ;; if any? neighbors with [plabel != ""] [set IAm (([IAm] of max-one-of neighbors with [plabel != ""] [IAm]) * 0.1 + IAm)]
end 


to RecountCityLeft
    if LeftKat = 1 [set kat1free (kat1free + 1) set kat1lived (kat1lived - 1)]  
    if LeftKat = 2 [set kat1free (kat2free + 1) set kat1lived (kat2lived - 1)]
    if LeftKat = 3 [set kat1free (kat3free + 1) set kat1lived (kat3lived - 1)] 
    set families (families - 1)
    if pxcor < 3 [set obydlenost round (families / dwellings * 100)]
    set inhabitants sum [members] of turtles-here
    if inhabitants  < 100 [set Obec 0]    
    if Hospody > ceiling ((inhabitants - 29) / 300) [set Hospody ceiling ((inhabitants - 29) / 300)]
    if Obchody > ceiling ((inhabitants - 49) / 200) [set Obchody ceiling ((inhabitants - 49) / 200)]
    if Doktori > ceiling ((inhabitants - 799) / 2000) [set Doktori ceiling ((inhabitants - 799) / 2000)]
    if Posty > ceiling ((inhabitants - 299) / 2500) [set Posty ceiling ((inhabitants - 299) / 2500)]
    if LinkyVerejneDopravy > ceiling ((inhabitants - 199) / 150) [set LinkyVerejneDopravy ceiling ((inhabitants - 199) / 150)] ;; u osad s malo obyvateli to nekdy vyjde -1, mohl bych to opravit ale necham to tam jako "penalizaci za spatne silnice"...
    if Skoly > ceiling ((inhabitants - 499) / 1000) [set Skoly ceiling ((inhabitants - 499) / 1000) ]
    if Kina > ceiling ((inhabitants - 799) / 2000) [set Kina ceiling ((inhabitants - 799) / 2000)] 
    if Farnosti > ceiling ((inhabitants - 29) / 6000) [set Farnosti ceiling ((inhabitants - 29) / 6000)] 
    if Kulturaky > ceiling ((inhabitants - 999) / 3000) [set Kulturaky ceiling ((inhabitants - 999) / 3000)] 
    set Vybavenost (Hospody + Obchody + Doktori + Posty + LinkyVerejneDopravy + Skoly + Kina + Farnosti + Kulturaky)
    set BonusObec (3 * Obec)
    set BonusObydlenost floor (Obydlenost / delitel-obydlenost)
    set IAm (Vybavenost + BonusObec + BonusObydlenost)
    ;; if any? neighbors with [plabel != ""] [set IAm (([IAm] of max-one-of neighbors with [plabel != ""] [IAm]) * 0.1 + IAm)]
end 


to StanoveniKategoriiBydleni
  set VolneKat1 patches with [kat1free > 0 ]
  set VolneKat2 patches with [kat2free > 0 ]
  set VolneKat3 patches with [kat3free > 0 ]
end