def main(): smallArgs = 'i:b:t:o:' longArgs = ['items=', 'bids=', 'tasks=', 'output_file='] try: opts, args = getopt.getopt(sys.argv[1:], smallArgs, longArgs) except getopt.GetoptError: print "check yo arguments" sys.exit(2) for opt, arg in opts: if opt in ('-i', '--items'): numItems = arg if opt in ('-b', '--bids'): numBids = arg if opt in ('-t', '--tasks'): numTasks = arg if opt in ('-o', '--output_file'): outFile = arg createData(numItems, numBids, numTasks, outFile) r = createTaskSchedule(outFile) r.run()
def main(): smallArgs = "i:b:t:o:" longArgs = ["items=", "bids=", "tasks=", "output_file="] try: opts, args = getopt.getopt(sys.argv[1:], smallArgs, longArgs) except getopt.GetoptError: print "check yo arguments" sys.exit(2) for opt, arg in opts: if opt in ("-i", "--items"): numItems = arg if opt in ("-b", "--bids"): numBids = arg if opt in ("-t", "--tasks"): numTasks = arg if opt in ("-o", "--output_file"): outFile = arg createData(numItems, numBids, numTasks, outFile) r = createTaskSchedule(outFile) r.run()
def main2(): numRobots = 4 # constant coalitionSize = 3 maxBidSubmissions = 10 taskSizes = [4] maxIterations = 1 nodeCount = [] dummyNodeCount = [] regularNodeCount = [] dummyTime = [] regularTime = [] dummyTimePerNode = [] regularTimePerNode = [] meanDummyTime = 0.0 meanRegularTime = 0.0 for taskSize in taskSizes: f = open("../statistics/dummy_regular_nodeCounts_N_times_RANDOM_" + str(taskSize) + "-2.txt", "w") for bidLimit in range(10, maxBidSubmissions+1): print "BidLimit: " + str(bidLimit) totalTime = float(0) maxBidsPerTask = int(math.ceil(float(bidLimit)/float(taskSize))) * 2 nodeCount = [] dummyNodeCount = [] regularNodeCount = [] dummyTime = [] regularTime = [] dummyTimePerNode = [] regularTimePerNode = [] meanDummyTime = 0.0 meanRegularTime = 0.0 for avg in range(maxIterations): # execute it 10 times for each bidSize print "Creating data....(" + str(avg) + ")" data = createData(numRobots, maxBidsPerTask, coalitionSize, bidLimit, taskSize) print "Finished Creating data!!" r = createTaskSchedule(data) print "Executing data on algorithm...." output = r.run() nodeCount.append(output[0]) dummyNodeCount.append(output[1]) regularNodeCount.append(output[2]) dummyTime.append(output[3]) regularTime.append(output[4]) meanDummyTime = output[3] / output[1] dummyTimePerNode.append(meanDummyTime) meanRegularTime = output[4] / output[2] regularTimePerNode.append(meanRegularTime) xTime = output[5] print "Finished running!!" totalTime += float(str(xTime)) print "----------------------------" avgTime = totalTime / 10 sd = calcSD(nodeCount) meanDummyTime = meanDummyTime / 10 meanRegularTime = meanRegularTime / 10 f.write(str(bidLimit) + ", " + str(avgTime) + ", " + str(nodeCount) + ", " + str(sd) + " ||| " + str(dummyNodeCount) + ", " + str(regularNodeCount) + ", " + str(dummyTime) + ", " + str(regularTime) + ", " + str(dummyTimePerNode) + ", " + str(regularTimePerNode) + ", " + str(meanDummyTime) + ", " + str(meanRegularTime) + "\n") f.flush() print str(bidLimit) + ", " + str(avgTime) print "----------------------------------------------------------------------------------------" f.close() print "Collected results for 'results_" + str(taskSize) + ".txt'"
def main2(): numRobots = 4 # constant coalitionSize = 3 maxBidSubmissions = 10 taskSizes = [4] maxIterations = 1 nodeCount = [] dummyNodeCount = [] regularNodeCount = [] dummyTime = [] regularTime = [] dummyTimePerNode = [] regularTimePerNode = [] meanDummyTime = 0.0 meanRegularTime = 0.0 for taskSize in taskSizes: f = open( "../statistics/dummy_regular_nodeCounts_N_times_RANDOM_" + str(taskSize) + "-2.txt", "w") for bidLimit in range(10, maxBidSubmissions + 1): print "BidLimit: " + str(bidLimit) totalTime = float(0) maxBidsPerTask = int(math.ceil( float(bidLimit) / float(taskSize))) * 2 nodeCount = [] dummyNodeCount = [] regularNodeCount = [] dummyTime = [] regularTime = [] dummyTimePerNode = [] regularTimePerNode = [] meanDummyTime = 0.0 meanRegularTime = 0.0 for avg in range( maxIterations): # execute it 10 times for each bidSize print "Creating data....(" + str(avg) + ")" data = createData(numRobots, maxBidsPerTask, coalitionSize, bidLimit, taskSize) print "Finished Creating data!!" r = createTaskSchedule(data) print "Executing data on algorithm...." output = r.run() nodeCount.append(output[0]) dummyNodeCount.append(output[1]) regularNodeCount.append(output[2]) dummyTime.append(output[3]) regularTime.append(output[4]) meanDummyTime = output[3] / output[1] dummyTimePerNode.append(meanDummyTime) meanRegularTime = output[4] / output[2] regularTimePerNode.append(meanRegularTime) xTime = output[5] print "Finished running!!" totalTime += float(str(xTime)) print "----------------------------" avgTime = totalTime / 10 sd = calcSD(nodeCount) meanDummyTime = meanDummyTime / 10 meanRegularTime = meanRegularTime / 10 f.write( str(bidLimit) + ", " + str(avgTime) + ", " + str(nodeCount) + ", " + str(sd) + " ||| " + str(dummyNodeCount) + ", " + str(regularNodeCount) + ", " + str(dummyTime) + ", " + str(regularTime) + ", " + str(dummyTimePerNode) + ", " + str(regularTimePerNode) + ", " + str(meanDummyTime) + ", " + str(meanRegularTime) + "\n") f.flush() print str(bidLimit) + ", " + str(avgTime) print "----------------------------------------------------------------------------------------" f.close() print "Collected results for 'results_" + str(taskSize) + ".txt'"