#region License Information
/* HeuristicLab
* Copyright (C) 2002-2012 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 HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Operators;
using HeuristicLab.Optimization;
using HeuristicLab.Optimization.Operators;
using HeuristicLab.Parameters;
using HeuristicLab.Random;
namespace HeuristicLab.Algorithms.MyAlgorithm {
[Item("RandomAlgorithm", "A algorithm which generates random numbers.")]
[Creatable("Algorithms")]
public sealed class RandomAlgorithm : EngineAlgorithm {
private RandomAlgorithm(RandomAlgorithm original, Cloner cloner)
: base(original, cloner) {
}
public RandomAlgorithm()
: base() {
Parameters.Add(new ValueParameter("Max", "The upper bound for the generated number. ", new DoubleValue(100.0)));
Parameters.Add(new ValueParameter("Min", "The lower bound for the generated number. ", new DoubleValue(0.0)));
RandomCreator randomCreator = new RandomCreator();
VariableCreator variableCreator = new VariableCreator();
UniformRandomizer uniformRandomizer = new UniformRandomizer();
ResultsCollector resultsCollector = new ResultsCollector();
//build the operator graph
OperatorGraph.InitialOperator = randomCreator;
randomCreator.Successor = variableCreator;
variableCreator.Successor = uniformRandomizer;
uniformRandomizer.Successor = resultsCollector;
//configure variableCreator
variableCreator.CollectedValues.Add(new ValueParameter("Value", new DoubleValue(0.0)));
//configure result collector
resultsCollector.CollectedValues.Add(new LookupParameter("Value"));
}
public override IDeepCloneable Clone(Cloner cloner) {
return new RandomAlgorithm(this, cloner);
}
}
}