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

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

Re-merged my fixes to BoaPartyExample to make it more readable and easier to edit

File size: 3.1 KB
RevLine 
[167]1package boaexample;
2
[178]3import java.util.List;
4
[172]5import java.util.Collections;
[167]6import java.util.HashMap;
7
[178]8import negotiator.boaframework.opponentmodel.HardHeadedFrequencyModel;
9
10import genius.core.boaframework.AcceptanceStrategy;
[167]11import genius.core.boaframework.BoaParty;
[178]12import genius.core.boaframework.OMStrategy;
13import genius.core.boaframework.OfferingStrategy;
14import genius.core.boaframework.OpponentModel;
15import genius.core.issue.IssueDiscrete;
16import genius.core.issue.ValueDiscrete;
[174]17import genius.core.parties.NegotiationInfo;
[178]18import genius.core.uncertainty.AdditiveUtilitySpaceFactory;
[167]19import genius.core.utility.AbstractUtilitySpace;
20
21/**
[172]22 * This example shows how BOA components can be made into an independent
23 * negotiation party.
[167]24 *
[172]25 * Note that this is equivalent to adding a BOA party via the GUI by selecting
26 * the components and parameters. However, this method gives more control over
27 * the implementation, as the agent designer can choose to override behavior
28 * (such as handling preference uncertainty).
[167]29 */
[177]30@SuppressWarnings("serial")
[178]31public class BoaPartyExample extends BoaParty
32{
33 @SuppressWarnings("unchecked")
[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.
44 HashMap<String, Double> noparams = (HashMap<String, Double>) Collections.EMPTY_MAP;
45 HashMap<String, Double> osParams = new HashMap<String, Double>();
[172]46 // Set the concession parameter "e" for the offering strategy to yield
47 // Boulware-like behavior
[169]48 osParams.put("e", 0.2);
[178]49
50 // Initialize all the components of this party to the choices defined above
51 configure(ac, noparams,
52 os, osParams,
53 om, noparams,
54 oms, noparams);
[172]55 super.init(info);
[167]56 }
[172]57
[167]58 /**
[172]59 * Specific functionality, such as the estimate of the utility space in the
60 * face of preference uncertainty, can be specified by overriding the
61 * default behavior.
[178]62 *
63 * This example estimator sets all weights and all evaluator values randomly.
[167]64 */
65 @Override
[172]66 public AbstractUtilitySpace estimateUtilitySpace() {
[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
79 // The factory is done with setting all parameters, now return the utility space
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
[178]89 // All the rest of the functionality is defined by the BOA framework
[167]90}
Note: See TracBrowser for help on using the repository browser.