コード例 #1
0
        /// <summary>
        /// Calculates the U of the facilitated trip
        /// </summary>
        /// <param name="tripChain"></param>
        /// <param name="oldU"></param>
        /// <param name="newU"></param>
        public void CalculateU(ITripChain tripChain, out double oldU, out double newU)
        {
            ITrip       facilitatedTrip     = (ITrip)tripChain["FacilitateTrip"];
            ISharedMode facilitatedTripMode = (ISharedMode)tripChain["SharedMode"];
            ITrip       connectingTrip      = tripChain["ConnectingChain"] as ITrip;

            //the mode data for the facilitated trip
            ModeData facilitatedTripData = ModeData.Get(facilitatedTrip);
            int      indexOfPass         = TashaRuntime.GetIndexOfMode(facilitatedTripMode);
            double   UofAuxiliaryTrip    = CalculateUofAuxTrip(tripChain);

            facilitatedTripData.V[indexOfPass] = facilitatedTripMode.CalculateV(facilitatedTrip);

            newU = facilitatedTripData.U(indexOfPass)
                   + UofAuxiliaryTrip;
            if (facilitatedTrip.Mode == null)
            {
                // if there is no other way
                oldU = float.NegativeInfinity;
            }
            else
            {
                if (connectingTrip == null)
                {
                    oldU = facilitatedTripData.U(TashaRuntime.GetIndexOfMode(facilitatedTrip.Mode));
                }
                else
                {
                    ModeData connectingTripData = ModeData.Get(connectingTrip);
                    oldU = facilitatedTripData.U(TashaRuntime.GetIndexOfMode(facilitatedTrip.Mode))
                           + connectingTripData.U(TashaRuntime.GetIndexOfMode(connectingTrip.Mode));
                }
            }
        }
コード例 #2
0
        private double CalculateUofAuxTrip(ITripChain currentTripChain)
        {
            double U = 0;

            for (int i = 0; i < currentTripChain.Trips.Count; i++)
            {
                var      trip = currentTripChain.Trips[i];
                ModeData md   = ModeData.MakeModeData();
                md.Store(trip);
                int indexOfMode = TashaRuntime.GetIndexOfMode(trip.Mode);
                md.V[indexOfMode]     = trip.Mode.CalculateV(trip);
                md.Error[indexOfMode] = this.GetNormal();
                U += md.U(indexOfMode);
            }
            currentTripChain.Attach("U", U);
            return(U);
        }