source: src/test/java/boaexample/BoaPartyExample.java@ 182

Last change on this file since 182 was 181, checked in by Tim Baarslag, 6 years ago

Extended UncertaintyAgentExample

File size: 3.1 KB
Line 
1package boaexample;
2
3import java.util.List;
4
5import java.util.Collections;
6import java.util.HashMap;
7import java.util.Map;
8
9import negotiator.boaframework.opponentmodel.HardHeadedFrequencyModel;
10
11import genius.core.boaframework.AcceptanceStrategy;
12import genius.core.boaframework.BoaParty;
13import genius.core.boaframework.OMStrategy;
14import genius.core.boaframework.OfferingStrategy;
15import genius.core.boaframework.OpponentModel;
16import genius.core.issue.IssueDiscrete;
17import genius.core.issue.ValueDiscrete;
18import genius.core.parties.NegotiationInfo;
19import genius.core.uncertainty.AdditiveUtilitySpaceFactory;
20import genius.core.utility.AbstractUtilitySpace;
21
22/**
23 * This example shows how BOA components can be made into an independent
24 * negotiation party.
25 *
26 * Note that this is equivalent to adding a BOA party via the GUI by selecting
27 * the components and parameters. However, this method gives more control over
28 * the implementation, as the agent designer can choose to override behavior
29 * (such as handling preference uncertainty).
30 */
31@SuppressWarnings("serial")
32public class BoaPartyExample extends BoaParty
33{
34 @Override
35 public void init(NegotiationInfo info)
36 {
37 // The choice for each component is made here
38 AcceptanceStrategy ac = new AC_Next();
39 OfferingStrategy os = new TimeDependent_Offering();
40 OpponentModel om = new HardHeadedFrequencyModel();
41 OMStrategy oms = new BestBid();
42
43 // All component parameters can be set below.
44 Map<String, Double> noparams = Collections.emptyMap();
45 Map<String, Double> osParams = new HashMap<String, Double>();
46 // Set the concession parameter "e" for the offering strategy to yield Boulware-like behavior
47 osParams.put("e", 0.2);
48
49 // Initialize all the components of this party to the choices defined above
50 configure(ac, noparams,
51 os, osParams,
52 om, noparams,
53 oms, noparams);
54 super.init(info);
55 }
56
57 /**
58 * Specific functionality, such as the estimate of the utility space in the
59 * face of preference uncertainty, can be specified by overriding the
60 * default behavior.
61 *
62 * This example estimator sets all weights and all evaluator values randomly.
63 */
64 @Override
65 public AbstractUtilitySpace estimateUtilitySpace()
66 {
67 AdditiveUtilitySpaceFactory additiveUtilitySpaceFactory = new AdditiveUtilitySpaceFactory(getDomain());
68 List<IssueDiscrete> issues = additiveUtilitySpaceFactory.getIssues();
69 for (IssueDiscrete i : issues)
70 {
71 additiveUtilitySpaceFactory.setWeight(i, rand.nextDouble());
72 for (ValueDiscrete v : i.getValues())
73 additiveUtilitySpaceFactory.setUtility(i, v, rand.nextDouble());
74 }
75
76 // Normalize the weights, since we picked them randomly in [0, 1]
77 additiveUtilitySpaceFactory.normalizeWeights();
78
79 // The factory is done with setting all parameters, now return the estimated utility space
80 return additiveUtilitySpaceFactory.getUtilitySpace();
81 }
82
83 @Override
84 public String getDescription()
85 {
86 return "Boa Party Example";
87 }
88
89 // All the rest of the functionality is defined by the components selected above, using the BOA framework
90}
Note: See TracBrowser for help on using the repository browser.