def getSchedule(text): text = text.rstrip() lines = text.split('\n') points = [] for l in lines: nums = l.rstrip().split(' ') #print "nums: ", nums numericNums = [int(x) for x in nums] points.append(s.MultiPhasePoint(numericNums)) print "number of points: ", len(points) return s.SampleSchedule(points)
def runScheduleWorkflowTestWithPostSelectionModification( cgen, spec, qmap, psel, form, pmod): myLogger = logging.getLogger("workflow") myLogger.debug("starting workflow: generating coordinates") points = cgen() # generate some coordinates myLogger.debug('generated ' + str(len(points)) + ' points') # see how many were generated # mySet = set(points) # (l1, l2) = len(mySet), len(points) myLogger.debug("selecting special points") special = spec() # select special points normal = filterSpecialPoints( special, points) # make sure no special points are left in the normal pool myLogger.debug( "selected special points .... points left in normal pool: " + str(len(normal)) + " specially selected points: " + str(len(special))) myLogger.debug("applying quadrature ...") (normList, specList) = ( qmap(normal), qmap(special) ) # apply quadrature to both the normal pool and the special pool myLogger.debug("quadrature applied to normal and special points") numAlreadySelected = len( specList.getPoints() ) # number of points that still need to be selected: original minus number of special points myLogger.debug("selecting normal points (" + str(numAlreadySelected) + " already selected)") selectedList = psel( normList, numAlreadySelected) # select that many points from the normal list myLen = len(selectedList.getPoints()) + len( specList.getPoints() ) # the number of points selected is the number in the special list plus the number selected from the normal list myLogger.debug("selected " + str(myLen) + " points total (special + normal)") allSelectedPoints = selectedList.getMultiPhasePoints( ) + specList.getMultiPhasePoints() myLogger.debug( "applying any post-selection modification operators to selected points ..." ) modifiedPoints = pmod( allSelectedPoints) # apply any post-selection modifications myLogger.debug( str(len(modifiedPoints)) + " points left after applying post-selection modifier ...") myLogger.debug("creating sample schedule ...") schedule = sc.SampleSchedule( modifiedPoints ) # create a schedule from all the special points and the normally-selected points myLogger.debug("sample schedule completed, formatting schedule") formatted = form(schedule) # format the schedule as a string myLogger.debug("sample schedule formatted") return (formatted, schedule)