Help calculating fastest curve to get to target value with constraints

32 Views Asked by At

I apologize ahead of time for not knowing the right terminology to ask this question well...

I am trying to calculate a table of values using the "fastest" ramp/rate/curve based on specified limits over a period (time).

For example, assuming I have a starting value of 3000 and a target of 2000 over 10 days, so the LINEAR data would look like so: (from python pandas testing I am playing with)

rt = { "y": [3000, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, 2000]}
test = pd.DataFrame(rt)
d2 = test.interpolate('linear')
d2

0  3000.00
1  2888.88
2  2777.77
3  2666.66
4  2555.55
5  2444.44
6  2333.33
7  2222.22
8  2111.11
9  2000.00

I am wanting to calculate the curve representing the fastest rate of change with limits, for example where maxDailyChange = 350 such that no daily value change is > maxDailyChange

I do not know what to call this, I am sure there is a name, terminology...

In a perfect scenario, or perhaps another option, the curve would be smoothed, such that the
rate of change was relative to the remaining distance to target ? (again, my lack of understanding makes it hard to describe well)

I am using python pandas and numpy to play around with the problem, but any help just understanding the problem would be of great help !

Cheers and thank you for any insight !

1

There are 1 best solutions below

1
On

I think I have found a suitable method for what I was looking for. I remembered using a Savitsky-Golay filter previously for smoothing interpolated missing values, and it turns out this function provides the desired result (or at least close enough).

Given the following data:

data = { "linear": [3000, 2888.88, 2777.77, 2666.66, 2555.55, 2444.44, 2333.33, 2222.22, 2111.11, 2000] },
         "linearsgol": [3040.454545, 2845.30303, 2668.712121, 2510.681818, 2371.212121, 2250.30303, 2147.954545, 2064.166667, 1998.939394, 1952.272727] },
         "fastest": [3000, 2800, 2600, 2400, 2200, 2000, 2000, 2000, 2000, 2000] },
         "fastestsgol": [3045.454545, 2778.787879, 2550, 2359.090909, 2206.060606, 2090.909091, 2013.636364, 1974.242424, 1972.727273, 2009.090909]
        } 

Where "fastest" is a simply a vector using the fastest possible rate, until the target is reached (target=2000),

and the maximum rate of change is 200,

applying the Savitsky-Golay filter to the "fastest" curve gives I think what I am looking for - which I think is a "Brachistochrone curve" ??

Plot of results