source: src/main/java/agents/anac/y2015/xianfa/XianFaAgent.java@ 127

Last change on this file since 127 was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 22.9 KB
Line 
1package agents.anac.y2015.xianfa;
2
3import java.util.ArrayList;
4import java.util.Collections;
5import java.util.HashMap;
6import java.util.List;
7import java.util.Random;
8
9import genius.core.AgentID;
10import genius.core.Bid;
11import genius.core.actions.Accept;
12import genius.core.actions.Action;
13import genius.core.actions.EndNegotiation;
14import genius.core.actions.Offer;
15import genius.core.issue.ISSUETYPE;
16import genius.core.issue.Issue;
17import genius.core.issue.IssueDiscrete;
18import genius.core.issue.IssueInteger;
19import genius.core.issue.Value;
20import genius.core.issue.ValueInteger;
21import genius.core.parties.AbstractNegotiationParty;
22import genius.core.parties.NegotiationInfo;
23import genius.core.utility.AdditiveUtilitySpace;
24import genius.core.utility.EvaluatorDiscrete;
25
26/**
27 * This is your negotiation party.
28 */
29public class XianFaAgent extends AbstractNegotiationParty {
30
31 /**
32 * Please keep this constructor. This is called by genius.
33 *
34 * @param utilitySpace
35 * Your utility space.
36 * @param deadlines
37 * The deadlines set for this negotiation.
38 * @param timeline
39 * Value counting from 0 (start) to 1 (end).
40 * @param randomSeed
41 * If you use any randomization, use this seed for it.
42 */
43
44 Bid partnerBid = null;
45 Bid myBid = null;
46 int rounds = 0;
47 double cRateA = 1;
48 double cRateB = 1;
49 double sRateA = 0;
50 double sRateB = 0;
51 String opponentA = "";
52 String opponentB = "";
53 double threshold = 0.99;
54 double discount;
55 int supposedNumber = 1;
56 int totalA = 1;
57 int totalB = 1;
58 boolean firstRound = true;
59 boolean startTiming = false;
60 int timeRds = 0;
61 double prevTime = 0;
62 double avgRdTime = 0;
63 double resValue;
64 Bid opponentABest = null;
65 int act = 0;
66 int attitude = 0;
67
68 /**
69 * fields for stats tracking
70 */
71 boolean debug = false;
72 Statistician stat;
73 int stat_bidsInList = -1;
74 int stat_bidsNotInList = 0;
75 int stat_goodBids = 0;
76 int stat_BAccepts = 0;
77 int stat_offerHistBest = 0;
78 double stat_avgTime = 0;
79 double stat_thatTime = 0;
80 boolean myTurnPrev = false;
81 ArrayList<Bid> myOfferedBids = new ArrayList<Bid>();
82 int myUniqueOffers = 1;
83 double aU = 1;
84 double oU = 1;
85
86 /**
87 *
88 * @author Kevin
89 *
90 */
91
92 @Override
93 public void init(NegotiationInfo info) {
94 super.init(info);
95 // if (utilitySpace.getDomain().getNumberOfPossibleBids() > 200000)
96 // attitude = 2;
97 // else attitude = 0;
98 try {
99 initTree();
100 calculate();
101 initBS();
102 initOpp();
103 if (debug)
104 stat = new Statistician(this);
105 } catch (Exception e) {
106 e.printStackTrace();
107 }
108 }
109
110 /**
111 * Each round this method gets called and ask you to accept or offer. The
112 * first party in the first round is a bit different, it can only propose an
113 * offer.
114 *
115 * @param validActions
116 * Either a list containing both accept and offer or only offer.
117 * @return The chosen action.
118 */
119 @Override
120 public Action chooseAction(List<Class<? extends Action>> validActions) {
121 updateSelf();
122 if (debug) {
123 if (rounds % 2 == 0)
124 stat.log();
125 }
126 Action action = null;
127 if (timeline.getTime() > 0.9) {
128 if (startTiming == false) {
129 startTiming = true;
130 prevTime = timeline.getTime();
131 timeRds++;
132 } else {
133 avgRdTime = (avgRdTime * (timeRds - 1))
134 + (timeline.getTime() - prevTime);
135 avgRdTime = avgRdTime / timeRds;
136 prevTime = timeline.getTime();
137 timeRds++;
138 }
139 }
140 try {
141 if (firstRound)
142 action = chooseBid(null);
143
144 else {
145 if (acceptable()) {
146 if (debug)
147 stat.log();
148 if (aU > utilitySpace.getUtility(partnerBid))
149 aU = utilitySpace.getUtility(partnerBid);
150 act = 1;
151 action = new Accept(getPartyId(), partnerBid);
152 } else if (timeline.getTime() > (1 - (avgRdTime * 1.2))) {
153 if (opponentABest != null) {
154 if (utilitySpace.getUtility(opponentABest) > resValue) {
155 if (utilitySpace.getUtility(opponentABest) > (1.03
156 * utilitySpace.getUtility(partnerBid))) {
157 stat_offerHistBest++;
158 if (oU > utilitySpace.getUtility(opponentABest))
159 oU = utilitySpace.getUtility(opponentABest);
160 action = new Offer(getPartyId(), opponentABest);
161 } else {
162 act = 1;
163 action = new Accept(getPartyId(), partnerBid);
164 }
165 } else {
166 action = chooseBid(partnerBid);
167 }
168 } else {
169 action = chooseBid(partnerBid);
170 }
171 } else {
172 action = chooseBid(partnerBid);
173 }
174 }
175 } catch (Exception e) {
176 e.printStackTrace();
177 System.out.println("catch chooseaction");
178 System.out.println("Exception in ChooseAction:" + e.getMessage());
179 act = 1;
180 action = new Accept(getPartyId(), partnerBid); // best guess if
181 // things go wrong.
182 }
183 if (timeline.getTime() == 1) {
184 act = 3;
185 action = new EndNegotiation(getPartyId());
186 }
187 if (act == 1) {
188 // System.out.println("Current action: Accept");
189 } else if (act == 2) {
190 partnerBid = new Bid(myBid);
191 // System.out.println("Current action: Offer");
192 } else if (act == 3) {
193 // System.out.println("Current action: End Negotiation");
194 } else {
195 // System.out.println("Current action: Rubbish");
196 }
197 return action;
198 }
199
200 /**
201 *
202 * @param partnerBid
203 * the bid the partner placed
204 * @return next action
205 */
206 private Action chooseBid(Bid partnerBid) {
207 Bid nextBid = null;
208 try {
209 nextBid = new Bid(getBid());
210 } catch (Exception e) {
211 System.out.println("Problem with received bid:" + e.getMessage()
212 + ". cancelling bidding");
213 }
214 if (nextBid == null) {
215 act = 1;
216 return (new Accept(getPartyId(), partnerBid));
217 }
218 try {
219 if (partnerBid != null) {
220 if (utilitySpace.getUtility(partnerBid) >= utilitySpace
221 .getUtility(nextBid)) {
222 act = 1;
223 return (new Accept(getPartyId(), partnerBid));
224 }
225 }
226 } catch (Exception e) {
227 e.printStackTrace();
228 act = 1;
229 // best guess if things go wrong.
230 return (new Accept(getPartyId(), partnerBid));
231 }
232 try {
233 if (oU > utilitySpace.getUtility(nextBid))
234 oU = utilitySpace.getUtility(nextBid);
235 } catch (Exception e) {
236 e.printStackTrace();
237 }
238
239 act = 2;
240 myBid = new Bid(nextBid);
241 return (new Offer(getPartyId(), nextBid));
242 }
243
244 private Bid getBid() throws Exception {
245 Bid bid = null;
246 if (attitude == 0) {
247 bid = getOb();
248 return bid;
249 } else if (attitude == 1) {
250 bid = offerBid();
251 return bid;
252 }
253
254 return bid;
255 }
256
257 private void updateSelf() {
258 myTurnPrev = true;
259 rounds++;
260 if (!opponentA.equals("") && !opponentB.equals("")) {
261 // conceding Rate : 1 - Conceder; 0 - Boulware
262 cRateA = 1 - (Math.min(0.95,
263 ((double) bidSet.size() / totalA) * 1000));
264 cRateB = 1 - (Math.min(0.95,
265 ((double) bidSetB.size() / totalB) * 1000));
266 // similarity Rate : 1 - Weak opposition; 0 - Strong opposition
267 sRateA = findHighestSimilarity(opponentA);
268 sRateB = findHighestSimilarity(opponentB);
269 if (rounds % 200 == 0) {
270 double t = timeline.getTime();
271 threshold = threshold - ((Math.max(cRateA, cRateB) * 0.00515)
272 * ((1 - t) * (1 - t) * (1 / discount)));
273 threshold = threshold
274 - ((Math.max(1 - sRateA, 1 - sRateB) * 0.0116)
275 * ((1 - t) * (1 - t) * (1 / discount)));
276 }
277 // printConsole();
278 }
279 if (attitude == 2)
280 return;
281 if (attitude == 1)
282 return;
283 if (rounds > 2000 || timeline.getTime() > 0.1) {
284 attitude = 1;
285 return;
286 }
287 }
288
289 public void printConsole() {
290 if (rounds % 2 == 0) {
291 System.out.println("This is round: " + rounds);
292 System.out.println("Time is: " + timeline.getTime());
293 System.out.println("Short List size: " + shortList.size());
294 for (int i = 0; i < shortList.size(); i++) {
295 try {
296 System.out
297 .println(utilitySpace.getUtility(shortList.get(i)));
298 } catch (Exception e) {
299 // TODO Auto-generated catch block
300 e.printStackTrace();
301 }
302 }
303 try {
304 System.out.println("utility of partnerBid: "
305 + utilitySpace.getUtility(partnerBid));
306 } catch (Exception e) {
307 e.printStackTrace();
308 }
309 System.out.println("Reservation value is: " + resValue);
310 System.out.println("Discount factor is: " + discount);
311 System.out.println("c rate A: " + cRateA);
312 System.out.println("c rate B: " + cRateB);
313 System.out.println("s rate A: " + sRateA);
314 System.out.println("s rate B: " + sRateB);
315 System.out.println("threshold: " + threshold);
316 System.out.println("My lowest accepted utility: " + aU);
317 System.out.println("My lowest offered utility: " + oU);
318 System.out.println("");
319 }
320 }
321
322 /**
323 * All offers proposed by the other parties will be received as a message.
324 * You can use this information to your advantage, for example to predict
325 * their utility.
326 *
327 * @param sender
328 * The party that did the action.
329 * @param action
330 * The action that party did.
331 */
332 @Override
333 public void receiveMessage(AgentID sender, Action action) {
334 super.receiveMessage(sender, action);
335 // Here you can listen to other parties' messages
336
337 // Assign party ids to the two opponents
338 if (sender != null && firstRound) {
339 if (!(opponentA.equals("") || opponentB.equals("")))
340 firstRound = false;
341 if (!myTurnPrev) {
342 if (!opponentA.equals("")) {
343 opponentB = sender.toString();
344 }
345 } else
346 opponentA = sender.toString();
347 }
348
349 if (action instanceof Offer) {
350 partnerBid = new Bid(((Offer) action).getBid());
351 try {
352 updateOpp(partnerBid, sender.toString(), 0);
353 } catch (Exception e) {
354 e.printStackTrace();
355 }
356 } else if (action instanceof Accept) {
357 if (partnerBid != null) {
358 try {
359 updateOpp(partnerBid, sender.toString(), 1);
360 } catch (Exception e) {
361 e.printStackTrace();
362 }
363 }
364 if (myTurnPrev) {
365 stat_goodBids++;
366 } else {
367 try {
368 if (opponentABest == null)
369 opponentABest = new Bid(partnerBid);
370 else if (utilitySpace
371 .getUtility(opponentABest) < getUtilitySpace()
372 .getUtility(partnerBid)) {
373 opponentABest = new Bid(partnerBid);
374 }
375 } catch (Exception e) {
376 e.printStackTrace();
377 }
378 stat_BAccepts++;
379 }
380 }
381 if (myTurnPrev)
382 myTurnPrev = false;
383 }
384
385 double mean = 0;
386 double median = 0;
387 double searchThreshold = 0.82;
388
389 public void calculate() throws Exception {
390 discount = utilitySpace.getDiscountFactor();
391 double add = 0.1;
392 double r = utilitySpace.getReservationValueUndiscounted();
393 if (r < 0.65)
394 add = 0.15;
395 resValue = Math.max(r, 0.5) + ((r / 0.9) * add);
396 if (resValue > 0.99) {
397 resValue = 0.99;
398 }
399 int size = allBidsList.size();
400 quickSort(allBidsList, 0, size - 1);
401 System.out.println("All bids List size is " + size);
402 }
403
404 public double findHighestSimilarity(String opponent) {
405 Bid bid = generateRandomBid();
406 if (opponent.equals(opponentA)) {
407 for (AIssue iss : issuesA) {
408 Value val = iss.getDesiredVal();
409 bid = bid.putValue(iss.getIssNr(), val);
410 }
411 } else if (opponent.equals(opponentB)) {
412 for (AIssue iss : issuesB) {
413 Value val = iss.getDesiredVal();
414 bid = bid.putValue(iss.getIssNr(), val);
415 }
416 }
417 try {
418 return utilitySpace.getUtility(bid);
419 } catch (Exception e) {
420 e.printStackTrace();
421 }
422 // System.out.println("error with find Highest similarity");
423 return 0;
424 }
425
426 public void quickSort(ArrayList<Bid> list, int n, int m) throws Exception {
427 int pivot_pos;
428 if (n >= m) {
429 return;
430 }
431 pivot_pos = partition(list, n, m);
432 quickSort(list, n, pivot_pos - 1);
433 quickSort(list, pivot_pos + 1, m);
434 }
435
436 public int partition(ArrayList<Bid> list, int low, int high)
437 throws Exception {
438 int last_small;
439 double pivot;
440 int mid = (low + high) / 2;
441 Collections.swap(list, low, mid);
442 pivot = utilitySpace.getUtility(list.get(low));
443 last_small = low;
444 for (int i = low + 1; i <= high; i++) {
445 if (utilitySpace.getUtility(list.get(i)) < pivot) {
446 Collections.swap(list, ++last_small, i);
447 }
448 }
449 Collections.swap(list, low, last_small);
450 return last_small;
451 }
452
453 /**
454 * bidding strategy
455 */
456
457 Tree tree;
458 private int maxDepth;
459 private EvaluatorDiscrete ed;
460 private IssueDiscrete id;
461 private IssueInteger ii;
462 ArrayList<Bid> allBidsList = new ArrayList<Bid>();
463 ArrayList<Bid> shortList = new ArrayList<Bid>();
464 Bid startingBid;
465
466 public void initTree() throws Exception {
467 this.tree = new Tree();
468 this.maxDepth = utilitySpace.getDomain().getIssues().size();
469 tree.addNewDepth();
470
471 for (int curDepth = 0; curDepth < maxDepth; curDepth++) { // for this
472 // depth
473 tree.addNewDepth(); // initialize new level
474 if (utilitySpace.getDomain().getIssues().get(curDepth)
475 .getType() == ISSUETYPE.DISCRETE) {
476 id = (IssueDiscrete) utilitySpace.getDomain().getIssues()
477 .get(curDepth);
478 ed = (EvaluatorDiscrete) ((AdditiveUtilitySpace) utilitySpace)
479 .getEvaluator(curDepth + 1);
480 for (int curMember = 0; curMember < tree
481 .getSizeOfLevel(curDepth); curMember++) { // for
482 // all
483 // nodes
484 // in
485 // this
486 // depth
487 for (int i = 0; i < id.getNumberOfValues(); i++) { // for
488 // all
489 // evaluations
490 // for
491 // next
492 // issue
493 // below
494 // this
495 // depth
496 Node node = new Node(id.getNumber(), id.getValue(i),
497 curDepth, ed.getEvaluation(id.getValue(i)));
498 tree.getMemberInLevel(curDepth, curMember).add(node);
499 tree.addNodeInDepth(node, curDepth + 1);
500 }
501 }
502 } else if (utilitySpace.getDomain().getIssues().get(curDepth)
503 .getType() == ISSUETYPE.INTEGER) {
504 ii = (IssueInteger) utilitySpace.getDomain().getIssues()
505 .get(curDepth);
506 for (int curMember = 0; curMember < tree
507 .getSizeOfLevel(curDepth); curMember++) { // for
508 // all
509 // nodes
510 // in
511 // this
512 // depth
513 Node node = new Node(ii.getNumber(),
514 new ValueInteger(ii.getUpperBound()), curDepth, 1);
515 tree.getMemberInLevel(curDepth, curMember).add(node);
516 tree.addNodeInDepth(node, curDepth + 1);
517 }
518 }
519 }
520 for (int i = 0; i < tree.getSizeOfLevel(tree.getLevels() - 1); i++) {
521 Bid bid = createBid(getBid(i));
522 allBidsList.add(bid);
523 }
524 }
525
526 public void initBS() throws Exception {
527 createLists();
528 for (int i = 0; i < tree.getLevels(); i++) {
529 for (int j = 0; j < tree.getSizeOfLevel(i); j++) {
530 Node node = tree.getMemberInLevel(i, j);
531 node = null;
532 }
533 }
534 tree = null;
535 }
536
537 private void createLists() throws Exception {
538 for (int i = allBidsList.size() - 1; i > -1; i--) {
539 if (utilitySpace.getUtility(allBidsList.get(i)) > resValue) {
540 shortList.add(new Bid(allBidsList.get(i)));
541 } else
542 break;
543 }
544 startingBid = new Bid(shortList.get(0));
545 myOfferedBids.add(startingBid);
546 System.out.println("utility of starting bid is: "
547 + utilitySpace.getUtility(startingBid));
548 // quickSort(shortList, 0, shortList.size()-1);
549 }
550
551 public Bid getOb() {
552 return startingBid;
553 }
554
555 public Bid offerBid() throws Exception {
556 if (rounds > (3000 * supposedNumber)
557 || timeline.getTime() > (0.124 * supposedNumber)) {
558 supposedNumber++;
559 }
560 if (myOfferedBids.size() < supposedNumber) {
561 String opponent;
562 String other;
563 int pos = 0;
564 double otherMax = 0;
565 if (cRateA > cRateB) {
566 opponent = opponentA;
567 other = opponentB;
568 } else {
569 opponent = opponentB;
570 other = opponentA;
571 }
572 for (int i = 0; i < shortList.size(); i++) {
573 if (utilitySpace.getUtility(shortList.get(i)) > threshold
574 && !myOfferedBids.contains(shortList.get(i))) {
575 if (favor(shortList.get(i), opponent) > 0.8) {
576 if (favor(shortList.get(i), other) > 0.8) {
577 myOfferedBids.add(shortList.get(i));
578 return shortList.get(i);
579 } else if (favor(shortList.get(i), other) > otherMax) {
580 otherMax = favor(shortList.get(i), other);
581 pos = i;
582 }
583 }
584 }
585 }
586 return shortList.get(pos);
587 }
588 return myOfferedBids.get(new Random().nextInt(myOfferedBids.size()));
589 }
590
591 public Bid createBid(Bid bid) {
592 Bid newBid = new Bid(bid);
593 return newBid;
594 }
595
596 public Bid getBid(int position) throws Exception {
597 HashMap<Integer, Value> values = new HashMap<Integer, Value>();
598 maxDepth = tree.getLevels() - 1;
599 values.put(tree.getMemberInLevel(maxDepth, position).getNumber(),
600 tree.getMemberInLevel(maxDepth, position).getValue());
601 Node node = tree.getMemberInLevel(maxDepth, position).getParent();
602 while (maxDepth != 0) {
603 values.put(node.getNumber(), node.getValue());
604 node = node.getParent();
605 maxDepth = maxDepth - 1;
606 }
607 Bid bid = new Bid(utilitySpace.getDomain(), values);
608 return bid;
609 }
610
611 public ArrayList<Bid> insertionSort(ArrayList<Bid> list, int n)
612 throws Exception {
613 for (int i = 1; i < n; i++) {
614 for (int j = i; (j > 0); j--) {
615 // System.out.println("j is: " + j);
616 if (utilitySpace.getUtility(list.get(j)) > utilitySpace
617 .getUtility(list.get(j - 1))) {
618 Collections.swap(list, j, j - 1);
619 } else
620 break;
621 }
622 }
623 return list;
624 }
625
626 public double favor(Bid bid, String opp) throws Exception {
627 double score = 0;
628 if (opp.equals(opponentA)) {
629 for (Issue iss : bid.getIssues()) {
630 for (int i = 0; i < issuesA.size(); i++) {
631 if (issuesA.get(i).getIssNr() == iss.getNumber()) {
632 double s = issuesA.get(i)
633 .getVal(bid.getValue(iss.getNumber()));
634 if (s > 1)
635 s = 1;
636 score = score + s;
637 break;
638 }
639 }
640 }
641 score = score / (utilitySpace.getDomain().getIssues().size());
642 } else if (opp.equals(opponentB)) {
643 for (Issue iss : bid.getIssues()) {
644 for (int i = 0; i < issuesB.size(); i++) {
645 if (issuesB.get(i).getIssNr() == iss.getNumber()) {
646 double s = issuesB.get(i)
647 .getVal(bid.getValue(iss.getNumber()));
648 if (s > 1)
649 s = 1;
650 score = score + s;
651 break;
652 }
653 }
654 }
655 score = score / (utilitySpace.getDomain().getIssues().size());
656 }
657 return score;
658 }
659
660 /**
661 * opponent model
662 */
663
664 ArrayList<Bid> bidSet = new ArrayList<Bid>();
665 ArrayList<AIssue> issuesA = new ArrayList<AIssue>();
666 ArrayList<Bid> bidSetB = new ArrayList<Bid>();
667 ArrayList<AIssue> issuesB = new ArrayList<AIssue>();
668 int totalBids = 0;
669
670 public void initOpp() {
671 for (int i = 0; i < utilitySpace.getDomain().getIssues().size(); i++) {
672 AIssue iss = new AIssue(
673 utilitySpace.getDomain().getIssues().get(i).getNumber());
674 if (utilitySpace.getDomain().getIssues().get(i)
675 .getType() == ISSUETYPE.DISCRETE) {
676 IssueDiscrete id = (IssueDiscrete) utilitySpace.getDomain()
677 .getIssues().get(i);
678 for (int j = 0; j < id.getValues().size(); j++) {
679 iss.getValues().put(id.getValue(j), 0.0);
680 }
681 } else if (utilitySpace.getDomain().getIssues().get(i)
682 .getType() == ISSUETYPE.INTEGER) {
683 IssueInteger ii = (IssueInteger) utilitySpace.getDomain()
684 .getIssues().get(i);
685 iss.getValues().put(new ValueInteger(ii.getUpperBound()), 0.0);
686 }
687 issuesA.add(iss);
688 }
689 for (int i = 0; i < utilitySpace.getDomain().getIssues().size(); i++) {
690 AIssue iss = new AIssue(
691 utilitySpace.getDomain().getIssues().get(i).getNumber());
692 if (utilitySpace.getDomain().getIssues().get(i)
693 .getType() == ISSUETYPE.DISCRETE) {
694 IssueDiscrete id = (IssueDiscrete) utilitySpace.getDomain()
695 .getIssues().get(i);
696 for (int j = 0; j < id.getValues().size(); j++) {
697 iss.getValues().put(id.getValue(j), 0.0);
698 }
699 } else if (utilitySpace.getDomain().getIssues().get(i)
700 .getType() == ISSUETYPE.INTEGER) {
701 IssueInteger ii = (IssueInteger) utilitySpace.getDomain()
702 .getIssues().get(i);
703 iss.getValues().put(new ValueInteger(ii.getUpperBound()), 0.0);
704 }
705 issuesB.add(iss);
706 }
707 }
708
709 public void updateOpp(Bid bid, String sender, int act) throws Exception {
710 boolean newVariation = true;
711 if (sender.equals(opponentA)) {
712 if (act == 0) {
713 totalA++;
714 for (int i = 0; i < bidSet.size(); i++) {
715 if (bidSet.get(i).equals(bid)) {
716 newVariation = false;
717 break;
718 }
719 }
720 if (newVariation == true) {
721 bidSet.add(bid);
722 }
723 for (int i = 0; i < bid.getIssues().size(); i++) {
724 for (int j = 0; j < issuesA.size(); j++) {
725 if (bid.getIssues().get(i).getNumber() == issuesA.get(j)
726 .getIssNr()) {
727 if (bid.getIssues().get(i)
728 .getType() == ISSUETYPE.DISCRETE) {
729 issuesA.get(j)
730 .setVal(bid.getValue(bid.getIssues()
731 .get(i).getNumber()), totalA,
732 0);
733 } else {
734 // ignore
735 }
736 }
737 }
738 }
739 } else {
740 for (int i = 0; i < bid.getIssues().size(); i++) {
741 for (int j = 0; j < issuesA.size(); j++) {
742 if (bid.getIssues().get(i).getNumber() == issuesA.get(j)
743 .getIssNr()) {
744 if (bid.getIssues().get(i)
745 .getType() == ISSUETYPE.DISCRETE) {
746 issuesA.get(j)
747 .setVal(bid.getValue(bid.getIssues()
748 .get(i).getNumber()), totalA,
749 1);
750 } else {
751 // ignore
752 }
753 }
754 }
755 }
756 }
757
758 } else if (sender.equals(opponentB)) {
759 if (act == 0) {
760 totalB++;
761 for (int i = 0; i < bidSetB.size(); i++) {
762 if (bidSetB.get(i).equals(bid)) {
763 newVariation = false;
764 break;
765 }
766 }
767 if (newVariation == true) {
768 bidSetB.add(bid);
769 }
770 for (int i = 0; i < bid.getIssues().size(); i++) {
771 for (int j = 0; j < issuesB.size(); j++) {
772 if (bid.getIssues().get(i).getNumber() == issuesB.get(j)
773 .getIssNr()) {
774 if (bid.getIssues().get(i)
775 .getType() == ISSUETYPE.DISCRETE) {
776 issuesB.get(j)
777 .setVal(bid.getValue(bid.getIssues()
778 .get(i).getNumber()), totalB,
779 0);
780 } else {
781 // ignore
782 }
783 }
784 }
785 }
786 } else {
787 for (int i = 0; i < bid.getIssues().size(); i++) {
788 for (int j = 0; j < issuesB.size(); j++) {
789 if (bid.getIssues().get(i).getNumber() == issuesB.get(j)
790 .getIssNr()) {
791 if (bid.getIssues().get(i)
792 .getType() == ISSUETYPE.DISCRETE) {
793 issuesB.get(j)
794 .setVal(bid.getValue(bid.getIssues()
795 .get(i).getNumber()), totalB,
796 1);
797 } else {
798 // ignore
799 }
800 }
801 }
802 }
803 }
804 }
805 }
806
807 /**
808 * acceptance criteria
809 */
810
811 public boolean acceptable() throws Exception {
812 double myUtility = utilitySpace.getUtility(partnerBid);
813 if ((myUtility > threshold) && (myUtility > resValue)) {
814 return true;
815 } else
816 return false;
817 }
818
819 @Override
820 public String getDescription() {
821 return "ANAC2015";
822 }
823
824}
Note: See TracBrowser for help on using the repository browser.