1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System.Collections.Generic;
|
---|
23 | using System.Linq;
|
---|
24 | using HeuristicLab.Encodings.BinaryVectorEncoding;
|
---|
25 | using HeuristicLab.Encodings.IntegerVectorEncoding;
|
---|
26 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
27 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
28 |
|
---|
29 | namespace HeuristicLab.Problems.Programmable {
|
---|
30 | public class ParameterVector {
|
---|
31 | protected Dictionary<string, BinaryVector> BinaryParameters;
|
---|
32 | protected Dictionary<string, IntegerVector> IntegerParameters;
|
---|
33 | protected Dictionary<string, RealVector> RealParameters;
|
---|
34 | protected Dictionary<string, Permutation> PermutationParameters;
|
---|
35 |
|
---|
36 | public ParameterVector(IEnumerable<KeyValuePair<string, BinaryVector>> binaryVectors = null,
|
---|
37 | IEnumerable<KeyValuePair<string, IntegerVector>> integerVectors = null,
|
---|
38 | IEnumerable<KeyValuePair<string, RealVector>> realVectors = null,
|
---|
39 | IEnumerable<KeyValuePair<string, Permutation>> permutations = null) {
|
---|
40 | if (binaryVectors != null) BinaryParameters = binaryVectors.ToDictionary(x => x.Key, x => x.Value);
|
---|
41 | if (integerVectors != null) IntegerParameters = integerVectors.ToDictionary(x => x.Key, x => x.Value);
|
---|
42 | if (realVectors != null) RealParameters = realVectors.ToDictionary(x => x.Key, x => x.Value);
|
---|
43 | if (permutations != null) PermutationParameters = permutations.ToDictionary(x => x.Key, x => x.Value);
|
---|
44 | }
|
---|
45 |
|
---|
46 | public BinaryVector Binary(string name) {
|
---|
47 | return BinaryParameters[name];
|
---|
48 | }
|
---|
49 |
|
---|
50 | public bool Binary(string name, int index) {
|
---|
51 | return BinaryParameters[name][index];
|
---|
52 | }
|
---|
53 |
|
---|
54 | public IEnumerable<string> BinaryNames {
|
---|
55 | get { return BinaryParameters.Keys; }
|
---|
56 | }
|
---|
57 |
|
---|
58 | public IntegerVector Integer(string name) {
|
---|
59 | return IntegerParameters[name];
|
---|
60 | }
|
---|
61 |
|
---|
62 | public int Integer(string name, int index) {
|
---|
63 | return IntegerParameters[name][index];
|
---|
64 | }
|
---|
65 |
|
---|
66 | public IEnumerable<string> IntegerNames {
|
---|
67 | get { return IntegerParameters.Keys; }
|
---|
68 | }
|
---|
69 |
|
---|
70 | public RealVector Real(string name) {
|
---|
71 | return RealParameters[name];
|
---|
72 | }
|
---|
73 |
|
---|
74 | public double Real(string name, int index) {
|
---|
75 | return RealParameters[name][index];
|
---|
76 | }
|
---|
77 |
|
---|
78 | public IEnumerable<string> RealNames {
|
---|
79 | get { return RealParameters.Keys; }
|
---|
80 | }
|
---|
81 |
|
---|
82 | public Permutation Permutation(string name) {
|
---|
83 | return PermutationParameters[name];
|
---|
84 | }
|
---|
85 |
|
---|
86 | public IEnumerable<string> PermutationNames {
|
---|
87 | get { return PermutationParameters.Keys; }
|
---|
88 | }
|
---|
89 | }
|
---|
90 | }
|
---|