#region License Information
/* HeuristicLab
* Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using HeuristicLab.Encodings.PermutationEncoding;
namespace HeuristicLab.Encodings.ParameterVectorEncoding {
public class ParameterVectorBuilder {
private HashSet booleanParameters;
private Dictionary> integerParameters;
private Dictionary> realParameters;
private Tuple permutationParameter;
public ParameterVectorBuilder() {
booleanParameters = null;
integerParameters = null;
realParameters = null;
permutationParameter = null;
}
public ParameterVectorBuilder AddBoolean(string name) {
if (booleanParameters == null) booleanParameters = new HashSet();
booleanParameters.Add(name);
return this;
}
public ParameterVectorBuilder AddInteger(string name, int min, int max, int? step = null) {
if (integerParameters == null) integerParameters = new Dictionary>();
integerParameters.Add(name, Tuple.Create(min, max, step));
return this;
}
public ParameterVectorBuilder AddReal(string name, double min, double max) {
if (realParameters == null) realParameters = new Dictionary>();
realParameters.Add(name, Tuple.Create(min, max));
return this;
}
public ParameterVectorBuilder SetPermutation(PermutationTypes type, int length) {
permutationParameter = Tuple.Create(type, length);
return this;
}
public ParameterVector Build() {
var vector = new ParameterVector();
vector.SetBooleanParameters(booleanParameters);
vector.SetIntegerParameters(integerParameters);
vector.SetRealParameters(realParameters);
vector.SetPermutationParameters(permutationParameter);
return vector;
}
}
}