当前位置: 首页>>代码示例>>C#>>正文


C# ITashaHousehold.NumberOfVehicleAvailable方法代码示例

本文整理汇总了C#中ITashaHousehold.NumberOfVehicleAvailable方法的典型用法代码示例。如果您正苦于以下问题:C# ITashaHousehold.NumberOfVehicleAvailable方法的具体用法?C# ITashaHousehold.NumberOfVehicleAvailable怎么用?C# ITashaHousehold.NumberOfVehicleAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITashaHousehold的用法示例。


在下文中一共展示了ITashaHousehold.NumberOfVehicleAvailable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: numVehiclesAvailable

 /// <summary>
 /// Gets if the requested vehicle is available (Excluding auxiliary trips)
 /// </summary>
 /// <param name="veqType"></param>
 /// <param name="start"></param>
 /// <param name="end"></param>
 /// <param name="hh"></param>
 /// <returns></returns>
 public int numVehiclesAvailable(IVehicleType veqType, Time start, Time end, ITashaHousehold hh)
 {
     return ( hh.NumberOfVehicleAvailable( new TashaTimeSpan( start, end ), veqType, false ) );
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:12,代码来源:ResourceAvailabilityModified.cs

示例2: AssignJointTours

 public void AssignJointTours(ITashaHousehold household)
 {
     ITashaMode rideShare = null;
     int rideShareIndex = -1;
     var allModes = this.Root.AllModes;
     var numberOfModes = allModes.Count;
     for ( int i = 0; i < numberOfModes; i++ )
     {
         if ( ( allModes[i] is ISharedMode ) && allModes[i].ModeName == "RideShare" )
         {
             rideShare = allModes[i];
             rideShareIndex = i;
         }
     }
     //no rideshare mode?
     if ( rideShare == null )
     {
         return;
     }
     //go through each joint tour and assign identical modes for each tripchain in a tour if possible
     foreach ( var element in household.JointTours )
     {
         List<ITripChain> tripChains = element.Value;
         IList<ITashaMode> nonVehicleModesChosen;
         double nonVehicleU;
         //does a non vehicle tour exist
         bool nonVehicleTour = BestNonVehicleModeSetForTour( tripChains, out nonVehicleModesChosen, out nonVehicleU );
         //the potential driver in this tour
         ITashaPerson potentialDriver = null;
         //finding potential driver who already has the car
         foreach ( var tripChain in tripChains )
         {
             if ( tripChain.requiresVehicle.Contains( rideShare.RequiresVehicle ) )
             {
                 potentialDriver = tripChain.Person;
                 break;
             }
         }
         //if no one has the car check if one is available
         if ( potentialDriver == null )
         {
             if ( household.NumberOfVehicleAvailable(
                 new TashaTimeSpan( tripChains[0].StartTime, tripChains[0].EndTime ), rideShare.RequiresVehicle, false ) > 0 )
             {
                 foreach ( var tc in tripChains )
                 {
                     if ( rideShare.RequiresVehicle.CanUse( tc.Person ) )
                     {
                         potentialDriver = tc.Person;
                         break;
                     }
                 }
             }
         }
         //No potential driver and no nonVehicle tour means that ppl in this tour have to take different modes which shouldnt happen
         if ( ( potentialDriver == null ) & ( !nonVehicleTour ) )
         {
             continue;
         }
         double oldU = Double.MinValue;
         if ( nonVehicleTour )
         {
             oldU = nonVehicleU;
         }
         //no driver, go to next tour
         if ( potentialDriver == null )
         {
             continue;
         }
         double newU = 0.0;
         bool success = true;
         /*
          * Now we assign the rideshare mode and if the total U of everyone using rideshare is less than that
          * of a non personal vehicle mode, everyone uses rideshare
          *
          */
         foreach ( var tripChain in tripChains )
         {
             foreach ( var trip in tripChain.Trips )
             {
                 ModeData md = (ModeData)trip.GetVariable( "MD" );
                 trip.Mode = rideShare;
                 trip.CalculateVTrip();
                 newU += md.U( rideShareIndex );
             }
             if ( !tripChain.Feasible() )
             {
                 success = false;
                 break;
             }
         }
         //reset modes
         if ( ( !success || newU <= oldU ) & ( nonVehicleTour ) )
         {
             SetModes( tripChains, nonVehicleModesChosen );
             //go to next joint trip
             continue;
         }
     }
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:100,代码来源:ModeChoiceAssignObservedMode.cs


注:本文中的ITashaHousehold.NumberOfVehicleAvailable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。