コード例 #1
0
        private void InitializeConstraintValues()
        {
            Constraints.Clear();

            foreach (var constraint in System.Constraints)
            {
                foreach (var group in constraint.ApplyTo(System))
                {
                    Constraints.Add(new AppliedConstraint
                    {
                        Constraint = constraint,
                        Particles  = group.ToList(),
                    });
                }
            }

            if (Constraints.Count == 0)
            {
                return;
            }

            constraintValues = Matrix <float> .Build.Dense(Constraints.Count, 1);

            constraintForces = new List <Vector <float> >();

            for (int i = 0; i < Constraints.Count; i++)
            {
                constraintValues[i, 0] = Constraints[i].Value;
                constraintForces.Add(Vector <float> .Build.Dense(GeneralizedCoordinateCount));
            }
        }
コード例 #2
0
        public virtual void SetSettings(Model.Settings settings)
        {
            Constraints.Clear();
            var sessionId = HttpContext.Current?.Request?.Cookies["ASP.Net_SessionId"]?.Value;

            if (settings.SessionOnly && !string.IsNullOrWhiteSpace(sessionId))
            {
                //Have to use the cookie since the session isn't initialized in this context.
                Constraints.Add(new SessionConstraint(sessionId));
            }
            if (!string.IsNullOrWhiteSpace(settings.Site))
            {
                Constraints.Add(new SiteConstraint(settings.Site));
            }
            if (!string.IsNullOrWhiteSpace(settings.IncludeUrlPattern))
            {
                Constraints.Add(new IncludeUrlConstraint(settings.IncludeUrlPattern));
            }
            if (!string.IsNullOrWhiteSpace(settings.ExcludeUrlPattern))
            {
                Constraints.Add(new ExcludeUrlConstraint(settings.ExcludeUrlPattern));
            }
            if (!string.IsNullOrWhiteSpace(settings.Language))
            {
                Constraints.Add(new LanguageConstraint(settings.Language));
            }

            MaxEnumerableIterations = settings.MaxEnumerableIterations;
            MaxMemoryEntries        = settings.MaxMemoryEntries;
            LogToDiagnostics        = settings.LogToDiagnostics;
            LogToMemory             = settings.LogToMemory;
            SetDefaultTaxonomies(settings.DefaultTaxonomies);
        }
コード例 #3
0
        //--------------------//

        #region Normalize
        /// <summary>
        /// Handles legacy elements (converts <see cref="Constraints"/> to <see cref="Versions"/>).
        /// </summary>
        /// <remarks>This method should be called to prepare a <see cref="Feed"/> for solver processing. Do not call it if you plan on serializing the feed again since it may loose some of its structure.</remarks>
        public virtual void Normalize()
        {
            if (Constraints.Count != 0)
            {
                Versions = Constraints.Aggregate(Versions ?? new VersionRange(), (current, constraint) => current.Intersect(constraint));
                Constraints.Clear();
            }
        }
コード例 #4
0
        /// <summary>
        /// Handles legacy elements (converts <see cref="Constraints"/> to <see cref="Versions"/>).
        /// </summary>
        /// <exception cref="InvalidDataException">One or more required fields are not set.</exception>
        /// <remarks>This method should be called to prepare a <see cref="Feed"/> for solver processing. Do not call it if you plan on serializing the feed again since it may loose some of its structure.</remarks>
        public virtual void Normalize()
        {
            EnsureNotNull(InterfaceUri, xmlAttribute: "interface", xmlTag: XmlTagName);

            if (Constraints.Count != 0)
            {
                Versions = Constraints.Aggregate(Versions ?? new VersionRange(), (current, constraint) => current.Intersect(constraint));
                Constraints.Clear();
            }
        }
コード例 #5
0
 //What is the purpose of this method? If someone wanted to clear the Model, they could just create a new one.
 public void Clear()
 {
     Loads.Clear();
     ClustersDictionary.Clear();
     SubdomainsDictionary.Clear();
     ElementsDictionary.Clear();
     NodesDictionary.Clear();
     GlobalDofOrdering = null;
     Constraints.Clear();
     ElementMassAccelerationHistoryLoads.Clear();
     ElementMassAccelerationLoads.Clear();
     MassAccelerationHistoryLoads.Clear();
     MassAccelerationLoads.Clear();
 }
コード例 #6
0
        public override void OnLoadData()
        {
            base.OnLoadData();

            if (managers.loading.currentMode == AppMode.Game)
            {
                try
                {
                    TaxiMod.ClearTaxiBuildings();
                    TransferManagerMod.ClearBuildingToBuildingExclusions();

                    Datav4 data;

                    // Always try to load the latest version if possible.
                    if (Datav4.TryLoadData(this, out data))
                    {
                        Constraints.LoadData(data);
                    }
                    else if (Datav3.TryLoadData(this, out data))
                    {
                        Constraints.LoadData(data);
                    }
                    else if (Datav2.TryLoadData(this, out data))
                    {
                        Constraints.LoadData(data);
                    }
                    else if (Datav1.TryLoadData(this, out data))
                    {
                        Constraints.LoadData(data);
                    }
                    else
                    {
                        Constraints.Clear();
                    }

                    // Update Taxi buildings cache ...
                    // TODO, FIXME: Make this less hacky ...
                    var buildings = Utils.GetSupportedServiceBuildings();
                    foreach (var building in buildings)
                    {
                        TaxiMod.RegisterTaxiBuilding(building);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                }
            }
        }
コード例 #7
0
ファイル: CallScope.cs プロジェクト: sukitha/twilio-net
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 public CallScope()
     : base()
 {
     DisplayName = "Call Scope";
     Constraints.Clear();
 }
コード例 #8
0
 public void SetConstraints(IEnumerable <LinearConstraint> constraints)
 {
     Constraints.Clear();
     Constraints.AddRange(constraints);
 }