本文整理汇总了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 ) );
}
示例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;
}
}
}