source: src/main/java/agents/anac/y2014/BraveCat/OpponentModelStrategies/ConcederBid.java

Last change on this file 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: 3.6 KB
Line 
1 package agents.anac.y2014.BraveCat.OpponentModelStrategies;
2
3 import agents.anac.y2014.BraveCat.OpponentModels.OpponentModel;
4 import java.util.ArrayList;
5 import java.util.HashMap;
6 import java.util.List;
7 import agents.anac.y2014.BraveCat.necessaryClasses.NegotiationSession;
8import genius.core.bidding.BidDetails;
9
10 public class ConcederBid extends OMStrategy
11 {
12 double updateThreshold = 1.1D;
13
14 public ConcederBid()
15 {
16 }
17
18 public ConcederBid(NegotiationSession negotiationSession, OpponentModel model)
19 {
20 try
21 {
22 super.init(negotiationSession, model);
23 } catch (Exception e) {
24 }
25 }
26
27 @Override
28 public void init(NegotiationSession negotiationSession, OpponentModel model, HashMap<String, Double> parameters)
29 throws Exception
30 {
31 super.init(negotiationSession, model);
32 if (parameters.get("t") != null)
33 this.updateThreshold = ((Double)parameters.get("t")).doubleValue();
34 else
35 System.out.println("OMStrategy assumed t = 1.1");
36 }
37
38 @Override
39 public BidDetails getBid(List<BidDetails> allBids)
40 {
41 if (allBids.size() == 1) {
42 return (BidDetails)allBids.get(0);
43 }
44 //----------------------------------------------------------------
45 List<BidDetails> BidsPredictedAsConceder = new ArrayList();
46 List<BidDetails> BidsPredictedAsUnfortunate = new ArrayList();
47 List<Double> BidsPredictedAsConcederUtility = new ArrayList();
48 List<Double> BidsPredictedAsUnfortunateUtility = new ArrayList();
49 for (BidDetails bid : allBids)
50 {
51 try {
52 Double evaluation = this.model.getBidEvaluation(bid);
53 if (evaluation < 0)
54 {
55 BidsPredictedAsUnfortunate.add(bid);
56 BidsPredictedAsUnfortunateUtility.add(evaluation);
57 }
58 else if(evaluation >= 0)
59 {
60 BidsPredictedAsConceder.add(bid);
61 BidsPredictedAsConcederUtility.add(evaluation);
62 }
63 } catch (Exception ex) {
64 }
65 }
66 //System.out.println("Unfortunate: " + BidsPredictedAsUnfortunate.size() + " Conceder: " + BidsPredictedAsConceder.size());
67 //----------------------------------------------------------------
68 if (BidsPredictedAsConceder.isEmpty()) {
69
70 /*double max = Double.NEGATIVE_INFINITY;
71 int maxindex = 0;
72 for(int i = 0; i < BidsPredictedAsUnfortunateUtility.size(); i++)
73 if(max < BidsPredictedAsUnfortunateUtility.get(i))
74 {
75 max = BidsPredictedAsUnfortunateUtility.get(i);
76 maxindex = i;
77 }
78 return (BidDetails)BidsPredictedAsUnfortunate.get(maxindex);*/
79 //Random r = new Random();
80 //return (BidDetails)BidsPredictedAsUnfortunate.get(r.nextInt(BidsPredictedAsUnfortunate.size()));
81 return this.negotiationSession.getOwnBidHistory().getLastBidDetails();
82 }
83 else
84 {
85 double max = Double.NEGATIVE_INFINITY;
86 int maxindex = 0;
87 for(int i = 0; i < BidsPredictedAsConcederUtility.size(); i++)
88 if(max < BidsPredictedAsConcederUtility.get(i))
89 {
90 max = BidsPredictedAsConcederUtility.get(i);
91 maxindex = i;
92 }
93 return (BidDetails)BidsPredictedAsConceder.get(maxindex);
94 //Random r = new Random();
95 //return (BidDetails)BidsPredictedAsConceder.get(r.nextInt(BidsPredictedAsConceder.size()));
96 }
97 }
98
99 @Override
100 public boolean canUpdateOM()
101 {
102 return this.negotiationSession.getTime() < this.updateThreshold;
103 }
104 }
Note: See TracBrowser for help on using the repository browser.