Contenuto principale

generateDriveCycles

R2026b

Generate RDE-compliant drive cycles

Since R2024b

    Description

    generateDriveCycles(obj) generates the number of drive cycles specified by the NTrips property that satisfy all configured UNECE Real Driving Emissions (RDE) constraints. The function exports generated drive cycles as CSV files to OutputFolder and stores them in the Data property of the RDE.DriveCycles object.

    Note

    Every property must be set before calling generateDriveCycles. If any property is unset, the function returns an Index exceeds array bounds error.

    example

    Examples

    collapse all

    Create an RDE.DriveCycles object, configure parameters, and generate compliant drive cycles.

    DriveCycles = RDE.DriveCycles;
    
    % Trip Structure (speed bins: urban <=60, rural 60-90, motorway >90 km/h)
    DriveCycles.dt = 1;
    DriveCycles.StopSpeedTh = 1/3.6;
    DriveCycles.OperationModeBoundaries = [60 90]/3.6;
    
    % Distance Composition (fraction of total trip distance per segment)
    DriveCycles.UrbanRatioRange = [0.29 0.44];
    DriveCycles.RuralRatioRange = [0.23 0.43];
    DriveCycles.MotorwayRatioRange = [0.23 0.43];
    
    % Speed Constraints (average and limit speeds per segment)
    DriveCycles.MotorwayUsualMaxSpeed = 145/3.6;
    DriveCycles.MotorwayAbsoluteSpeedTimeRatio = 0.03;
    DriveCycles.MotorwayAbsoluteMaxSpeed = 160/3.6;
    DriveCycles.UrbanAverageSpeedRange = [15 40]/3.6;
    DriveCycles.RuralAverageSpeedRange = [60 90]/3.6;
    DriveCycles.MotorwayAverageSpeedRange = [90 145]/3.6;
    DriveCycles.MotorwayUsualMinSpeed = 100/3.6;
    DriveCycles.MotorwayUsualMinSpeedTime = 5*60;
    
    % Urban Stop Conditions (stop = speed <= StopSpeedTh)
    DriveCycles.UrbanStopRatioRange = [0.06 0.3];
    DriveCycles.UrbanMinStopTime = 10;
    DriveCycles.UrbanMinStopCount = 2;
    
    % Trip Duration and Distance (90-120 min, >=16 km per segment)
    DriveCycles.TripDurationRange = [90 120]*60;
    DriveCycles.UrbanMinDistance = 16000;
    DriveCycles.RuralMinDistance = 16000;
    DriveCycles.MotorwayMinDistance = 16000;
    
    % VA95 Dynamic Boundary (upper limit - trip invalid if too aggressive)
    DriveCycles.VA95VelocityThreshold = 74.6/3.6;
    DriveCycles.VA95BoundarySpeedCoeff1 = 0.136;
    DriveCycles.VA95BoundaryBias1 = 14.44;
    DriveCycles.VA95BoundarySpeedCoeff2 = 0.0742;
    DriveCycles.VA95BoundaryBias2 = 18.966;
    
    % RPA Dynamic Boundary (lower limit - trip invalid if too passive)
    DriveCycles.RPAVelocityThreshold = 94.05/3.6;
    DriveCycles.RPABoundarySpeedCoeff = -0.0016;
    DriveCycles.RPABoundaryBias = 0.1755;
    DriveCycles.RPALowerBound = 0.025;
    
    % Generation Parameters (shape: lower = more aggressive; window: higher = smoother)
    DriveCycles.ShapeParameter = 1;
    DriveCycles.SmoothingMethod = 'rloess';
    DriveCycles.SmoothingWindowLength = 5;
    DriveCycles.NTrips = 4;
    DriveCycles.NumberOfIterations = 10000;
    DriveCycles.OutputFolder = fullfile(pwd(),'results');
    
    generateDriveCycles(DriveCycles);

    Input Arguments

    collapse all

    RDE drive cycle generator object, specified as an RDE.DriveCycles object with all required properties configured.

    Algorithms

    For each of the NTrips trips, the generateDriveCycles function completes these steps:

    1. Retrieves constraint function handles for all configured RDE boundary conditions.

    2. Generates a candidate trip using a gamma probability distribution parameterized by ShapeParameter to produce velocity samples. The function then smooths the velocity profile using smoothdata with the specified SmoothingMethod and SmoothingWindowLength.

    3. Evaluates the candidate trip against all constraints: trip duration, distance composition, average speeds, stop conditions, 95th percentile velocity times positive acceleration (VA95) high dynamic boundary, and relative positive acceleration (RPA) low dynamic boundary.

    4. If the candidate trip does not satisfy all constraints, the function repeats steps 2 and 3 up to NumberOfIterations times.

    5. Exports the valid trip as a timetable and writes it to a CSV file in OutputFolder.

    If the output folder specified by OutputFolder does not exist, the function creates the folder automatically.

    Version History

    Introduced in R2024b