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

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

Quick fix

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;
[179]7import java.util.Map;
[167]8
[178]9import negotiator.boaframework.opponentmodel.HardHeadedFrequencyModel;
10
11import genius.core.boaframework.AcceptanceStrategy;
[167]12import genius.core.boaframework.BoaParty;
[178]13import genius.core.boaframework.OMStrategy;
14import genius.core.boaframework.OfferingStrategy;
15import genius.core.boaframework.OpponentModel;
16import genius.core.issue.IssueDiscrete;
17import genius.core.issue.ValueDiscrete;
[174]18import genius.core.parties.NegotiationInfo;
[178]19import genius.core.uncertainty.AdditiveUtilitySpaceFactory;
[167]20import 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]32public class BoaPartyExample extends BoaParty
33{
34 @SuppressWarnings("unchecked")
[172]35 @Override
[178]36 public void init(NegotiationInfo info)
37 {
38 // The choice for each component is made here
39 AcceptanceStrategy ac = new AC_Next();
40 OfferingStrategy os = new TimeDependent_Offering();
41 OpponentModel om = new HardHeadedFrequencyModel();
42 OMStrategy oms = new BestBid();
43
44 // All component parameters can be set below.
[179]45 Map<String, Double> noparams = Collections.emptyMap();
46 Map<String, Double> osParams = new HashMap<String, Double>();
[172]47 // Set the concession parameter "e" for the offering strategy to yield
48 // Boulware-like behavior
[169]49 osParams.put("e", 0.2);
[178]50
51 // Initialize all the components of this party to the choices defined above
52 configure(ac, noparams,
53 os, osParams,
54 om, noparams,
55 oms, noparams);
[172]56 super.init(info);
[167]57 }
[172]58
[167]59 /**
[172]60 * Specific functionality, such as the estimate of the utility space in the
61 * face of preference uncertainty, can be specified by overriding the
62 * default behavior.
[178]63 *
64 * This example estimator sets all weights and all evaluator values randomly.
[167]65 */
66 @Override
[172]67 public AbstractUtilitySpace estimateUtilitySpace() {
[178]68 AdditiveUtilitySpaceFactory additiveUtilitySpaceFactory = new AdditiveUtilitySpaceFactory(getDomain());
69 List<IssueDiscrete> issues = additiveUtilitySpaceFactory.getIssues();
70 for (IssueDiscrete i : issues)
71 {
72 additiveUtilitySpaceFactory.setWeight(i, rand.nextDouble());
73 for (ValueDiscrete v : i.getValues())
74 additiveUtilitySpaceFactory.setUtility(i, v, rand.nextDouble());
75 }
76
77 // Normalize the weights, since we picked them randomly in [0, 1]
78 additiveUtilitySpaceFactory.normalizeWeights();
79
80 // The factory is done with setting all parameters, now return the utility space
81 return additiveUtilitySpaceFactory.getUtilitySpace();
[167]82 }
[178]83
[177]84 @Override
[178]85 public String getDescription()
86 {
[177]87 return "Boa Party Example";
88 }
89
[178]90 // All the rest of the functionality is defined by the BOA framework
[167]91}
Note: See TracBrowser for help on using the repository browser.