1 | package agents.anac.y2014.Atlas;
|
---|
2 |
|
---|
3 | import java.io.Serializable;
|
---|
4 | import java.util.List;
|
---|
5 | import java.util.Random;
|
---|
6 |
|
---|
7 | import genius.core.Agent;
|
---|
8 | import genius.core.Bid;
|
---|
9 | import genius.core.NegotiationResult;
|
---|
10 | import genius.core.actions.Accept;
|
---|
11 | import genius.core.actions.Action;
|
---|
12 | import genius.core.actions.ActionWithBid;
|
---|
13 | import genius.core.actions.Offer;
|
---|
14 | import genius.core.issue.Issue;
|
---|
15 | import genius.core.issue.IssueInteger;
|
---|
16 | import genius.core.issue.ValueInteger;
|
---|
17 |
|
---|
18 | //csv�o—Í
|
---|
19 | //import java.io.FileWriter;
|
---|
20 | //import java.io.BufferedWriter;
|
---|
21 | //import java.io.PrintWriter;
|
---|
22 |
|
---|
23 | public class Atlas extends Agent {
|
---|
24 | private Action actionOfPartner = null;
|
---|
25 |
|
---|
26 | // Ž©•ª‚Ì�÷•à�í—ª‚ÉŠÖ‚·‚é•Ï�”
|
---|
27 | private boolean tension = true; // �÷•à‚ÉŠÖ‚µ‚Ä‚ÌŽp�¨�i�‰Šú’l�F‹‹C�j�i–{“–‚ÍŽã‹C‚Ì‚Ù‚¤‚ª‚¢‚¢‚ª�C�‰Žè‚ªŽã‹C‚¾‚Æ‘ŠŽè‚ÉŠ¨ˆá‚¢‚ð‚³‚¹‚Ä‚µ‚Ü‚¤‚Æ‚¢‚¤ƒ�ƒ^“I‚È�í—ª�j
|
---|
28 | private double border_bid_utility = 1.0; // ‹«ŠE’l
|
---|
29 |
|
---|
30 | // ‘ŠŽè‚ÌofferŠÖ˜A‚Ì•Ï�”
|
---|
31 | private Bid best_partner_bid = null; // Œ»�Ý‚ÌŒð�Â’†‚É‚¨‚¯‚é‘ŠŽè‚Ì’ñŽ¦Bid‚Ì’†‚Å�Å‘åŒø—p’l‚Æ‚È‚éBid
|
---|
32 | private Bid prev_partner_bid = null; // ˆê‚‘O‚Ì‘ŠŽè‚Ì’ñŽ¦Bid�i‹ß–T’T�õ‚Å—p‚¢‚é�j
|
---|
33 | private double prev_offeredUtilFromOpponent = 0;
|
---|
34 |
|
---|
35 | // ”ñ�펞ŠÖ˜A
|
---|
36 | private boolean attack_flag = false;
|
---|
37 | private double partner_last_bid_time = 0.0;
|
---|
38 | private double partner_prev_last_bid_time = 0.0;
|
---|
39 | private double last_time = 0.99;
|
---|
40 | private double time_scale = 0.01;
|
---|
41 |
|
---|
42 | // ”»’èŠÖ˜A‚̃tƒ‰ƒO
|
---|
43 | private boolean first_offer_flag = true;
|
---|
44 | private boolean first_offer_decision_flag = false;
|
---|
45 | private boolean repeat_flag = true;
|
---|
46 |
|
---|
47 | // ‰ß‹Ž‚̃ZƒbƒVƒ‡ƒ“ƒf�[ƒ^‚©‚ç’l‚ðŽó‚¯Žæ‚é•Ï�”
|
---|
48 | private boolean last_tension = true;
|
---|
49 | private boolean is_agreement;
|
---|
50 | private Bid last_bid = null;
|
---|
51 | private Bid max_bid = null;
|
---|
52 | private Bid true_best_agreement_bid = null;
|
---|
53 | private Bid false_best_agreement_bid = null;
|
---|
54 | private int true_failure_num = 0;
|
---|
55 | private int false_agreement_num = 0;
|
---|
56 | private double false_agreement_average_utility_with_discount = 0;
|
---|
57 | private double partner_attack_num = 0;
|
---|
58 | private double partner_guard_num = 0;
|
---|
59 | private double last_bid_time = 1.0;
|
---|
60 | private boolean tension_true_seal_flag = false;
|
---|
61 | private double true_repeat_time = 1.0;
|
---|
62 | private double false_repeat_time = 1.0;
|
---|
63 | double false_agreement_best_utility = 0.0;
|
---|
64 |
|
---|
65 | // �d‚Ý•t‚«•½‹Ï‚ð‹�‚߂邽‚ß‚É—p‚¢‚é•Ï�”
|
---|
66 | private int partner_bid_count = 0;
|
---|
67 | private double partner_bid_utility_weighted_average = 0;
|
---|
68 |
|
---|
69 | // ’è�”
|
---|
70 | private static int NEAR_ITERATION = 100;
|
---|
71 | private static int SA_ITERATION = 10;
|
---|
72 | private static int SAMPLE_NUM = 10;
|
---|
73 | private static int ARRAY_LIM = 1000;
|
---|
74 | private static int ERROR_TIME_SCALE_LIM = 3;
|
---|
75 |
|
---|
76 | // // csv�o—Í—p•Ï�”
|
---|
77 | // // Ž©•ª‚Ì’ñŽ¦‚µ‚½Bid‚ÌŒø—p’l
|
---|
78 | // FileWriter fw;
|
---|
79 | // PrintWriter pw_my_u;
|
---|
80 | // // ‘ŠŽè‚Ì’ñŽ¦‚µ‚½Bid‚ÌŒø—p’l
|
---|
81 | // FileWriter fw_p;
|
---|
82 | // PrintWriter pw_pa_u;
|
---|
83 | // // Ž©•ª‚Ì’ñŽ¦‚µ‚½Bid‚Ì‹«ŠE�ü
|
---|
84 | // FileWriter fw_b;
|
---|
85 | // PrintWriter pw_my_b;
|
---|
86 | // //
|
---|
87 | // Ž©•ª‚Ì’ñŽ¦‚µ‚½Bid‚Ì�d‚Ý•t‚«•â�³�Ï‚Ý‹«ŠE�ü
|
---|
88 | // FileWriter fw_b_t;
|
---|
89 | // PrintWriter pw_my_b_t;
|
---|
90 | // // Ž©•ª‚Ì’ñŽ¦‚µ‚½Bid‚Ì•â�³�Ï‚Ý
|
---|
91 | // FileWriter fw_b_c;
|
---|
92 | // PrintWriter pw_my_b_c;
|
---|
93 |
|
---|
94 | @Override
|
---|
95 | public void init() {
|
---|
96 | try {
|
---|
97 | initPrevSessionData();
|
---|
98 |
|
---|
99 | // �Å�‰‚Ì‚P‰ñ–Ú‚Ì‚Ý�CSA‚É‚æ‚èŒø—p’l‚Ì�Å‘å’l‚ð‹�‚ß‚é
|
---|
100 | if (sessionNr == 0) {
|
---|
101 | Bid check_b;
|
---|
102 | for (int i = 0; i < utilitySpace.getDomain().getIssues().size()
|
---|
103 | * 10; i++) {
|
---|
104 | check_b = getBestBidbySA();
|
---|
105 | if (max_bid == null
|
---|
106 | || utilitySpace.getUtility(check_b) >= utilitySpace
|
---|
107 | .getUtility(max_bid)) {
|
---|
108 | max_bid = new Bid(check_b);
|
---|
109 | }
|
---|
110 | if (utilitySpace.getUtility(max_bid) == 1.0) {
|
---|
111 | break;
|
---|
112 | }
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | } catch (Exception e1) {
|
---|
117 | // TODO Auto-generated catch block
|
---|
118 | e1.printStackTrace();
|
---|
119 | }
|
---|
120 | }
|
---|
121 |
|
---|
122 | @Override
|
---|
123 | public String getVersion() {
|
---|
124 | return "3.1";
|
---|
125 | }
|
---|
126 |
|
---|
127 | @Override
|
---|
128 | public String getName() {
|
---|
129 | return "Atlas";
|
---|
130 | }
|
---|
131 |
|
---|
132 | @Override
|
---|
133 | public void ReceiveMessage(Action opponentAction) {
|
---|
134 | actionOfPartner = opponentAction;
|
---|
135 | }
|
---|
136 |
|
---|
137 | @Override
|
---|
138 | public Action chooseAction() {
|
---|
139 | Action action = null;
|
---|
140 | try {
|
---|
141 | if (actionOfPartner == null)
|
---|
142 | action = chooseBidAction();
|
---|
143 | if (actionOfPartner instanceof Offer) {
|
---|
144 | Bid partnerBid = ((Offer) actionOfPartner).getBid();
|
---|
145 |
|
---|
146 | // �d‚Ý•t‚«•½‹Ï‚ð‹�‚ß‚é
|
---|
147 | if (partner_bid_count == 0) {
|
---|
148 | partner_bid_utility_weighted_average = utilitySpace
|
---|
149 | .getUtility(partnerBid);
|
---|
150 | } else {
|
---|
151 | partner_bid_utility_weighted_average = (utilitySpace
|
---|
152 | .getUtility(partnerBid)
|
---|
153 | + partner_bid_utility_weighted_average) / 2;
|
---|
154 | }
|
---|
155 | // ‘ŠŽè‚ÌBid‚µ‚½Žž��‚ð‹L˜^‚µ‚Ä‚¨‚
|
---|
156 | partner_prev_last_bid_time = partner_last_bid_time;
|
---|
157 | partner_last_bid_time = timeline.getTime();
|
---|
158 | time_scale = (((partner_last_bid_time
|
---|
159 | - partner_prev_last_bid_time)
|
---|
160 | + time_scale * partner_bid_count)
|
---|
161 | / (partner_bid_count + 1));
|
---|
162 | last_time = 1.0 - time_scale * ERROR_TIME_SCALE_LIM;
|
---|
163 | partner_bid_count++;
|
---|
164 |
|
---|
165 | // get current time
|
---|
166 | double time = timeline.getTime();
|
---|
167 | double offeredUtilFromOpponent = utilitySpace
|
---|
168 | .getUtility(partnerBid);
|
---|
169 |
|
---|
170 | // // //�o—Í—p
|
---|
171 | // pw_pa_u.print(timeline.getTime());
|
---|
172 | // pw_pa_u.print(",");
|
---|
173 | // pw_pa_u.print(offeredUtilFromOpponent);
|
---|
174 | // pw_pa_u.print(",");
|
---|
175 | // pw_pa_u.println();
|
---|
176 |
|
---|
177 | action = chooseBidAction();
|
---|
178 |
|
---|
179 | prev_partner_bid = new Bid(partnerBid);
|
---|
180 | if (best_partner_bid == null) {
|
---|
181 | best_partner_bid = new Bid(partnerBid);
|
---|
182 | } else if (utilitySpace.getUtility(partnerBid) > utilitySpace
|
---|
183 | .getUtility(best_partner_bid)) {
|
---|
184 | best_partner_bid = new Bid(partnerBid);
|
---|
185 | }
|
---|
186 |
|
---|
187 | Bid myBid = ((Offer) action).getBid();
|
---|
188 | double myOfferedUtil = utilitySpace.getUtility(myBid);
|
---|
189 | // accept under certain circumstances
|
---|
190 | if (isAcceptable(partnerBid, offeredUtilFromOpponent,
|
---|
191 | myOfferedUtil, time))
|
---|
192 | action = new Accept(getAgentID(), partnerBid);
|
---|
193 | }
|
---|
194 | // if (timeline.getType().equals(Timeline.Type.Time)) {
|
---|
195 | // sleep(0.005); // just for fun
|
---|
196 | // }
|
---|
197 | } catch (Exception e) {
|
---|
198 | System.out.println("Exception in ChooseAction:" + e.getMessage());
|
---|
199 | action = new Accept(getAgentID(),
|
---|
200 | ((ActionWithBid) actionOfPartner).getBid()); // best
|
---|
201 | // guess
|
---|
202 | // if
|
---|
203 | // things
|
---|
204 | // go
|
---|
205 | // wrong.
|
---|
206 | }
|
---|
207 | return action;
|
---|
208 | }
|
---|
209 |
|
---|
210 | private boolean isAcceptable(Bid partnerBid, double offeredUtilFromOpponent,
|
---|
211 | double myOfferedUtil, double time) throws Exception {
|
---|
212 | // ‘ŠŽè‚ÌŒø—p’l
|
---|
213 | double P = offeredUtilFromOpponent;
|
---|
214 | prev_offeredUtilFromOpponent = offeredUtilFromOpponent;
|
---|
215 |
|
---|
216 | // ‹«ŠE’l‚Ì�X�V
|
---|
217 | getBorderUtility();
|
---|
218 |
|
---|
219 | if (P >= border_bid_utility
|
---|
220 | && P >= utilitySpace.getUtility(best_partner_bid)) {
|
---|
221 | return true;
|
---|
222 | }
|
---|
223 |
|
---|
224 | // ‘¦Œˆ”»’è
|
---|
225 | if (!tension && false_best_agreement_bid != null
|
---|
226 | && P >= utilitySpace.getUtility(false_best_agreement_bid)) {
|
---|
227 | // ‚±‚Ì‚Ü‚ÜŒð�‚𑱂¯‚½�ê�‡
|
---|
228 | double parameter = partner_guard_num + partner_attack_num;
|
---|
229 | // —˜“¾(‘ŠŽè‚ªŽã‹C‚ÌŽž)
|
---|
230 | double get_point = utilitySpace.getDiscountFactor()
|
---|
231 | - utilitySpace.getUtility(false_best_agreement_bid);
|
---|
232 | // ‘¹Ž¸(‘ŠŽè‚ª‹‹C‚ÌŽž)
|
---|
233 | double lost_point = false_agreement_average_utility_with_discount
|
---|
234 | - utilitySpace.getUtility(false_best_agreement_bid);
|
---|
235 |
|
---|
236 | // Šú‘Ò’l(‘ŠŽè‚ÌŽp�¨‚Í‹‹CorŽã‹C‚Å‚»‚ꂼ‚ê‚ÌŠm—¦‚͉ߋŽ‚ÌŒð�‚ðŽQ�Æ‚·‚é)
|
---|
237 | double mean_point = get_point
|
---|
238 | * ((partner_guard_num + 0.5) / (parameter + 1))
|
---|
239 | + lost_point
|
---|
240 | * ((partner_attack_num + 0.5) / (parameter + 1));
|
---|
241 |
|
---|
242 | if (mean_point < 0) {
|
---|
243 | // first_offer_decision_flag = true;
|
---|
244 | return true;
|
---|
245 | }
|
---|
246 | }
|
---|
247 |
|
---|
248 | // ”ñ�í—p
|
---|
249 | if (!tension && timeline.getTime() > (last_time - time_scale * 0)
|
---|
250 | && P > utilitySpace.getReservationValue()) {
|
---|
251 | attack_flag = true;
|
---|
252 | return true;
|
---|
253 | }
|
---|
254 |
|
---|
255 | return false;
|
---|
256 | }
|
---|
257 |
|
---|
258 | private Action chooseBidAction() {
|
---|
259 | Bid nextBid = null;
|
---|
260 | try {
|
---|
261 | // ‘¦Œˆ”»’èŠÖ˜A‚̃tƒ‰ƒOŠÇ—�
|
---|
262 | first_offer_decision_flag = false;
|
---|
263 |
|
---|
264 | nextBid = getBid();
|
---|
265 |
|
---|
266 | first_offer_flag = false;
|
---|
267 | } catch (Exception e) {
|
---|
268 | System.out.println("Problem with received bid:" + e.getMessage()
|
---|
269 | + ". cancelling bidding");
|
---|
270 | }
|
---|
271 | if (nextBid == null)
|
---|
272 | return (new Accept(getAgentID(),
|
---|
273 | ((ActionWithBid) actionOfPartner).getBid()));
|
---|
274 | return (new Offer(getAgentID(), nextBid));
|
---|
275 | }
|
---|
276 |
|
---|
277 | private Bid getBid() throws Exception {
|
---|
278 | // ”ñ�í—p
|
---|
279 | if (!tension) {
|
---|
280 | // Žã‹C‚Ì‚Æ‚«�C‘ŠŽè‚Ì�¡‚Ü‚Å‚ÌŒð�‚ÌBid‚ðŒð�Â�I—¹�¡‘O‚Å’ñŽ¦‚·‚é
|
---|
281 | if (timeline.getTime() > (last_time - time_scale * 2)
|
---|
282 | && best_partner_bid != null
|
---|
283 | && false_best_agreement_bid != null) {
|
---|
284 | attack_flag = true;
|
---|
285 | // �¬‚³‚¢•û
|
---|
286 | if (timeline.getTime() > (last_time - time_scale * 1)) {
|
---|
287 | if (utilitySpace
|
---|
288 | .getUtility(false_best_agreement_bid) < utilitySpace
|
---|
289 | .getUtility(best_partner_bid)) {
|
---|
290 | if (utilitySpace.getUtility(
|
---|
291 | false_best_agreement_bid) > utilitySpace
|
---|
292 | .getReservationValue()) {
|
---|
293 | return false_best_agreement_bid;
|
---|
294 | }
|
---|
295 | } else {
|
---|
296 | if (utilitySpace
|
---|
297 | .getUtility(best_partner_bid) > utilitySpace
|
---|
298 | .getReservationValue()) {
|
---|
299 | return best_partner_bid;
|
---|
300 | }
|
---|
301 | }
|
---|
302 | }
|
---|
303 | // ‘å‚«‚¢•û
|
---|
304 | if (utilitySpace
|
---|
305 | .getUtility(false_best_agreement_bid) > utilitySpace
|
---|
306 | .getUtility(best_partner_bid)) {
|
---|
307 | if (utilitySpace
|
---|
308 | .getUtility(false_best_agreement_bid) > utilitySpace
|
---|
309 | .getReservationValue()) {
|
---|
310 | return false_best_agreement_bid;
|
---|
311 | }
|
---|
312 | } else {
|
---|
313 | if (utilitySpace.getUtility(best_partner_bid) > utilitySpace
|
---|
314 | .getReservationValue()) {
|
---|
315 | return best_partner_bid;
|
---|
316 | }
|
---|
317 | }
|
---|
318 | }
|
---|
319 |
|
---|
320 | if (timeline.getTime() > (last_time - time_scale * 1) && !tension
|
---|
321 | && false_best_agreement_bid == null
|
---|
322 | && best_partner_bid != null
|
---|
323 | && utilitySpace.getUtility(best_partner_bid) > utilitySpace
|
---|
324 | .getReservationValue()) {
|
---|
325 | attack_flag = true;
|
---|
326 | return best_partner_bid;
|
---|
327 | }
|
---|
328 | if (timeline.getTime() > (last_time - time_scale * 1) && !tension
|
---|
329 | && best_partner_bid == null
|
---|
330 | && false_best_agreement_bid != null
|
---|
331 | && utilitySpace
|
---|
332 | .getUtility(false_best_agreement_bid) > utilitySpace
|
---|
333 | .getReservationValue()) {
|
---|
334 | attack_flag = true;
|
---|
335 | return false_best_agreement_bid;
|
---|
336 | }
|
---|
337 | }
|
---|
338 |
|
---|
339 | // ‹«ŠE’l‚Ì�X�V
|
---|
340 | getBorderUtility();
|
---|
341 |
|
---|
342 | // csv�o—Í—p
|
---|
343 | // pw_my_b_c.print(timeline.getTime());
|
---|
344 | // pw_my_b_c.print(",");
|
---|
345 | // pw_my_b_c.print(border_bid_utility);
|
---|
346 | // pw_my_b_c.print(",");
|
---|
347 | // pw_my_b_c.println();
|
---|
348 |
|
---|
349 | Bid bid = null;
|
---|
350 | Bid check_bid = null;
|
---|
351 |
|
---|
352 | // ‹ß–T’T�õ(’¼‘O‚Ì‘ŠŽè‚Ì’ñŽ¦Bid‚ðŠî�€)
|
---|
353 | if (prev_partner_bid != null || last_bid != null) {
|
---|
354 | if (prev_partner_bid != null) {
|
---|
355 | bid = new Bid(prev_partner_bid);
|
---|
356 | } else {
|
---|
357 | bid = new Bid(last_bid);
|
---|
358 | }
|
---|
359 | // Žp�¨‚Å’T�õ•û–@‚ð•Ï�X
|
---|
360 | try {
|
---|
361 | for (int i = 0; i < NEAR_ITERATION; i++) {
|
---|
362 | if (tension) {
|
---|
363 | // ‹‹C
|
---|
364 | bid = getBestBidbyNear(bid);
|
---|
365 |
|
---|
366 | if (utilitySpace.getUtility(bid) > border_bid_utility) {
|
---|
367 | break;
|
---|
368 | }
|
---|
369 | } else {
|
---|
370 | // Žã‹C
|
---|
371 | bid = getBetterBidbyNear(bid);
|
---|
372 | }
|
---|
373 | }
|
---|
374 | } catch (Exception e) {
|
---|
375 | System.out.println("Problem with received bid(Near:last):"
|
---|
376 | + e.getMessage() + ". cancelling bidding");
|
---|
377 | }
|
---|
378 | }
|
---|
379 |
|
---|
380 | // ‹ß–T’T�õ‚ÌŒ‹‰Ê�C–ž‘«‚Ì‚¢‚Bid‚𓾂ç‚ê‚È‚©‚Á‚½�ê�‡�CSA‚ÅBid‚ð’T�õ
|
---|
381 | if (bid == null || utilitySpace.getUtility(bid) < border_bid_utility
|
---|
382 | || (tension && utilitySpace.getUtility(bid) < utilitySpace
|
---|
383 | .getUtility(max_bid))) {
|
---|
384 | try {
|
---|
385 | for (int i = 0; i < SA_ITERATION; i++) {
|
---|
386 | if (tension) {
|
---|
387 | // ‹‹C
|
---|
388 | check_bid = getBestBidbySA();
|
---|
389 | if (bid == null || utilitySpace.getUtility(
|
---|
390 | check_bid) > utilitySpace.getUtility(bid)) {
|
---|
391 | bid = new Bid(check_bid);
|
---|
392 | }
|
---|
393 |
|
---|
394 | if (utilitySpace.getUtility(bid) == 1.0) {
|
---|
395 | break;
|
---|
396 | }
|
---|
397 | } else {
|
---|
398 | // Žã‹C
|
---|
399 | check_bid = getBetterBidbySA();
|
---|
400 | if (bid == null || (utilitySpace
|
---|
401 | .getUtility(bid) < border_bid_utility
|
---|
402 | || (utilitySpace
|
---|
403 | .getUtility(check_bid) < utilitySpace
|
---|
404 | .getUtility(bid))
|
---|
405 | && utilitySpace.getUtility(
|
---|
406 | check_bid) > border_bid_utility)) {
|
---|
407 | bid = new Bid(check_bid);
|
---|
408 | }
|
---|
409 | }
|
---|
410 | }
|
---|
411 | } catch (Exception e) {
|
---|
412 | System.out.println("Problem with received bid(SA):"
|
---|
413 | + e.getMessage() + ". cancelling bidding");
|
---|
414 | }
|
---|
415 | }
|
---|
416 |
|
---|
417 | // �Å‘åBid‚Ì�X�V
|
---|
418 | if (bid != null && utilitySpace.getUtility(max_bid) <= utilitySpace
|
---|
419 | .getUtility(bid)) {
|
---|
420 | max_bid = new Bid(bid);
|
---|
421 | }
|
---|
422 |
|
---|
423 | // “¾‚ç‚ꂽBid‚ª‹«ŠE’l‚æ‚è‚à�¬‚³‚¢�ê�‡�C�Å‘åŒø—p’l‚Æ‚È‚éBid‚ð’ñŽ¦‚·‚é
|
---|
424 | if (bid == null || utilitySpace.getUtility(bid) < border_bid_utility
|
---|
425 | || (tension && utilitySpace.getUtility(bid) < utilitySpace
|
---|
426 | .getUtility(max_bid))) {
|
---|
427 | bid = new Bid(max_bid);
|
---|
428 | }
|
---|
429 |
|
---|
430 | // ‘¦Œˆ”»’è
|
---|
431 | if (!tension && first_offer_flag && false_best_agreement_bid != null) {
|
---|
432 | // ‚±‚Ì‚Ü‚ÜŒð�‚𑱂¯‚½�ê�‡
|
---|
433 | double parameter = partner_guard_num + partner_attack_num;
|
---|
434 |
|
---|
435 | // —˜“¾(‘ŠŽè‚ªŽã‹C‚ÌŽž)
|
---|
436 | double get_point = utilitySpace.getDiscountFactor()
|
---|
437 | - utilitySpace.getUtility(false_best_agreement_bid);
|
---|
438 | // ‘¹Ž¸(‘ŠŽè‚ª‹‹C‚ÌŽž)
|
---|
439 | double lost_point = false_agreement_average_utility_with_discount
|
---|
440 | - utilitySpace.getUtility(false_best_agreement_bid);
|
---|
441 |
|
---|
442 | // Šú‘Ò’l(‘ŠŽè‚ÌŽp�¨‚Í‹‹CorŽã‹C‚Å‚»‚ꂼ‚ê‚ÌŠm—¦‚͉ߋŽ‚ÌŒð�‚ðŽQ�Æ‚·‚é)
|
---|
443 | double mean_point = get_point
|
---|
444 | * ((partner_guard_num + 0.5) / (parameter + 1))
|
---|
445 | + lost_point
|
---|
446 | * ((partner_attack_num + 0.5) / (parameter + 1));
|
---|
447 |
|
---|
448 | if (mean_point < 0) {
|
---|
449 | first_offer_decision_flag = true;
|
---|
450 | return false_best_agreement_bid;
|
---|
451 | }
|
---|
452 | }
|
---|
453 |
|
---|
454 | if (last_bid != null) {
|
---|
455 | // ‹‹C‚̘A�Ÿ”»’è
|
---|
456 | if (true_best_agreement_bid != null && tension
|
---|
457 | && first_offer_flag) {
|
---|
458 | return true_best_agreement_bid;
|
---|
459 | }
|
---|
460 | // �ÄŒ»”»’è
|
---|
461 | if (repeat_flag && utilitySpace.getDiscountFactor() < 1.0) {
|
---|
462 | // ‹‹C‚Ì�ÄŒ»”»’è
|
---|
463 | if (tension && true_best_agreement_bid != null
|
---|
464 | && true_repeat_time <= timeline.getTime()) {
|
---|
465 | repeat_flag = false;
|
---|
466 | return true_best_agreement_bid;
|
---|
467 | }
|
---|
468 |
|
---|
469 | // Žã‹C‚Ì�ÄŒ»”»’è
|
---|
470 | if (!tension && false_best_agreement_bid != null
|
---|
471 | && false_repeat_time <= timeline.getTime()) {
|
---|
472 | repeat_flag = false;
|
---|
473 | return false_best_agreement_bid;
|
---|
474 | }
|
---|
475 | }
|
---|
476 | }
|
---|
477 |
|
---|
478 | // //csv�o—Í—p
|
---|
479 | // pw_my_u.print(timeline.getTime());
|
---|
480 | // pw_my_u.print(",");
|
---|
481 | // pw_my_u.print(utilitySpace.getUtility(bid));
|
---|
482 | // pw_my_u.print(",");
|
---|
483 | // pw_my_u.println();
|
---|
484 |
|
---|
485 | return bid;
|
---|
486 | }
|
---|
487 |
|
---|
488 | // ‹«ŠE’l‚ð�X�V‚·‚éŠÖ�”
|
---|
489 | private void getBorderUtility() throws Exception {
|
---|
490 | double compensate = 0; // ‹«ŠE’l•â�³—p‚Ì•Ï�”
|
---|
491 | double time_compensate = 0; // ŽžŠÔ‚É‚æ‚é‹«ŠE’l•â�³—p‚Ì•Ï�”
|
---|
492 | // ‹«ŠE’l‚Ì�X�V
|
---|
493 | border_bid_utility = timeline.getTime()
|
---|
494 | * (1.0 - utilitySpace.getDiscountFactor())
|
---|
495 | + utilitySpace.getDiscountFactor();
|
---|
496 |
|
---|
497 | // Discount‚ª�‚‚¢‚Æ‚«‚É�÷•à‚µ‚·‚¬‚邱‚Æ‚ð–h‚®‚½‚ß‚É�CŠeŽp�¨‚Ì1�í–Ú‚ÍŠî–{‹«ŠE’l‚ð‚Æ‚ç‚È‚¢‚悤‚É‚·‚é
|
---|
498 | if ((tension && true_failure_num == 0)
|
---|
499 | || (!tension && false_agreement_num == 0)) {
|
---|
500 | border_bid_utility = 1.0;
|
---|
501 | }
|
---|
502 |
|
---|
503 | // //csv�o—Í—p
|
---|
504 | // pw_my_b.print(timeline.getTime());
|
---|
505 | // pw_my_b.print(",");
|
---|
506 | // pw_my_b.print(border_bid_utility);
|
---|
507 | // pw_my_b.print(",");
|
---|
508 | // pw_my_b.println();
|
---|
509 |
|
---|
510 | if (tension) {
|
---|
511 | // ‚à‚µ�C‹«ŠE�ü‚ª�Å—Ç’ñŽ¦Bid‚ÌŒø—p’l‚æ‚è’á‚¢Žž�C‹«ŠE’l‚ð‚»‚ÌŒø—p’l‚É‚·‚é
|
---|
512 | if (true_best_agreement_bid != null
|
---|
513 | && border_bid_utility < utilitySpace
|
---|
514 | .getUtility(true_best_agreement_bid)) {
|
---|
515 | border_bid_utility = utilitySpace
|
---|
516 | .getUtility(true_best_agreement_bid);
|
---|
517 | }
|
---|
518 | } else {
|
---|
519 | // Žã‹C‚Ì�ê�‡
|
---|
520 | // �d‚Ý•t‚«•½‹Ï‚ð—˜—p‚µ‚½•â�³‚ð“K—p
|
---|
521 | // SAMPLE_NUM(“_)ƒTƒ“ƒvƒ‹�W‚Ü‚Á‚Ä‚¢‚é�ê�‡�C–â‘è‹óŠÔ‚É‚æ‚Á‚Ä‹«ŠE’l‚ðŠÉ˜a‚ð�l‚¦‚é
|
---|
522 | if (SAMPLE_NUM < partner_bid_count) {
|
---|
523 | compensate = (prev_offeredUtilFromOpponent
|
---|
524 | - partner_bid_utility_weighted_average)
|
---|
525 | * prev_offeredUtilFromOpponent
|
---|
526 | * (1.0 - utilitySpace.getReservationValue());
|
---|
527 |
|
---|
528 | // ŽžŠÔŒo‰ß‚Æ‘ŠŽè‚Ì�Å—ÇBid‚É‚æ‚é�÷•à‚ð—˜—p‚µ‚½•â�³‚ð“K—p
|
---|
529 | if (best_partner_bid != null) {
|
---|
530 | time_compensate = timeline.getTime()
|
---|
531 | * (border_bid_utility
|
---|
532 | - utilitySpace.getUtility(best_partner_bid))
|
---|
533 | * utilitySpace.getUtility(best_partner_bid)
|
---|
534 | * (1.0 - utilitySpace.getReservationValue());
|
---|
535 |
|
---|
536 | if (time_compensate < 0) {
|
---|
537 | time_compensate = 0;
|
---|
538 | }
|
---|
539 | }
|
---|
540 |
|
---|
541 | if (compensate * (1.0 + time_compensate) > time_compensate
|
---|
542 | && false_agreement_num > 0) {
|
---|
543 | border_bid_utility = border_bid_utility
|
---|
544 | - compensate * (1.0 + time_compensate);
|
---|
545 | } else {
|
---|
546 | border_bid_utility = border_bid_utility - time_compensate;
|
---|
547 | }
|
---|
548 |
|
---|
549 | if (timeline.getTime() > 0.90) {
|
---|
550 | border_bid_utility = border_bid_utility
|
---|
551 | - 10 * (timeline.getTime() - 0.90)
|
---|
552 | * (border_bid_utility - utilitySpace
|
---|
553 | .getUtility(best_partner_bid));
|
---|
554 | }
|
---|
555 | }
|
---|
556 | }
|
---|
557 |
|
---|
558 | // ‚à‚µ�C‹«ŠE�ü‚ª�Å—Ç’ñŽ¦Bid‚ÌŒø—p’l‚æ‚è’á‚¢Žž�C‹«ŠE’l‚ð‚»‚ÌŒø—p’l‚É‚·‚é
|
---|
559 | if (false_best_agreement_bid != null
|
---|
560 | && border_bid_utility < utilitySpace
|
---|
561 | .getUtility(false_best_agreement_bid)) {
|
---|
562 | border_bid_utility = utilitySpace
|
---|
563 | .getUtility(false_best_agreement_bid);
|
---|
564 | }
|
---|
565 |
|
---|
566 | // ‚à‚µ�C‹«ŠE�ü‚ªŒ»�Ý‚ÌŒð�‚Ì�Å—Ç’ñŽ¦Bid‚ÌŒø—p’l‚æ‚è’á‚¢Žž�C‹«ŠE’l‚ð‚»‚ÌŒø—p’l‚É‚·‚é
|
---|
567 | if (best_partner_bid != null && border_bid_utility < utilitySpace
|
---|
568 | .getUtility(best_partner_bid)) {
|
---|
569 | border_bid_utility = utilitySpace.getUtility(best_partner_bid);
|
---|
570 | }
|
---|
571 |
|
---|
572 | // ReservationValue‚Ì•û‚ª‹«ŠE’l‚æ‚è‘å‚«‚‚Ȃ鎞(•ÛŒ¯—p)
|
---|
573 | if (border_bid_utility < utilitySpace.getReservationValue()) {
|
---|
574 | border_bid_utility = utilitySpace.getReservationValue();
|
---|
575 | }
|
---|
576 |
|
---|
577 | // //csv�o—Í—p
|
---|
578 | // pw_my_b_t.print(timeline.getTime());
|
---|
579 | // pw_my_b_t.print(",");
|
---|
580 | // pw_my_b_t.print(border_bid_utility);
|
---|
581 | // pw_my_b_t.print(",");
|
---|
582 | // pw_my_b_t.println();
|
---|
583 | }
|
---|
584 |
|
---|
585 | // SA(�Å‘åŒø—p’lBid)
|
---|
586 | private Bid getBestBidbySA() throws Exception {
|
---|
587 | // SA‚É‚æ‚é’T�õ‚ð�s‚¢�CBid‚ð•Ô‚·
|
---|
588 | Bid current_b, next_b, bid = null; // Œ»�Ý‚ÌBid‚Æ�Å“KBid‚Æ‹ß–T‚ÌBid�CŽã‹C‚Ì‚Æ‚«‚Ì‚½‚ß‚ÌBid�C•Ô‹p—p‚ÌBid
|
---|
589 | double current_u, best_u, next_u; // Œ»�Ý‚ÌBid‚ÌŒø—p’l‚Æ�Å“KBid‚ÌŒø—p’l‚Æ‹ß–T‚ÌBid‚ÌŒø—p’l
|
---|
590 | int next_v; // ‹ß–T‚ÌBid‚Ì•Ï�XŒã‚Ìvalue‚Ì’l
|
---|
591 | double temperature; // ‰·“x
|
---|
592 | double cool = 0.99; // —â‹p“x
|
---|
593 | double p; // ‘JˆÚŠm—¦
|
---|
594 | double diff; // Œ»�Ý‚ÌBid‚Æ‹ß–T‚ÌBid‚ÌŒø—p’l‚Ì�·
|
---|
595 | Random randomnr = new Random(); // —��”
|
---|
596 | int step = 1;// •Ï�X‚·‚é•�
|
---|
597 | int step_num = 1; // •Ï�X‚·‚é‰ñ�”
|
---|
598 | int flag; // step‚Ì•„�†
|
---|
599 |
|
---|
600 | Bid best[];
|
---|
601 | best = new Bid[ARRAY_LIM];
|
---|
602 | int random_count = 0; // “¯‚¶Œø—p’l‚ðŽ�‚Â�Å‘å’l‚ÌBid‚ÌŒÂ�”
|
---|
603 |
|
---|
604 | // �‰Šú‰ð‚Ì�¶�¬
|
---|
605 | if (prev_partner_bid == null) {
|
---|
606 | current_b = utilitySpace.getDomain().getRandomBid(null);
|
---|
607 | } else {
|
---|
608 | current_b = new Bid(prev_partner_bid);
|
---|
609 | }
|
---|
610 |
|
---|
611 | do {
|
---|
612 | current_u = utilitySpace.getUtility(current_b);
|
---|
613 |
|
---|
614 | // �Å“K‰ð‚Ì�‰Šú‰»
|
---|
615 | best[0] = new Bid(current_b);
|
---|
616 | best_u = current_u;
|
---|
617 | // ƒJƒEƒ“ƒ^‚̃ŠƒZƒbƒg
|
---|
618 | random_count = 0;
|
---|
619 |
|
---|
620 | temperature = 1000000; // ŠJŽn‰·“x‚̃Zƒbƒg
|
---|
621 |
|
---|
622 | // ‰·“x‚ª�\•ª‰º‚ª‚é‚©�C–Ú“I‚̃†�[ƒeƒBƒŠƒeƒB‚ðŽæ“¾‚Å‚«‚é‚܂Ń‹�[ƒv
|
---|
623 | while (temperature > 0.0001) {
|
---|
624 | next_b = new Bid(current_b); // next_b‚ð�‰Šú‰»
|
---|
625 | List<Issue> issues = utilitySpace.getDomain().getIssues(); // ‘Sissue‚̎擾
|
---|
626 |
|
---|
627 | // ‹ß–T‚ÌBid‚ðŽæ“¾‚·‚é
|
---|
628 | for (int i = 0; i < step_num; i++) {
|
---|
629 | int issueIndex = randomnr.nextInt(issues.size()); // issue‚͈͓̔à‚Åindex‚ðƒ‰ƒ“ƒ_ƒ€‚ÉŽw’è
|
---|
630 | IssueInteger lIssueInteger = (IssueInteger) issues
|
---|
631 | .get(issueIndex); // Žw’肵‚½index‚Ìissue
|
---|
632 | int issueNumber = lIssueInteger.getNumber(); // issue”Ô�†
|
---|
633 | int max = lIssueInteger.getUpperBound();// ‘I‚ñ‚¾issue‚ɑΉž‚·‚évalue‚Ì�Å‘å’l
|
---|
634 | int min = lIssueInteger.getLowerBound();// ‘I‚ñ‚¾issue‚ɑΉž‚·‚évalue‚Ì�Å�¬’l
|
---|
635 | ValueInteger issueValue = (ValueInteger) next_b
|
---|
636 | .getValue(issueNumber); // ‘I‚ñ‚¾issue‚ɑΉž‚·‚évalue
|
---|
637 | int issueValueInt = Integer.valueOf(issueValue.toString())
|
---|
638 | .intValue(); // ‘I‚ñ‚¾issue‚ɑΉž‚·‚évalue(integer)
|
---|
639 |
|
---|
640 | // velue‚Ì�ãŒÀ‚ƉºŒÀ‚ð�l‚¦‚ĕψÊ�istep�j‚Ì•„�†(flag)‚ð�Ý’è‚·‚é
|
---|
641 | if (issueValueInt + step > max) {
|
---|
642 | flag = -1;
|
---|
643 | } else if (issueValueInt - step < min) {
|
---|
644 | flag = 1;
|
---|
645 | } else if (randomnr.nextInt(2) == 0) {
|
---|
646 | flag = 1;
|
---|
647 | } else {
|
---|
648 | flag = -1;
|
---|
649 | }
|
---|
650 |
|
---|
651 | next_v = issueValueInt + flag * step; // •Ï�XŒã‚Ìvalue‚ðŒvŽZ‚·‚é
|
---|
652 | next_b = next_b.putValue(issueNumber,
|
---|
653 | new ValueInteger(next_v)); // ‹ß–T‚ÌBid‚ð‹�‚ß‚é
|
---|
654 | }
|
---|
655 |
|
---|
656 | next_u = utilitySpace.getUtility(next_b); // ‹ß–T‚ÌBid‚ÌŒø—p’l‚ð‹�‚ß‚é
|
---|
657 | diff = current_u - next_u; // ‘JˆÚŠm—¦‚ð‹�‚ß‚é
|
---|
658 |
|
---|
659 | if (diff > 0.0) {
|
---|
660 | p = Math.exp(-diff / temperature); // Œ»�Ý‚ÌŒø—p’l‚Ì•û‚ª�‚‚¢�ê�‡
|
---|
661 | } else {
|
---|
662 | p = 1.0; // ‹ß–T‚ÌŒø—p’l‚Ì•û‚ª�‚‚¢�ê�‡
|
---|
663 | }
|
---|
664 |
|
---|
665 | if (p > randomnr.nextDouble()) {
|
---|
666 | current_b = new Bid(next_b); // Bid‚Ì�X�V
|
---|
667 | current_u = next_u; // Utility‚Ì�X�V
|
---|
668 | }
|
---|
669 |
|
---|
670 | // �Å“K‰ð‚Ì�X�V
|
---|
671 | if (next_u > best_u) {
|
---|
672 | random_count = 0;
|
---|
673 | best[random_count] = new Bid(next_b);
|
---|
674 | best_u = next_u;
|
---|
675 | // ƒJƒEƒ“ƒ^‚̃ŠƒZƒbƒg
|
---|
676 | random_count++;
|
---|
677 | }
|
---|
678 |
|
---|
679 | // “¯‚¶Œø—p’l‚ðŽ�‚ÂBid‚ð‹L‰¯‚µ‚Ä‚¨‚
|
---|
680 | if (next_u == best_u) {
|
---|
681 | best[random_count % ARRAY_LIM] = new Bid(next_b);
|
---|
682 | random_count++;
|
---|
683 | }
|
---|
684 | // ‰·“x‚ð‰º‚°‚é
|
---|
685 | temperature = temperature * cool;
|
---|
686 | }
|
---|
687 |
|
---|
688 | // Œø—p’l‚ª�Å‘å‚Æ‚È‚éBid‚ð•Ô‚·
|
---|
689 | if (bid == null || best_u > utilitySpace.getUtility(bid)) {
|
---|
690 | if (random_count > ARRAY_LIM) {
|
---|
691 | bid = new Bid(best[randomnr.nextInt(ARRAY_LIM)]);
|
---|
692 | } else {
|
---|
693 | bid = new Bid(best[randomnr.nextInt(random_count)]);
|
---|
694 | }
|
---|
695 | }
|
---|
696 | } while (utilitySpace.getUtility(bid) < utilitySpace
|
---|
697 | .getReservationValue());
|
---|
698 |
|
---|
699 | return bid;
|
---|
700 | }
|
---|
701 |
|
---|
702 | // SA(‹«ŠE’l•t‹ß‚ÌBid)
|
---|
703 | private Bid getBetterBidbySA() throws Exception {
|
---|
704 | // SA‚É‚æ‚é’T�õ‚ð�s‚¢�CBid‚ð•Ô‚·
|
---|
705 | Bid current_b, best_b, next_b, better_b = null, bid = null; // Œ»�Ý‚ÌBid‚Æ�Å“KBid‚Æ‹ß–T‚ÌBid�CŽã‹C‚Ì‚Æ‚«‚Ì‚½‚ß‚ÌBid�C•Ô‹p—p‚ÌBid
|
---|
706 | double current_u, best_u, next_u, better_u = 0; // Œ»�Ý‚ÌBid‚ÌŒø—p’l‚Æ�Å“KBid‚ÌŒø—p’l‚Æ‹ß–T‚ÌBid‚ÌŒø—p’l
|
---|
707 | int next_v; // ‹ß–T‚ÌBid‚Ì•Ï�XŒã‚Ìvalue‚Ì’l
|
---|
708 | double temperature; // ‰·“x
|
---|
709 | double cool = 0.99; // —â‹p“x
|
---|
710 | double p; // ‘JˆÚŠm—¦
|
---|
711 | double diff; // Œ»�Ý‚ÌBid‚Æ‹ß–T‚ÌBid‚ÌŒø—p’l‚Ì�·
|
---|
712 | Random randomnr = new Random(); // —��”
|
---|
713 | int step = 1;// •Ï�X‚·‚é•�
|
---|
714 | int step_num = 1; // •Ï�X‚·‚é‰ñ�”
|
---|
715 | int flag; // step‚Ì•„�†
|
---|
716 |
|
---|
717 | Bid better[];
|
---|
718 | better = new Bid[ARRAY_LIM];
|
---|
719 | int random_count = 0; // “¯‚¶Œø—p’l‚ðŽ�‚‹«ŠE’l•t‹ß‚ÌBid‚ÌŒÂ�”
|
---|
720 |
|
---|
721 | // �‰Šú‰ð‚Ì�¶�¬
|
---|
722 | if (prev_partner_bid == null) {
|
---|
723 | current_b = utilitySpace.getDomain().getRandomBid(null);
|
---|
724 | } else {
|
---|
725 | current_b = new Bid(prev_partner_bid);
|
---|
726 | }
|
---|
727 |
|
---|
728 | do {
|
---|
729 | current_u = utilitySpace.getUtility(current_b);
|
---|
730 |
|
---|
731 | // �Å“K‰ð‚Ì�‰Šú‰»
|
---|
732 | best_b = new Bid(current_b);
|
---|
733 | best_u = current_u;
|
---|
734 |
|
---|
735 | // ‹«ŠE’l•t‹ß‚ÌBid‚Ì�‰Šú‰»
|
---|
736 | better_b = null;
|
---|
737 | better_u = 0;
|
---|
738 |
|
---|
739 | temperature = 1000000; // ŠJŽn‰·“x‚̃Zƒbƒg
|
---|
740 |
|
---|
741 | // ‰·“x‚ª�\•ª‰º‚ª‚é‚©�C–Ú“I‚̃†�[ƒeƒBƒŠƒeƒB‚ðŽæ“¾‚Å‚«‚é‚܂Ń‹�[ƒv
|
---|
742 | while (temperature > 0.0001) {
|
---|
743 | next_b = new Bid(current_b); // next_b‚ð�‰Šú‰»
|
---|
744 | List<Issue> issues = utilitySpace.getDomain().getIssues(); // ‘Sissue‚̎擾
|
---|
745 |
|
---|
746 | // ‹ß–T‚ÌBid‚ðŽæ“¾‚·‚é
|
---|
747 | for (int i = 0; i < step_num; i++) {
|
---|
748 | int issueIndex = randomnr.nextInt(issues.size()); // issue‚͈͓̔à‚Åindex‚ðƒ‰ƒ“ƒ_ƒ€‚ÉŽw’è
|
---|
749 | IssueInteger lIssueInteger = (IssueInteger) issues
|
---|
750 | .get(issueIndex); // Žw’肵‚½index‚Ìissue
|
---|
751 | int issueNumber = lIssueInteger.getNumber(); // issue”Ô�†
|
---|
752 | int max = lIssueInteger.getUpperBound();// ‘I‚ñ‚¾issue‚ɑΉž‚·‚évalue‚Ì�Å‘å’l
|
---|
753 | int min = lIssueInteger.getLowerBound();// ‘I‚ñ‚¾issue‚ɑΉž‚·‚évalue‚Ì�Å�¬’l
|
---|
754 | ValueInteger issueValue = (ValueInteger) next_b
|
---|
755 | .getValue(issueNumber); // ‘I‚ñ‚¾issue‚ɑΉž‚·‚évalue
|
---|
756 | int issueValueInt = Integer.valueOf(issueValue.toString())
|
---|
757 | .intValue(); // ‘I‚ñ‚¾issue‚ɑΉž‚·‚évalue(integer)
|
---|
758 |
|
---|
759 | // velue‚Ì�ãŒÀ‚ƉºŒÀ‚ð�l‚¦‚ĕψÊ�istep�j‚Ì•„�†(flag)‚ð�Ý’è‚·‚é
|
---|
760 | if (issueValueInt + step > max) {
|
---|
761 | flag = -1;
|
---|
762 | } else if (issueValueInt - step < min) {
|
---|
763 | flag = 1;
|
---|
764 | } else if (randomnr.nextInt(2) == 0) {
|
---|
765 | flag = 1;
|
---|
766 | } else {
|
---|
767 | flag = -1;
|
---|
768 | }
|
---|
769 |
|
---|
770 | next_v = issueValueInt + flag * step; // •Ï�XŒã‚Ìvalue‚ðŒvŽZ‚·‚é
|
---|
771 | next_b = next_b.putValue(issueNumber,
|
---|
772 | new ValueInteger(next_v)); // ‹ß–T‚ÌBid‚ð‹�‚ß‚é
|
---|
773 | }
|
---|
774 |
|
---|
775 | next_u = utilitySpace.getUtility(next_b); // ‹ß–T‚ÌBid‚ÌŒø—p’l‚ð‹�‚ß‚é
|
---|
776 | diff = current_u - next_u; // ‘JˆÚŠm—¦‚ð‹�‚ß‚é
|
---|
777 |
|
---|
778 | if (diff > 0.0) {
|
---|
779 | p = Math.exp(-diff / temperature); // Œ»�Ý‚ÌŒø—p’l‚Ì•û‚ª�‚‚¢�ê�‡
|
---|
780 | } else {
|
---|
781 | p = 1.0; // ‹ß–T‚ÌŒø—p’l‚Ì•û‚ª�‚‚¢�ê�‡
|
---|
782 | }
|
---|
783 |
|
---|
784 | if (p > randomnr.nextDouble()) {
|
---|
785 | current_b = new Bid(next_b); // Bid‚Ì�X�V
|
---|
786 | current_u = next_u; // Utility‚Ì�X�V
|
---|
787 | }
|
---|
788 |
|
---|
789 | // �Å“K‰ð‚Ì�X�V
|
---|
790 | if (next_u > best_u) {
|
---|
791 | best_b = new Bid(next_b);
|
---|
792 | best_u = next_u;
|
---|
793 | }
|
---|
794 |
|
---|
795 | // ‹«ŠE’l•t‹ß‚Ì’l‚ð•Ô‚·‚½‚ß‚É‹L‰¯‚·‚é
|
---|
796 | // �‰Šú‰»
|
---|
797 | if (better_b == null && best_u > border_bid_utility) {
|
---|
798 | better_b = new Bid(best_b);
|
---|
799 | better_u = best_u;
|
---|
800 | random_count = 0;
|
---|
801 | better[random_count] = new Bid(next_b);
|
---|
802 | // ƒJƒEƒ“ƒ^‚ðƒZƒbƒg
|
---|
803 | random_count++;
|
---|
804 | }
|
---|
805 | // �X�V
|
---|
806 | if (next_u < better_u && next_u > border_bid_utility) {
|
---|
807 | better_b = new Bid(next_b);
|
---|
808 | better_u = next_u;
|
---|
809 | random_count = 0;
|
---|
810 |
|
---|
811 | better[random_count] = new Bid(next_b);
|
---|
812 | // ƒJƒEƒ“ƒ^‚ðƒZƒbƒg
|
---|
813 | random_count++;
|
---|
814 | }
|
---|
815 |
|
---|
816 | // “¯‚¶Œø—p’l‚ðŽ�‚ÂBid‚ð‹L‰¯‚µ‚Ä‚¨‚
|
---|
817 | if (next_u == better_u) {
|
---|
818 | better[random_count % ARRAY_LIM] = new Bid(next_b);
|
---|
819 | random_count++;
|
---|
820 | }
|
---|
821 |
|
---|
822 | // ‰·“x‚ð‰º‚°‚é
|
---|
823 | temperature = temperature * cool;
|
---|
824 | }
|
---|
825 |
|
---|
826 | if (better_b != null) {
|
---|
827 | // Œø—p’l‚ª‹«ŠE’l•t‹ß‚Æ‚È‚éBid‚ð•Ô‚·
|
---|
828 | if (bid == null || better_u < utilitySpace.getUtility(bid)) {
|
---|
829 | if (random_count > ARRAY_LIM) {
|
---|
830 | bid = new Bid(better[randomnr.nextInt(ARRAY_LIM)]);
|
---|
831 | } else {
|
---|
832 | bid = new Bid(better[randomnr.nextInt(random_count)]);
|
---|
833 | }
|
---|
834 | }
|
---|
835 | } else {
|
---|
836 | // ‹«ŠE’l‚æ‚è‘å‚«‚ÈŒø—p’l‚ðŽ�‚ÂBid‚ªŒ©‚‚©‚ç‚È‚©‚Á‚½‚Æ‚«‚Í�CŒø—p’l‚ª�Å‘å‚Æ‚È‚éBid‚ð•Ô‚·
|
---|
837 | if (bid == null) {
|
---|
838 | bid = new Bid(best_b);
|
---|
839 | }
|
---|
840 | }
|
---|
841 | } while (utilitySpace.getUtility(bid) < utilitySpace
|
---|
842 | .getReservationValue());
|
---|
843 |
|
---|
844 | return bid;
|
---|
845 | }
|
---|
846 |
|
---|
847 | // ‹ß–T’T�õ(�Å‘åŒø—p’lBid)
|
---|
848 | private Bid getBestBidbyNear(Bid baseBid) throws Exception {
|
---|
849 | Bid current_b = new Bid(baseBid); // Œ»�Ý‚ÌBid
|
---|
850 | double current_u = utilitySpace.getUtility(baseBid); // Œ»�Ý‚ÌBid‚ÌŒø—p’l
|
---|
851 |
|
---|
852 | Bid best_b = new Bid(baseBid); // �œKBid
|
---|
853 | double best_u = current_u; // �Å“KBid‚ÌŒø—p’l
|
---|
854 |
|
---|
855 | Random randomnr = new Random(); // —��”
|
---|
856 | Bid best[];
|
---|
857 | best = new Bid[ARRAY_LIM];
|
---|
858 | int random_count = 0; // “¯‚¶Œø—p’l‚ðŽ�‚Â�Å‘å’l‚ÌBid‚ÌŒÂ�”
|
---|
859 |
|
---|
860 | List<Issue> issues = utilitySpace.getDomain().getIssues(); // ‘Sissue‚̎擾
|
---|
861 |
|
---|
862 | int lim = issues.size();
|
---|
863 |
|
---|
864 | for (int i = 0; i < lim; i++) {
|
---|
865 | IssueInteger lIssueInteger = (IssueInteger) issues.get(i); // Žw’肵‚½index‚Ìissue
|
---|
866 | int issueNumber = lIssueInteger.getNumber(); // issue”Ô�†
|
---|
867 | int max = lIssueInteger.getUpperBound();// ‘I‚ñ‚¾issue‚ɑΉž‚·‚évalue‚Ì�Å‘å’l
|
---|
868 | int min = lIssueInteger.getLowerBound();// ‘I‚ñ‚¾issue‚ɑΉž‚·‚évalue‚Ì�Å�¬’l
|
---|
869 |
|
---|
870 | for (int j = min; j <= max; j++) {
|
---|
871 | current_b = current_b.putValue(issueNumber,
|
---|
872 | new ValueInteger(j)); // ‹ß–T‚ÌBid‚ð‹�‚ß‚é
|
---|
873 | current_u = utilitySpace.getUtility(current_b);
|
---|
874 |
|
---|
875 | // �Å‘åŒø—p’l‚Æ‚È‚éBid‚ð•Û‘¶
|
---|
876 | if (current_u > best_u) {
|
---|
877 | best_b = new Bid(current_b);
|
---|
878 | best_u = utilitySpace.getUtility(current_b);
|
---|
879 | random_count = 0;
|
---|
880 | best[random_count] = new Bid(current_b);
|
---|
881 | // ƒJƒEƒ“ƒ^‚̃ŠƒZƒbƒg
|
---|
882 | random_count++;
|
---|
883 | }
|
---|
884 |
|
---|
885 | // “¯‚¶Œø—p’l‚ðŽ�‚ÂBid‚ð‹L‰¯‚µ‚Ä‚¨‚
|
---|
886 | if (current_u == best_u) {
|
---|
887 | best[random_count % ARRAY_LIM] = new Bid(current_b);
|
---|
888 | random_count++;
|
---|
889 | }
|
---|
890 |
|
---|
891 | current_b = new Bid(baseBid);
|
---|
892 | }
|
---|
893 | }
|
---|
894 |
|
---|
895 | // Œø—p’l‚ª�Å‘å‚Æ‚È‚éBid‚ð•Ô‚·
|
---|
896 | if (random_count > ARRAY_LIM) {
|
---|
897 | best_b = new Bid(best[randomnr.nextInt(ARRAY_LIM)]);
|
---|
898 | } else {
|
---|
899 | best_b = new Bid(best[randomnr.nextInt(random_count)]);
|
---|
900 | }
|
---|
901 |
|
---|
902 | return best_b;
|
---|
903 | }
|
---|
904 |
|
---|
905 | // ‹ß–T’T�õ(‹«ŠE’l•t‹ß‚ÌBid)
|
---|
906 | private Bid getBetterBidbyNear(Bid baseBid) throws Exception {
|
---|
907 | Bid current_b = new Bid(baseBid); // Œ»�Ý‚ÌBid
|
---|
908 | double current_u = utilitySpace.getUtility(baseBid); // Œ»�Ý‚ÌBid‚ÌŒø—p’l
|
---|
909 |
|
---|
910 | Bid best_b = new Bid(baseBid); // �œKBid
|
---|
911 | double best_u = current_u; // �Å“KBid‚ÌŒø—p’l
|
---|
912 |
|
---|
913 | Bid better_b = null; // ‹«ŠE’l•t‹ß‚ÌŒø—p’l‚ðŽ�‚ÂBid
|
---|
914 | double better_u = 0; // ‹«ŠE’l•t‹ß‚ÌŒø—p’l‚ðŽ�‚ÂBid‚ÌŒø—p’l
|
---|
915 |
|
---|
916 | Random randomnr = new Random(); // —��”
|
---|
917 | Bid better[];
|
---|
918 | better = new Bid[ARRAY_LIM];
|
---|
919 | int random_count = 0; // “¯‚¶Œø—p’l‚ðŽ�‚‹«ŠE’l•t‹ß‚ÌBid‚ÌŒÂ�”
|
---|
920 |
|
---|
921 | List<Issue> issues = utilitySpace.getDomain().getIssues(); // ‘Sissue‚̎擾
|
---|
922 |
|
---|
923 | int lim = issues.size();
|
---|
924 |
|
---|
925 | for (int i = 0; i < lim; i++) {
|
---|
926 | IssueInteger lIssueInteger = (IssueInteger) issues.get(i); // Žw’肵‚½index‚Ìissue
|
---|
927 | int issueNumber = lIssueInteger.getNumber(); // issue”Ô�†
|
---|
928 | int max = lIssueInteger.getUpperBound();// ‘I‚ñ‚¾issue‚ɑΉž‚·‚évalue‚Ì�Å‘å’l
|
---|
929 | int min = lIssueInteger.getLowerBound();// ‘I‚ñ‚¾issue‚ɑΉž‚·‚évalue‚Ì�Å�¬’l
|
---|
930 |
|
---|
931 | for (int j = min; j <= max; j++) {
|
---|
932 | current_b = current_b.putValue(issueNumber,
|
---|
933 | new ValueInteger(j)); // ‹ß–T‚ÌBid‚ð‹�‚ß‚é
|
---|
934 | current_u = utilitySpace.getUtility(current_b);
|
---|
935 |
|
---|
936 | // �Å‘åŒø—p’l‚Æ‚È‚éBid‚ð•Û‘¶
|
---|
937 | if (current_u > best_u) {
|
---|
938 | best_b = new Bid(current_b);
|
---|
939 | best_u = utilitySpace.getUtility(current_b);
|
---|
940 | }
|
---|
941 |
|
---|
942 | // ‹«ŠE’l•t‹ß‚Ì’l‚ð•Ô‚·‚½‚ß‚É‹L‰¯‚·‚é
|
---|
943 | // �‰Šú‰»
|
---|
944 | if (better_b == null && best_u > border_bid_utility) {
|
---|
945 | better_b = new Bid(best_b);
|
---|
946 | better_u = current_u;
|
---|
947 |
|
---|
948 | better[0] = new Bid(best_b);
|
---|
949 | // ƒJƒEƒ“ƒ^‚ðƒZƒbƒg
|
---|
950 | random_count = 1;
|
---|
951 | }
|
---|
952 | // �X�V
|
---|
953 | if (current_u < better_u && current_u > border_bid_utility) {
|
---|
954 | better_b = new Bid(current_b);
|
---|
955 | better_u = current_u;
|
---|
956 | random_count = 0;
|
---|
957 | better[random_count] = new Bid(current_b);
|
---|
958 | // ƒJƒEƒ“ƒ^‚ðƒZƒbƒg
|
---|
959 | random_count++;
|
---|
960 | }
|
---|
961 |
|
---|
962 | // “¯‚¶Œø—p’l‚ðŽ�‚ÂBid‚ð‹L‰¯‚µ‚Ä‚¨‚
|
---|
963 | if (current_u == better_u) {
|
---|
964 | better[random_count % ARRAY_LIM] = new Bid(current_b);
|
---|
965 | random_count++;
|
---|
966 | }
|
---|
967 |
|
---|
968 | current_b = new Bid(baseBid);
|
---|
969 | }
|
---|
970 | }
|
---|
971 |
|
---|
972 | if (better_b != null) {
|
---|
973 | // Œø—p’l‚ª‹«ŠE’l•t‹ß‚Æ‚È‚éBid‚ð•Ô‚·
|
---|
974 | if (random_count > ARRAY_LIM) {
|
---|
975 | better_b = new Bid(better[randomnr.nextInt(ARRAY_LIM)]);
|
---|
976 | } else {
|
---|
977 | better_b = new Bid(better[randomnr.nextInt(random_count)]);
|
---|
978 | }
|
---|
979 | } else {
|
---|
980 | // ‹«ŠE’l‚æ‚è‘å‚«‚ÈŒø—p’l‚ðŽ�‚ÂBid‚ªŒ©‚‚©‚ç‚È‚©‚Á‚½‚Æ‚«‚Í�CŒø—p’l‚ª�Å‘å‚Æ‚È‚éBid‚ð•Ô‚·
|
---|
981 | better_b = new Bid(best_b);
|
---|
982 | }
|
---|
983 |
|
---|
984 | return better_b;
|
---|
985 | }
|
---|
986 |
|
---|
987 | private void initPrevSessionData() throws Exception {
|
---|
988 | // csv�o—Í—p
|
---|
989 | // fw = new FileWriter("/Users/Mori/Program/R/anac/Atlas_Session_mu"+
|
---|
990 | // sessionNr + ".csv", false);
|
---|
991 | // pw_my_u = new PrintWriter(new BufferedWriter(fw));
|
---|
992 | // // ‘ŠŽè‚Ì’ñŽ¦‚µ‚½Bid‚ÌŒø—p’l
|
---|
993 | // fw_p = new
|
---|
994 | // FileWriter("/Users/Mori/Program/R/anac/Atlas_Session_Data_pu" +
|
---|
995 | // sessionNr + ".csv", false);
|
---|
996 | // pw_pa_u = new PrintWriter(new BufferedWriter(fw_p));
|
---|
997 | // // Ž©•ª‚Ì’ñŽ¦‚µ‚½Bid‚Ì‹«ŠE�ü
|
---|
998 | // fw_b = new
|
---|
999 | // FileWriter("/Users/Mori/Program/R/anac/Atlas_Session_Data_mb" +
|
---|
1000 | // sessionNr + ".csv", false);
|
---|
1001 | // pw_my_b = new PrintWriter(new BufferedWriter(fw_b));
|
---|
1002 | // //
|
---|
1003 | // Ž©•ª‚Ì’ñŽ¦‚µ‚½Bid‚Ì�d‚Ý•t‚«•â�³�Ï‚Ý‹«ŠE�ü
|
---|
1004 | // fw_b_t = new
|
---|
1005 | // FileWriter("/Users/Mori/Program/R/anac/Atlas_Session_Data_mbt" +
|
---|
1006 | // sessionNr + ".csv", false);
|
---|
1007 | // pw_my_b_t = new PrintWriter(new BufferedWriter(fw_b_t));
|
---|
1008 | // // Ž©•ª‚Ì’ñŽ¦‚µ‚½Bid‚Ì•â�³�Ï‚Ý
|
---|
1009 | // fw_b_c = new
|
---|
1010 | // FileWriter("/Users/Mori/Program/R/anac/Atlas_Session_Data_mbc" +
|
---|
1011 | // sessionNr + ".csv", false);
|
---|
1012 | // pw_my_b_c = new PrintWriter(new BufferedWriter(fw_b_c));
|
---|
1013 |
|
---|
1014 | Serializable prev = this.loadSessionData();
|
---|
1015 | MySessionData mySessionData = (MySessionData) prev;
|
---|
1016 |
|
---|
1017 | // •Ï�”‚Ì�‰Šú‰»
|
---|
1018 | if (sessionNr > 0 && prev != null) {
|
---|
1019 | mySessionData = (MySessionData) prev;
|
---|
1020 | last_tension = mySessionData.tension;
|
---|
1021 | is_agreement = mySessionData.isAgreement;
|
---|
1022 | last_bid = mySessionData.lastBid;
|
---|
1023 | max_bid = mySessionData.max_bid;
|
---|
1024 | true_best_agreement_bid = mySessionData.true_best_agreement_bid;
|
---|
1025 | false_best_agreement_bid = mySessionData.false_best_agreement_bid;
|
---|
1026 | true_failure_num = mySessionData.true_failure_num;
|
---|
1027 | false_agreement_num = mySessionData.false_agreement_num;
|
---|
1028 | false_agreement_average_utility_with_discount = mySessionData.false_agreement_average_utility_with_discount;
|
---|
1029 | partner_attack_num = mySessionData.partner_attack_num;
|
---|
1030 | partner_guard_num = mySessionData.partner_guard_num;
|
---|
1031 | last_time = mySessionData.last_time;
|
---|
1032 | last_bid_time = mySessionData.last_bid_time;
|
---|
1033 | tension_true_seal_flag = mySessionData.tension_true_seal_flag;
|
---|
1034 | true_repeat_time = mySessionData.true_repeat_time;
|
---|
1035 | false_repeat_time = mySessionData.false_repeat_time;
|
---|
1036 | false_agreement_best_utility = mySessionData.false_agreement_best_utility;
|
---|
1037 |
|
---|
1038 | // Žp�¨‚ÌŒˆ’è
|
---|
1039 | if (is_agreement && last_tension) {
|
---|
1040 | // ‹‹C‚Å�‡ˆÓ‚µ‚½�ê�‡�C‹‹C‚ÅŒð�‚ð‘±�s‚·‚é
|
---|
1041 | tension = true;
|
---|
1042 | } else {
|
---|
1043 | if (false_best_agreement_bid == null) {
|
---|
1044 | tension = false;
|
---|
1045 | } else {
|
---|
1046 | // ‹‹C‚Ì�ê�‡
|
---|
1047 | double parameter = partner_guard_num + partner_attack_num;
|
---|
1048 | if (parameter == 0) {
|
---|
1049 | parameter = 1;
|
---|
1050 | }
|
---|
1051 | // —˜“¾�i‘ŠŽè‚ªŽã‹C‚Ì‚Æ‚«‚É“¾‚éŒø—p’l�iŽc‚è‚ÌŒð�‰ñ�”•ª�j�j
|
---|
1052 | double get_utility_true = (utilitySpace.getDiscountFactor()
|
---|
1053 | - false_agreement_average_utility_with_discount)
|
---|
1054 | * (sessionsTotal - (sessionNr));
|
---|
1055 | // ‘¹Ž¸�i‹‹C‚ÅŽ¸”s‚µ‚½‚Æ‚«‚ÉŽ¸‚¤Œø—p’l�i1‰ñ•ª�j�j
|
---|
1056 | double lost_utility_true = utilitySpace
|
---|
1057 | .getReservationValueWithDiscount(1.0)
|
---|
1058 | - false_agreement_average_utility_with_discount;
|
---|
1059 | // Šú‘Ò’l(‘ŠŽè‚ÌŽp�¨‚Í‹‹CorŽã‹C‚Å‚»‚ꂼ‚ê‚ÌŠm—¦‚͉ߋŽ‚ÌŒð�‚ðŽQ�Æ‚·‚é)
|
---|
1060 | double utility_true = get_utility_true
|
---|
1061 | * ((partner_guard_num) / (parameter))
|
---|
1062 | + lost_utility_true
|
---|
1063 | * ((partner_attack_num) / (parameter));
|
---|
1064 | // Šú‘Ò’l‚É‹‹C‚Å‚ÌŽ¸”s‚ÌŽÀ�Ñ’l‚𔽉f
|
---|
1065 | utility_true += (utilitySpace
|
---|
1066 | .getReservationValueWithDiscount(1.0)
|
---|
1067 | - false_agreement_average_utility_with_discount)
|
---|
1068 | * true_failure_num;
|
---|
1069 |
|
---|
1070 | if (utility_true > 0) {
|
---|
1071 | tension = true;
|
---|
1072 | } else {
|
---|
1073 | tension = false;
|
---|
1074 | }
|
---|
1075 | }
|
---|
1076 | }
|
---|
1077 |
|
---|
1078 | // 2�í–Ú‚ÍDiscountFactor‚ª1.0‚æ‚è�¬‚³‚¢Žž�C•K‚¸Žã‹C‚É‚È‚é
|
---|
1079 | if (sessionNr == 1 && utilitySpace.getDiscountFactor() < 1.0) {
|
---|
1080 | tension = false;
|
---|
1081 | }
|
---|
1082 |
|
---|
1083 | // 3�í–ÚˆÈ�~‚Í1�í–Ú‚Å�‡ˆÓ‚É�¬Œ÷‚µ‚Ä‚¢‚é‚Æ‚«‹‹C‚É–ß‚·
|
---|
1084 | if (sessionNr > 1 && utilitySpace.getDiscountFactor() < 1.0
|
---|
1085 | && true_failure_num == 0) {
|
---|
1086 | tension = true;
|
---|
1087 | }
|
---|
1088 |
|
---|
1089 | // ‹‹C••ˆóƒtƒ‰ƒO‚ª—§‚Á‚Ä‚¢‚鎞‚ÍŽã‹CŒÅ’è
|
---|
1090 | if (tension_true_seal_flag) {
|
---|
1091 | tension = false;
|
---|
1092 | }
|
---|
1093 | }
|
---|
1094 | }
|
---|
1095 |
|
---|
1096 | @Override
|
---|
1097 | public void endSession(NegotiationResult result) {
|
---|
1098 | try {
|
---|
1099 | // data‚ðcsv�o—Í‚·‚éŠÖ�”
|
---|
1100 | // pw_my_u.close();
|
---|
1101 | // pw_pa_u.close();
|
---|
1102 | // pw_my_b.close();
|
---|
1103 | // pw_my_b_t.close();
|
---|
1104 | // pw_my_b_c.close();
|
---|
1105 |
|
---|
1106 | boolean isAgreement = result.isAgreement();
|
---|
1107 | Bid lastBid = null;
|
---|
1108 |
|
---|
1109 | if (isAgreement) {
|
---|
1110 | // Accept‚µ‚½�ê�‡
|
---|
1111 | lastBid = result.getLastBid();
|
---|
1112 |
|
---|
1113 | if (tension) {
|
---|
1114 | // ‹‹C‚ÌŽž
|
---|
1115 | partner_guard_num++;
|
---|
1116 |
|
---|
1117 | // �‡ˆÓ‚µ‚½�Å‘åŒø—p’lBid‚ð‹L˜^
|
---|
1118 | if (true_best_agreement_bid == null
|
---|
1119 | || utilitySpace.getUtility(lastBid) >= utilitySpace
|
---|
1120 | .getUtility(true_best_agreement_bid)) {
|
---|
1121 | true_best_agreement_bid = new Bid(lastBid);
|
---|
1122 | true_repeat_time = timeline.getTime();
|
---|
1123 | }
|
---|
1124 | } else {
|
---|
1125 | // ‘¦Œˆ‚µ‚½�ê�‡‚ð�œ‚�ˆ—�
|
---|
1126 | if (!first_offer_decision_flag) {
|
---|
1127 | // Žã‹C‚ÌŽž
|
---|
1128 | if (attack_flag) {
|
---|
1129 | partner_attack_num++;
|
---|
1130 | } else {
|
---|
1131 | if (false_best_agreement_bid != null) {
|
---|
1132 | // “¾‚ç‚ꂽŒø—p’l‚ª�C‰ß‹Ž‚ÌŒð�‚Ì�Å—Ç‚ÌŒø—p’lˆÈ‰º‚Å‚ ‚è�C‚©‚Â�C‘O‰ñ‚ÌŽp�¨‚Æ�¡‰ñ‚ÌŽp�¨‚ª“¯‚¶‚Å‚ ‚é�ê�‡
|
---|
1133 | if (utilitySpace.getUtility(
|
---|
1134 | lastBid) < utilitySpace.getUtility(
|
---|
1135 | false_best_agreement_bid)
|
---|
1136 | && ((tension && last_tension)
|
---|
1137 | || (!tension
|
---|
1138 | && !last_tension))) {
|
---|
1139 | partner_attack_num++;
|
---|
1140 | }
|
---|
1141 | // “¾‚ç‚ꂽŒø—p’l‚ª�C‰ß‹Ž‚ÌŒð�‚Ì�Å—Ç‚ÌŒø—p’lˆÈ�ã‚Å‚ ‚è�C‚©‚Â�C‘O‰ñ‚ÌŽp�¨‚Æ�¡‰ñ‚ÌŽp�¨‚ª“¯‚¶‚Å‚ ‚é�ê�‡
|
---|
1142 | if (utilitySpace.getUtility(
|
---|
1143 | lastBid) > utilitySpace.getUtility(
|
---|
1144 | false_best_agreement_bid)
|
---|
1145 | && ((tension && last_tension)
|
---|
1146 | || (!tension
|
---|
1147 | && !last_tension))) {
|
---|
1148 | partner_guard_num++;
|
---|
1149 | }
|
---|
1150 | }
|
---|
1151 | }
|
---|
1152 |
|
---|
1153 | // �‡ˆÓ‚µ‚½�Å‘åŒø—p’lBid‚ð‹L˜^
|
---|
1154 | if (false_best_agreement_bid == null || utilitySpace
|
---|
1155 | .getUtility(lastBid) >= utilitySpace
|
---|
1156 | .getUtility(false_best_agreement_bid)) {
|
---|
1157 | false_best_agreement_bid = new Bid(lastBid);
|
---|
1158 | // �ÄŒ»ŽžŠÔ‚ð�Ý’è‚·‚é
|
---|
1159 | false_repeat_time = timeline.getTime();
|
---|
1160 | }
|
---|
1161 |
|
---|
1162 | // �‡ˆÓ‚µ‚½Discount�ž‚Ý�Å‘åŒø—p’l‚ð‹L˜^
|
---|
1163 | if (utilitySpace.getUtilityWithDiscount(lastBid,
|
---|
1164 | timeline.getTime()) > false_agreement_best_utility) {
|
---|
1165 | false_agreement_best_utility = utilitySpace
|
---|
1166 | .getUtilityWithDiscount(lastBid,
|
---|
1167 | timeline.getTime());
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 | // •½‹Ï’l‚ð‹L˜^
|
---|
1171 | false_agreement_average_utility_with_discount = ((false_agreement_average_utility_with_discount
|
---|
1172 | * false_agreement_num)
|
---|
1173 | + utilitySpace.getUtilityWithDiscount(lastBid,
|
---|
1174 | timeline.getTime()))
|
---|
1175 | / (false_agreement_num + 1);
|
---|
1176 | false_agreement_num++;
|
---|
1177 |
|
---|
1178 | // ‹‹C••ˆóƒtƒ‰ƒO‚ÌŠm’è
|
---|
1179 | if (utilitySpace.getDiscountFactor() < utilitySpace
|
---|
1180 | .getUtilityWithDiscount(lastBid,
|
---|
1181 | timeline.getTime())
|
---|
1182 | && utilitySpace.getDiscountFactor() < 1.0
|
---|
1183 | && utilitySpace.getUtility(
|
---|
1184 | false_best_agreement_bid) < 1.0) {
|
---|
1185 | tension_true_seal_flag = true;
|
---|
1186 | } else {
|
---|
1187 | tension_true_seal_flag = false;
|
---|
1188 | }
|
---|
1189 | }
|
---|
1190 | }
|
---|
1191 | } else {
|
---|
1192 | // Accept‚µ‚È‚©‚Á‚½�ê�‡
|
---|
1193 | partner_attack_num++;
|
---|
1194 |
|
---|
1195 | if (tension) {
|
---|
1196 | // ‹‹C‚ÌŽž
|
---|
1197 | true_failure_num++;
|
---|
1198 | } else {
|
---|
1199 | // Žã‹C‚ÌŽž
|
---|
1200 | // Šî–{“I‚ÉŒð�‚Í�¬—§‚·‚邪�C‘ŠŽè‚ª‚ ‚Ü‚è‚É‚à’x‚¢‚Æ‚«‚É‚ÍŒð�‚ª�¬—§‚µ‚È‚¢�ê�‡‚ª‚ ‚é‚̂ŃAƒWƒƒƒXƒg�D
|
---|
1201 | last_time = partner_last_bid_time;
|
---|
1202 | }
|
---|
1203 | }
|
---|
1204 |
|
---|
1205 | // ‘Å‚¿�؂莞��‚Ì�Ý’è
|
---|
1206 | if (last_time < 1.0 - time_scale || sessionNr == 0) {
|
---|
1207 | last_time = 1.0 - time_scale;
|
---|
1208 | }
|
---|
1209 |
|
---|
1210 | MySessionData mySessionData = new MySessionData(tension,
|
---|
1211 | isAgreement, lastBid, max_bid, true_best_agreement_bid,
|
---|
1212 | false_best_agreement_bid, true_failure_num,
|
---|
1213 | false_agreement_num,
|
---|
1214 | false_agreement_average_utility_with_discount,
|
---|
1215 | partner_attack_num, partner_guard_num, last_time,
|
---|
1216 | timeline.getTime(), tension_true_seal_flag,
|
---|
1217 | true_repeat_time, false_repeat_time,
|
---|
1218 | false_agreement_best_utility);
|
---|
1219 | this.saveSessionData(mySessionData);
|
---|
1220 |
|
---|
1221 | } catch (Exception e) {
|
---|
1222 | // TODO Auto-generated catch block
|
---|
1223 | e.printStackTrace();
|
---|
1224 | }
|
---|
1225 | }
|
---|
1226 |
|
---|
1227 | @Override
|
---|
1228 | public String getDescription() {
|
---|
1229 | return "ANAC2014 compatible with non-linear utility spaces";
|
---|
1230 | }
|
---|
1231 | }
|
---|
1232 |
|
---|
1233 | class MySessionData implements Serializable {
|
---|
1234 | Boolean tension; // Œð�Â’†‚ÌŽp�¨
|
---|
1235 | Boolean isAgreement; // �‡ˆÓ‚µ‚½‚©”Û‚©
|
---|
1236 | Bid lastBid; // �‡ˆÓBid
|
---|
1237 | Bid max_bid; // Ž©•ª‚É‚Æ‚Á‚Ä‚Ì�Å‘åŒø—p’lBid
|
---|
1238 | Bid true_best_agreement_bid; // ‹‹C‚Ì�ó‘Ԃ̉ߋŽ‚Ì�‡ˆÓBid‚Ì’†‚Å�Å‘åŒø—p’l‚Æ‚È‚éBid
|
---|
1239 | Bid false_best_agreement_bid; // Žã‹C‚Ì�ó‘Ԃ̉ߋŽ‚Ì�‡ˆÓBid‚Ì’†‚Å�Å‘åŒø—p’l‚Æ‚È‚éBid
|
---|
1240 | int true_failure_num; // ‹‹C�ó‘Ô‚Å‚ÌŒð�ÂŽ¸”s�”
|
---|
1241 | int false_agreement_num; // Žã‹C�ó‘Ô‚Å‚ÌŒð�Â�¬Œ÷�”
|
---|
1242 | double false_agreement_average_utility_with_discount; // Žã‹C�ó‘Ԃł̃fƒBƒXƒJƒEƒ“ƒg�ž‚Ý‚ÌŠl“¾Œø—p’l‚Ì•½‹Ï
|
---|
1243 | double partner_attack_num; // Œð�‘ŠŽè‚Ì‹‹C‚̉ñ�”
|
---|
1244 | double partner_guard_num; // Œð�‘ŠŽè‚ÌŽã‹C‚̉ñ�”
|
---|
1245 | double last_time; // �ÅŒã‚ÌŒð�Â‚ð‚·‚éŽž��
|
---|
1246 | double last_bid_time; // ‘O‰ñ‚ÌŒð�Â�I—¹Žž��
|
---|
1247 | boolean tension_true_seal_flag; // ‹‹C••ˆóƒtƒ‰ƒO
|
---|
1248 | double true_repeat_time; // ‹‹C‚Ì�ÄŒ»”»’è—p‚ÌŽžŠÔ
|
---|
1249 | double false_repeat_time; // Žã‹C‚Ì�ÄŒ»”»’è—p‚ÌŽžŠÔ
|
---|
1250 | double false_agreement_best_utility; // ƒfƒBƒXƒJƒEƒ“ƒg�ž‚Ý‚ÌŠl“¾Œø—p’l‚Ì�Å‘å’l
|
---|
1251 |
|
---|
1252 | public MySessionData(Boolean tension, Boolean isAgreement, Bid lastBid,
|
---|
1253 | Bid max_bid, Bid true_best_agreement_bid,
|
---|
1254 | Bid false_best_agreement_bid, int true_failure_num,
|
---|
1255 | int false_agreement_num,
|
---|
1256 | double false_agreement_average_utility_with_discount,
|
---|
1257 | double partner_attack_num, double partner_guard_num,
|
---|
1258 | double last_time, double last_bid_time,
|
---|
1259 | boolean tension_true_seal_flag, double true_repeat_time,
|
---|
1260 | double false_repeat_time, double false_agreement_best_utility) {
|
---|
1261 |
|
---|
1262 | this.tension = tension;
|
---|
1263 | this.isAgreement = isAgreement;
|
---|
1264 | this.lastBid = lastBid;
|
---|
1265 | this.max_bid = max_bid;
|
---|
1266 | this.true_best_agreement_bid = true_best_agreement_bid;
|
---|
1267 | this.false_best_agreement_bid = false_best_agreement_bid;
|
---|
1268 | this.true_failure_num = true_failure_num;
|
---|
1269 | this.false_agreement_num = false_agreement_num;
|
---|
1270 | this.false_agreement_average_utility_with_discount = false_agreement_average_utility_with_discount;
|
---|
1271 | this.partner_attack_num = partner_attack_num;
|
---|
1272 | this.partner_guard_num = partner_guard_num;
|
---|
1273 | this.last_time = last_time;
|
---|
1274 | this.last_bid_time = last_bid_time;
|
---|
1275 | this.tension_true_seal_flag = tension_true_seal_flag;
|
---|
1276 | this.true_repeat_time = true_repeat_time;
|
---|
1277 | this.false_repeat_time = false_repeat_time;
|
---|
1278 | this.false_agreement_best_utility = false_agreement_best_utility;
|
---|
1279 | }
|
---|
1280 | } |
---|