Exemple #1
0
        public IntegerVectorEncoding(string name, int length, int min = int.MinValue, int max = int.MaxValue, int?step = null)
            : base(name)
        {
            if (min >= max)
            {
                throw new ArgumentException("min must be less than max", "min");
            }
            if (step.HasValue && step.Value <= 0)
            {
                throw new ArgumentException("step must be greater than zero or null", "step");
            }

            var bounds = new IntMatrix(1, step.HasValue ? 3 : 2);

            bounds[0, 0] = min;
            bounds[0, 1] = max;
            if (step.HasValue)
            {
                bounds[0, 2] = step.Value;
            }

            lengthParameter = new FixedValueParameter <IntValue>(Name + ".Length", new IntValue(length));
            boundsParameter = new ValueParameter <IntMatrix>(Name + ".Bounds", bounds);
            Parameters.Add(lengthParameter);
            Parameters.Add(boundsParameter);

            SolutionCreator = new UniformRandomIntegerVectorCreator();
            RegisterParameterEvents();
            DiscoverOperators();
        }
Exemple #2
0
        public IntegerVectorEncoding(string name, int length, IList <int> min, IList <int> max, IList <int> step = null)
            : base(name)
        {
            if (min.Count == 0)
            {
                throw new ArgumentException("Bounds must be given for the integer parameters.");
            }
            if (min.Count != max.Count)
            {
                throw new ArgumentException("min must be of the same length as max", "min");
            }
            if (step != null && min.Count != step.Count)
            {
                throw new ArgumentException("step must be of the same length as min or null", "step");
            }
            if (min.Zip(max, (mi, ma) => mi >= ma).Any(x => x))
            {
                throw new ArgumentException("min must be less than max in each dimension", "min");
            }

            var bounds = new IntMatrix(min.Count, step != null ? 3 : 2);

            for (int i = 0; i < min.Count; i++)
            {
                bounds[i, 0] = min[i];
                bounds[i, 1] = max[i];
                if (step != null)
                {
                    bounds[i, 2] = step[i];
                }
            }

            lengthParameter = new FixedValueParameter <IntValue>(Name + ".Length", new IntValue(length));
            boundsParameter = new ValueParameter <IntMatrix>(Name + ".Bounds", bounds);
            Parameters.Add(lengthParameter);
            Parameters.Add(boundsParameter);

            SolutionCreator = new UniformRandomIntegerVectorCreator();
            RegisterParameterEvents();
            DiscoverOperators();
        }
Exemple #3
0
 protected UniformRandomIntegerVectorCreator(UniformRandomIntegerVectorCreator original, Cloner cloner) : base(original, cloner)
 {
 }
 protected UniformRandomIntegerVectorCreator(UniformRandomIntegerVectorCreator original, Cloner cloner) : base(original, cloner) { }