using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Data; using HeuristicLab.Encodings.RealVectorEncoding; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Problems.MultiObjectiveTestFunction; namespace HeuristicLab.Problems.TestFunctions { [Item("ZDT4", "//http://www.tik.ee.ethz.ch/sop/download/supplementary/testproblems/ [30.11.2015]")] [StorableClass] public class ZDT4 : MultiObjectiveTestFunction { public override DoubleMatrix Bounds { get { return new DoubleMatrix(new double[,] { { 0, 1 } }); //definition in the source is contradicting itself the known paretofront is for [0,1] } } public override bool[] Maximization { get { return new bool[] { false, false }; } } public override int MaximumProblemSize { get { return int.MaxValue; } } public override int MaximumSolutionSize { get { return 2; } } public override int MinimumProblemSize { get { return 1; } } public override int MinimumSolutionSize { get { return 2; } } public override int ActualSolutionSize { get { return 2; } set { } } [StorableConstructor] protected ZDT4(bool deserializing) : base(deserializing) { } protected ZDT4(ZDT4 original, Cloner cloner) : base(original, cloner) { } public ZDT4() : base() { } public override IDeepCloneable Clone(Cloner cloner) { return new ZDT4(this, cloner); } public override double[] Evaluate(RealVector r) { double g = 0; for (int i = 1; i < r.Length; i++) { double v = r[i]; g += v * v - 10 * Math.Cos(4 * Math.PI * v); } g = 1.0 + 10.0 * (r.Length - 1) + g; double d = r[0] / g; return new double[] { r[0], g * (1.0 - d * d) }; } } }