Пример #1
0
        public BpEaRealVectorEncoding(string name, int length, IList <double> min, IList <double> max, IList <String> featureNames)
            : base(name)
        {
            if (min.Count == 0)
            {
                throw new ArgumentException("Bounds must be given for the real parameters.");
            }
            if (min.Count != max.Count)
            {
                throw new ArgumentException("min must be of the same length as max", "min");
            }
            if (min.Zip(max, (mi, ma) => mi >= ma).Any(x => x))
            {
                throw new ArgumentException("min must be less than max in each dimension", "min");
            }

            DoubleMatrix bounds = new DoubleMatrix(min.Count, 2);

            for (int i = 0; i < min.Count; i++)
            {
                bounds[i, 0] = min[i];
                bounds[i, 1] = max[i];
            }
            bounds.RowNames = new List <string>(featureNames);
            lengthParameter = new FixedValueParameter <IntValue>(Name + ".Length", new IntValue(length));
            boundsParameter = new ValueParameter <DoubleMatrix>(Name + ".Bounds", bounds);
            Parameters.Add(lengthParameter);
            Parameters.Add(boundsParameter);

            SolutionCreator = new UniformRandomRealVectorCreator();
            RegisterParameterEvents();
            DiscoverOperators();
        }
Пример #2
0
        public BpEaRealVectorEncoding(string name, int length, double min = double.MinValue, double max = double.MaxValue)
            : base(name)
        {
            if (min >= max)
            {
                throw new ArgumentException("min must be less than max", "min");
            }

            var bounds = new DoubleMatrix(1, 2);

            bounds[0, 0] = min;
            bounds[0, 1] = max;

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

            SolutionCreator = new UniformRandomRealVectorCreator();
            RegisterParameterEvents();
            DiscoverOperators();
        }