Supply & Demand

No preview image

1 collaborator

Default-person Eric Horowitz (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 4.1.2 • Viewed 763 times • Downloaded 50 times • Run 8 times
Download the 'Supply & Demand' modelDownload this modelEmbed this model

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


WHAT IS IT?

This section could give a general understanding of what the model is trying to show or explain.

HOW IT WORKS

This section could explain what rules the agents use to create the overall behavior of the model.

HOW TO USE IT

This section could explain how to use the model, including a description of each of the items in the interface tab.

THINGS TO NOTICE

This section could give some ideas of things for the user to notice while running the model.

THINGS TO TRY

This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.

EXTENDING THE MODEL

This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.

NETLOGO FEATURES

This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.

RELATED MODELS

This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.

CREDITS AND REFERENCES

This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.

Comments and Questions

I´m a novice in netlogo model

I just making my first project this moment

Posted over 7 years ago

Click to Run Model




Globals [price]
Breed [Buyers Buyer]
Breed [Cars Car]
Buyers-own [willingtopay]
Cars-own [willingtosellfor]
turtles-own [partner]

to setup
  
  clear-all                                                     ;clear the world
  create-Buyers 50                                              ;create buyers, put them in random places
  [
  setxy random-xcor random-ycor
  ]
  create-Cars 50                                                ;create cars, put them in random places
  [
   setxy random-xcor random-ycor
  ]
  ask buyers [set shape "buyersleeping"]                        ;give buyers default neutral shapes
  ask cars [set shape "carsleeping"]                            ;give cars default neutral shapes        
  ask Buyers [set willingtopay (who + 50 + Change-in-Demand)]    ;set price buyers are willing to pay
  ask Cars [set willingtosellfor (who + 1 - Change-in-Supply)] ;set price cars are willing to sell for
  set price Initial-Price                                       ;converts price set by slider into variable that can change
end 

to go
  ;these commands repeat most of the startup procedures for when "go" is called after a price change
  ask buyers [set shape "buyersleeping"]
  ask cars [set shape "carsleeping"]
  ;ask Buyers [set willingtopay (who + 1 + Change-in-Demand)]
  ;ask Cars [set willingtosellfor (who - 49 - Change-in-Supply)]
  ask turtles [set partner nobody] 
  ask turtles [setxy random-xcor random-ycor]
  
  ;if you're a buyer willing to buy and haven't bought, show that you're looking
  ask buyers [if willingtopay >= price and partner = nobody and not any? buyers with [shape = "buyermad"][set shape "buyerlooking"]]
  
  ;if you're a car willing to sell haven't sold, and there are buyers, show that you're selling.
  ask cars [if willingtosellfor <= price and partner = nobody and not any? cars with [shape = "carmad"][set shape "carlooking"]]
  
  ;if you're a buyer willing to buy and haven't bought, find a car to buy
  ask buyers [if shape = "buyerlooking" [findseller]]
  
  ;if you're a car who wants to sell and there are no buyers left, look angry
  ask cars [if willingtosellfor <= price and partner = nobody and not any? buyers with [shape = "buyerlooking"] [set shape "carmad"]]
  
  ;if nobody is looking to buy or sell, stop and announce the equilibrium price ahs been reached
  if not any? cars with [shape = "carlooking"] 
     and not any? cars with [shape = "carmad"]
        and not any? buyers with [shape = "buyerlooking"] 
           and not any? buyers with [shape = "buyermad"]
              [output-print " " output-type "Equilibrium price reached! " output-type count cars with [partner != nobody] output-type " Cars sold for $" output-type price output-type " each."  stop]
  
  ;if buyers and cars are angry, and they are willing to adjust prices, make them adjust their prices
  if any? buyers with [shape = "buyermad"] and price-adjusting [raiseprice]
  if any? cars with [shape = "carmad"] and price-adjusting [lowerprice]
  
  ;if buyers and cars are angry, but they are not willing to adjust prices, stop and announced they are angry
  if any? buyers with [shape = "buyermad"] and not price-adjusting [output-print "Buyers are angry!" stop]
  if any? cars with [shape = "carmad"] and not price-adjusting [output-print "Sellers are angry!" stop]
end 

to findseller
  ;if there are cars who want to buy, but can't, make them mad
  ask buyers [if willingtopay >= price and partner = nobody and not any? cars with [shape = "carlooking"] [set shape "buyermad"]]
  
  ;if there are sellers who want to sell, but can't, make them mad
  ask cars [if willingtosellfor <= price and partner = nobody and not any? buyers with [shape = "buyerlooking"] [set shape "carmad"]]
  
  ;if there are cars left who want to be sold, wander around and look for them
  if any? cars with [shape = "carlooking"] and partner = nobody [lt random 40 rt random 40 fd 1 checkseller]
end 

to checkseller
  ;if there is an unsold car who wants to sell on this spot, buy it and make both of you happy.
  if any? other turtles-here with [(partner = nobody) and (shape = "carlooking")]
       [set partner one-of other turtles-here with [partner = nobody and shape = "carlooking"] 
       set shape "buyerhappy"
       ask partner [set partner myself set shape "carhappy"]]
  update-plot
  
  ;if there's not car here, look somewhere else
  if not any? other turtles-here with [shape = "carlooking"][findseller]
end 

to raiseprice
  ;annoucne your are raising the price, then raise the price
  Output-print "Angry Buyers with no cars offer to pay more." output-type "Price rises to $" output-type price + 1 output-print "." 
         output-print " "
  set price (price + 1)
  ;wait 2
  go
end 

to lowerprice
  ;announce you are lowering the price, then lower the price
  Output-print "Sellers angry nobody will buy their car offer lower prices." output-type "Price drops to $" output-type price - 1
       output-print "." output-print " "
  set price (price - 1)
 ; wait 2
  go
end 

to update-plot
set-current-plot "Change in Price"
set-current-plot-pen "Price"
plot price
set-current-plot "Change in Quantity"
set-current-plot-pen "cars sold"
plot count cars with [partner != nobody]
end 
  

There are 2 versions of this model.

Uploaded by When Description Download
Eric Horowitz over 8 years ago No description provided Download this version
Eric Horowitz over 8 years ago Initial upload Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.