Example #1
0
def create_report_drone1_mass_cost(data):
    matplotlib_settings()
    cs = CommonStats(data)

    r = Report()
    figure_num_implementations2(r, data, cs, 'num_missions', 'endurance')
    figure_discrete_choices2(r, data, cs, 'num_missions', 'endurance')

    f = r.figure()
    with f.plot('total_cost', **fig) as pylab:

        ieee_spines_zoom3(pylab)

        x = cs.get_functionality('num_missions')
        y = cs.get_functionality('endurance')
        z = cs.get_min_resource('total_cost')
        plot_field(pylab, x, y, z, cmap=colormap)
        pylab.title('total_cost', color=color_resources,  y=1.08)


    with f.plot('total_mass', **fig) as pylab:

        ieee_spines_zoom3(pylab)

        x = cs.get_functionality('num_missions')
        y = cs.get_functionality('endurance')
        z = cs.get_min_resource('total_mass')
        plot_field(pylab, x, y, z, cmap=colormap)
        pylab.title('total_mass', color=color_resources,  y=1.08)

    return r
def create_report_drone1_mass_cost(data):
    matplotlib_settings()
    cs = CommonStats(data)
    
    r = Report() 
    figure_num_implementations2(r, data, cs, 'num_missions', 'endurance')
    figure_discrete_choices2(r, data, cs, 'num_missions', 'endurance')

    f = r.figure()
    with f.plot('total_cost', **fig) as pylab:
  
        ieee_spines_zoom3(pylab)
  
        x = cs.get_functionality('num_missions')
        y = cs.get_functionality('endurance')
        z = cs.get_min_resource('total_cost')
        plot_field(pylab, x, y, z, cmap=colormap)
        pylab.title('total_cost', color=color_resources,  y=1.08)
        

    with f.plot('total_mass', **fig) as pylab:
  
        ieee_spines_zoom3(pylab)
  
        x = cs.get_functionality('num_missions')
        y = cs.get_functionality('endurance')
        z = cs.get_min_resource('total_mass')
        plot_field(pylab, x, y, z, cmap=colormap)
        pylab.title('total_mass', color=color_resources,  y=1.08)
        
    return r
def create_report_min_mass(data):
    matplotlib_settings()

    cs = CommonStats(data)
    r = Report() 
    figure_num_implementations2(r, data, cs, 'missions', 'capacity')
    figure_discrete_choices2(r, data, cs, 'missions', 'capacity')
    
    f = r.figure()
    with f.plot('mass', **fig) as pylab:
  
        ieee_spines_zoom3(pylab)
  
        x = cs.get_functionality('missions')
        y = cs.get_functionality('capacity')
        z = cs.get_min_resource('mass')
        plot_field(pylab, x, y, z, cmap=colormap)
        pylab.title('mass', color=color_resources,  y=1.08)
        do_axes(pylab)
        
    return r
Example #4
0
def create_report_min_mass(data):
    matplotlib_settings()

    cs = CommonStats(data)
    r = Report()
    figure_num_implementations2(r, data, cs, 'missions', 'capacity')
    figure_discrete_choices2(r, data, cs, 'missions', 'capacity')

    f = r.figure()
    with f.plot('mass', **fig) as pylab:

        ieee_spines_zoom3(pylab)

        x = cs.get_functionality('missions')
        y = cs.get_functionality('capacity')
        z = cs.get_min_resource('mass')
        plot_field(pylab, x, y, z, cmap=colormap)
        pylab.title('mass', color=color_resources,  y=1.08)
        do_axes(pylab)

    return r
Example #5
0
def figure_discrete_choices2(r, data, cs, fname1, fname2):

    num_solutions = cs.all_num_implementations
    all_discrete_choices = compute_discrete_choices(data)

    possible = [
        "",
        "LCO",
        "LFP",
        "NiCad",
        "NiMH",
        "LiPo",
        "LCO-LiPo-NiMH",
        "LCO-LiPo-NiCad",
        "LCO-LFP-LiPo-NiCad",
        "LCO-LFP-LiPo",
        "LCO-LFP-LiPo-NiMH",
        "LCO-LiPo-NiCad-NiMH",
        "LCO-LFP-LiPo-NiCad-NiMH",
        "LCO-LiPo",
        "LCO-LFP",
        "LCO-LFP-NiMH",
        "LCO-NiMH",
        "LCO-NiCad",
        "LCO-NiCad-NiMH",
        "LCO-LFP-NiCad",
        "LCO-LFP-NiCad-NiMH",
        "LCO-NiCad-NiMH",
    ]
    possible_this = sorted(np.unique(all_discrete_choices))
    for p in possible_this:
        if not p in possible:
            msg = "Did not anticipate %r as an option." % p
            raise ValueError(msg)

    choice_as_int = np.zeros(dtype="int", shape=len(all_discrete_choices))
    for i, x in enumerate(all_discrete_choices):
        choice_as_int[i] = possible.index(x)

    def do_axes(pylab):
        from mcdp_ipython_utils.plotting import set_axis_colors

        set_axis_colors(pylab, color_functions, color_functions)

    with r.plot("choice_as_int", **fig) as pylab:

        ieee_spines_zoom3(pylab)

        x = cs.get_functionality(fname1)
        y = cs.get_functionality(fname2)
        z = choice_as_int
        plot_field(pylab, x, y, z, cmap="viridis", vmin=0, vmax=len(possible))
        pylab.title("choice_as_int", y=1.08)
        do_axes(pylab)

    possible_indiv = set()
    for p in possible:
        for x in p.split("-"):
            possible_indiv.add(x)

    f = r.figure()
    for p in sorted(possible_indiv):
        if not p:
            continue

        feasible = np.array([p in _ for _ in all_discrete_choices])
        with f.plot("where_%s" % p, **fig) as pylab:

            ieee_spines_zoom3(pylab)

            x = cs.get_functionality(fname1)
            y = cs.get_functionality(fname2)

            AND = np.logical_and
            is_best = AND(feasible, num_solutions == 1)
            is_one_of_two = AND(feasible, num_solutions == 2)
            is_one_of_three = AND(feasible, num_solutions == 3)
            is_one_of_four_or_more = AND(feasible, num_solutions >= 4)

            grey = "#bbbbbb"
            color_infeasible = "red"
            pylab.plot(
                x[cs.is_feasible],
                y[cs.is_feasible],
                ".",
                markersize=2,
                markerfacecolor=grey,
                markeredgecolor="none",
                color="none",
                clip_on=False,
            )
            pylab.plot(
                x[cs.is_not_feasible],
                y[cs.is_not_feasible],
                ".",
                markersize=2,
                markerfacecolor=color_infeasible,
                markeredgecolor="none",
                color="none",
                clip_on=False,
            )

            def plot(where, marker, color):
                markersize = 3.5
                pylab.plot(
                    x[where],
                    y[where],
                    marker,
                    markersize=markersize,
                    markeredgecolor="none",
                    markerfacecolor=color,
                    color="none",
                    clip_on=False,
                )

            plot(is_best, "o", "black")
            plot(is_one_of_two, "d", "#000088")
            plot(is_one_of_three, ">", "#880000")
            plot(is_one_of_four_or_more, "s", "#880088")

            pylab.title("%s" % p, y=1.08)
            do_axes(pylab)

    r.text("possible", possible)
    r.text("text_choice_as_int", choice_as_int)
    r.text("choices", all_discrete_choices)
Example #6
0
def figure_num_implementations2(r, data, cs, fname1, fname2):
    assert isinstance(cs, CommonStats)
    
    f1 = cs.get_functionality(fname1)
    f2 = cs.get_functionality(fname2)
    
    def do_axes(pylab):
        pylab.xlabel(fname1)
        pylab.ylabel(fname2)
        set_axis_colors(pylab, color_functions, color_functions)


    with r.plot('feasibility', **fig) as pylab:
        ieee_spines_zoom3(pylab)
          
        pylab.plot(f1[cs.one_solution], 
                   f2[cs.one_solution],
                    'k.', markersize=4, **popt)
        pylab.plot(f1[cs.multiple_solutions], 
                   f2[cs.multiple_solutions],
                   'ms', markersize=4, **popt)
        pylab.plot(f1[cs.is_not_feasible],
                   f2[cs.is_not_feasible], 'r.', markersize=0.5, **popt)
          
        do_axes(pylab)

    with r.plot('implementations', **fig) as pylab:
        ieee_spines_zoom3(pylab) 
          
        pylab.plot(f1[cs.one_implementation], 
                   f2[cs.one_implementation],
                    'k.', markersize=4, **popt)
        pylab.plot(f1[cs.multiple_implementations], 
                   f2[cs.multiple_implementations],
                   'ms', markersize=4, **popt)
        pylab.plot(f1[cs.is_not_feasible],
                   f2[cs.is_not_feasible], 'r.', markersize=0.5, **popt)
          
        do_axes(pylab)
         
         
    with r.plot('num_implementations', **fig) as pylab:
  
        ieee_spines_zoom3(pylab)
  
        x = f1
        y = f2
        z = cs.all_num_implementations
        plot_field(pylab, x, y, z, cmap='winter', vmin=0, vmax=5)
        pylab.title('num implementations', color=color_resources, y=1.08)
        do_axes(pylab)

    with r.plot('num_solutions', **fig) as pylab:
  
        ieee_spines_zoom3(pylab)
  
        x = f1
        y = f2
        z = cs.all_num_solutions
        plot_field(pylab, x, y, z, cmap='winter', vmin=0, vmax=5)
        pylab.title('num solutions', color=color_resources,  y=1.08)
        do_axes(pylab)
        
    misc = 'num solutions: %s\n num implementations: %s' % (cs.all_num_solutions, cs.all_num_implementations)
#     r.text('misc', misc)
    
    
    
Example #7
0
def figure_discrete_choices2(r, data, cs, fname1, fname2):
    
    num_solutions = cs.all_num_implementations
    all_discrete_choices = compute_discrete_choices(data)
    
    possible = ['', 'LCO', 
                'LFP', 
                'NiCad',
                'NiMH',
                'LiPo',
                'LCO-LiPo-NiMH',
                'LCO-LiPo-NiCad',
                'LCO-LFP-LiPo-NiCad',
                'LCO-LFP-LiPo',
                'LCO-LFP-LiPo-NiMH',
                'LCO-LiPo-NiCad-NiMH',
                'LCO-LFP-LiPo-NiCad-NiMH',
                'LCO-LiPo',
                'LCO-LFP',
                'LCO-LFP-NiMH',
                'LCO-NiMH',
                 'LCO-NiCad',
                 'LCO-NiCad-NiMH', 
                 'LCO-LFP-NiCad', 
                 'LCO-LFP-NiCad-NiMH', 
                 'LCO-NiCad-NiMH']    
    possible_this = sorted(np.unique(all_discrete_choices))
    for p in possible_this:
        if not p in possible:
            msg = 'Did not anticipate %r as an option.' % p
            raise ValueError(msg)

    choice_as_int = np.zeros(dtype='int', shape=len(all_discrete_choices))
    for i, x in enumerate(all_discrete_choices):
        choice_as_int[i] = possible.index(x)
    
    def do_axes(pylab):
        from mcdp_ipython_utils.plotting import set_axis_colors    
        set_axis_colors(pylab, color_functions, color_functions)
    
    with r.plot('choice_as_int', **fig) as pylab:
  
        ieee_spines_zoom3(pylab)
  
        x = cs.get_functionality(fname1)
        y = cs.get_functionality(fname2)
        z = choice_as_int
        plot_field(pylab, x, y, z, cmap='viridis', vmin=0, vmax=len(possible))
        pylab.title('choice_as_int',  y=1.08)
        do_axes(pylab)

    possible_indiv = set()
    for p in possible:
        for x in p.split('-'):
            possible_indiv.add(x)
    
        
    f = r.figure()
    for p in sorted(possible_indiv):
        if not p: continue
        
        feasible = np.array([p in _ for _ in all_discrete_choices])
        with f.plot('where_%s' % p, **fig) as pylab:
            
            ieee_spines_zoom3(pylab)
  
            x = cs.get_functionality(fname1)
            y = cs.get_functionality(fname2)
            
            AND = np.logical_and
            is_best = AND(feasible, num_solutions == 1)
            is_one_of_two = AND(feasible, num_solutions == 2)
            is_one_of_three = AND(feasible, num_solutions == 3)
            is_one_of_four_or_more = AND(feasible, num_solutions >= 4)
            
            grey = '#bbbbbb'
            color_infeasible = 'red'
            pylab.plot(x[cs.is_feasible], 
                       y[cs.is_feasible], '.', markersize=2, 
                       markerfacecolor=grey,
                       markeredgecolor='none', color='none', 
                       clip_on=False)
            pylab.plot(x[cs.is_not_feasible], 
                       y[cs.is_not_feasible], '.', markersize=2, 
                       markerfacecolor=color_infeasible,
                       markeredgecolor='none', color='none', 
                       clip_on=False)

            def plot(where, marker, color):            
                markersize = 3.5
                pylab.plot(x[where], y[where], marker, markersize=markersize, 
                           markeredgecolor='none',
                           markerfacecolor=color, 
                           color='none', clip_on=False)
                
            plot(is_best, 'o', 'black')
            plot(is_one_of_two, 'd', '#000088')
            plot(is_one_of_three, '>','#880000')
            plot(is_one_of_four_or_more,'s', '#880088')
            
            pylab.title('%s' % p,  y=1.08)
            do_axes(pylab)
    
    r.text('possible', possible) 
    r.text('text_choice_as_int', choice_as_int)  
    r.text('choices', all_discrete_choices)
Example #8
0
def figure_num_implementations2(r, data, cs, fname1, fname2):
    assert isinstance(cs, CommonStats)

    f1 = cs.get_functionality(fname1)
    f2 = cs.get_functionality(fname2)

    def do_axes(pylab):
        pylab.xlabel(fname1)
        pylab.ylabel(fname2)
        set_axis_colors(pylab, color_functions, color_functions)

    with r.plot('feasibility', **fig) as pylab:
        ieee_spines_zoom3(pylab)

        pylab.plot(f1[cs.one_solution],
                   f2[cs.one_solution],
                   'k.',
                   markersize=4,
                   **popt)
        pylab.plot(f1[cs.multiple_solutions],
                   f2[cs.multiple_solutions],
                   'ms',
                   markersize=4,
                   **popt)
        pylab.plot(f1[cs.is_not_feasible],
                   f2[cs.is_not_feasible],
                   'r.',
                   markersize=0.5,
                   **popt)

        do_axes(pylab)

    with r.plot('implementations', **fig) as pylab:
        ieee_spines_zoom3(pylab)

        pylab.plot(f1[cs.one_implementation],
                   f2[cs.one_implementation],
                   'k.',
                   markersize=4,
                   **popt)
        pylab.plot(f1[cs.multiple_implementations],
                   f2[cs.multiple_implementations],
                   'ms',
                   markersize=4,
                   **popt)
        pylab.plot(f1[cs.is_not_feasible],
                   f2[cs.is_not_feasible],
                   'r.',
                   markersize=0.5,
                   **popt)

        do_axes(pylab)

    with r.plot('num_implementations', **fig) as pylab:

        ieee_spines_zoom3(pylab)

        x = f1
        y = f2
        z = cs.all_num_implementations
        plot_field(pylab, x, y, z, cmap='winter', vmin=0, vmax=5)
        pylab.title('num implementations', color=color_resources, y=1.08)
        do_axes(pylab)

    with r.plot('num_solutions', **fig) as pylab:

        ieee_spines_zoom3(pylab)

        x = f1
        y = f2
        z = cs.all_num_solutions
        plot_field(pylab, x, y, z, cmap='winter', vmin=0, vmax=5)
        pylab.title('num solutions', color=color_resources, y=1.08)
        do_axes(pylab)

    misc = 'num solutions: %s\n num implementations: %s' % (
        cs.all_num_solutions, cs.all_num_implementations)