Money Flow

No preview image

1 collaborator

Default-person SangHee Kim (Author)

Tags

(This model has yet to be categorized with any tags)
Parent of 1 model: Planned Economy
Model group MAM-2015 | Visible to everyone | Changeable by the author
Model was written in NetLogo 5.2.0 • Viewed 570 times • Downloaded 40 times • Run 0 times
Download the 'Money Flow' modelDownload this modelEmbed this model

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


Comments and Questions

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

Click to Run Model

turtles-own [
  goal
  workplace
  house
  favorite-retail
  money]
breed [workers worker]
breed [businessmen businessman]

patches-own [
  popularity
  business-income
  business-revenue
  factory-revenue
  factory-income
  number-of-employees
  employees
  business-partner
  area-wealth]

globals [
  factories
  houses
  businesses
  retailers
  GDI 
  worker-income
  businessmen-income
  average-factory-revenue
  average-business-revenue]

to setup
  clear-all
  reset-ticks
  set houses (list)
  set factories (list)
  set businesses (list)
  ask patches [
    set pcolor green]
  
;;;;;;;;;;;;;;;;;;INITIAL BUILDING CREATION;;;;;;;;;;;;;;;;;;;;;;;;;
;The three 'if' statements generate houses, factories, and businesses and create turtles with respective shapes.
;The number of these patches can be determined by the users with corresponding sliders.
;For factories and businesses, they are given initial revenues, and sets the income (how much the turtles earn) as
;1% of the revenue + the minimum wage of the model ($5)

    ask n-of initial-number-of-houses patches [
      set pcolor red
      set houses (fput self houses)
      sprout 1 [
        set shape "house"
        set color yellow
        set size 2]]

  
    ask n-of initial-number-of-factories patches with [pcolor != red][
      set pcolor blue
      set factory-revenue 2000
      set factory-income (factory-revenue * 0.01) + 5
      set factories (fput self factories)
      set employees (list)
      sprout 1 [
        set color violet
        set shape "Factory"
        set size 4.5]]

     ask n-of initial-number-of-businesses patches [
      set pcolor white
      set businesses (fput self businesses)
      set business-revenue 2000
      set business-income (business-revenue * 0.01) + 5
      set employees (list)
      set business-partner one-of patches with [pcolor = blue]
      sprout 1[
        set shape "building"
        set color white
        set size 4.5
        ]]
  


;;;;;;;;;;;;;;;;;;;;;;INITIAL TURTLE CREATION;;;;;;;;;;;;;;;;;;;;;;;;;;
;Creates two sets of turtles: Businessmen and Workers
;They are generated on top of the green patches so that they will not be generated on top of buildings

   ask n-of businessmen-count patches with [pcolor = green] 
  [sprout-businessmen 1 [
    set xcor random-xcor
    set ycor random-ycor
    set workplace one-of patches with [pcolor = white]
    ask workplace [
      set number-of-employees number-of-employees + 1     ;Makes the workplace count how many employees are currently working there
      set employees (fput myself employees)]              ;Puts self in the list of employees
    set house one-of patches with [pcolor = red]          ;Sets house as one of the red patches
    set color white
    set size 1.3
    set money 0                                           ;Starts the life with no money
    set shape "person"
    set goal workplace
  ]]
    ask patches with [pcolor = white][
    if employees = [] [ 
      set pcolor green
      ask turtles-here [die]
      set business-revenue 2000
      set business-income 0]]
    
    ask n-of worker-count patches with [pcolor = green] 
  [sprout-workers 1 [
       set workplace one-of patches with [pcolor = blue]
       ask workplace [set number-of-employees number-of-employees + 1]
       set house one-of patches with [pcolor = red]
       set color blue
       set size 1.3
       set money 0                                        
       set shape "person"
       set goal workplace
       let house-xcor [pxcor] of house
       let house-ycor [pycor] of house
       let own-house patch house-xcor house-ycor             ;Sets one of the businesses that is closest to home
       set favorite-retail min-one-of patches with [pcolor = white] [distance own-house] ;Sets the retailer to shop at based on how close it is to the turtle's house      
      ]]
end 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go                                                      
  update-data
  check-business-income
  check-if-defunct
  if length businesses = 0 or length factories = 0 [stop]    ;Stops the model if there is no factories or businesses remaining because 
  move-workers                                               ;;otherwise the model will run into fatal error
  move-businessmen
  run-business
  conduct-business
  wealth-distribution-view
  tick
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;MOVEMENT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Determines the basic movement behavior of the businessmen

to move-businessmen
  ask businessmen with [color = white][
    ifelse patch-here = goal
      [ ifelse [pcolor] of patch-here = white;                            ;When businessmen reach the workplace,
        [set goal house                                                   ;set house as the goal to move to,
         set money money + [business-income] of workplace                 ;and earns money from workplace as income
         ask workplace [                                                  ;and decreases the amount earned from the workplace's revenue
           set business-revenue business-revenue - business-income]
         if ticks mod 75 = 0 [
           set money money - [business-income] of workplace]]                           ;Businessmen goes to shopping
        [set goal workplace]]                                             
      [walk-towards-goal]]
end 

;Determines the basic movement behavior of the workers

to move-workers                                                                     
  ask workers with [color = blue][                                       
    ifelse patch-here = goal
      [ ifelse [pcolor] of patch-here = blue                              ;When the workers reach the factory,  
        [set goal house                                                   ;set the house as the goal,
         set money money + factory-income                                 ;and earn money from the factory as income
         ask workplace [                                                  ;and decreases the amount earned from the factory's revenue
           set factory-revenue factory-revenue - factory-income]]
        [set goal workplace]]
      [walk-towards-goal]
      if ticks mod 75 = 0[                                                ;Checks if the workers have enough money every 50 ticks
        if money > (GDI / (worker-count + businessmen-count))[            ;by comparing the wealth with GDI divided by number of turtles
          set color violet                                                ;And if so, set color to violet, which sets the command for them to go to the retailers
          go-to-retail]]]
      
   ask workers with [color = violet][                                     ;Asks the violet turtles
      ifelse patch-here = favorite-retail                                 ;checks if they are currently at the favorite retailer.
        [ifelse [pcolor] of patch-here = black                            ;If so, checks if the favorite retailer has closed down.
          [let house-xcor [pxcor] of house                                ;If it is closed down, get the xy coordinate of the house
           let house-ycor [pycor] of house                                ; and uses them to calculate distance of the retailer to the house
           let own-house patch house-xcor house-ycor                      ; and choose the retailer that is closest to home as the favorite one                     
           set favorite-retail min-one-of patches with 
                          [pcolor = white] [distance myself]]             
        
          [set goal house                                                 ;If the retailer has not closed down,
           set color blue                                                 ; return to the blue color to mark as not going to the retailer,
           set money money - [business-income] of patch-here              ; and subtract the worker's money to the 'price' of the retailer (business-income).
           let total-revenue [business-revenue] of patch-here             ;Afterwards, give the retailer the money from the workers
           let price ([business-income] of patch-here) + 5
           ask patch-here [set business-revenue total-revenue + price]
           walk-towards-goal]]
        [go-to-retail]]
end 

to check-if-defunct                                                        ;Checks if the turtles' workplace is being torn down
  ask businessmen[                                                         ;Asks both businessmen and workers if their workplaces are colored black, move to different place
    if workplace != nobody and [pcolor] of workplace = black [             ;and set it as the new house/workplace
      set workplace one-of patches with [pcolor = white]
   ]]

  ask workers [
    if workplace != nobody and [pcolor] of workplace = black [
      set workplace one-of patches with [pcolor = blue]]]
end 

to walk-towards-goal           ;Makes the turtles move towards their goals
  if goal != nobody[
  face goal
  fd 1]
end 





;;;;;;;;;;;;;;;;;;;;;;ECONOMY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to check-business-income                                       ;Checks and updates the revenue of the business
  ask patches with [pcolor = white][                           ;so that the data will be accurately represented in the GDI charts.
    if ticks mod 5 = 0 [                                       ;Also checks to see if the businesses' or factories' revenues are less than $1, 
    set business-income business-revenue * 0.01 + 5]           ;in which case it will go bankrupt and turn black                       
    if business-revenue < 1 [                                                      
      set pcolor black
      ask turtles-here with [size = 4.5] [die]]] 
  ask patches with [pcolor = blue][
    if ticks mod 5 = 0 [
      set factory-income factory-revenue * 0.01 + 5]
    if factory-revenue < 1 [
      set pcolor black
      ask turtles-here with [size = 4.5] [die]]]                                               
end 

to run-business
  if ticks mod 50 = 0 [
  ask patches with [pcolor = white] [                                                  ;Asks the businesses to choose one of its employers to
    if number-of-employees != 0 and business-partner != nobody[                        ;conduct business with its business partner.
      if business-revenue > (GDI)                                                      ;It only does this once every 50 ticks, and if the revenue is greater than GDI
      [ let good-man one-of employees                                                  ; to make sure that it has enough money.
        if [color] of good-man = white [                                               ;Once this action is chosen, business will spend 10% of its revenue as investment.
          ask good-man [
           set color gray
           set goal [business-partner] of myself
           set business-revenue business-revenue - (business-revenue * 0.1)]]]]]]
end 

to conduct-business
  ask turtles with [color = gray] [                                                    ;Asks the employer that was chosen to conduct business
    ifelse patch-here = goal                                                           ; to go to the factory that is set as the business partner.
    [ if [pcolor] of patch-here = blue                                                 ;Once the employer is there, add to the revenue of the factory the 10%
        [ set money money + [business-income] of workplace                             ; of the business' revenue.
          let factory-money [factory-income] of goal                                   ;Afterwards, set the goal back to the workplace again.
          let price [business-revenue] of workplace
          let income [business-income] of workplace
          ask workplace [set business-revenue business-revenue + factory-money - business-income]
          ask goal [set factory-revenue factory-revenue + (price * 0.1) - income]
          set color white
          set goal workplace]]
    [walk-towards-goal]]
end       

to go-to-retail
  if favorite-retail != nobody [            ;The turtle goes to its favorite retailer
     face favorite-retail                                                                
     fd 1]                                                         
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DATA ANALYSIS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to update-data
  ;With each tick, the following data are updated:
  ;GDI
  ;Total wealth of all workers
  ;Total wealth of all businessmen
  ;Average revenue of factories
  ;Average revenue of businesses
  
  set GDI sum [factory-income] of patches + sum [business-income] of patches
  set worker-income (sum [money] of workers) / worker-count
  set businessmen-income (sum [money] of businessmen) / businessmen-count
  set average-factory-revenue (sum [factory-revenue] of patches) / initial-number-of-factories
  set average-business-revenue (sum [business-revenue] of patches) / initial-number-of-businesses
end 

to wealth-distribution-view
  ;Changes the shades of the patches to reflect the wealth distribution based on GDI.
  ;Lighter the shade of green, the wealthier, and vice versa
  ;Ranges are > 99%, 90-99%, 75-90%, 50-75%, 25-50%, 10-25%, and < 10% of GDI.
  
  ask patches with [pcolor != white and pcolor != blue and pcolor != black and pcolor != red][
      set area-wealth (sum [business-income] of neighbors + sum [factory-income] of neighbors + sum [area-wealth] of neighbors) / 8
      let average-GDI (GDI / (initial-number-of-factories + initial-number-of-businesses))
      if area-wealth > (average-GDI * 0.99) [set pcolor green + 3]
      if area-wealth > (average-GDI * 0.90) and area-wealth < (average-GDI * 0.99) [set pcolor green + 2] 
      if area-wealth >= (average-GDI * 0.75) and area-wealth < (average-GDI * 0.9)  [set pcolor green + 1]
      if area-wealth >= (average-GDI * 0.5) and area-wealth < (average-GDI * 0.75)  [set pcolor green]
      if area-wealth >= (average-GDI * 0.25) and area-wealth < (average-GDI * 0.5)  [set pcolor green - 1]
      if area-wealth >= (average-GDI * 0.1) and area-wealth < (average-GDI * 0.25)  [set pcolor green - 2]
      if area-wealth < (average-GDI * 0.1) [set pcolor green - 3]]
end 

There are 5 versions of this model.

Uploaded by When Description Download
SangHee Kim almost 9 years ago Finalized version of the model, including comments and the info tab Download this version
SangHee Kim almost 9 years ago Final Version Download this version
SangHee Kim almost 9 years ago Changes described in the progress report Download this version
SangHee Kim almost 9 years ago Changes described in the progress report Download this version
SangHee Kim almost 9 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Final Project Progress Report #1.docx word Progress Report #1 almost 9 years ago, by SangHee Kim Download
Final Project Progress Report #2.docx word Progress Report #2 almost 9 years ago, by SangHee Kim Download
Final Project Progress Report #3.docx word Progress Report #3 almost 9 years ago, by SangHee Kim Download
Final Report.docx word Final Report of the model almost 9 years ago, by SangHee Kim Download

This model does not have any ancestors.

Children:

Graph of models related to 'Money Flow'