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

📄 ga---dca-scott010506.nlogo

📁 NETLOGO
💻 NLOGO
📖 第 1 页 / 共 4 页
字号:
  ; This implements the bidding strategies as described in the model write-up document.   ; I'm sure that it's not right. I'm fairly confident the "money-saver" strategy  ; mostly works. It's the others that I have little to no confidence in.  locals [ temp the-bid-value lowest-new-bid ]  ifelse high-valuation-bidder? [   ; high valuation bidder    ifelse bidder-type = "crazy-louie" [ ; U(lowest-new-winning-bid, P-posted-price)      set the-bid-value (lowest-new-winning-bid + random (P-posted-price - lowest-new-winning-bid))      ][      ifelse bidder-type = "less-crazy" [ ; U(lowest-new-winning-bid, anticipated final auction price)        set the-bid-value (lowest-new-winning-bid + random (p-a - lowest-new-winning-bid))        ][        ifelse bidder-type = "money-saver" [ ; minimum possible bid          set the-bid-value (lowest-new-winning-bid)          ][          ifelse bidder-type = "hate-bidding" [             set the-bid-value (P-posted-price - w * time-remaining)            ][            ifelse bidder-type = "want-to-win" [              set the-bid-value (lowest-new-winning-bid + random (P-posted-price - lowest-new-winning-bid))              ][               set the-bid-value (p-a) ; rational bidder, pa              ]]]]]    ][    ; low valuation bidder    ; I've defined "lowest-new-bid" to keep bidders from bidding lower than they've    ; previously bid.    set lowest-new-bid max (list lowest-new-winning-bid agent-recent-bid)    ; print "lowest-new-bid = " + lowest-new-bid    ; print "p-a = " + p-a + "  /  v = " + the-valuation    ifelse bidder-type = "crazy-louie" [      set temp min (list p-a the-valuation )      ; set temp p-a      set the-bid-value (lowest-new-bid + random (temp - lowest-new-bid))      ][      ifelse bidder-type = "less-crazy" [        set the-bid-value (lowest-new-bid + random (the-valuation - lowest-new-bid))        ][        ifelse bidder-type = "money-saver" [          set the-bid-value (min (list lowest-new-bid the-valuation))          ][          ifelse bidder-type = "hate-bidding" [            set the-bid-value (the-valuation)            ][            ifelse bidder-type = "want-to-win" [              ][              set the-bid-value (p-a)              ]]]]]    ]  ; the following shouldn't be necessary once the bids are calculated correctly.  report max (list R-reserve-price min (list the-valuation the-bid-value))  ; Instead, we should be able to use  ; report the-bid-valueendto-report calculate-p-a [ w v ]  ; This calculates p(a) using various formula.  ; Question: Should we use lowest-new-winning-bid or lowest-winning-bid for the following calculations?  ifelse high-valuation-bidder? [    ifelse p-a-calculation = "increasing" [      report lowest-new-winning-bid + (P-posted-price - lowest-new-winning-bid) * (1 - 2 ^ ((-1 * time-remaining) / length-of-game))      ][      ifelse p-a-calculation = "random" [        report lowest-new-winning-bid + random-float (P-posted-price - lowest-new-winning-bid)        ][        ifelse p-a-calculation = "linear1" [          ifelse length-of-game = time-remaining [            report P-posted-price            ][            report min (list P-posted-price (lowest-new-winning-bid * (length-of-game / (length-of-game - time-remaining))))            ]          ][          ifelse p-a-calculation = "linear2" [            report min (list lowest-new-winning-bid (R-reserve-price + (P-posted-price - R-reserve-price) * (length-of-game - time-remaining) / length-of-game))            ][            report lowest-new-winning-bid            ]]]]    ][    ; This isn't used for low valuation bidders so it doesn't matter what this value is.    report V-valuation    ]endto-report calculate-valuation  ; This calculates the valuation that each consumer puts on the good.  ; report random-normal (P-posted-price * 0.9) 12  report ( min-valuation + (random-float (max-valuation - min-valuation)) )endto-report calculate-waiting-cost  ; This calculates the waiting cost that each consumer has.   ; If the slider is set to "equal", then every consumer gets the  ; same waiting cost; otherwise, it is chosen  ; from a uniform distribution [0, max-waiting-cost).  ifelse waiting-cost-values = "equal"    [ report max-waiting-cost ]    [ report random-float max-waiting-cost ]endto-report time-remaining  ; calculates the time remaining in an auction.  report length-of-game - clockendto do-plots   ; this completes all plots for this model  plot-revenue  plot-diffendto plot-revenue   ; this simply plots the values in the "Average Revenue" plot  set-current-plot "Average Revenue"  auto-plot-on  plot-this-value "open-auction" auction-num (total-auction-revenue / auction-num)  plot-this-value "open-posted" auction-num (total-posted-price-revenue / auction-num)  plot-this-value "sealed-auction" auction-num (sealed-total-auction-revenue / auction-num)  plot-this-value "sealed-posted" auction-num (sealed-total-posted-price-revenue / auction-num)  plot-this-value "only-posted" auction-num (total-solo-posted-price-revenue / auction-num)endto plot-diff  ; this simply plots the values in the "% by which..." plot  set-current-plot "% by which both differs from just posted"  plot-this-value "open" auction-num ascending-diff  plot-this-value "sealed" auction-num sealed-diff  plot-this-value "plus50percent" auction-num 0.5  plot-this-value "zero" auction-num 0.0  plot-this-value "minus50percent" auction-num -0.5endto plot-this-value [the-pen-name x-value y-value]  ; this handles the plotting of an (x,y) pair on a plot  set-current-plot-pen the-pen-name  ppd  plotxy x-value y-value  ppuend; ******************* initialization procedures *******************to initialize-global  ; this initialization runs before any auctions are run  ca  set auction-num 0  set total-solo-posted-price-revenue 0  set total-auction-revenue 0  set total-posted-price-revenue 0  set number-of-auctions 0  set total-posted-price-purchasers 0  set show-bid-amount? trueendto initialize-auction  ; this initialization runs before each auction is run  clear-patches  clear-turtles  set min-valuation 0  set max-valuation 100  set length-of-game 168  set x-offset round (length-of-game / 2)  set y-offset round (max-valuation / 2)  set winners-list []  set winning-bid-list []  set winner-info []  set winning-bid-info []  set-posted-price the-posted-price  set-reserve-price  set next-buyer-arrival 0  set-time-next-buyer  set-lowest-winning-bid []  set solo-posted-price-revenue 0  set auction-revenue 0  set posted-price-revenue 0  set posted-price-purchasers 0  set-pline  set-rlineendto set-turtle-info [ strategy-type ]  locals [the-color-offset]  set the-color-offset -2  set size 5  set shape "person"  ; set color xcor * 10 + 5  ifelse strategy-type = "crazy-louie" [     set color orange + the-color-offset     ][    ifelse strategy-type = "less-crazy" [      set color brown + the-color-offset      ][      ifelse strategy-type = "money-saver" [        set color turquoise + the-color-offset        ][        ifelse strategy-type = "hate-bidding" [          set color violet + the-color-offset          ][          ifelse strategy-type = "want-to-win" [            set color magenta + the-color-offset            ][            set color pink + the-color-offset            ]]]]]endto-report determine-bidding-strategy  ; This is used to randomly assign a bidding strategy to a buyer when  ; it is created. The sliders on the model page determine the relative  ; ratios of each type of buyer. (The ratios can range from 0 to 5 for  ; each bidding strategy type.) The "money-saver" strategy is the  ; default value if all sliders are set to 0.   locals [total-points spread-per-point the-random-value    crazy-louie-cutoff less-crazy-cutoff money-saver-cutoff hate-bidding-cutoff want-to-win-cutoff ]  ; crazy-louie less-crazy money-saver hate-bidding rational-guy want-to-win  set total-points (crazy-louie + less-crazy + money-saver + hate-bidding + rational-guy + want-to-win)  if total-points = 0 [ report "money-saver" ]  if total-points = 1 [    ifelse crazy-louie = 1       [ report "crazy-louie" ][       ifelse less-crazy = 1         [ report "less-crazy" ][        ifelse money-saver = 1          [ report "money-saver" ][          ifelse hate-bidding = 1            [ report "hate-bidding" ][            ifelse want-to-win = 1              [ report "want-to-win" ][              report "rational-guy"              ]]]]]    ]  ; thus, total-points must be greater than 1  set spread-per-point 1.0 / total-points  set crazy-louie-cutoff (spread-per-point * crazy-louie)  set less-crazy-cutoff ( crazy-louie-cutoff + (spread-per-point * less-crazy))  set money-saver-cutoff ( less-crazy-cutoff + (spread-per-point * money-saver))  set hate-bidding-cutoff ( money-saver-cutoff + (spread-per-point * hate-bidding))  set want-to-win-cutoff ( hate-bidding-cutoff + (spread-per-point * want-to-win))  set the-random-value random-float 1.0  ifelse the-random-value < crazy-louie-cutoff     [ report "crazy-louie" ] [    ifelse the-random-value < less-crazy-cutoff      [ report "less-crazy" ] [      ifelse the-random-value < money-saver-cutoff        [ report "money-saver" ] [        ifelse the-random-value < hate-bidding-cutoff           [ report "hate-bidding" ] [          ifelse the-random-value < want-to-win-cutoff             [ report "want-to-win" ] [            report "rational-guy" ]]]]]end; ******************* graphics procedures *******************to set-pline  ; shows the level of the posted price  draw-solid-horizontal-line y-P-posted-price redendto set-rline  ; shows the level of the reserve price  ;show "set-rline "  draw-dotted-horizontal-line y-R-reserve-price (green - 2)endto update-bid-line  ;show "update-bid-line "  remove-old-bid-line  add-new-bid-lineendto remove-old-bid-line  ask patches [    if pcolor = blue and pcolor != green - 2 and pcolor != red [set pcolor black]    ]endto add-new-bid-line  draw-solid-horizontal-line (round y-lowest-winning-bid) blueendto draw-timeline [the-current-time]  ask patches [    if pxcor = the-current-time - 1 [      if pycor != y-P-posted-price and           pycor != y-R-reserve-price  [        set pcolor black        ]      if pycor = y-lowest-winning-bid [        set pcolor blue        ]      ]    if pxcor = the-current-time and         pycor != y-P-posted-price and         pycor != y-R-reserve-price [      set pcolor yellow      ]    ]end; ******************* price manipulation procedures *******************to set-reserve-price  ; sets the reserve price and at the same time sets the y-coord of the related line  ; set R-reserve-price the-price  set y-R-reserve-price R-reserve-price - y-offset - 1endto set-posted-price [the-price]  ; sets the posted price and at the same time sets the y-coord of the related line  set P-posted-price the-price  set y-P-posted-price the-price - y-offsetendto set-lowest-winning-bid [list-of-bid-values] ;SAM: I think this is right now, but let's check.  ; sets the lowest buying price and at the same time sets the y-coord of the related line  locals [ min-bid-value num-of-winning-bids ]  set num-of-winning-bids length list-of-bid-values  ifelse num-of-winning-bids >= Q-quantity [    set lowest-winning-bid min list-of-bid-values    set lowest-new-winning-bid lowest-winning-bid + increment    ][     ifelse num-of-winning-bids > 0 [      set lowest-winning-bid min list-of-bid-values      ifelse lowest-new-basis = "lowest-winning-bid" [        set lowest-new-winning-bid lowest-winning-bid        ][ ; else if lowest-new-basis = "reserve"        set lowest-new-winning-bid R-reserve-price        ]      ][ ; num-of-winning-bids = 0      set lowest-winning-bid R-reserve-price      set lowest-new-winning-bid R-reserve-price      ]    ]  set y-lowest-winning-bid lowest-new-winning-bid - y-offsetend; ******************* utility procedures *******************to draw-solid-horizontal-line [y-coord the-color]  ask patches [    if pycor = y-coord [      set pcolor the-color      ]  ]endto draw-dotted-horizontal-line [y-coord the-color]  ask patches [    if pycor = y-coord and pxcor mod 2 = 0 [      set pcolor the-color      ]  ] endto-report round-value [ v decimals ]  ; round the value v to decimals  report ( round ( v * 10 ^ decimals ) ) / ( 10 ^ decimals )end@#$#@#$#@GRAPHICS-WINDOW4141096735690523.01101110111CC-WINDOW5614976709Command Center0MONITOR7498136547NILnext-buyer-arrival01SLIDER356132

⌨️ 快捷键说明

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