Permalink
Browse files

Faster W'bal algorithm

Using Andy Froncioni's modification to the original
formula that removes the need for Tau and also lets
the exponentials drop out.

Massive speed improvement!
  • Loading branch information...
liversedge committed Apr 24, 2014
1 parent 900319b commit d75c088938471164a13e7cee75090ec88ac48bf6
Showing with 25 additions and 44 deletions.
  1. +2 −1 src/DBAccess.cpp
  2. +23 −43 src/WPrime.cpp
View
@@ -90,8 +90,9 @@
// 69 23 Mar 2014 Mark Liversedge Updated Gompertz constansts for An-TISS sigmoid
// 70 27 Mar 2014 Mark Liversedge Add file CRC to refresh only if contents change (not just timestamps)
// 71 14 Apr 2014 Mark Liversedge Added average lef/right vector metrics (Pedal Smoothness / Torque Effectiveness)
// 72 24 Apr 2014 Mark Liversedge Andy Froncioni's faster algorithm for W' bal
int DBSchemaVersion = 71;
int DBSchemaVersion = 72;
DBAccess::DBAccess(Context* context) : context(context), db(NULL)
{
View
@@ -185,33 +185,22 @@ WPrime::setRide(RideFile *input)
values.resize(last+1);
xvalues.resize(last+1);
QVector<double> myvalues(last+1);
int stop = last / 2;
WPrimeIntegrator a(inputArray, 0, stop, TAU);
WPrimeIntegrator b(inputArray, stop+1, last, TAU);
double W = WPRIME;
for (int t=0; t<=last; t++) {
a.start();
b.start();
if(smoothed.value(t) < CP) {
W = W + (CP-smoothed.value(t))*(WPRIME-W)/WPRIME;
} else {
W = W + (CP-smoothed.value(t));
}
a.wait();
b.wait();
if (W > maxY) maxY = W;
if (W < minY) minY = W;
// sum values
for (int t=0; t<=last; t++) {
values[t] = a.output[t] + b.output[t];
values[t] = W;
xvalues[t] = double(t) / 60.00f;
}
// now subtract WPRIME and work out minimum etc
for(int t=0; t <= last; t++) {
double value = WPRIME - values[t];
values[t] = value;
if (value > maxY) maxY = value;
if (value < minY) minY = value;
}
if (minY < -30000) minY = 0; // the data is definitely out of bounds!
// so lets not excacerbate the problem - truncate
@@ -357,33 +346,24 @@ WPrime::setErg(ErgFile *input)
values.resize(last+1);
xvalues.resize(last+1);
QVector<double> myvalues(last+1);
int stop = last / 2;
WPrimeIntegrator a(inputArray, 0, stop, TAU);
WPrimeIntegrator b(inputArray, stop+1, last, TAU);
double W = WPRIME;
for (int t=0; t<=last; t++) {
a.start();
b.start();
if(smoothed.value(t) < CP) {
W = W + (CP-smoothed.value(t))*(WPRIME-W)/WPRIME;
} else {
W = W + (CP-smoothed.value(t));
}
a.wait();
b.wait();
if (W > maxY) maxY = W;
if (W < minY) minY = W;
// sum values
for (int t=0; t<=last; t++) {
values[t] = a.output[t] + b.output[t];
xvalues[t] = t * 1000;
values[t] = W;
xvalues[t] = double(t) / 60.00f;
}
// now subtract WPRIME and work out minimum etc
for(int t=0; t <= last; t++) {
double value = WPRIME - values[t];
values[t] = value;
if (value > maxY) maxY = value;
if (value < minY) minY = value;
}
if (minY < -30000) minY = 0; // the data is definitely out of bounds!
// so lets not excacerbate the problem - truncate
// STEP 3: FIND MATCHES

0 comments on commit d75c088

Please sign in to comment.