Optimally allocating a resource with time-varying demand and cost
Styling

I don't think PEP8 actually says anything about this, but I prefer to have spaces after commas in just about anything.  The comma is a way of separating two items, but sometimes it just isn't enough and other times it just looks squashed without the space.  You should not, however, put spaces around the = sign in all cases.  From PEP8:


  Don't use spaces around the = sign when used to indicate a keyword argument or a default parameter value. 


You break that rule in the definition of discretise().

Again from PEP8:


  Use the function naming rules: lowercase with words separated by underscores as necessary to improve readability.


That is under the title Method Names and Instance Variables.  Classes should be PascalCase, but your variables should be as defined above.  Your variables, T, H, V, and X should have more descriptive names besides the fact that they should be lowercase.  I realize that you use v in val(), but if you gave more descriptive names to your variables, there wouldn't be a clash.


v = min(no_pump  , pump   )



What are you doing with all that whitespace?  It should look like this:

v = min(no_pump, pump)


You have many cases of things such as i+1, ii/10.0, etc.  PEP8 doesn't actually say anything against that, but my opinion is that you should use whitespace around the operators unless it makes something look confusing.  For example, a*b + c*d would look confusing if there were spaces around the asterisks, but in the case of val(ii/10.0), for example, I would prefer it to be val(ii / 10.0).

The logic


def record(D,key,item):
    if key in D.keys():
        D[key].append(item)
    else:
        D[key] = [item]



That function could be simplified to this:

def record(D, key, item):
    D.setdefault(key, []).append(item)


Take a look at the docs.  If you wanted to leave it how it was, though, you could still take out the .keys() part of the if statement.  Turning a dictionary into an iterator, which in does, turns it into an iterator of its keys.


def memoize(*args):
    cache = {}

    def memoizedFunction(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]

    memoizedFunction.cache = cache
    return memoizedFunction



Using memoizedFunction.cache = cache isn't helping you here.  You aren't even using it.  You might be better off defining a class:

class Memoize:
    def __init__(self, function):
        self.function = function
        self.cache = {}

    def __call__(self, *args):
        if args not in self.cache:
            self.cache[args] = self.function(*args)
        return self.cache[args]


I changed the name to Memoize to comply with PEP8, but that just means that you need to change @memoize to @Memoize.


        #           pump off         pump on    



It isn't clear to me what that comment is saying.  The pump on part goes beyond the end of the next line.  If you meant it to be a comment on a different line, you should move it.


v = min(no_pump  , pump   )

# record optimal policy 
if v == no_pump:
    pos = 0
else:
    pos = 1



Here would be a good use of the cmp() function:

v = cmp(no_pump, pump)
if v &lt;= 0:
    pos = 0
else:
    pos = 1



ts = time.time()
...
te = time.time()



I can tell from the last line, print te - ts that those are meant to stand for time start and time end, but why not spell it out?  In this case it's fairly easy to tell what they are for, but it's a good habit to make your variable names very clear.  I would define them as start_time and end_time.