def execute_schedule(day, sched, popt, initial_temperature):
    """
    sched is a list of (hsp, csp) setpoints at 30m intervals
    """
    output = []
    actions = []
    prev_temp = initial_temperature
    weather = predict_weather(day)
    print len(sched), len(weather)
    for idx, epoch in enumerate(sched):
        if prev_temp < epoch[0]: # hsp
            next_temp = next_temperature(popt, prev_temp, 1, weather[idx]) # 1 is heat
            actions.append(1)
        elif prev_temp > epoch[1]: # csp
            next_temp = next_temperature(popt, prev_temp, 2, weather[idx]) # 2 is cool
            actions.append(2)
        else:
            next_temp = next_temperature(popt, prev_temp, 0, weather[idx]) # 0 is off
            actions.append(0)
        print prev_temp, weather[idx], actions[-1], next_temp
        output.append(next_temp)
        prev_temp = next_temp

    return output, actions