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; }
/// <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())); }
/// <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)); }
/// <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>())); }