Exemple #1
0
            private double GetWeightedObjValue(Connection C, TravelMode Modes)
            {
                double Time = C.GetTravelTime(Date, ArrivalTime[C.GetSource()], Modes);

                /* GetTravelTime returns an infinity time if the route should not be considered */
                if (Time != double.PositiveInfinity)
                {
                    if (C is RConnection)
                    {
                        //Time *= routerFactors.WalkingFactor;
                        Time += 30; //TEST
                    }
                    else if (C is TConnection)
                    {
                        /* This is a fix introduced in order to skip the Mobalt buses (which are considered carpooling means) if the weight is >=50 */
                        if (string.Compare(C.GetTimeTable().Entries.First().AgencyId, "Mobalt###Mobalt") == 0)
                        {
                            if (routerFactors.CarpoolingFactor >= 50)
                            {
                                return(double.PositiveInfinity);
                            }
                        }

                        if (Parent[C.GetSource()] != null)
                        {
                            if (Parent[C.GetSource()] is TConnection)
                            {
                                TConnection PC = Parent[C.GetSource()] as TConnection;
                                if ((C as TConnection).TimeTable.RouteId != PC.TimeTable.RouteId)
                                {
                                    //Time *= routerFactors.TransportationChangeFactor; //BUG!!! If Time==0 => no delay added for transportation changes
                                    Time  = (Time > 60) ? Time : 60; // since we have 1 minute step, add 1 minute delay if the original Time is 0 and we have a transportation change
                                    Time *= routerFactors.TransportationChangeFactor;
                                    //Time += routerFactors.TransportationChangeFactor; //TEST add X seconds for each PT change
                                }
                            }

                            Time *= routerFactors.TransportationFactor;
                            //Time += routerFactors.TransportationFactor*3; //TEST add X seconds for each PT change
                        }
                    }
                    else if (C is CConnection)
                    {
                        if (Parent[C.GetSource()] != null)
                        {
                            if (Parent[C.GetSource()] is CConnection)
                            {
                                CConnection PC = Parent[C.GetSource()] as CConnection;

                                Time *= routerFactors.CarpoolingFactor;

                                if ((string.Compare(C.GetCarpoolerId(), PC.GetCarpoolerId()) != 0))
                                {
                                    return(double.PositiveInfinity);
                                }
                            }
                        }
                    }
                }

                double ObjValue = minObjValue + Time;

                return(ObjValue);
            }