예제 #1
0
def main(start_iter, end_iter, snapshots_path, visible_range, hi_dim_bc):
    """
    START_ITER: Plot data that begins at this iteration (generation)\n
    END_ITER: Plot data that ends at this iteration (generation)\n
    SNAPSHOTS_PATH: Path(s) to One or multiple 2-D BCs
    """
    start_iter = int(start_iter)
    end_iter = int(end_iter)

    FigureControl.init(start_iter, end_iter, visible_range)

    for idx, path in enumerate(snapshots_path):
        print("Generating Cloud Plot {} from {}".format(idx, path))
        cplot = CloudPlotRolloutAtari("Cloud Plot {} ({})".format(idx, path),
                                      start_iter, end_iter, path,
                                      visible_range)
        gs.cloud_plots.add(cplot)
        gs.canvas2cloud_plot[cplot.fig.canvas] = cplot

    gs.fitness_plot = FitnessPlot("Fitness Plot", start_iter, end_iter,
                                  snapshots_path[0])

    hbc_path, hbc_dim = hi_dim_bc
    if hbc_path != None and hbc_dim != None:
        print("Generating Cloud Plot H-D from {}".format(hbc_path))
        hbcplot = CloudPlotHDBC(
            "Cloud Plot {}-D BC ({})".format(hbc_dim, hbc_path), start_iter,
            end_iter, hbc_path, visible_range, hbc_dim)
        gs.cloud_plots.add(hbcplot)
        gs.canvas2cloud_plot[hbcplot.fig.canvas] = hbcplot

    p.show()
예제 #2
0
 def update_plot(cls, vis):
     """update the plots"""
     for cplot in gs.cloud_plots:
         cplot.annot.set_visible(vis)
     gs.fitness_plot.floating_annot.set_visible(vis)
     FigureControl.draw_all_cloud_plots()
     gs.fitness_plot.fig.canvas.draw_idle()
예제 #3
0
 def onpick(cls, event):
     """mouse pick event on fitness plot"""
     event_len = len(event.ind)
     if not event_len:
         return True
     value = event.ind[-1] + FigureControl.minPossibleGenNumber
     vis_now = FigureControl.isVisible(value)
     FigureControl.makeGenVisible(value, not vis_now, "dist")
예제 #4
0
 def eligibleClick(self, buttonClicked):
     if buttonClicked == "next":
         return (not FigureControl.isVisible(
             FigureControl.maxPossibleGenNumber),
                 "max gen already displayed")
     elif buttonClicked == "prev":
         return (not FigureControl.isVisible(
             FigureControl.minPossibleGenNumber),
                 "min gen already displayed")
     elif buttonClicked == "movie":
         return True, ""
     else:
         return False, "bad button"
예제 #5
0
    def button_3(cls, cloud_plot, artist, ind):
        """click with button 3, i.e., right button"""
        is_parent = cloud_plot.is_parent_artist(artist, ind)
        gen = cloud_plot.artist2gen[artist]

        for cpl in gs.cloud_plots:
            if is_parent:
                cpl.show_new_labels_gen(gen)
            else:
                row_idx = cloud_plot.artist2data[artist][ind]
                this_data = cpl.fetch_child_data_point(gen, row_idx)
                cpl.show_new_labels_dp(this_data)
        FigureControl.draw_all_cloud_plots()
        cloud_plot.button_3(artist, ind)
예제 #6
0
 def button_1(cls, cloud_plot, artist, ind):
     """click with button 1, i.e., left button"""
     is_parent = cloud_plot.is_parent_artist(artist, ind)
     gen = cloud_plot.artist2gen[artist]
     if is_parent:
         vis_now = FigureControl.isVisible(gen)
         FigureControl.makeGenVisible(gen, not vis_now, "dist")
     else:
         row_idx = cloud_plot.artist2data[artist][ind]
         for cpl in gs.cloud_plots:
             this_data = cpl.fetch_child_data_point(gen, row_idx)
             cpl.show_new_labels_dp(this_data)
         FigureControl.draw_all_cloud_plots()
     cloud_plot.button_1(artist, ind)
    def update(self, value):
        """update the fitness plot"""
        if value < 0:
            self.dot.set_data([[value], [-1]])
            self.ax.set_title("")
        else:
            self.dot.set_data([[value], [self.y[value-self.x[0]]]])
            self.ax.set_title("Gen {}  Fitness {:.8f} ".format(value, self.y[value-self.x[0]]))

            vis_now = FigureControl.isVisible(value)
            if not vis_now:
                FigureControl.makeGenVisible(value, True, "dist",
                                             skip_fitness_plot=True)

        self.fig.canvas.draw()
예제 #8
0
    def reset(self, event=None):
        #t1 = time.time()

        if FigureControl.numVisibleGenNumber() != 0:
            while FigureControl.numVisibleGenNumber() != 0:
                genNumber = FigureControl.maxVisibleGenNumber()
                print("cleaning ...", genNumber)
                FigureControl.hideOffSprings(genNumber)

        FigureControl.clear_labels()
        self.home()
예제 #9
0
 def prev(self, event=None):
     ok, err = self.eligibleClick("prev")
     if not ok:
         FigureControl.print_error(err)
     else:
         print("showing prevGen")
         nextGenNum = FigureControl.maxPossibleGenNumber
         if FigureControl.numVisibleGenNumber() > 0:
             nextGenNum = max(
                 FigureControl.minVisibleGenNumber() - FigureControl.step,
                 FigureControl.minPossibleGenNumber)
         FigureControl.makeGenVisible(nextGenNum, True, "prev")
예제 #10
0
 def home(self, event=None):
     FigureControl.set_home()
예제 #11
0
 def movie(self, event):
     FigureControl.movie(event)