source: src/test/java/bilateralexamples/BoaPartyExample.java@ 209

Last change on this file since 209 was 186, checked in by Tim Baarslag, 5 years ago

Release 9.1.8

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