source: src/main/java/agents/bayesianopponentmodel/OpponentModel.java

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

Initial import : Genius 9.0.0

File size: 1.5 KB
RevLine 
[1]1package agents.bayesianopponentmodel;
2
3import java.util.ArrayList;
4
5import genius.core.Bid;
6import genius.core.BidIterator;
7import genius.core.Domain;
8
9public class OpponentModel {
10
11 private boolean isCrashed = false;
12
13 protected Domain fDomain;
14 public ArrayList<Bid> fBiddingHistory;
15
16 public Domain getDomain() { return fDomain; }
17 Double minUtility=null,maxUtility=null;
18 public double getExpectedUtility(Bid pBid) throws Exception {return -1;}
19 public double getNormalizedUtility(Bid pBid) throws Exception
20 {
21 double u=getExpectedUtility(pBid);
22 if (minUtility==null || maxUtility==null) findMinMaxUtility();
23 double value = (u-minUtility)/(maxUtility-minUtility);
24 if (Double.isNaN(value)) {
25 if (!isCrashed) {
26 isCrashed = true;
27 System.err.println("Bayesian scalable encountered NaN and therefore crashed");
28 }
29 return 0.0;
30 }
31
32 return (u-minUtility)/(maxUtility-minUtility);
33 }
34 public void updateBeliefs(Bid pBid) throws Exception { };
35 public double getExpectedWeight(int pIssueNumber) { return 0;}
36 public boolean haveSeenBefore(Bid pBid) {
37 for(Bid tmpBid : fBiddingHistory) {
38 if(pBid.equals(tmpBid)) return true;
39 }
40 return false;
41 }
42 protected void findMinMaxUtility() throws Exception
43 {
44 BidIterator biditer=new BidIterator(fDomain);
45 minUtility=1.; maxUtility=0.; double u;
46
47 while (biditer.hasNext())
48 {
49 Bid b=biditer.next();
50 u=getExpectedUtility(b);
51
52 if (minUtility>u) minUtility=u;
53 if (maxUtility<u) maxUtility=u;
54 }
55 }
56
57 public boolean isCrashed() {
58 return isCrashed;
59 }
60}
Note: See TracBrowser for help on using the repository browser.