⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ga---dca-scott010506.nlogo

📁 NETLOGO
💻 NLOGO
📖 第 1 页 / 共 4 页
字号:
; __extensions [ "http://www.samoore.com/auctionmodel/auction.jar" ]__extensions [ "auction.jar" ]; thresholdValue posted-price auctionDuration-hours lambda-per-hour waiting-cost-per-hour lowerV upperV quantity; thresholdValue double integer double double double double integerglobals [  clock  ; Keeps the current time in the current auction  auction-num ; the number of the current auction  length-of-game ; The total length of an auction  max-valuation ; the maximum value that any consumer can value the good up for auction  min-valuation ; the minimum value that any consumer can value the good up for auction  P-posted-price ; the posted price at which the auctioned good can be purchased  y-P-posted-price ; the y-coordinate for the posted price  lowest-winning-bid ; the lowest current winning bid for the auctioned good  y-lowest-winning-bid ; the y-coordinate for the lowest winning bid  lowest-new-winning-bid ; the lowest new winning bid that can be submitted  highest-winning-bid ; the value of the highest winning bid  ; R-reserve-price ; the reserve price set for the auction  y-R-reserve-price ; the y-coordinate for the reserve price  next-buyer-arrival ; the time on the clock at which the next buyer is going to arrive  winners-list ; a list of the bidders who, if the auction ended, would win the auction  winning-bid-list ; a list of the winning bids  winner-info ; a list of information about the winning bidders  winning-bid-info ; a list of information about the winning bids  ; Slider: increment ; the smallest amount by which the current winning bid must be increased  auction-revenue ; the total amount the firm makes from the current auction  total-auction-revenue ; the total amount the firm makes from all of the auctions  posted-price-revenue ; the total amount the firm makes from the posted price sales during the                        ; current auction  total-posted-price-revenue ; the total amount the firm makes from all posted price sales during                        ; all auctions  posted-price-purchasers ; the total number of consumers who make a posted price purchase during                        ; the current auction  total-posted-price-purchasers ; the total number of consumers who make a posted price purchase                        ; during all auctions  total-ascending ; the total amount the firm made from both posted price and auction during open                        ; ascending auction  number-of-auctions ; the number of auctions run  x-offset ; a graphical display x-coordinate offset  y-offset ; a graphical display y-coordinate offset  show-bid-amount? ; show bid amount on display or just a circle?  sealed-auction-revenue ; the amount the firm would have made at this sealed bid auction  sealed-total-auction-revenue ; the total amount the firm would have made from all sealed bid                                ; auctions  sealed-posted-price-revenue ; the amount the firm would have made from posted price sales during                               ; sealed bid auction  sealed-total-posted-price-revenue ; the total amount the firm would have made from all posted                        ; price sales  total-sealed ; the total amount the firm would have made from both posted-price and auction                ; during sealed bid auction  ascending-diff ; the percentage by which revenues from an open ascending auction (and associated                  ; posted price revenues) would differ from the total revenues from just posted price  sealed-diff    ; the percentage by which revenues from a sealed q+1 auction (and associated                  ; posted price revenues) would differ from the total revenues from just posted price  solo-posted-price-revenue  ; the amount the firm would have made from just a posted price sale                             ; from the beginning of the current auction  total-solo-posted-price-revenue ; the amount the firm would have made from just a posted price sale                                  ; from the beginning of the simulation  ]breeds [buyers bids]buyers-own [ ; all of this info is consumer-specific and private to the consumer  V-valuation ; valuation of the good  arrival-time ; time the consumer arrived at the auction  threshold ; threshold value for this consumer in the sealed bid auction  winning? ; is the consumer currently winning the auction  live-bidder? ; is the consumer currently bidding in the auction  made-purchase-at-posted? ; did the consumer make a purchase at the posted price?  W-waiting-cost ; waiting cost; only pertinent if this is a high-valuation consumer  bidding-strategy-type ; the bidding strategy that the consumer utilizes  anticipated-final-auction-price ; the consumer's anticipated final auction cost  bid ; the amount that the consumer is bidding for the good  most-recent-bid ; the most recent bid that the consumer made  number-of-bids ; the number of bids that the consumer made in this auction  monitoring-cost ; cost of monitoring the auction --- not used yet  sealed-would-have-bought-at-posted? ; in the sealed bid auction the consumer would have bought                        ; at the posted price  sealed-would-have-won-auction? ; in the sealed bid auction the consumer would have been in the                        ; set of winners  sealed-price-paid-at-auction ; in the sealed bid auction the price the consumer would have paid  ]bids-own [  amount ; the amount of the bid  the-bidder ; who made the bid  the-time ; the time of the bid  ]to setup  ; this is run before everything else is run  initialize-globalendto go  ; this runs one auction. This differs from many NetLogo models in that this does not run just  ; one step of the auction --- it runs the whole thing. Thus, an auction cannot be interrupted.  initialize-auction  run-clockendto run-clock  ; This is the auction itself. "check-for-new-buyer" is the actual bidding process. Everything  ; else is basically bookkeeping.  set clock 0  while [clock < length-of-game] [     draw-timeline clock - x-offset    set clock clock + 1    check-for-new-buyer    update-bid-line    update-consumer-status    update-statistics  ]  end-gameendto update-consumer-status  ask buyers with [live-bidder?] [    if V-valuation < lowest-winning-bid [ drop-out-of-bidding ]  ]endto update-statistics  ; calculates statistics after every clock tick  ifelse (count buyers with [winning?]) > 0 [    ifelse payment-plan = "uniform-price"       [ set auction-revenue ( Q-quantity * (min values-from buyers with [winning?] [bid]) ) ]      [ set auction-revenue sum values-from buyers with [winning?] [bid] ]    ][    set auction-revenue 0    ]  set posted-price-purchasers (count buyers with [made-purchase-at-posted?])  set posted-price-revenue P-posted-price * posted-price-purchasersendto end-game  ; this is run after each and every auction  set auction-num (auction-num + 1)  handle-equivalent-sealed-bid-auction  handle-posted-price-if-solo   set total-solo-posted-price-revenue (total-solo-posted-price-revenue + solo-posted-price-revenue)   set number-of-auctions (number-of-auctions + 1)  ask buyers with [not winning? and not made-purchase-at-posted?] [ set size 2 ]  set total-auction-revenue (total-auction-revenue + auction-revenue)  set total-posted-price-revenue (total-posted-price-revenue + posted-price-revenue)  set total-ascending (total-ascending + total-auction-revenue + total-posted-price-revenue)  set total-posted-price-purchasers (total-posted-price-purchasers + posted-price-purchasers)  set sealed-total-auction-revenue (sealed-total-auction-revenue + sealed-auction-revenue)  set sealed-total-posted-price-revenue (sealed-total-posted-price-revenue + sealed-posted-price-revenue)  set total-sealed (total-sealed + sealed-total-auction-revenue + sealed-total-posted-price-revenue)  ifelse total-solo-posted-price-revenue > 0 [    set ascending-diff ((total-ascending - total-solo-posted-price-revenue) / total-solo-posted-price-revenue) / auction-num    set sealed-diff ((total-sealed - total-solo-posted-price-revenue) / total-solo-posted-price-revenue) / auction-num    ][    set ascending-diff 0    set sealed-diff 0    ]  do-plotsendto-report set-as-winner-of-sealed-auction [q-plus-one-valuation count-of-winners]  set sealed-would-have-won-auction? true  set sealed-price-paid-at-auction q-plus-one-valuation  report count-of-winners + 1endto handle-posted-price-if-solo  locals [ count-of-buyers price-if-solo ]  set price-if-solo (min-valuation + max-valuation) / 2  set count-of-buyers count buyers with [ V-valuation >= price-if-solo ]  set solo-posted-price-revenue (count-of-buyers * price-if-solo)endto handle-equivalent-sealed-bid-auction   locals [list-of-valuations q-plus-one-valuation count-of-winners]  set count-of-winners 0  ask buyers with [high-valuation-bidder?] [    if ((length-of-game - arrival-time) > threshold) [      set sealed-would-have-bought-at-posted? true      ]    ]  set list-of-valuations        sort-by [?1 > ?2]             values-from buyers with [not sealed-would-have-bought-at-posted?] [V-valuation]  ifelse length list-of-valuations >= (Q-quantity + 1) [ ; if there are at least Q+1 bids    set q-plus-one-valuation (item Q-quantity list-of-valuations) ; select item Q since 0-based    ][ ; if there are not at least Q+1 bids, then set the price that will be paid to the reserve price    set q-plus-one-valuation R-reserve-price    ]  ; this finds the top winners to the sealed bid auction  ask buyers with [not sealed-would-have-bought-at-posted?] [    if (V-valuation > q-plus-one-valuation) and (count-of-winners < Q-quantity) [      set count-of-winners set-as-winner-of-sealed-auction q-plus-one-valuation count-of-winners      ]    ] ; end ask buyers  ; in case of ties (at the minimum bid), this completes the list of auction winners  if count-of-winners < Q-quantity [ ; there are multiple consumers with equivalent bids    ask buyers with [(not sealed-would-have-bought-at-posted?) and                      (not sealed-would-have-won-auction?) and                      (V-valuation = q-plus-one-valuation)] [      if count-of-winners < Q-quantity [        set count-of-winners set-as-winner-of-sealed-auction q-plus-one-valuation count-of-winners        ]      ]    ] ; end if count-of-winners < Q-quantity  ; now we have marked all appropriate winners and we need to calculate all the results  set sealed-auction-revenue        sum values-from buyers with [sealed-would-have-won-auction?] [ sealed-price-paid-at-auction ]  set sealed-posted-price-revenue        (count buyers with [sealed-would-have-bought-at-posted?]) * P-posted-priceendto set-time-next-buyer  ; this function is called at the beginning of the model and after each person   ; is added to determine when the next buyer will arrive  set next-buyer-arrival next-buyer-arrival + random-exponential exponential-meanendto check-for-new-buyer  ; If the clock passes the arrival time for the next buyer, a new buyer will be   ;   added and the time of the next buyer will be calculated.   if clock > next-buyer-arrival [    new-buyer next-buyer-arrival    set-time-next-buyer    ]endto new-buyer [arrival-time-of-this-buyer]  ; This creates a new buyer. At the end of the creation process, it also checks  ; if this new consumer wants to bid in the auction.  cct-buyers 1 [    set V-valuation calculate-valuation    set arrival-time arrival-time-of-this-buyer    set W-waiting-cost calculate-waiting-cost    set bidding-strategy-type determine-bidding-strategy    set anticipated-final-auction-price (calculate-p-a W-waiting-cost V-valuation)    set winning? false    set made-purchase-at-posted? false    set most-recent-bid 0    set monitoring-cost 0    set number-of-bids 0    set bid 0    set sealed-would-have-bought-at-posted? false    set sealed-would-have-won-auction? false    set xcor clock - x-offset    set ycor V-valuation - y-offset    set-turtle-info bidding-strategy-type     ifelse V-valuation < lowest-new-winning-bid       [ drop-out-of-bidding ]      [ set live-bidder? true ]    set threshold         thresholdValue P-posted-price length-of-game exponential-mean W-waiting-cost min-valuation max-valuation Q-quantity    check-to-bid W-waiting-cost bidding-strategy-type V-valuation     ]endto check-with-all-buyers-if-they-want-to-bid  ; does just what it says.  ask buyers with [live-bidder? and not winning? and not made-purchase-at-posted?] [    check-to-bid W-waiting-cost bidding-strategy-type V-valuation     ]endto check-to-bid [ w bidder-type the-valuation ]  ; This is the process an agent goes through when it is considering to submit a bid.  ; It first determines whether or not it will bid. If it decides to, when it   ; determines what the bid will be. If the amount of the bid is   locals [ the-new-bid-id ]  if (live-bidder? and agent-should-bid? w the-valuation winning?) [    set anticipated-final-auction-price (calculate-p-a W-waiting-cost V-valuation)    set bid (bid-amount bidder-type anticipated-final-auction-price w the-valuation most-recent-bid)    if (bid >= lowest-new-winning-bid) and (bid > most-recent-bid) [      set the-new-bid-id (make-new-bid xcor color bid who)      update-winning-bid-list (turtle the-new-bid-id)      set most-recent-bid bid      ; Once a consumer has submitted a bid, then all other consumers need to       ; be given a chance to respond to the bid.      check-with-all-buyers-if-they-want-to-bid      ]    ]endto-report make-new-bid [ p-xcor p-color the-bid-amount id-of-the-bidder ]  ; Creates the bid turtle. Also updates the turtle for the related  ; buyer turtle.  locals [ the-bid-id ]  hatch-bids 1 [    set amount the-bid-amount    set the-time clock    set the-bidder id-of-the-bidder    set ycor the-bid-amount - y-offset    set xcor p-xcor    set-bid-turtle-info p-color the-time    set the-bid-id who    ]  ask turtle id-of-the-bidder [    set bid the-bid-amount    set number-of-bids (number-of-bids + 1)    ]  report the-bid-idendto set-bid-turtle-info [ color-of-the-bidder time-of-bid ]  set shape "circle"  set color color-of-the-bidder  ifelse show-bid-amount? [    set size 0    set label-color color-of-the-bidder    set label time-of-bid    ][    set size 1    ]endto update-winning-bid-list [ the-new-bid ]  locals [ winner-id-list losing-bidder ask-loser]  set ask-loser false  set winning-bid-list lput the-new-bid winning-bid-list  set winning-bid-list sort-by [amount-of ?1 > amount-of ?2] winning-bid-list  if length winning-bid-list > Q-quantity [    set losing-bidder turtle (the-bidder-of (last winning-bid-list))    ask losing-bidder [ set winning? false ]    set ask-loser true    set winning-bid-list sublist winning-bid-list 0 Q-quantity    ]  set winning-bid-info        map [the-bidder-of ? + ":" + ( round-value amount-of ? 2 )] winning-bid-list  set winner-id-list map [the-bidder-of ?] winning-bid-list  set winners-list map [turtle ?] winner-id-list  set winner-info        map [who-of ? + "/" + number-of-bids-of ? + "/" + ( round-value bid-of ? 2 )] winners-list  set highest-winning-bid max (map [amount-of ?] winning-bid-list)  set-lowest-winning-bid map [amount-of ?] winning-bid-list  if ask-loser [    if member? losing-bidder winners-list [ set ask-loser false ]    ]  foreach winners-list [ set winning? true ]  if ask-loser [    ask losing-bidder [      check-to-bid W-waiting-cost bidding-strategy-type V-valuation       ]    ]endto-report agent-should-bid? [ w v win? ]  ; This determines if the agent should bid.  locals [ t-r benefit-of-buying-early]  ifelse (not win?) or (not member? (turtle who) winners-list) [    ifelse v >= lowest-new-winning-bid [      ifelse v >= P-posted-price [        set t-r time-remaining        set benefit-of-buying-early              (P-posted-price - lowest-winning-bid) * 2 ^ (-1 * (t-r / length-of-game))        ifelse benefit-of-buying-early > (w * t-r) [          report true          ][           make-purchase-at-posted-price          report false           ]        ][        report true ; this is not necessarily true if bidding is costly        ]      ][      drop-out-of-bidding      report false      ]    ][    report false    ]endto drop-out-of-bidding  set live-bidder? false  set winning? false  set color gray  set size 2endto make-purchase-at-posted-price  set live-bidder? false  set made-purchase-at-posted? true  set color red  set size 2endto-report the-buyer-valuation [the-turtle]  report (value-from the-turtle [V-valuation])endto-report high-valuation-bidder?  ; Determines if the agent is a high-valuation bidder.  ifelse V-valuation >= P-posted-price    [ report true ]    [ report false ]endto-report bid-amount [ bidder-type p-a w the-valuation agent-recent-bid]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -