class_docstr: !
  @brief Genetic algorithm visualizer is used to show clustering results that are specific for
          this particular algorithm: clusters, evolution of global and local optimum.
  @details The visualizer requires 'ga_observer' that collects evolution of clustering process in
            genetic algorithm. The observer is created by user and passed to genetic algorithm. There
            is usage example of the visualizer using the observer:
  @code
      from pyclustering.cluster.ga import genetic_algorithm, ga_observer, ga_visualizer
      from pyclustering.utils import read_sample
      from pyclustering.samples.definitions import SIMPLE_SAMPLES
  
  
      # Read data for clustering
      sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE1)
  
      # Create instance of observer that will collect all information:
      observer_instance = ga_observer(True, True, True)
  
      # Create genetic algorithm where observer will collect information:
      ga_instance = genetic_algorithm(data=sample,
                                      count_clusters=2,
                                      chromosome_count=20,
                                      population_count=20,
                                      count_mutation_gens=1,
                                      observer=observer_instance)
  
      # Start processing
      ga_instance.process()
  
      # Obtain results
      clusters = ga_instance.get_clusters()
  
      # Print cluster to console
      print("Amount of clusters: '%d'. Clusters: '%s'" % (len(clusters), clusters))
  
      # Show cluster using observer:
      ga_visualizer.show_clusters(sample, observer_instance)
  @endcode
  
  @see cluster_visualizer
class_docstr_tok: ["!","@","brief","Genetic","algorithm","visualizer","is","used","to","show","clustering","results","that","are","specific","for","this","particular","algorithm",":","clusters",",","evolution","of","global","and","local","optimum",".","@","details","The","visualizer","requires","'ga_observer","'","that","collects","evolution","of","clustering","process","in","genetic","algorithm",".","The","observer","is","created","by","user","and","passed","to","genetic","algorithm",".","There","is","usage","example","of","the","visualizer","using","the","observer",":","@","code","from","pyclustering.cluster.ga","import","genetic_algorithm",",","ga_observer",",","ga_visualizer","from","pyclustering.utils","import","read_sample","from","pyclustering.samples.definitions","import","SIMPLE_SAMPLES","#","Read","data","for","clustering","sample","=","read_sample","(","SIMPLE_SAMPLES.SAMPLE_SIMPLE1",")","#","Create","instance","of","observer","that","will","collect","all","information",":","observer_instance","=","ga_observer","(","True",",","True",",","True",")","#","Create","genetic","algorithm","where","observer","will","collect","information",":","ga_instance","=","genetic_algorithm","(","data=sample",",","count_clusters=2",",","chromosome_count=20",",","population_count=20",",","count_mutation_gens=1",",","observer=observer_instance",")","#","Start","processing","ga_instance.process","(",")","#","Obtain","results","clusters","=","ga_instance.get_clusters","(",")","#","Print","cluster","to","console","print","(","``","Amount","of","clusters",":","'","%","d","'",".","Clusters",":","'","%","s","'","''","%","(","len","(","clusters",")",",","clusters",")",")","#","Show","cluster","using","observer",":","ga_visualizer.show_clusters","(","sample",",","observer_instance",")","@","endcode","@","see","cluster_visualizer"]
docstr: !
  @brief Displays evolution of fitness function for the best chromosome, for the current best chromosome and
          average value among all chromosomes.
  @details Created figure should be closed by `close()` method of this visualizer.
  
  @param[in] observer (ga_observer): Genetic algorithm observer that was used for collecting evolution in the algorithm and
              where whole required information for visualization is stored.
  @param[in] start_iteration (uint): Iteration from that evolution should be shown.
  @param[in] stop_iteration (uint): Iteration after that evolution shouldn't be shown.
  @param[in] ax (Axes): Canvas where evolution should be displayed.
  @param[in] display (bool): If 'True' then visualization of the evolution will be shown by the function.
              This argument should be 'False' if you want to add something else to the canvas and display it later.
  
  @return (figure, Axis) Figure and axis where evolution was shown. Figure might be `None` if axis was provided to
           that method.
docstr_tok: ["!","@","brief","Displays","evolution","of","fitness","function","for","the","best","chromosome",",","for","the","current","best","chromosome","and","average","value","among","all","chromosomes",".","@","details","Created","figure","should","be","closed","by","`","close","(",")","`","method","of","this","visualizer",".","@","param","[","in","]","observer","(","ga_observer",")",":","Genetic","algorithm","observer","that","was","used","for","collecting","evolution","in","the","algorithm","and","where","whole","required","information","for","visualization","is","stored",".","@","param","[","in","]","start_iteration","(","uint",")",":","Iteration","from","that","evolution","should","be","shown",".","@","param","[","in","]","stop_iteration","(","uint",")",":","Iteration","after","that","evolution","should","n't","be","shown",".","@","param","[","in","]","ax","(","Axes",")",":","Canvas","where","evolution","should","be","displayed",".","@","param","[","in","]","display","(","bool",")",":","If","'True","'","then","visualization","of","the","evolution","will","be","shown","by","the","function",".","This","argument","should","be","'False","'","if","you","want","to","add","something","else","to","the","canvas","and","display","it","later",".","@","return","(","figure",",","Axis",")","Figure","and","axis","where","evolution","was","shown",".","Figure","might","be","`","None","`","if","axis","was","provided","to","that","method","."]
code: def show_evolution(
      observer,
      start_iteration=0,
      stop_iteration=None,
      ax=None,
      display=True,
  ):
      """!
      @brief Displays evolution of fitness function for the best chromosome, for the current best chromosome and
              average value among all chromosomes.
      @details Created figure should be closed by `close()` method of this visualizer.
  
      @param[in] observer (ga_observer): Genetic algorithm observer that was used for collecting evolution in the algorithm and
                  where whole required information for visualization is stored.
      @param[in] start_iteration (uint): Iteration from that evolution should be shown.
      @param[in] stop_iteration (uint): Iteration after that evolution shouldn't be shown.
      @param[in] ax (Axes): Canvas where evolution should be displayed.
      @param[in] display (bool): If 'True' then visualization of the evolution will be shown by the function.
                  This argument should be 'False' if you want to add something else to the canvas and display it later.
  
      @return (figure, Axis) Figure and axis where evolution was shown. Figure might be `None` if axis was provided to
               that method.
  
      """
  
      figure = None
      if ax is None:
          figure, ax = plt.subplots(1)
          ax.set_title("Evolution")
  
      if stop_iteration is None:
          stop_iteration = len(observer)
  
      (line_best,) = ax.plot(
          observer.get_global_best()["fitness_function"][
              start_iteration:stop_iteration
          ],
          "r",
      )
      (line_current,) = ax.plot(
          observer.get_population_best()["fitness_function"][
              start_iteration:stop_iteration
          ],
          "k",
      )
      (line_mean,) = ax.plot(
          observer.get_mean_fitness_function()[
              start_iteration:stop_iteration
          ],
          "c",
      )
  
      if start_iteration < (stop_iteration - 1):
          ax.set_xlim([start_iteration, (stop_iteration - 1)])
  
      ax.set_xlabel("Iteration")
      ax.set_ylabel("Fitness function")
      ax.legend(
          [line_best, line_current, line_mean],
          ["The best pop.", "Cur. best pop.", "Average"],
          prop={"size": 10},
      )
      ax.grid()
  
      if display is True:
          plt.show()
  
      return figure, ax
  
imports: import numpy
  import matplotlib.pyplot
  import matplotlib.animation
  from pyclustering.cluster import cluster_visualizer
  from pyclustering.cluster.ga_maths import ga_math
label_desc: Use image node_id 1 for calling the ga_visualizer obj's underlying member method code with example usage: obj.show_evolution(observer, start_iteration, stop_iteration, ax, display) and returns: figure,  ax