1 | package genius.core;
|
---|
2 |
|
---|
3 | import java.io.Serializable;
|
---|
4 | import java.util.HashMap;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Simple class which stores the parameters given to a negotiation strategy, for
|
---|
8 | * example an concession factor.
|
---|
9 | *
|
---|
10 | * @author Mark Hendrikx
|
---|
11 | */
|
---|
12 | public class StrategyParameters implements Serializable {
|
---|
13 |
|
---|
14 | /**
|
---|
15 | *
|
---|
16 | */
|
---|
17 | private static final long serialVersionUID = 265616574821536192L;
|
---|
18 | /** Parameters as specified in the agent repository. */
|
---|
19 | protected HashMap<String, String> strategyParam;
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Create an empty hashmap of parameters.
|
---|
23 | */
|
---|
24 | public StrategyParameters() {
|
---|
25 | strategyParam = new HashMap<String, String>();
|
---|
26 | }
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Add a parameter to the list of parameters.
|
---|
30 | *
|
---|
31 | * @param name
|
---|
32 | * of the parameter.
|
---|
33 | * @param value
|
---|
34 | * of the parameter.
|
---|
35 | */
|
---|
36 | public void addVariable(String name, String value) {
|
---|
37 | strategyParam.put(name, value);
|
---|
38 | }
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * Returns the value of the parameter with the given name as string.
|
---|
42 | *
|
---|
43 | * @param name
|
---|
44 | * of the given parameter.
|
---|
45 | * @return value of the parameter as string.
|
---|
46 | */
|
---|
47 | public String getValueAsString(String name) {
|
---|
48 | return strategyParam.get(name);
|
---|
49 | }
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Returns the value of the parameter with the given name as double.
|
---|
53 | *
|
---|
54 | * @param name
|
---|
55 | * of the given parameter.
|
---|
56 | * @return value of the parameter as double.
|
---|
57 | */
|
---|
58 | public double getValueAsDouble(String name) {
|
---|
59 | return Double.parseDouble(strategyParam.get(name));
|
---|
60 | }
|
---|
61 |
|
---|
62 | @Override
|
---|
63 | public String toString() {
|
---|
64 | String result = "";
|
---|
65 | for (String key: this.strategyParam.keySet()) {
|
---|
66 | result += ";" + key + "=" + this.strategyParam.get(key);
|
---|
67 | }
|
---|
68 | return result;
|
---|
69 | }
|
---|
70 | } |
---|