source: src/main/java/agents/anac/y2014/BraveCat/OpponentModelStrategies/BestBid.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: 2.1 KB
Line 
1 package agents.anac.y2014.BraveCat.OpponentModelStrategies;
2
3 import agents.anac.y2014.BraveCat.OpponentModels.OpponentModel;
4 import java.util.HashMap;
5 import java.util.List;
6 import java.util.Random;
7 import agents.anac.y2014.BraveCat.necessaryClasses.NegotiationSession;
8import genius.core.bidding.BidDetails;
9
10 public class BestBid extends OMStrategy
11 {
12 double updateThreshold = 1.1D;
13
14 public BestBid()
15 {
16 }
17
18 public BestBid(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 double bestUtil = -1.0D;
45 BidDetails bestBid = (BidDetails)allBids.get(0);
46
47 boolean allWereZero = true;
48
49 for (BidDetails bid : allBids)
50 {
51 try
52 {
53 double evaluation = this.model.getBidEvaluation(bid);
54 if (evaluation > 0.0001D)
55 {
56 allWereZero = false;
57 }
58 if (evaluation > bestUtil)
59 {
60 bestBid = bid;
61 bestUtil = evaluation;
62 }
63 } catch (Exception ex)
64 {
65 System.out.println("Exception occured while executing getBidEvaluation in Best Bid OMStrategy!");
66 }
67 }
68
69 if (allWereZero) {
70 Random r = new Random();
71 return (BidDetails)allBids.get(r.nextInt(allBids.size()));
72 }
73 return bestBid;
74 }
75
76 @Override
77 public boolean canUpdateOM()
78 {
79 return this.negotiationSession.getTime() < this.updateThreshold;
80 }
81 }
Note: See TracBrowser for help on using the repository browser.