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