aboutsummaryrefslogtreecommitdiff
path: root/brandt.c
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2016-11-01 13:16:41 +0100
committerMarkus Teich <markus.teich@stusta.mhn.de>2016-11-01 13:16:41 +0100
commit44079d5cbbab5eeea367e9420b29c5b6f48eede8 (patch)
treeba89ccb0855b7200712b5797de2ca692db7c3766 /brandt.c
parente98bb69ce22f1b8680feaf163e34d9a8734652cc (diff)
downloadlibbrandt-44079d5cbbab5eeea367e9420b29c5b6f48eede8.tar.gz
libbrandt-44079d5cbbab5eeea367e9420b29c5b6f48eede8.zip
handle n <= m case in m+1st price auctions
The lowest possible price from the price map will be the price each bidder has to pay. Since the seller can define the price map, he can set the lowest price to the lowest he is willing to sell one item at.
Diffstat (limited to 'brandt.c')
-rw-r--r--brandt.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/brandt.c b/brandt.c
index dab0ad2..ff106fb 100644
--- a/brandt.c
+++ b/brandt.c
@@ -67,6 +67,31 @@ BRANDT_bidder_start (struct BRANDT_Auction *auction,
67 atype = auction->m > 0 ? auction_mPlusFirstPrice : auction_firstPrice; 67 atype = auction->m > 0 ? auction_mPlusFirstPrice : auction_firstPrice;
68 outcome = auction->outcome_public ? outcome_public : outcome_private; 68 outcome = auction->outcome_public ? outcome_public : outcome_private;
69 69
70 if (auction_mPlusFirstPrice == atype && n <= auction->m)
71 { /* fewer bidders than items to sell. every bidder won with lowest price */
72 struct BRANDT_Result *res;
73 if (auction->outcome_public)
74 {
75 res = GNUNET_new_array (n, struct BRANDT_Result);
76 for (uint16_t h = 0; h < n; h++)
77 {
78 res[h].bidder = h;
79 res[h].price = 0;
80 res[h].status = BRANDT_bidder_won;
81 }
82 auction->result (auction->closure, res, n);
83 }
84 else
85 {
86 res = GNUNET_new (struct BRANDT_Result);
87 res->bidder = i;
88 res->price = 0;
89 res->status = BRANDT_bidder_won;
90 auction->result (auction->closure, res, 1);
91 }
92 return;
93 }
94
70 /* On M+1st price auctions we multiply the amount of prizes by the amount of 95 /* On M+1st price auctions we multiply the amount of prizes by the amount of
71 * bidders and resctrict each bidder to his own distinct subset of the 96 * bidders and resctrict each bidder to his own distinct subset of the
72 * prices. This is done for tie breaking. An additional proof is used in the 97 * prices. This is done for tie breaking. An additional proof is used in the
@@ -104,12 +129,26 @@ seller_start (void *arg)
104 129
105 ad->task = NULL; 130 ad->task = NULL;
106 131
107 if (0 == (ad->n = ad->start (ad->closure))) 132 ad->n = ad->start (ad->closure);
133 if (0 == ad->n)
108 { 134 {
109 weprintf ("no bidders registered for auction"); 135 weprintf ("no bidders registered for auction");
110 ad->result (ad->closure, NULL, 0); 136 ad->result (ad->closure, NULL, 0);
111 return; 137 return;
112 } 138 }
139 else if (ad->n <= ad->m)
140 {
141 struct BRANDT_Result *res = GNUNET_new_array (ad->n, struct BRANDT_Result);
142
143 weprintf ("less bidders than needed, selling for lowest price");
144 for (uint16_t i = 0; i < ad->n; i++)
145 {
146 res[i].bidder = i;
147 res[i].price = 0;
148 res[i].status = BRANDT_bidder_won;
149 }
150 ad->result (ad->closure, res, ad->n);
151 }
113 152
114 atype = ad->m > 0 ? auction_mPlusFirstPrice : auction_firstPrice; 153 atype = ad->m > 0 ? auction_mPlusFirstPrice : auction_firstPrice;
115 outcome = ad->outcome_public ? outcome_public : outcome_private; 154 outcome = ad->outcome_public ? outcome_public : outcome_private;