From a801f5aec8fd2845ffb855e32062e586ccbd6019 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Tue, 29 Apr 2014 21:02:20 +0100 Subject: [PATCH] Andy Froncioni W'bal optiimsation (contd) .. forgot to remove the threaded integrator which is no longer needed and then found it is still being used by the minForCP() method, so tidied that up. --- src/WPrime.cpp | 81 +++++--------------------------------------------- src/WPrime.h | 17 ----------- 2 files changed, 8 insertions(+), 90 deletions(-) diff --git a/src/WPrime.cpp b/src/WPrime.cpp index b8487f0fa..641b2568b 100644 --- a/src/WPrime.cpp +++ b/src/WPrime.cpp @@ -466,61 +466,21 @@ WPrime::PCP() int WPrime::minForCP(int cp) { - QTime time; // for profiling performance of the code - time.start(); - - // input array contains the actual W' expenditure - // and will also contain non-zero values - double tau; - double totalBelowCP=0; - double countBelowCP=0; - QVector inputArray(last+1); - for (int i=0; i cp ? value-cp : 0; - - if (value < cp) { - totalBelowCP += value; - countBelowCP++; - } - } - - if (countBelowCP > 0) - tau = 546.00f * pow(E,-0.01*(CP - (totalBelowCP/countBelowCP))) + 316.00f; - else - tau = 546.00f * pow(E,-0.01*(CP)) + 316.00f; - - tau = int(tau); // round it down - - // STEP 2: ITERATE OVER DATA TO CREATE W' DATA SERIES // lets run forward from 0s to end of ride int min = WPRIME; - QVector myvalues(last+1); + double W = WPRIME; + for (int t=0; t<=last; t++) { - int stop = last / 2; + if(smoothed.value(t) < cp) { + W = W + (cp-smoothed.value(t))*(WPRIME-W)/WPRIME; + } else { + W = W + (cp-smoothed.value(t)); + } - WPrimeIntegrator a(inputArray, 0, stop, tau); - WPrimeIntegrator b(inputArray, stop+1, last, tau); - - a.start(); - b.start(); - - a.wait(); - b.wait(); - - // sum values - for (int t=0; t<=last; t++) - myvalues[t] = a.output[t] + b.output[t]; - - // now subtract WPRIME and work out minimum etc - for(int t=0; t <= last; t++) { - double value = WPRIME - myvalues[t]; - if (value < min) min = value; + if (W < min) min = W; } - //qDebug()<<"compute time="< &source, int begin, int end, double TAU) : - source(source), begin(begin), end(end), TAU(TAU) -{ - output.resize(source.size()); -} - -void -WPrimeIntegrator::run() -{ - // run from start to stop adding decay to end - for (int t=begin; t &source, int begin, int end, double TAU); - - // integrate from start to stop from source into output - // basically sums in the exponential decays, but we break it - // into threads to parallelise the work - void run(); - - QVector &source; - int begin, end; - double TAU; - - // resized to match source holds results - QVector output; -}; #endif