/// <summary> /// Instantiates binary transformation strategy used by <see cref="T:Localwire.Graphinder.Core.Algorithms.GeneticAlgorithm.GeneticAlgorithm"/> mutation. /// </summary> /// <param name="transformationType"></param> public BinaryTransformationStrategy(BinaryTransformationType transformationType = BinaryTransformationType.RandomBitFlip) { TransformationType = transformationType; //Enforce setting transformation action in case of transformationType = 0; //TODO: Make _transformationType nullable? _binaryTransformation = BinaryTransformation.Request(_transformationType); }
/// <summary> /// Requests action for given transformation type. /// </summary> /// <param name="transformation">Transformation type.</param> /// <returns>Transformation action.</returns> public static Action<bool[]> Request(BinaryTransformationType transformation) { switch (transformation) { case BinaryTransformationType.RandomBitFlip: return new BinaryTransformation().RandomBitFlip; case BinaryTransformationType.AllBitFlip: return new BinaryTransformation().AllBitFlip; default: return new BinaryTransformation().RandomBitFlip; } }
/// <summary> /// Requests action for given transformation type. /// </summary> /// <param name="transformation">Transformation type.</param> /// <returns>Transformation action.</returns> public static Action <bool[]> Request(BinaryTransformationType transformation) { switch (transformation) { case BinaryTransformationType.RandomBitFlip: return(new BinaryTransformation().RandomBitFlip); case BinaryTransformationType.AllBitFlip: return(new BinaryTransformation().AllBitFlip); default: return(new BinaryTransformation().RandomBitFlip); } }