Ejemplo n.º 1
0
        private DecisionVector(DecisionSpace decisionSpace,
                               IEnumerable <object> values)
        {
            this.decisionSpace = decisionSpace;
            var elements = values as object[] ?? values.ToArray();

            //Check that all values are sensible
            if (!decisionSpace.IsAcceptableDecisionVector(elements))
            {
                throw new ArgumentOutOfRangeException(nameof(values),
                                                      "These values are not accepted by the decision space");
            }

            vector = elements;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Static constructor which takes an array of integers.
 /// Useful when the decision space is homomorphic and continuous.
 /// </summary>
 /// <param name="decisionSpace">The decision space definition</param>
 /// <param name="values">The points inside that decision space defining this solution</param>
 /// <returns>A new Decision Vector</returns>
 /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="values"/> are not valid.</exception>
 public static DecisionVector CreateFromArray(DecisionSpace decisionSpace,
                                              IEnumerable <double> values)
 {
     return(new DecisionVector(decisionSpace, values.Cast <object>().ToArray()));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Static constructor which takes a comma-separated list of values.
 /// Useful when the decision space is heteromorphic.
 /// </summary>
 /// <param name="decisionSpace">The decision space definition</param>
 /// <param name="values">The points inside that decision space defining this solution</param>
 /// <returns>A new Decision Vector</returns>
 /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="values"/> are not valid.</exception>
 public static DecisionVector CreateFromItems(DecisionSpace decisionSpace,
                                              params object[] values)
 {
     return(new DecisionVector(decisionSpace, values));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Returns a new empty Decision Vector.
 /// </summary>
 /// <returns>A <see cref="DecisionVector"/> with no elements.</returns>
 public static DecisionVector CreateForEmpty()
 {
     return(new DecisionVector(DecisionSpace.CreateForEmpty(), new List <object>()));
 }