private static int GetIndexOfConstraintDimension(IConstraint constraint, ReadOnlyCollection<DimensionWithValues> dimensionValues,
			QualifiedDimension dimension)
		{
			int ret = 0;
			foreach (DimensionWithValues dv in dimensionValues)
			{
				if (IsSubset(dimension, dv.Dimension))
				{
					return ret;
				}
				ret++;
			}
			throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
				"Dimension {0} from constraint {1} was not found in the matrix (all dimensions: {2}).",
				dimension.FullyQualifiedName, constraint.GetType().Name, string.Join(",", dimensionValues.Select(dv => dv.Dimension.FullyQualifiedName))));
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="DimensionWithValues"/> struct.
		/// </summary>
		/// <param name="dimension">The dimension.</param>
		/// <param name="values">The values.</param>
		public DimensionWithValues(QualifiedDimension dimension, IEnumerable<ValueFactoryWithOptionalConcreteValue> values)
		{
			_dimension = dimension;
			_values = new List<ValueFactoryWithOptionalConcreteValue>(values);
		}
		private static bool IsSubset(QualifiedDimension superset, QualifiedDimension subset)
		{
			return superset.Path.Count >= subset.Path.Count &&
				superset.FullPath.Take(subset.FullPath.Count()).SequenceEqual(subset.FullPath);
		}
		private static IEnumerable<QualifiedDimension> ExpandOuterMatrixDimensionIfNeeded(QualifiedDimension toExpand, ReadOnlyCollection<DimensionWithValues> dimensionValues)
		{
			IEnumerable<QualifiedDimension> ret = dimensionValues.Select(dv => dv.Dimension).Where(d => IsSubset(d, toExpand));
			if (toExpand.BaseDimension is Matrix && ret.Any())
			{
				return ret;
			}
			else
			{
				return Enumerable.Repeat(toExpand, 1);
			}
		}
Beispiel #5
0
		private static int GetIndexOfDimension(QualifiedDimension targetDimension, ReadOnlyCollection<DimensionWithValues> dimensionValues,
			string origin)
		{
			int ret = 0;
			foreach (DimensionWithValues dv in dimensionValues)
			{
				if (targetDimension.Equals(dv.Dimension))
				{
					return ret;
				}
				ret++;
			}
			throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
				"Dimension {0} from {1} was not found in the explored matrix (all dimensions: {2}).",
				targetDimension.FullyQualifiedName, origin, string.Join(",", dimensionValues.Select(dv => dv.Dimension.FullyQualifiedName))));
		}