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

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

Make it easier to change and adapt BoaPartyExample

File size: 3.0 KB
Line 
1package boaexample;
2
3import java.util.List;
4
5import java.util.Collections;
6import java.util.HashMap;
7
8import negotiator.boaframework.opponentmodel.HardHeadedFrequencyModel;
9
10import genius.core.boaframework.AcceptanceStrategy;
11import genius.core.boaframework.BoaParty;
12import genius.core.boaframework.OMStrategy;
13import genius.core.boaframework.OfferingStrategy;
14import genius.core.boaframework.OpponentModel;
15import genius.core.issue.IssueDiscrete;
16import genius.core.issue.ValueDiscrete;
17import genius.core.parties.NegotiationInfo;
18import genius.core.uncertainty.AdditiveUtilitySpaceFactory;
19import genius.core.utility.AbstractUtilitySpace;
20
21/**
22 * This example shows how BOA components can be made into an independent
23 * negotiation party.
24 *
25 * Note that this is equivalent to adding a BOA party via the GUI by selecting
26 * the components and parameters. However, this method gives more control over
27 * the implementation, as the agent designer can choose to override behavior
28 * (such as handling preference uncertainty).
29 */
30public class BoaPartyExample extends BoaParty {
31
32 @SuppressWarnings("unchecked")
33 @Override
34 public void init(NegotiationInfo info)
35 {
36 // The choice for each component is made here
37 AcceptanceStrategy ac = new AC_Next();
38 OfferingStrategy os = new TimeDependent_Offering();
39 OpponentModel om = new HardHeadedFrequencyModel();
40 OMStrategy oms = new BestBid();
41
42 // All component parameters can be set below.
43 HashMap<String, Double> noparams = (HashMap<String, Double>) Collections.EMPTY_MAP;
44 HashMap<String, Double> osParams = new HashMap<String, Double>();
45 // Set the concession parameter "e" for the offering strategy to yield
46 // 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 AdditiveUtilitySpaceFactory additiveUtilitySpaceFactory = new AdditiveUtilitySpaceFactory(getDomain());
67 List<IssueDiscrete> issues = additiveUtilitySpaceFactory.getIssues();
68 for (IssueDiscrete i : issues)
69 {
70 additiveUtilitySpaceFactory.setWeight(i, rand.nextDouble());
71 for (ValueDiscrete v : i.getValues())
72 additiveUtilitySpaceFactory.setUtility(i, v, rand.nextDouble());
73 }
74
75 // Normalize the weights, since we picked them randomly in [0, 1]
76 additiveUtilitySpaceFactory.normalizeWeights();
77
78 // The factory is done with setting all parameters, now return the utility space
79 return additiveUtilitySpaceFactory.getUtilitySpace();
80 }
81
82 // All the rest of the functionality is defined by the BOA framework
83
84}
Note: See TracBrowser for help on using the repository browser.