Esempio n. 1
0
            import matplotlib
            if matplotlib.__version__ < '0.65':
                import matplotlib.matlab as MM
            else:
                import matplotlib.pylab as MM
        except:
            print ' If you had Matplotlib installed, you would be looking'
            print ' at timing plots right now...'
            sys.exit(0)

        darkblue = '#2c11cf'
        lightblue = '#8f84e0'
        steelblue = '#5d82ef'
        x = range(len(t_lst.keys()))
        ax = []
        ax.append(MM.axes([.05, .05, .40, .40]))  # lower left
        ax.append(MM.axes([.05, .55, .40, .40]))  # upper left
        ax.append(MM.axes([.55, .05, .40, .40]))  # lower right
        ax.append(MM.axes([.55, .55, .40, .40]))  # upper right
        for i in range(4):
            ax[i].plot(x, [t_lst[k][i] for k in K],
                       color=darkblue,
                       linewidth=3)
            ax[i].plot(x, [t_ref[k][i] for k in K],
                       color=lightblue,
                       linewidth=3)
            ax[i].set_xticks([])
            ax[i].set_title('Limited memory p = %-d' % plist[i],
                            fontsize='small')
            ax[i].legend(['Python', 'Fortran'], 'upper left')
        for i in [2, 3]:
Esempio n. 2
0
    def __init__(self, solvers, **kwargs):

        self.solvers = solvers

        # Obtain options class with all default values
        self.opts = OptionClass()

        # Assign non-default options
        self.SetOptions(**kwargs)
        self.bw = self.opts.bw

        import matplotlib
        matplotlib.use(self.opts.backend)
        if matplotlib.__version__ < '0.65':
            import matplotlib.matlab as MM
        else:
            import matplotlib.pylab as MM

        self.linestyle = [ '-', '--', '-.', ':', '.', ',', 'o', '^', 'v', '<',
                           '>', 's', '+', 'x', 'D', 'd', '1', '2', '3', '4',
                           'h', 'H', 'p', '|', '_' ]
        self.nlstyles = len(self.linestyle)

        self.grays = [ '0.0', '0.5', '0.8', '0.2', '0.6', '0.9', '0.4', '0.95' ]
        self.ngrays = len(self.grays)

        self.color = [ 'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w' ]
        self.ncolors = len(self.color)

        self.metrics = MetricsClass(self.solvers, self.opts)
        self.pprofs  = RatioClass(self.metrics, self.opts)

        self.nprobs = self.metrics.nprobs
        self.nsolvs = self.metrics.nsolvs

        self.ax = MM.axes()

        # Generate the y-axis data
        self.ydata = numpy.arange(self.nprobs) * (1.0 / self.nprobs)

        # Set the x-axis ranges
        self.xmax = self.pprofs.maxrat + 1.0e-3
        if self.opts.logscale is not None:
            self.xmax = max(self.opts.logscale, self.xmax)
        else:
            self.xmax = max(1, self.xmax)
        self.epsilon = 0.0

        plotargs = {}
        if self.opts.logscale is not None:
            self.mmplotcmd = self.ax.semilogx
            plotargs['basex'] = self.opts.logscale
            self.epsilon = 0.001
            self.xmin = 1.0
        else:
            self.mmplotcmd = self.ax.plot
            self.xmin = 0.0

        # Generate arguments for the gplot command
        self.profiles = []
        lscount = 0
        colcount = 0

        for s in range(self.nsolvs):
            if self.bw:
                #curcolor = 'k'
                curcolor = self.grays[(colcount % self.ngrays)]
            else:
                curcolor = self.color[(colcount % self.ncolors)]
            lstyle = '' #self.linestyle[(lscount % self.nlstyles)]
            sname = self.solvers[s]
            srats = self.pprofs.solv_ratios(s)

            if self.opts.logscale is not None:
                srats += self.epsilon

            self.profiles.append(self.mmplotcmd(srats,
                                                self.ydata,
                                                curcolor + lstyle,
                                                linewidth=2.5,
                                                drawstyle='steps-pre',
                                                antialiased=True,
                                                **plotargs))
            #if self.bw: lscount += 1
            #if (lscount % self.nlstyles) == 0 and not self.bw:
            colcount += 1

        if self.opts.logscale is not None:
            self.ax.set_xscale('log', basex=self.opts.logscale)

        # Set legend if required
        if self.opts.legend:
            self.ax.legend(self.solvers, 'lower right')

        if self.opts.title:
            self.ax.set_title(self.opts.title)
        if self.opts.xlabel:
            self.ax.set_xlabel(self.opts.xlabel)
        if self.opts.ylabel:
            self.ax.set_ylabel(self.opts.ylabel)

        self.ax.set_xlim([self.xmin, self.xmax])
        self.ax.set_ylim([self.opts.ymin, self.opts.ymax])
        self.show = MM.show
        self.savefig = MM.savefig
Esempio n. 3
0
            import matplotlib
            if matplotlib.__version__ < '0.65':
                import matplotlib.matlab as MM
            else:
                import matplotlib.pylab as MM
        except:
            print ' If you had Matplotlib installed, you would be looking'
            print ' at timing plots right now...'
            sys.exit(0)

        darkblue = '#2c11cf'
        lightblue = '#8f84e0'
        steelblue = '#5d82ef'
        x = range(len(t_lst.keys()))
        ax = []
        ax.append(MM.axes([ .05, .05, .40, .40 ])) # lower left
        ax.append(MM.axes([ .05, .55, .40, .40 ])) # upper left
        ax.append(MM.axes([ .55, .05, .40, .40 ])) # lower right
        ax.append(MM.axes([ .55, .55, .40, .40 ])) # upper right
        for i in range(4):
            ax[i].plot(x, [ t_lst[k][i] for k in K ], color=darkblue,  linewidth=3)
            ax[i].plot(x, [ t_ref[k][i] for k in K ], color=lightblue, linewidth=3)
            ax[i].set_xticks([])
            ax[i].set_title('Limited memory p = %-d' % plist[i], fontsize='small')
            ax[i].legend(['Python', 'Fortran'], 'upper left')
        for i in [2,3]:
            ax[i].set_ylabel('Time (s)', fontsize='small')
        MM.show()

        # For the number of iterations, use first value of p as reference
        x = range(len(i_lst.keys()))