コード例 #1
0
        public virtual void AddIndependendVariableValues <T>(IVariable variable, IEnumerable <T> values)
        {
            if (!Functions.Contains(variable))
            {
                throw new ArgumentOutOfRangeException("variable",
                                                      "Function is not a part of the store, add it to the Functions first.");
            }
            IMultiDimensionalArray variableValuesArray = FunctionValues[Functions.IndexOf(variable)];

            bool addingNewValues = variableValuesArray.Count == 0;

            foreach (T o in values)
            {
                if (addingNewValues)
                {
                    variableValuesArray.Add(o);
                }
                else
                {
                    if (!variableValuesArray.Contains(o)) // TODO: slow, optimize it somehow
                    {
                        variableValuesArray.Add(o);
                    }
                }
            }
        }
コード例 #2
0
        private IMultiDimensionalArray GetValues(IVariable variable)
        {
            if (variable.CachedValues == null)
            {
                variable.CachedValues = FunctionValues[functions.IndexOf(variable)];
            }

            return(variable.CachedValues);
        }
コード例 #3
0
        private void SetIndependendFunctionValues(IVariable variable, IVariableFilter[] filters, IEnumerable values)
        {
            IMultiDimensionalArray array = FunctionValues[functions.IndexOf(variable)];

            if (filters.Length != 0)
            {
                throw new ArgumentException("don't use filters to set independend variables. the only exception is an index filter with index equal to count");
            }

            array.AddRange(values);
        }
コード例 #4
0
        public virtual object Clone()
        {
            var clonedNetwork = (Network)Activator.CreateInstance(GetType());

            clonedNetwork.Name     = Name;
            clonedNetwork.Geometry = Geometry == null ? null : ((IGeometry)Geometry.Clone());

            foreach (var node in Nodes)
            {
                INode clonedNode = (INode)node.Clone();
                clonedNetwork.Nodes.Add(clonedNode);
            }
            foreach (IBranch branch in Branches)
            {
                IBranch clonedBranch = (IBranch)branch.Clone();
                clonedBranch.Source = clonedNetwork.Nodes[Nodes.IndexOf(branch.Source)];
                clonedBranch.Target = clonedNetwork.Nodes[nodes.IndexOf(branch.Target)];
                clonedNetwork.Branches.Add(clonedBranch);
            }
            return(clonedNetwork);
        }
コード例 #5
0
        public virtual void AddIndependendVariableValues <T>(IVariable variable, IEnumerable <T> values)
        {
            ThrowIfVariableNotPartOfStore(variable);

            IMultiDimensionalArray variableValuesArray = FunctionValues[Functions.IndexOf(variable)];

            bool addingNewValues = variableValuesArray.Count == 0;

            foreach (T o in values)
            {
                if (addingNewValues || variable.SkipUniqueValuesCheck)
                {
                    variableValuesArray.Add(o);
                }
                else
                {
                    if (!variableValuesArray.Contains(o)) // TODO: slow, optimize it somehow
                    {
                        variableValuesArray.Add(o);
                    }
                }
            }
        }