Exemplo n.º 1
0
        public override void GeneratePossibleResourceStatus()
        {
            foreach (Movement m in DataRepository.MovementList)
            {
                if (m is VehicleWaitingMovement)
                {
                    VehicleWaitingMovement vwm = m as VehicleWaitingMovement;
                    if (vwm.BindingVehicle == this)
                    {
                        VehicleStatus status = new VehicleStatus()
                        {
                            Location = vwm.FromLocation, HandlingMovement = m
                        };
                        PossibleResourceStatus.Add(status);
                    }
                }
                else if (m is TrainSegmentMovement)
                {
                    VehicleStatus status = new VehicleStatus()
                    {
                        Location = m.FromLocation, HandlingMovement = m
                    };
                    PossibleResourceStatus.Add(status);

                    status = new VehicleStatus()
                    {
                        Location = m.ToLocation, HandlingMovement = m
                    };
                    PossibleResourceStatus.Add(status);

                    status = new VehicleStatus()
                    {
                        Location = Parameters.VirtualOnWayLocation, HandlingMovement = m
                    };
                    PossibleResourceStatus.Add(status);
                }
            }
        }
Exemplo n.º 2
0
        public void Preprocess()
        {
            // generate movement
            DateTime startTime = DateTime.Now;

            // normal movement
            foreach (Train tr in DataRepository.TrainList)
            {
                tr.GenerateCandidateMovement();
            }

            // vehicle waiting movement
            foreach (Resource r in DataRepository.ResourceList)
            {
                if (r is Vehicle)
                {
                    foreach (Location sta in DataRepository.LocationList)
                    {
                        if (!(sta is Station))
                        {
                            continue;
                        }
                        for (int t = 0; t <= Parameters.TimeHorizon; t++)
                        {
                            VehicleWaitingMovement m = new VehicleWaitingMovement()
                            {
                                ID             = DataRepository.MovementList.Count.ToString(),
                                BindingVehicle = (Vehicle)r,
                                FromLocation   = sta,
                                ToLocation     = sta,
                                FromTime       = t,
                                ToTime         = t,
                            };
                            DataRepository.MovementList.Add(m);
                        }
                    }
                }
            }

            // possible resource status
            Parallel.ForEach <Resource>(DataRepository.ResourceList, r =>
                                        //foreach (Resource r in DataRepository.ResourceList)
            {
                r.GeneratePossibleResourceStatus();
            }
                                        );

            // resource selection for movements
            Parallel.ForEach <Movement>(DataRepository.MovementList, m =>
                                        //foreach (Movement m in DataRepository.MovementList)
            {
                m.GenerateResourceSelectionGroup();
            }
                                        );

            // time dependent resource possibility for resources
            Parallel.ForEach <Resource>(DataRepository.ResourceList, r =>
                                        //foreach (Resource r in DataRepository.ResourceList)
            {
                r.GenerateTimeDependentPossibleResourceStatus();
            }
                                        );

            // output debug data
            if (Parameters.DebugLog)
            {
                DataRepository.OutputMovements();
                DataRepository.OutputResourceStatus();
                DataRepository.OutputMovementResource();
            }

            Console.WriteLine("Preprocessing time: {0}", (DateTime.Now - startTime).TotalSeconds);
        }