import pickle


def read_analysis_files(pathnames):
    """Reads in simulation analysis files (as produced by pathsim_analysis.py).
    Returns list of start times, end times, and statistics."""
    
    start_time = None
    end_time = None
    compromise_stats = []
    for pathname in pathnames:
        with open(pathname, 'rb') as f:
            new_start_time = pickle.load(f)
            new_end_time = pickle.load(f)
            new_compromise_stats = pickle.load(f)
            if (start_time == None):
                start_time = new_start_time
            else:
                start_time = min(start_time, new_start_time)
            if (end_time == None):
                end_time = new_end_time
            else:
                end_time = min(end_time, new_end_time)
            compromise_stats.extend(new_compromise_stats)
    return (start_time, end_time, compromise_stats)