Exemple #1
0
def report():
  def autolabel(rect_s):
      # attach some text labels
      for rect in rect_s:
          height = rect.get_height()
          ax.text(rect.get_x() + rect.get_width()/2., 1.05*height,
                  '%0.2f' % height,
                  ha='center', va='bottom')
  processors_stats = evaluate_model(MODEL)
  width = 0.6
  size = len(ALGOS)+1
  ind = np.arange(start=0, step=size*width, stop=PROCESSORS*size*width, dtype=float)
  fig, ax = plt.subplots()
  rects = ()
  algos = ()
  for index, algo_name in enumerate(ALGOS):
    means = ()
    iqrs = ()
    for p_i in range(1, PROCESSORS+1):
      means += (processors_stats[p_i][algo_name]["mean"], )
      iqrs += (processors_stats[p_i][algo_name]["iqr"], )
    rect = ax.bar(ind + index*width, means, width, color=COLORS[index], yerr=iqrs, ecolor='black')
    rects += (rect, )
    algos += (algo_name, )
  measure = MEASURE.__name__.split("_")[0].upper()
  ax.set_ylabel(measure)
  ax.set_title(measure)
  ax.set_xticks(ind + len(ALGOS)*width/2)
  ax.set_xticklabels(tuple(range(1, PROCESSORS+1)))
  ax.legend(rects, algos)

  #for rect in rects:autolabel(rect)
  folder = mkdir(FOLDER+"/figures/")
  plt.savefig(folder+"%s_%s.png"%(MODEL, MEASURE.__name__.split("_")[0]))
Exemple #2
0
def _single_test(repeat=0):
    experiment = sys.argv[1]
    problem = None
    if experiment == "SHP":
        INPUT = SHP_Min
        setRecordPoint(True)
        return
    elif experiment == "WPT":
        INPUT = WPT_Min
        problem = WebPortal()
    elif experiment == "ERS":
        INPUT = ERS_Min
        problem = EmergencyResponse()
    else:
      return

    num_consumers = int(str(sys.argv[3]).strip())
    solvers = replicateSolver(INPUT.s, num_consumers)
    outputFileParentName = str(sys.argv[2]).strip()

    # Establish communication queues
    mgr = multiprocessing.Manager()
    taskQueue = []
    for i in xrange(num_consumers):
        taskQueue.append(mgr.Queue())
    ParetoFront = mgr.Queue()
    totalTime = mgr.Queue()

    # Enqueue initial tasks
    for i in xrange(num_consumers):
        taskQueue[i].put("Task")

    # Start consumers
    consumersList = [ Consumer(taskQueue, ParetoFront, totalTime, i, outputFileParentName, num_consumers, solvers[i], INPUT)
                    for i in xrange(num_consumers)]
    starttime = time.time()
    for w in consumersList:
        w.start()

    for w in consumersList:
        w.join()

    runningtime = 0.0
    while totalTime.qsize() > 0:
        ttime = totalTime.get()
        if (float(ttime) < runningtime):
            runningtime = float(ttime)

    endtime = time.time()

    TotalOverlappingParetoFront = ParetoFront.qsize()
    pf = []
    while not ParetoFront.empty():
        pf.append(ParetoFront.get())
    pf = problem.convert_to_points(pf)
    pf = sel_nsga2(problem, pf, Cons.default_settings().GALE_pop_size)
    new_dir = mkdir("results/"+str(datetime.date.today())+"/")
    outputFileParent = open(new_dir+str(outputFileParentName+'.csv'), 'a')
    try:
        # keep a zero position for the same merging program as opGIA
        # in fact, here zero should be 356, as we already check it using the above code
        outputFileParent.writelines(str(num_consumers) + ',' + str(TotalOverlappingParetoFront) +',' + '0' + ',' + str(endtime - starttime) + '\n')
    finally:
        outputFileParent.close()
    obj_file = mkdir(new_dir+"/repeat_"+str(repeat)+"/") + str(outputFileParentName)+"_"+str(num_consumers)+"_objs"
    write_objs([one.objectives for one in pf], obj_file)