Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit bb508da3 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

added IterationStatistics for performance measuring

parent f975d7fc
No related branches found
No related tags found
No related merge requests found
Job [-],Input File [-],Cycle [-],Status,Mass [kg],Loading [kg],time [s],distance [km],speed [km/h],altitudeDelta [m],FC-Map [g/h],FC-Map [g/km],FC-AUXc [g/h],FC-AUXc [g/km],FC-WHTCc [g/h],FC-WHTCc [g/km],FC-AAUX [g/h],FC-AAUX [g/km],FC-Final [g/h],FC-Final [g/km],FC-Final [l/100km],FC-Final [l/100tkm],CO2 [g/km],CO2 [g/tkm],P_wheel_in_pos [kW],P_brake_loss [kW],P_eng_out_pos [kW],P_eng_out_neg [kW],E_aux_FAN [kWh],E_aux_STP [kWh],E_aux_AC [kWh],E_aux_PS [kWh],E_aux_ES [kWh],E_aux_sum [kWh],E_air [kWh],E_roll [kWh],E_grad [kWh],E_inertia [kWh],E_brake [kWh],E_gbx_axl_loss [kWh],E_ret_loss [kWh],E_tc_loss [kWh],E_eng_out_pos [kWh],E_eng_out_neg [kWh],a [m/s^2],a_pos [m/s^2],a_neg [m/s^2],AccelerationTimeShare [%],DecelerationTimeShare [%],CruiseTimeShare [%],StopTimeShare [%]
2-0,12t Delivery Truck,LongHaul.vdri,Success,7750.0000,0.0000,4544.7743,100.1850,79.3584,-2.5494,14928.1995,188.1112,14928.1995,188.1112,15044.6394,189.5784,15044.6394,189.5784,15044.6394,189.5784,22.7859,,599.0678,,57.9544,0.8532,75.6554,-16.3708,0.8435,0.4672,0.2525,1.4900,2.2368,5.2901,50.6334,20.0004,-0.0512,0.0000,1.0772,15.9289,0.0000,0.0000,88.4933,-0.8804,0.0000,0.4627,-0.4662,4.3794,4.3134,0.0000,1.4742
2-1,12t Delivery Truck,LongHaul.vdri,Success,7750.0000,4150.0000,4574.5666,100.1850,78.8416,-2.5494,16547.5682,209.8838,16547.5682,209.8838,16676.6392,211.5209,16676.6392,211.5209,16676.6392,211.5209,25.4232,6.1261,668.4060,161.0617,66.6100,2.4444,86.0351,-15.8558,0.8490,0.4703,0.2542,1.4998,2.2515,5.3247,50.3756,29.4211,-0.0786,0.0000,3.1061,16.1961,0.0000,0.0000,100.0772,-1.0250,0.0000,0.4200,-0.4759,4.6568,4.0446,0.0000,1.4646
2-2,12t Delivery Truck,LongHaul.vdri,Success,7750.0000,4150.0000,4574.5666,100.1850,78.8416,-2.5494,16547.5682,209.8838,16547.5682,209.8838,16676.6392,211.5209,16676.6392,211.5209,16676.6392,211.5209,25.4232,6.1261,668.4060,161.0617,66.6100,2.4444,86.0351,-15.8558,0.8490,0.4703,0.2542,1.4998,2.2515,5.3247,50.3756,29.4211,-0.0786,0.0000,3.1061,16.1961,0.0000,0.0000,100.0772,-1.0250,0.0000,0.4200,-0.4759,4.6568,4.0446,0.0000,1.4646
2-3,12t Delivery Truck,RegionalDelivery.vdri,Success,7750.0000,0.0000,1580.7711,25.8360,58.8381,0.0101,10796.3012,183.4916,10796.3012,183.4916,10802.7790,183.6017,10802.7790,183.6017,10802.7790,183.6017,22.0675,,580.1814,,40.4898,2.2577,64.7531,-8.3571,0.3167,0.1406,0.0878,0.5622,0.6620,1.7693,10.7354,5.1202,-0.0001,0.0000,0.9913,4.0827,0.0000,0.0000,21.3940,-0.4322,0.0000,0.4901,-0.5314,13.9241,12.7848,0.0000,7.2117
2-4,12t Delivery Truck,RegionalDelivery.vdri,Success,7750.0000,2983.8900,1583.3376,25.8360,58.7427,0.0101,11907.2364,202.7014,11907.2364,202.7014,11914.3807,202.8230,11914.3807,202.8230,11914.3807,202.8230,24.3778,8.1698,640.9207,214.7937,46.7806,3.7696,75.9980,-11.2300,0.3172,0.1408,0.0880,0.5631,0.6631,1.7722,10.6922,6.8643,-0.0002,0.0000,1.6579,4.1756,0.0000,0.0000,24.1477,-0.7165,0.0000,0.4665,-0.5103,14.9810,13.4640,0.0000,7.2000
2-5,12t Delivery Truck,RegionalDelivery.vdri,Success,7750.0000,4150.0000,1584.9491,25.8360,58.6830,0.0101,12325.0194,210.0270,12325.0194,210.0270,12332.4144,210.1530,12332.4144,210.1530,12332.4144,210.1530,25.2588,6.0865,664.0836,160.0201,49.1906,4.3746,80.4332,-11.8038,0.3175,0.1409,0.0881,0.5637,0.6637,1.7740,10.6534,7.5320,-0.0002,0.0000,1.9260,4.2116,0.0000,0.0000,25.1871,-0.8189,0.0000,0.4431,-0.4858,15.9722,14.2677,0.0000,7.1927
2-6,12t Delivery Truck,UrbanDelivery.vdri,Aborted,7750.0000,0.0000,906.0032,4.9742,19.7651,-7.4125,4408.4726,223.0431,4408.4726,223.0431,4367.9147,220.9911,4367.9147,220.9911,4367.9147,220.9911,26.5614,,698.3320,,13.1643,5.0283,37.3407,-6.9963,0.1551,0.0781,0.0378,0.3324,0.3504,0.9537,0.5806,0.9857,-0.1559,0.0295,1.2655,0.8116,0.0000,0.0000,3.8777,-0.2921,0.0076,0.5538,-0.6160,20.9945,17.6796,0.0000,29.8428
2-7,12t Delivery Truck,UrbanDelivery.vdri,Aborted,7750.0000,2983.8900,686.4355,4.4473,23.3240,-6.5605,5871.9648,251.7561,5871.9648,251.7561,5817.9427,249.4399,5817.9427,249.4399,5817.9427,249.4399,29.9808,10.0475,788.2302,264.1620,20.5155,9.2052,50.6685,-7.5826,0.1175,0.0592,0.0286,0.2519,0.2655,0.7227,0.5563,1.1816,-0.1911,0.0290,1.7552,0.7508,0.0000,0.0000,4.4481,-0.2784,0.0100,0.5367,-0.6031,24.2336,20.0000,0.0000,21.4150
2-8,12t Delivery Truck,UrbanDelivery.vdri,Aborted,7750.0000,4150.0000,1995.5984,12.2235,22.0509,-7.3852,5664.0624,256.8634,5664.0624,256.8634,5611.9530,254.5002,5611.9530,254.5002,5611.9530,254.5002,30.5890,7.3708,804.2207,193.7881,19.8581,8.2179,52.3756,-8.3023,0.3416,0.1719,0.0832,0.7319,0.7715,2.1000,1.4655,3.5633,-0.2384,0.0294,4.5554,2.0750,0.0000,0.0000,12.5032,-0.8591,0.0035,0.5393,-0.5926,21.1028,18.7469,0.0000,25.9163
......@@ -44,6 +44,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
protected override IResponse DoSimulationStep()
{
IterationStatistics.StartIteration();
// estimate distance to be traveled within the next TargetTimeInterval
var ds = Container.VehicleSpeed.IsEqual(0)
? Constants.SimulationSettings.DriveOffDistance
......@@ -52,6 +54,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
var loopCount = 0;
IResponse response;
do {
IterationStatistics.Increment(this, "Iterations");
Container.BrakePower = 0.SI<Watt>();
response = CyclePort.Request(AbsTime, ds);
response.Switch().
......@@ -72,6 +76,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
}
} while (!(response is ResponseSuccess || response is ResponseCycleFinished));
IterationStatistics.Increment(this, "Distance", Container.Distance.Value());
IterationStatistics.Increment(this, "Time", AbsTime.Value());
IterationStatistics.FinishIteration(AbsTime);
return response;
}
......
......@@ -145,6 +145,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
}
Container.RunStatus = Status.Success;
Container.FinishSimulation();
IterationStatistics.FinishSimulation(RunName + CycleName + RunSuffix + RunIdentifier);
Log.Info("VectoJob finished.");
}
......
......@@ -144,6 +144,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun)
{
IterationStatistics.Increment(this, "Requests");
Log.Debug("Engine Powertrain Power Request: torque: {0}, angularVelocity: {1}, power: {2}", torque, angularVelocity,
torque * angularVelocity);
......
......@@ -32,6 +32,7 @@
using System;
using System.Diagnostics;
using System.Linq;
using iTextSharp.text.pdf;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......@@ -101,6 +102,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public IResponse Request(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient)
{
IterationStatistics.Increment(this, "Requests");
VehicleStopped = false;
Log.Debug("==== DRIVER Request (distance) ====");
Log.Debug(
......@@ -120,6 +124,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public IResponse Request(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient)
{
IterationStatistics.Increment(this, "Requests");
VehicleStopped = true;
Log.Debug("==== DRIVER Request (time) ====");
Log.Debug(
......@@ -152,6 +158,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public IResponse DrivingActionAccelerate(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient,
IResponse previousResponse = null)
{
IterationStatistics.Increment(this, "Accelerate");
Log.Debug("DrivingAction Accelerate");
var operatingPoint = ComputeAcceleration(ds, targetVelocity);
......@@ -229,6 +237,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// <returns></returns>
public IResponse DrivingActionCoast(Second absTime, Meter ds, MeterPerSecond maxVelocity, Radian gradient)
{
IterationStatistics.Increment(this, "Coast");
Log.Debug("DrivingAction Coast");
return CoastOrRollAction(absTime, ds, maxVelocity, gradient, false);
......@@ -244,6 +253,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// <returns></returns>
public IResponse DrivingActionRoll(Second absTime, Meter ds, MeterPerSecond maxVelocity, Radian gradient)
{
IterationStatistics.Increment(this, "Roll");
Log.Debug("DrivingAction Roll");
var retVal = CoastOrRollAction(absTime, ds, maxVelocity, gradient, true);
......@@ -345,6 +356,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public IResponse DrivingActionBrake(Second absTime, Meter ds, MeterPerSecond nextTargetSpeed, Radian gradient,
IResponse previousResponse = null, Meter targetDistance = null)
{
IterationStatistics.Increment(this, "Brake");
Log.Debug("DrivingAction Brake");
IResponse retVal = null;
......@@ -509,6 +521,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Default(r => { throw new UnexpectedResponseException("cannot use response for searching braking power!", r); });
try {
var iterations = 0;
DataBus.BrakePower = SearchAlgorithm.Search(DataBus.BrakePower, deltaPower, deltaPower.Abs(),
getYValue: result => {
var response = (ResponseDryRun)result;
......@@ -524,8 +537,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var response = (ResponseDryRun)result;
var delta = DataBus.ClutchClosed(absTime) ? response.DeltaDragLoad : response.GearboxPowerRequest;
return delta.Value();
});
},
iterationCount: ref iterations);
IterationStatistics.Increment(this, "SearchBrakingPower", iterations);
return operatingPoint;
} catch (Exception) {
Log.Error("Failed to find operating point for braking power! absTime: {0}", absTime);
throw;
......@@ -554,6 +571,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var delta = origDelta;
try {
var iterations = 0;
retVal.Acceleration = SearchAlgorithm.Search(acceleration, delta,
Constants.SimulationSettings.OperatingPointInitialSearchIntervalAccelerating,
getYValue: response => {
......@@ -583,13 +601,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var r = (ResponseDryRun)response;
delta = actionRoll ? r.GearboxPowerRequest : (coasting ? r.DeltaDragLoad : r.DeltaFullLoad);
return delta.Value();
});
},
iterationCount: ref iterations);
if (
!retVal.Acceleration.IsBetween(DriverData.AccelerationCurve.MaxDeceleration(),
DriverData.AccelerationCurve.MaxAcceleration())) {
Log.Info("Operating Point outside driver acceleration limits: a: {0}", retVal.Acceleration);
}
IterationStatistics.Increment(this, "SearchOperatingPoint", iterations);
return ComputeTimeInterval(retVal.Acceleration, retVal.SimulationDistance);
} catch (Exception) {
......
......@@ -215,10 +215,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// </returns>
public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun)
{
IterationStatistics.Increment(this, "Requests");
Log.Debug("Gearbox Power Request: torque: {0}, angularVelocity: {1}", torque, angularVelocity);
if (DataBus.VehicleStopped) {
_engageTime = absTime;
}
IResponse retVal;
// TODO: MQ 2016/03/10: investigate further the effects of having the condition angularvelocity != 0
if (ClutchClosed(absTime) /* && !angularVelocity.IsEqual(0) */) {
......
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using TUGraz.VectoCommon.Utils;
namespace TUGraz.VectoCore.Utils
{
public static class IterationStatistics
{
private static readonly ThreadLocal<List<DataEntry>> DataLocal = new ThreadLocal<List<DataEntry>>(() => new List<DataEntry>());
public static List<DataEntry> Data{get { return DataLocal.Value; }}
private static readonly ThreadLocal<Stopwatch> TimerLocal = new ThreadLocal<Stopwatch>(Stopwatch.StartNew);
private static Stopwatch Timer{get { return TimerLocal.Value; }}
private static readonly ThreadLocal<Dictionary<string, Dictionary<string, double>>> CurrentLocal =
new ThreadLocal<Dictionary<string, Dictionary<string, double>>>(
() => new Dictionary<string, Dictionary<string, double>>());
private static Dictionary<string, Dictionary<string, double>> Current
{
get { return CurrentLocal.Value; }
set { CurrentLocal.Value = value; }
}
[Conditional("TRACE")]
public static void Increment<T>(T o, string key, double? value = null)
{
var t = typeof(T).Name;
if (!Current.ContainsKey(t))
Current[t] = new Dictionary<string, double>();
if (Current[t].ContainsKey(key))
if (value.HasValue)
Current[t][key] += value.Value;
else
Current[t][key]++;
else {
if (value.HasValue)
Current[t][key] = value.Value;
else
Current[t][key] = 1;
}
}
public static void StartIteration()
{
Timer.Restart();
}
[Conditional("TRACE"), MethodImpl(MethodImplOptions.Synchronized)]
public static void FinishIteration(Second absTime)
{
Timer.Stop();
Data.Add(new DataEntry(absTime, Timer.Elapsed, Current));
Current = new Dictionary<string, Dictionary<string, double>>();
}
[Conditional("TRACE")]
public static void FinishSimulation(string runName)
{
var table = new DataTable();
table.Columns.Add("Distance", typeof(double));
table.Columns.Add("Time", typeof(double));
table.Columns.Add("StepDuration", typeof(double));
table.Columns.Add("StepIterationCount", typeof(double));
table.Columns.Add("NumDriverRequests", typeof(double));
table.Columns.Add("NumAccelActions", typeof(double));
table.Columns.Add("NumBrakeActions", typeof(double));
table.Columns.Add("NumCoastActions", typeof(double));
table.Columns.Add("NumRollActions", typeof(double));
table.Columns.Add("SearchOPIterations", typeof(double));
table.Columns.Add("SearchBrakeIterations", typeof(double));
table.Columns.Add("NumGearboxRequests", typeof(double));
table.Columns.Add("NumEngineRequests", typeof(double));
foreach (var entry in Data) {
var row = table.NewRow();
row["StepDuration"] = entry.Duration.TotalMilliseconds;
if (entry.Values.ContainsKey("DistanceRun")) {
row["Distance"] = entry.Values["DistanceRun"].ContainsKey("Distance") ? entry.Values["DistanceRun"]["Distance"] : 0;
row["Time"] = entry.Values["DistanceRun"].ContainsKey("Time") ? entry.Values["DistanceRun"]["Time"] : 0;
row["StepIterationCount"] = entry.Values["DistanceRun"].ContainsKey("Iterations") ? entry.Values["DistanceRun"]["Iterations"] : 0;
}
if (entry.Values.ContainsKey("Driver")) {
row["NumDriverRequests"] = entry.Values["Driver"].ContainsKey("Requests") ? entry.Values["Driver"]["Requests"] : 0;
row["NumAccelActions"] = entry.Values["Driver"].ContainsKey("Accelerate") ? entry.Values["Driver"]["Accelerate"] : 0;
row["NumBrakeActions"] = entry.Values["Driver"].ContainsKey("Brake") ? entry.Values["Driver"]["Brake"] : 0;
row["NumCoastActions"] = entry.Values["Driver"].ContainsKey("Coast") ? entry.Values["Driver"]["Coast"] : 0;
row["NumRollActions"] = entry.Values["Driver"].ContainsKey("Roll") ? entry.Values["Driver"]["Roll"] : 0;
row["SearchOPIterations"] = entry.Values["Driver"].ContainsKey("SearchOperatingPoint") ? entry.Values["Driver"]["SearchOperatingPoint"] : 0;
row["SearchBrakeIterations"] = entry.Values["Driver"].ContainsKey("SearchBrakingPower") ? entry.Values["Driver"]["SearchBrakingPower"] : 0;
}
if (entry.Values.ContainsKey("Gearbox")) {
row["NumGearboxRequests"] = entry.Values["Gearbox"].ContainsKey("Requests") ? entry.Values["Gearbox"]["Requests"] : 0;
}
if (entry.Values.ContainsKey("CombustionEngine")) {
row["NumEngineRequests"] = entry.Values["CombustionEngine"].ContainsKey("Requests") ? entry.Values["CombustionEngine"]["Requests"] : 0;
}
table.Rows.Add(row);
}
var writer = new StreamWriter("statistics_" + runName + ".csv");
VectoCSVFile.Write(writer, table);
}
public sealed class DataEntry
{
public readonly TimeSpan Duration;
public readonly Second Time;
public readonly Dictionary<string, Dictionary<string, double>> Values;
public DataEntry(Second time, TimeSpan duration, Dictionary<string, Dictionary<string, double>> values)
{
Time = time;
Duration = duration;
Values = values;
}
}
}
}
\ No newline at end of file
......@@ -202,6 +202,7 @@
</Compile>
<Compile Include="Utils\DataTableExtensionMethods.cs" />
<Compile Include="Utils\DateTimeFallbackDeserializer.cs" />
<Compile Include="Utils\IterationStatistics.cs" />
<Compile Include="Utils\RessourceHelper.cs" />
<Compile Include="Models\Declaration\Segment.cs" />
<Compile Include="Models\Declaration\Axle.cs" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment