[10753] | 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;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
| 25 |
|
---|
| 26 | namespace HeuristicLab.Encodings.ParameterVectorEncoding {
|
---|
| 27 | public class ParameterVectorBuilder {
|
---|
| 28 | private HashSet<string> booleanParameters;
|
---|
| 29 | private Dictionary<string, Tuple<int, int, int?>> integerParameters;
|
---|
| 30 | private Dictionary<string, Tuple<double, double>> realParameters;
|
---|
| 31 | private Tuple<PermutationTypes, int> permutationParameter;
|
---|
| 32 |
|
---|
| 33 | public ParameterVectorBuilder() {
|
---|
[10754] | 34 | booleanParameters = null;
|
---|
| 35 | integerParameters = null;
|
---|
| 36 | realParameters = null;
|
---|
[10753] | 37 | permutationParameter = null;
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | public ParameterVectorBuilder AddBoolean(string name) {
|
---|
[10754] | 41 | if (booleanParameters == null) booleanParameters = new HashSet<string>();
|
---|
[10753] | 42 | booleanParameters.Add(name);
|
---|
| 43 | return this;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | public ParameterVectorBuilder AddInteger(string name, int min, int max, int? step = null) {
|
---|
[10754] | 47 | if (integerParameters == null) integerParameters = new Dictionary<string, Tuple<int, int, int?>>();
|
---|
[10753] | 48 | integerParameters.Add(name, Tuple.Create(min, max, step));
|
---|
| 49 | return this;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | public ParameterVectorBuilder AddReal(string name, double min, double max) {
|
---|
[10754] | 53 | if (realParameters == null) realParameters = new Dictionary<string, Tuple<double, double>>();
|
---|
[10753] | 54 | realParameters.Add(name, Tuple.Create(min, max));
|
---|
| 55 | return this;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | public ParameterVectorBuilder SetPermutation(PermutationTypes type, int length) {
|
---|
| 59 | permutationParameter = Tuple.Create(type, length);
|
---|
| 60 | return this;
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | public ParameterVector Build() {
|
---|
| 64 | var vector = new ParameterVector();
|
---|
| 65 | vector.SetBooleanParameters(booleanParameters);
|
---|
| 66 | vector.SetIntegerParameters(integerParameters);
|
---|
| 67 | vector.SetRealParameters(realParameters);
|
---|
| 68 | vector.SetPermutationParameters(permutationParameter);
|
---|
| 69 | return vector;
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
| 72 | }
|
---|