#region License Information
/* HeuristicLab
* Copyright (C) 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.Encodings.RealVectorEncoding;
using HeuristicLab.Optimization;
using HeuristicLab.Parameters;
using HEAL.Attic;
namespace HeuristicLab.Problems.TestFunctions {
///
/// A function that returns a random variable in [0;1) independent of the inputs.
///
/// It does not really matter.
///
public override bool Maximization {
get { return false; }
}
///
/// The minimum value that can be "found" is 0.
///
public override double BestKnownQuality {
get { return 0; }
}
///
/// Gets the lower and upper bound of the function.
///
public override DoubleMatrix Bounds {
get { return new DoubleMatrix(new double[,] { { -100, 100 } }); }
}
///
/// Gets the minimum problem size (1).
///
public override int MinimumProblemSize {
get { return 1; }
}
///
/// Gets the (theoretical) maximum problem size (2^31 - 1).
///
public override int MaximumProblemSize {
get { return int.MaxValue; }
}
public ILookupParameter RandomParameter {
get { return (ILookupParameter)Parameters["Random"]; }
}
[StorableConstructor]
protected RandomEvaluator(StorableConstructorFlag _) : base(_) { }
protected RandomEvaluator(RandomEvaluator original, Cloner cloner) : base(original, cloner) { }
public RandomEvaluator()
: base() {
Parameters.Add(new LookupParameter("Random", "The random number generator to use."));
}
public override IDeepCloneable Clone(Cloner cloner) {
return new RandomEvaluator(this, cloner);
}
public override RealVector GetBestKnownSolution(int dimension) {
return new RealVector(dimension);
}
public override double Evaluate(RealVector point) {
return ExecutionContext == null ? new System.Random().NextDouble() : RandomParameter.ActualValue.NextDouble();
}
}
}