parameters: (self, mode='f', invert=False)
docstring: Generates Parallel Coordinate Plot of Gradient: magnitude of (scaled) partial
          derivative dFi/dXj vs. X et F.
  
  
          **USAGE:**
          analysis.plot_gradient_pcp([mode='c', invert=True])
  
          * mode: 'f'/'c' to use fitness/constraint jacobian matrix.
          * invert: if True, parallel axes are objectives, colors are search variables (not suitable
            for single-objective problems).if False, parallel axes are search variables, colors are
            objectives (not suitable for univariate problems).
  
  
          **NOTE:** the plot will be shown on screen or saved to file depending on the  option that was
          selected when instantiating the analysis class.
docstring_summary: Generates Parallel Coordinate Plot of Gradient: magnitude of (scaled) partial
          derivative dFi/dXj vs. X et F.
docstring_tokens: Generates Parallel Coordinate Plot of Gradient : magnitude of ( scaled ) partial derivative dFi / dXj vs . X et F .
function: def plot_gradient_pcp(self, mode='f', invert=False):
          """
          Generates Parallel Coordinate Plot of Gradient: magnitude of (scaled) partial
          derivative dFi/dXj vs. X et F.
  
  
          **USAGE:**
          analysis.plot_gradient_pcp([mode='c', invert=True])
  
          * mode: 'f'/'c' to use fitness/constraint jacobian matrix.
          * invert: if True, parallel axes are objectives, colors are search variables (not suitable
            for single-objective problems).if False, parallel axes are search variables, colors are
            objectives (not suitable for univariate problems).
  
  
          **NOTE:** the plot will be shown on screen or saved to file depending on the  option that was
          selected when instantiating the analysis class.
          """
          if mode == 'f':
              if self.grad_npoints == 0:
                  raise ValueError(
                      "analysis.plot_gradient_pcp: sampling and getting gradient first is necessary")
              else:
                  dim = self.f_dim
                  grad = self.grad
                  npoints = self.grad_npoints
                  string = 'Objective '
          elif mode == 'c':
              if self.c_dim == 0:
                  raise ValueError(
                      "analysis.plot_gradient_pcp: mode 'c' selected for unconstrained problem")
              if self.c_grad_npoints == 0:
                  raise ValueError(
                      "analysis.plot_gradient_pcp: sampling and getting c_gradient first is necessary")
              else:
                  dim = self.c_dim
                  grad = self.c_grad
                  npoints = self.c_grad_npoints
                  string = 'Constraint '
          else:
              raise ValueError(
                  "analysis.plot_gradient_pcp: choose a valid mode 'f' or 'c'")
  
          if invert is False and self.cont_dim == 1:
              raise ValueError(
                  "analysis.plot_gradient_pcp: this plot makes no sense for univariate problems")
          if invert is True and dim == 1:
              raise ValueError(
                  "analysis.plot_gradient_pcp: this plot makes no sense for single-" + string.lower() + "problems")
  
          try:
              from pandas.tools.plotting import parallel_coordinates as pc
              from pandas import DataFrame as df
              from matplotlib.pyplot import show, title, grid, ylabel, xlabel, cla, clf, xticks
              from numpy import asarray, transpose
          except ImportError:
              raise ImportError(
                  "analysis.plot_gradient_pcp needs pandas, numpy and matplotlib to run. Are they installed?")
          gradient = []
          if invert:
              aux = 1
              file_string = ' (inverted)'
          else:
              aux = 0
              file_string = ''
          for i in range(npoints):
              if invert:
                  tmp = [['x' + str(x + 1) for x in range(self.cont_dim)]]
              else:
                  tmp = []
              for j in range(dim):
                  if invert:
                      tmp.append([])
                  else:
                      if mode == 'c':
                          if j < self.c_dim - self.ic_dim:
                              tmp.append(['Constraint h' + str(j + 1)])
                          else:
                              tmp.append(
                                  ['Constraint g' + str(j - self.c_dim + self.ic_dim + 1)])
                      else:
                          tmp.append(['Objective ' + str(j + 1)])
  
                  tmp[j + aux].extend(grad[i][j])
  
              if invert:
                  tmp2 = []
                  for ii in range(self.cont_dim):
                      tmp2.append([])
                      for jj in range(dim + 1):
                          tmp2[ii].append(tmp[jj][ii])
                  gradient.extend(tmp2)
              else:
                  gradient.extend(tmp)
  
          gradient = df(gradient)
  
          title(string + 'Gradient/Jacobian PCP \n')
          grid(True)
          ylabel('Derivative value (scaled)')
          if invert:
              xlabel(string)
          else:
              xlabel('Dimension')
  
          plot = pc(gradient, 0)
          if mode == 'c' and invert:
              try:
                  xlocs = range(self.c_dim)
                  xlabels = ['h' + str(i + 1) for i in range(self.c_dim - self.ic_dim)] + [
                      'g' + str(i + 1) for i in range(self.ic_dim)]
                  xticks(xlocs, [x.format(xlocs[i])
                                 for i, x in enumerate(xlabels)])
              except (IndexError, ValueError):
                  pass
          f = plot.get_figure()
          if self.dir is None:
              show(f)
              cla()
              clf()
          else:
              f.savefig(self.dir + '/figure_' + str(self.fignum) + '.png')
              output = open(self.dir + '/log.txt', 'r+')
              output.seek(0, 2)
              print('*' + string + 'Gradient/Jacobian PCP plot' + file_string +
                    ' : <figure_' + str(self.fignum) + '.png>', file=output)
              self.fignum += 1
              cla()
              clf()
              output.close()
function_tokens: def plot_gradient_pcp ( self , mode = 'f' , invert = False ) : if mode == 'f' : if self . grad_npoints == 0 : raise ValueError ( "analysis.plot_gradient_pcp: sampling and getting gradient first is necessary" ) else : dim = self . f_dim grad = self . grad npoints = self . grad_npoints string = 'Objective ' elif mode == 'c' : if self . c_dim == 0 : raise ValueError ( "analysis.plot_gradient_pcp: mode 'c' selected for unconstrained problem" ) if self . c_grad_npoints == 0 : raise ValueError ( "analysis.plot_gradient_pcp: sampling and getting c_gradient first is necessary" ) else : dim = self . c_dim grad = self . c_grad npoints = self . c_grad_npoints string = 'Constraint ' else : raise ValueError ( "analysis.plot_gradient_pcp: choose a valid mode 'f' or 'c'" ) if invert is False and self . cont_dim == 1 : raise ValueError ( "analysis.plot_gradient_pcp: this plot makes no sense for univariate problems" ) if invert is True and dim == 1 : raise ValueError ( "analysis.plot_gradient_pcp: this plot makes no sense for single-" + string . lower ( ) + "problems" ) try : from pandas . tools . plotting import parallel_coordinates as pc from pandas import DataFrame as df from matplotlib . pyplot import show , title , grid , ylabel , xlabel , cla , clf , xticks from numpy import asarray , transpose except ImportError : raise ImportError ( "analysis.plot_gradient_pcp needs pandas, numpy and matplotlib to run. Are they installed?" ) gradient = [ ] if invert : aux = 1 file_string = ' (inverted)' else : aux = 0 file_string = '' for i in range ( npoints ) : if invert : tmp = [ [ 'x' + str ( x + 1 ) for x in range ( self . cont_dim ) ] ] else : tmp = [ ] for j in range ( dim ) : if invert : tmp . append ( [ ] ) else : if mode == 'c' : if j < self . c_dim - self . ic_dim : tmp . append ( [ 'Constraint h' + str ( j + 1 ) ] ) else : tmp . append ( [ 'Constraint g' + str ( j - self . c_dim + self . ic_dim + 1 ) ] ) else : tmp . append ( [ 'Objective ' + str ( j + 1 ) ] ) tmp [ j + aux ] . extend ( grad [ i ] [ j ] ) if invert : tmp2 = [ ] for ii in range ( self . cont_dim ) : tmp2 . append ( [ ] ) for jj in range ( dim + 1 ) : tmp2 [ ii ] . append ( tmp [ jj ] [ ii ] ) gradient . extend ( tmp2 ) else : gradient . extend ( tmp ) gradient = df ( gradient ) title ( string + 'Gradient/Jacobian PCP \n' ) grid ( True ) ylabel ( 'Derivative value (scaled)' ) if invert : xlabel ( string ) else : xlabel ( 'Dimension' ) plot = pc ( gradient , 0 ) if mode == 'c' and invert : try : xlocs = range ( self . c_dim ) xlabels = [ 'h' + str ( i + 1 ) for i in range ( self . c_dim - self . ic_dim ) ] + [ 'g' + str ( i + 1 ) for i in range ( self . ic_dim ) ] xticks ( xlocs , [ x . format ( xlocs [ i ] ) for i , x in enumerate ( xlabels ) ] ) except ( IndexError , ValueError ) : pass f = plot . get_figure ( ) if self . dir is None : show ( f ) cla ( ) clf ( ) else : f . savefig ( self . dir + '/figure_' + str ( self . fignum ) + '.png' ) output = open ( self . dir + '/log.txt' , 'r+' ) output . seek ( 0 , 2 ) print ( '*' + string + 'Gradient/Jacobian PCP plot' + file_string + ' : <figure_' + str ( self . fignum ) + '.png>' , file = output ) self . fignum += 1 cla ( ) clf ( ) output . close ( )