model

model preview image

1 collaborator

Default-person ifelab lerma (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.2.0 • Viewed 65 times • Downloaded 3 times • Run 0 times
Download the 'model' 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

globals [seed-number R-rate R*-rate R**-rate  Taxes deathcounter]
Extensions [array]
breed [householders householder]
breed [banks bank]
breed [firms firm]
breed [centralbanks Centralbank ]



householders-own [income  NBK W dep C0 conso wealth Div infoLevel ethicLevel ethical ethicalExperience ETHIQUE ]
banks-own [K Mcb TP FP P Prem RL deposits]
firms-own [firmMoney NBF price act Work LL Y TY N I Pr chP chA Fpp Rent TDIV debt money-Need se-index fin-index  positiveImpact weightedImpact Se-weight]
Centralbanks-own [TMCB]

to setup
  clear-all
  set-random-seed
  setup-patches
  setup-turtles
  reset-ticks
end 

to set-random-seed
 let my-seed 123; user-input "Enter a random seed (an integer):"
end 

to setup-patches
  ask patches [
    set pcolor brown
  ]
end 

to setup-turtles
  create-householders howManycapitalists
  [set shape "person"
    set size 1
    set color 2
    set label "c"
    setxy random-xcor random-ycor
    set infoLevel  infoHouseholders + random-float 5 ; info level retourne un nb aléatoire entre 0 et 5 , on rajoute l'infohouseholders sur le slider
    set ethicLevel  EthicsHouseholders + random-float 5
    set ethical nobody ;  boolean var, true or false
    ; la consommation initiale
    set C0 random 5998 ; valeur de la consommation moyenne des ménages Bam Aout 2019
    set Taxes 0.5
    set ethicalExperience 1
    set conso 4000
    set dep 4500
    set income 9000
            ]

   create-householders howManyWorkers
  [set shape "person"
    set size 1
    set color 2
    set label "w"
    setxy random-xcor random-ycor
    set infoLevel  infoHouseholders + random-float 5
    set ethicLevel EthicsHouseholders + random-float 5
    set ethical nobody
    set C0 random 5998
    set Taxes 0.5
    set ethicalExperience 1
    set conso 4000
    set dep 4500
    set income 9000
    ]

create-banks howManytraditionalBanks ; 19
  [set shape "house"
    set size 2.5
    set color gray
    set label "Trad"
    setxy random-xcor random-ycor ; position au hasard
    ask banks [if any? other banks-here[move-to one-of patches]] ; une banque par patch
    set FP 50000000
    set K 1000000
    set R-rate 0.04
    set R*-rate 0.0225
    set R**-rate 0.0225
    ; la prime de risque
    set Prem  (R-rate - R**-rate)
  ]

  create-banks howManyEthicalBanks ; 5
  [set shape "house"
    set size 2.5
    set color 53
    setxy random-xcor random-ycor
    set label "Ethic"
    set FP 50000000;
    set K 1000000
    set R-rate 0.04
    set R*-rate 0.0225
    set R**-rate 0.0225

  ]

  create-Centralbanks 1
  [set shape "house"
    set size 4
    set color 2
    set label " centralbank"
    setxy 0 0
            ]

 create-firms howManyFirms
  [set shape "factory"
    set size 2
    set color yellow
    setxy random-xcor random-ycor
    set se-index EindexFirms
    set fin-index random-float 10
    set firmMoney 10000 + random 1000
    set positiveImpact 0
    set weightedImpact 0
  ]
end 

to go

ask householders
[
    set W 1500 + random 8000
   Myincome
    ask my-links [ die ]
    create-link-with one-of firms
      [set color 8]
    consumption
    householderAct
    set wealth wealth + dep
    forward random 4 left random 180
        householders-interaction
  ]


  Ask banks
[
    create-link-with min-one-of Centralbanks  [distance myself][set color 1]
      CBdeposit
    set TP  (FP + deposits + Mcb )
    set Prem  (R-rate - R**-rate)
    set P  ((R-rate * K) - (R*-rate * deposits) - (R**-rate * Mcb) )
    set FP FP + P
    set RL  FP / K
   if TP < 5000000
            [ set label "Fall"
              die
             ]

]

Ask firms
  [
    firmact ;
    Let T 0
    ask my-links [ ask other-end [ if label = "w" [set T T + 1 ]]]
    set Work T
    let cap 0
    ask my-links [ ask other-end [ if label = "c" [set cap cap + 1 ]]]
    set Act cap
    Set N (T + Act )
    let At  1
    let Ut 1
    Let L 0
    ask my-links [ ask other-end [ if label = "w" or label = "c" [set L L + W ]]]
    set LL L
    let alpha 0.7
    set Y  (At * (( Ut * firmMoney ) ^ alpha) * (( LL ) ^ ( 1 - alpha )) )
    set TY TY + Y
    Loan
    set I (I + firmMoney)
    set ChP  LL
    set Pr  ( chA - ChP - (R-rate * firmMoney ) )
    set Fpp (Fpp + Pr)
    ifelse I != 0
    [ set Rent  Fpp / I ]
    [set Rent 0]
    If Rent > 0
    [ set fin-index 10 - Random-float 5 ]
    dividente ;
    Bankrupt
  ]
    if random 200 > 180
    [createFirm]



  tick
end 

to Myincome
  ifelse any? links with [color = green or color = blue ]
   [let D  (R-rate * dep)
       set income (W + D + Div)]
  [set income (W + Div)]
end 

to consumption
    let sigma random-float 0.45
    set conso (C0 + sigma * ( income - (Taxes * income)))
  let Con conso
    ask my-links [ ask other-end [set chA chA + Con ]]
end 

to householderAct
  set NBK 0;
  Set ETHIQUE (infoLevel * ethicLevel * (1.1 - random-float 0.2) * (ethicalExperience ))

  ifelse ETHIQUE > 49
    [set ethical true
    if ethicLevel > 6 or ethicLevel = 6
       [ifelse any? banks with [label = "Ethic"]
       [move-to one-of banks with [label = "Ethic"]]
          [set NBK NBK + 1]]
    if ethicLevel < 6
      [ ifelse any? banks with [label = "Ethic"]
       [move-to one-of banks with [label = "Ethic"]]
       [if any? banks with [label = "Trad"]
          [move-to one-of banks with [label = "Trad"]]]]]

     [set ethical false
          ifelse any? banks with [label = "Trad"]
        [move-to one-of banks with [label = "Trad"]]
      [if any? banks with [label = "Ethic"]
          [move-to one-of banks with [label = "Ethic"]]]]

; effectuer un dépôt
    If any? banks-here
  [if income > conso
      [ Let myDeposit (income - conso)
        set dep myDeposit
        ask banks-here [set deposits deposits + myDeposit]
        ]

  ]

; effectuer un retrait
  If any? banks-here
 [if income < conso
  [let myWithdraw (conso - income)
      set dep (-1 * myWithdraw)
      ask banks-here [set deposits deposits - myWithdraw ]
      set color 16]]
end 

to householders-interaction
  forward random 2 right random 360
  let speaker one-of other householders-here
  if speaker != nobody
  [ifelse [ethicLevel] of speaker > 6
    [if ethicalExperience < 10
      [ set ethicalExperience ethicalExperience + 1
    ]]
      [if ethicalExperience > 1
        [ set ethicalExperience ethicalExperience - 1
        ]]]
end 

to CBdeposit
  let F (0.7 * (FP + deposits))
  ifelse K > F
  [ Let M ( K - F  )
    Ask my-links [ask Centralbanks [set TMCB TMCB + M ]]
   set Mcb M ]
    [ set Mcb 0 ]
end 

to firmact
  set NBF 0
  ask my-links with [color = green or color = blue] [die]
  ifelse se-index + random-float 3  > 5
   [ ifelse any? banks with [label = "Ethic"]
   [ create-link-with one-of banks with [label = "Ethic"]
        [set color green ]]
             [ set NBF NBF + 1 ]]
     [ create-link-with one-of banks with [label = "Trad"]
        [set color blue ]]
end 

to Loan
  If y < chA
 [ let q (LL ^ 0.3) ;
    if q != 0
  [let H  (( chA / q ) ^ ( 1 / 0.7))
  let crd  (H - FirmMoney)
     if any? links with [color = green or color = blue ]
      [set firmMoney firmMoney + crd
        ask my-links with [color = green] [ask other-end [set k k + crd]]
        ask my-links with [color = blue] [ask other-end  [set k k + crd]]]]]
end 

to Bankrupt
  if Pr < -30000
  [set color black
    set deathcounter deathcounter + 1
      ]
  if Pr < -30000
 [die]
end 

to createFirm
  create-firms 1
  [set shape "factory"
    set size 2
    set color yellow
    setxy random-xcor random-ycor
    set se-index EindexFirms
    set fin-index random-float 10
    set firmMoney 10000 + random 1000
    set positiveImpact 0
    set weightedImpact 0
  ]
end 

to dividente
    if Act > 0
  [ Let beta random-float 0.3
    Let A (beta * Pr)   ;
  if A > 0
    [set TDIV A
     Let B A / Act
      ask my-links [ ask other-end [ if label = "c" [set Div B ]]]

    ]
  ]
end 

There is only one version of this model, created 9 months ago by ifelab lerma.

Attached files

File Type Description Last updated
model.png preview Preview for 'model' 9 months ago, by ifelab lerma Download

This model does not have any ancestors.

This model does not have any descendants.