[167] | 1 | package boaexample;
|
---|
| 2 |
|
---|
[178] | 3 | import java.util.List;
|
---|
| 4 |
|
---|
[172] | 5 | import java.util.Collections;
|
---|
[167] | 6 | import java.util.HashMap;
|
---|
[179] | 7 | import java.util.Map;
|
---|
[167] | 8 |
|
---|
[178] | 9 | import negotiator.boaframework.opponentmodel.HardHeadedFrequencyModel;
|
---|
| 10 |
|
---|
| 11 | import genius.core.boaframework.AcceptanceStrategy;
|
---|
[167] | 12 | import genius.core.boaframework.BoaParty;
|
---|
[178] | 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;
|
---|
[174] | 18 | import genius.core.parties.NegotiationInfo;
|
---|
[178] | 19 | import genius.core.uncertainty.AdditiveUtilitySpaceFactory;
|
---|
[167] | 20 | import genius.core.utility.AbstractUtilitySpace;
|
---|
| 21 |
|
---|
| 22 | /**
|
---|
[172] | 23 | * This example shows how BOA components can be made into an independent
|
---|
| 24 | * negotiation party.
|
---|
[167] | 25 | *
|
---|
[172] | 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).
|
---|
[167] | 30 | */
|
---|
[177] | 31 | @SuppressWarnings("serial")
|
---|
[178] | 32 | public class BoaPartyExample extends BoaParty
|
---|
| 33 | {
|
---|
[172] | 34 | @Override
|
---|
[178] | 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.
|
---|
[179] | 44 | Map<String, Double> noparams = Collections.emptyMap();
|
---|
| 45 | Map<String, Double> osParams = new HashMap<String, Double>();
|
---|
[181] | 46 | // Set the concession parameter "e" for the offering strategy to yield Boulware-like behavior
|
---|
[169] | 47 | osParams.put("e", 0.2);
|
---|
[178] | 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);
|
---|
[172] | 54 | super.init(info);
|
---|
[167] | 55 | }
|
---|
[172] | 56 |
|
---|
[167] | 57 | /**
|
---|
[172] | 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.
|
---|
[178] | 61 | *
|
---|
| 62 | * This example estimator sets all weights and all evaluator values randomly.
|
---|
[167] | 63 | */
|
---|
| 64 | @Override
|
---|
[181] | 65 | public AbstractUtilitySpace estimateUtilitySpace()
|
---|
| 66 | {
|
---|
[178] | 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 |
|
---|
[181] | 79 | // The factory is done with setting all parameters, now return the estimated utility space
|
---|
[178] | 80 | return additiveUtilitySpaceFactory.getUtilitySpace();
|
---|
[167] | 81 | }
|
---|
[178] | 82 |
|
---|
[177] | 83 | @Override
|
---|
[178] | 84 | public String getDescription()
|
---|
| 85 | {
|
---|
[177] | 86 | return "Boa Party Example";
|
---|
| 87 | }
|
---|
| 88 |
|
---|
[181] | 89 | // All the rest of the functionality is defined by the components selected above, using the BOA framework
|
---|
[167] | 90 | }
|
---|