1 | package boaexample;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 | import java.util.Collections;
|
---|
5 | import java.util.HashMap;
|
---|
6 |
|
---|
7 | import genius.core.boaframework.BoaParty;
|
---|
8 | import genius.core.parties.NegotiationInfo;
|
---|
9 | import genius.core.issue.IssueDiscrete;
|
---|
10 | import genius.core.issue.ValueDiscrete;
|
---|
11 | import genius.core.uncertainty.AdditiveUtilitySpaceFactory;
|
---|
12 | import genius.core.utility.AbstractUtilitySpace;
|
---|
13 | import negotiator.boaframework.opponentmodel.HardHeadedFrequencyModel;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * This example shows how BOA components can be made into an independent
|
---|
17 | * negotiation party.
|
---|
18 | *
|
---|
19 | * Note that this is equivalent to adding a BOA party via the GUI by selecting
|
---|
20 | * the components and parameters. However, this method gives more control over
|
---|
21 | * the implementation, as the agent designer can choose to override behavior
|
---|
22 | * (such as handling preference uncertainty).
|
---|
23 | */
|
---|
24 | public class BoaPartyExample extends BoaParty {
|
---|
25 |
|
---|
26 | @Override
|
---|
27 | public void init(NegotiationInfo info) {
|
---|
28 | HashMap<String, Double> noparams = (HashMap<String, Double>) Collections.EMPTY_MAP;
|
---|
29 | HashMap<String, Double> osParams = new HashMap<String, Double>();
|
---|
30 | // Set the concession parameter "e" for the offering strategy to yield
|
---|
31 | // Boulware-like behavior
|
---|
32 | osParams.put("e", 0.2);
|
---|
33 |
|
---|
34 | configure(new AC_Next(), noparams, new TimeDependent_Offering(),
|
---|
35 | osParams, new HardHeadedFrequencyModel(), noparams,
|
---|
36 | new BestBid(), noparams);
|
---|
37 | super.init(info);
|
---|
38 | }
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * Specific functionality, such as the estimate of the utility space in the
|
---|
42 | * face of preference uncertainty, can be specified by overriding the
|
---|
43 | * default behavior.
|
---|
44 | *
|
---|
45 | * This example estimator sets all weights and all evaluator values randomly.
|
---|
46 | */
|
---|
47 | @Override
|
---|
48 | public AbstractUtilitySpace estimateUtilitySpace() {
|
---|
49 | AdditiveUtilitySpaceFactory additiveUtilitySpaceFactory = new AdditiveUtilitySpaceFactory(getDomain());
|
---|
50 | List<IssueDiscrete> issues = additiveUtilitySpaceFactory.getIssues();
|
---|
51 | for (IssueDiscrete i : issues)
|
---|
52 | {
|
---|
53 | additiveUtilitySpaceFactory.setWeight(i, rand.nextDouble());
|
---|
54 | for (ValueDiscrete v : i.getValues())
|
---|
55 | additiveUtilitySpaceFactory.setUtility(i, v, rand.nextDouble());
|
---|
56 | }
|
---|
57 |
|
---|
58 | // Normalize the weights, since we picked them randomly in [0, 1]
|
---|
59 | additiveUtilitySpaceFactory.normalizeWeights();
|
---|
60 |
|
---|
61 | // The factory is done with setting all parameters, now return the utility space
|
---|
62 | return additiveUtilitySpaceFactory.getUtilitySpace();
|
---|
63 | }
|
---|
64 |
|
---|
65 | // All the rest of the functionality is defined by the BOA framework
|
---|
66 |
|
---|
67 | }
|
---|