plan_file_parser.py
Go to the documentation of this file.
00001 import re
00002 
00003 def makespanFromPlan(plan):
00004     """ Plan is a list of (start, op, duration)
00005         Return the makespan of the plan. """
00006     latest_timestamp = -1
00007     for (st, op, dur) in plan:
00008         ts = st + dur
00009         if ts > latest_timestamp:
00010             latest_timestamp = ts
00011     assert latest_timestamp >= 0
00012     return latest_timestamp
00013 
00014 def parsePlan(file):
00015     # Matches: start_time: (some action stuff) [duration]
00016     exp = "([0-9\\.]+) *: *\\(([a-zA-Z0-9\\-_ ]+)\\) *\\[([0-9\\.]+)\\]"
00017     with open(file, "r") as f:
00018         for line in f:
00019             line = line.strip()
00020             if not line or line.startswith(";"):    # empty lines, comments start with ;
00021                 continue
00022             m = re.match(exp, line)
00023             if not m:
00024                 print "NO MATCH FOR", line
00025             start_time = (float)(m.group(1))
00026             op = m.group(2)
00027             duration = (float)(m.group(3))
00028             yield (start_time, op, duration)
00029 
00030 


planner_benchmarks
Author(s): Multiple
autogenerated on Mon Oct 6 2014 07:51:52