source: src/test/java/boaexample/BoaPartyExample.java@ 173

Last change on this file since 173 was 173, checked in by Tim Baarslag, 6 years ago

BoaPartyExample now includes an example of estimating the utility space

File size: 2.5 KB
RevLine 
[167]1package boaexample;
2
[173]3import java.util.List;
[172]4import java.util.Collections;
[167]5import java.util.HashMap;
6
7import genius.core.boaframework.BoaParty;
[172]8import genius.core.parties.NegotiationInfo;
[173]9import genius.core.issue.IssueDiscrete;
10import genius.core.issue.ValueDiscrete;
11import genius.core.uncertainty.AdditiveUtilitySpaceFactory;
[167]12import genius.core.utility.AbstractUtilitySpace;
[172]13import 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]24public 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}
Note: See TracBrowser for help on using the repository browser.