[167] | 1 | package boaexample;
|
---|
| 2 |
|
---|
[173] | 3 | import java.util.List;
|
---|
[172] | 4 | import java.util.Collections;
|
---|
[167] | 5 | import java.util.HashMap;
|
---|
| 6 |
|
---|
| 7 | import genius.core.boaframework.BoaParty;
|
---|
[172] | 8 | import genius.core.parties.NegotiationInfo;
|
---|
[173] | 9 | import genius.core.issue.IssueDiscrete;
|
---|
| 10 | import genius.core.issue.ValueDiscrete;
|
---|
| 11 | import genius.core.uncertainty.AdditiveUtilitySpaceFactory;
|
---|
[167] | 12 | import genius.core.utility.AbstractUtilitySpace;
|
---|
[172] | 13 | import negotiator.boaframework.opponentmodel.HardHeadedFrequencyModel;
|
---|
[167] | 14 |
|
---|
| 15 | /**
|
---|
[172] | 16 | * This example shows how BOA components can be made into an independent
|
---|
| 17 | * negotiation party.
|
---|
[167] | 18 | *
|
---|
[172] | 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).
|
---|
[167] | 23 | */
|
---|
[172] | 24 | public class BoaPartyExample extends BoaParty {
|
---|
[169] | 25 |
|
---|
[172] | 26 | @Override
|
---|
| 27 | public void init(NegotiationInfo info) {
|
---|
| 28 | HashMap<String, Double> noparams = (HashMap<String, Double>) Collections.EMPTY_MAP;
|
---|
[169] | 29 | HashMap<String, Double> osParams = new HashMap<String, Double>();
|
---|
[172] | 30 | // Set the concession parameter "e" for the offering strategy to yield
|
---|
| 31 | // Boulware-like behavior
|
---|
[169] | 32 | osParams.put("e", 0.2);
|
---|
[172] | 33 |
|
---|
| 34 | configure(new AC_Next(), noparams, new TimeDependent_Offering(),
|
---|
| 35 | osParams, new HardHeadedFrequencyModel(), noparams,
|
---|
| 36 | new BestBid(), noparams);
|
---|
| 37 | super.init(info);
|
---|
[167] | 38 | }
|
---|
[172] | 39 |
|
---|
[167] | 40 | /**
|
---|
[172] | 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.
|
---|
[173] | 44 | *
|
---|
| 45 | * This example estimator sets all weights and all evaluator values randomly.
|
---|
[167] | 46 | */
|
---|
| 47 | @Override
|
---|
[172] | 48 | public AbstractUtilitySpace estimateUtilitySpace() {
|
---|
[173] | 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();
|
---|
[167] | 63 | }
|
---|
[173] | 64 |
|
---|
| 65 | // All the rest of the functionality is defined by the BOA framework
|
---|
[169] | 66 |
|
---|
[167] | 67 | }
|
---|