Exemplo n.º 1
0
        /// <summary>
        /// Schedule all train in an enumeration diregarding resource occupation and connections
        /// </summary>
        protected void BasicSchedule(IEnumerable <TrainRun> trains)
        {
            foreach (var trainRun in trains)
            {
                var train = CurrentProblem.GetTrain(trainRun.ServiceIntentionId);
                // ----------------------------------------------------
                for (int k = 0; k < trainRun.TrainRunSections.Count; ++k)
                {
                    var thisSection = trainRun.TrainRunSections[k];
                    var nextSection = (k < trainRun.TrainRunSections.Count - 1)
                  ? trainRun.TrainRunSections[k + 1]
                  : null;

                    // ------------------------------------------------
                    // Is there a min entry/exit time
                    var thisRequirement = train.GetRequirement(thisSection.SectionMarker);
                    var nextRequirement = train.GetRequirement(nextSection?.SectionMarker);

                    // ------------------------------------------------
                    // Start time is always last exit time unless this is the first section
                    thisSection.EntryTime = k > 0 ? trainRun.TrainRunSections[k - 1].ExitTime : thisRequirement.EntryEarliest;

                    // ------------------------------------------------
                    // Set exit time
                    thisSection.ExitTime = Math.Max(thisRequirement.ExitEarliest,
                                                    thisSection.EntryTime + thisSection.MinimumRunningTime +
                                                    thisRequirement.MinStoppingTime);

                    // Consider minEntryTime for next section
                    thisSection.ExitTime = Math.Max(thisSection.ExitTime, nextRequirement.EntryEarliest);
                }
            }
        }
Exemplo n.º 2
0
        public int GetSize()
        {
            if (this.MinSize == this.MaxSize)
            {
                return(this.MinSize);
            }

            int maxSteps = (this.MaxSize - this.MinSize) / this.SizeStep;

            return(this.MinSize + (int)(Math.Random() * maxSteps) * this.SizeStep);
        }