source: src/main/java/agents/similarity/Similarity.java@ 126

Last change on this file since 126 was 126, checked in by Aron Hammond, 6 years ago

Added function to calculate opposition to MultiLateralAnalysis.java

Moved code to add RLBOA listeners to RLBOAUtils is misc package

Added input for strategyParameters to SessionPanel (gui)

!! close SessionInfo after tournament; this caused /tmp/ to fill up with GeniusData files

Our own package:

  • Added opponents and strategies that are mentioned in the report
  • Change class hierarchy, agents can now extend from RLBOAagentBilateral to inherit RL functionality.
  • States extend from AbstractState
File size: 1.6 KB
Line 
1package agents.similarity;
2
3import java.util.ArrayList;
4
5import genius.core.Bid;
6import genius.core.Domain;
7import genius.core.xml.SimpleElement;
8
9public class Similarity {
10 private Domain fDomain;
11 private double fWeights[];
12 private ArrayList<SimilarityFunction> fSimilarityFunctions;
13
14 public Similarity(Domain pDomain) {
15 fDomain = pDomain;
16 fSimilarityFunctions = new ArrayList<SimilarityFunction>();
17 }
18
19 public final double getSimilarity(Bid pMyBid, Bid pOpponentBid) {
20 double lSimilarity = 0;
21 for (int i = 0; i < fSimilarityFunctions.size(); i++) {
22 lSimilarity += fWeights[i]
23 * fSimilarityFunctions.get(i).getSimilarityValue(pMyBid,
24 pOpponentBid);
25 }
26
27 return lSimilarity;
28 }
29
30 public void loadFromXML(SimpleElement pRoot) {
31 SimpleElement lXMLUtilitySpace = (SimpleElement) (pRoot
32 .getChildByTagName("utility_space")[0]);
33 SimpleElement lXMLObjective = (SimpleElement) (lXMLUtilitySpace
34 .getChildByTagName("objective")[0]);
35 Object[] lXMLIssue = lXMLObjective.getChildByTagName("issue");
36 fWeights = new double[lXMLIssue.length];
37 for (int j = 0; j < lXMLIssue.length; j++) {
38 Object[] lXMLSimFn = ((SimpleElement) (lXMLIssue[j]))
39 .getChildByTagName("similarity_function");
40 if (lXMLSimFn == null || lXMLSimFn.length == 0) {
41 continue;
42 }
43 SimilarityFunction lSimFn = new SimilarityFunction(fDomain);
44 // load weights
45 fWeights[j] = Double.valueOf(((SimpleElement) (lXMLSimFn[0]))
46 .getAttribute("weight"));
47 lSimFn.loadFromXML((SimpleElement) (lXMLSimFn[0]), Integer
48 .valueOf(((SimpleElement) (lXMLIssue[j]))
49 .getAttribute("index")));
50 fSimilarityFunctions.add(lSimFn);
51 }// for
52 }
53}
Note: See TracBrowser for help on using the repository browser.