1 | package agents.anac.y2010.Southampton.analysis;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.HashMap;
|
---|
5 |
|
---|
6 | import genius.core.issue.ValueDiscrete;
|
---|
7 |
|
---|
8 | public class BidSpaceDiscrete {
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * @param discreteEvaluationFunctions
|
---|
12 | * @param discreteWeights
|
---|
13 | * @return
|
---|
14 | */
|
---|
15 | public static ValueDiscrete[][] getDiscreteCombinations(ArrayList<HashMap<ValueDiscrete, Double>> discreteEvaluationFunctions,
|
---|
16 | ArrayList<Double> discreteWeights) {
|
---|
17 | return getDiscrete(getDiscreteCombinationValues(discreteEvaluationFunctions), discreteEvaluationFunctions, discreteWeights);
|
---|
18 | }
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * @param discreteCombinationValues
|
---|
22 | * @param discreteEvaluationFunctions
|
---|
23 | * @param discreteWeights
|
---|
24 | * @return
|
---|
25 | */
|
---|
26 | private static ValueDiscrete[][] getDiscrete(ArrayList<int[]> discreteCombinationValues,
|
---|
27 | ArrayList<HashMap<ValueDiscrete, Double>> discreteEvaluationFunctions, ArrayList<Double> discreteWeights) {
|
---|
28 | ValueDiscrete[][] result = new ValueDiscrete[discreteCombinationValues.size()][discreteEvaluationFunctions.size()];
|
---|
29 |
|
---|
30 | int i = 0;
|
---|
31 | for (int[] discreteCombinationValue : discreteCombinationValues) {
|
---|
32 | for (int j = 0; j < discreteEvaluationFunctions.size(); j++) {
|
---|
33 | result[i][j] = (ValueDiscrete) discreteEvaluationFunctions.get(j).keySet().toArray()[discreteCombinationValue[j]];
|
---|
34 | }
|
---|
35 | i++;
|
---|
36 | }
|
---|
37 |
|
---|
38 | return result;
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * @param discreteEvaluationFunctions
|
---|
43 | * @return
|
---|
44 | */
|
---|
45 | private static ArrayList<int[]> getDiscreteCombinationValues(ArrayList<HashMap<ValueDiscrete, Double>> discreteEvaluationFunctions) {
|
---|
46 | int[] space = new int[discreteEvaluationFunctions.size() + 1];
|
---|
47 | space[0] = 1;
|
---|
48 | int i = 0;
|
---|
49 |
|
---|
50 | // Work out how many 'sections' there are
|
---|
51 | for (HashMap<ValueDiscrete, Double> discreteEvaluationFunction : discreteEvaluationFunctions) {
|
---|
52 | i++;
|
---|
53 | space[i] = space[i - 1] * discreteEvaluationFunction.size();
|
---|
54 | }
|
---|
55 |
|
---|
56 | // Work out what the combinations of spaces are
|
---|
57 | return BidSpace.getCombinationValues(space);
|
---|
58 | }
|
---|
59 | }
|
---|