Skip to content

CadetCareerProblem – Results Visualizations Methods

display_all_results_graphs(p_dict={}, printing=None)

Saves all charts for the current solution and for the solutions in the solution names list if specified

Source code in afccp/main.py
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
def display_all_results_graphs(self, p_dict={}, printing=None):
    """
    Saves all charts for the current solution and for the solutions in the solution names list if specified
    """

    if printing is None:
        printing = self.printing

    # Create solution folder if necessary
    self._manage_solution_folder()

    # Determine what kind of results charts we're creating
    if 'solution_names' not in p_dict:  # Regular Solution Charts
        desired_charts = 'desired_charts'
        if printing:
            print("Saving all solution results charts to the corresponding folder...")

    else:  # Solution Comparison Charts
        desired_charts = 'desired_comparison_charts'
        p_dict['results_graph'] = 'Solution Comparison'
        if printing:
            print("Saving all solution comparison charts to the corresponding folder...")

        # Evaluate the solutions to get metrics
        self._evaluate_all_solutions(p_dict['solution_names'])

    # Loop through the subset of AFSC charts that I actually care about
    charts = []
    for obj, version in self.mdl_p[desired_charts]:
        if printing:
            print("<Objective '" + obj + "' version '" + version + "'>")

        # Build the figure
        if obj in self.value_parameters['objectives'] or obj == 'Extra':
            p_dict["objective"] = obj
            p_dict["version"] = version
            p_dict['macro_chart_kind'] = 'AFSC Chart'
            charts.append(self.display_results_graph(p_dict))
        else:
            if printing:
                print("Objective '" + obj + "' passed since it isn't in our set of objectives.")

    # Loop through the subset of "other charts" that I care about
    if self.mdl_p['results_graph'] != "Solution Comparison":  # Only for a solution-specific chart
        for kind, version in self.mdl_p['desired_other_charts']:
            if printing:
                print("<Other Charts '" + kind + "' version '" + version + "'>")

            # Build the figure
            p_dict['objective'] = "Extra"
            p_dict["version"] = version
            p_dict['macro_chart_kind'] = 'Accessions Group'
            charts.append(self.display_results_graph(p_dict))


    return charts

display_cadet_individual_utility_graph(p_dict={}, printing=None)

Builds the cadet utility graph for a particular cadet

Source code in afccp/main.py
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
def display_cadet_individual_utility_graph(self, p_dict={}, printing=None):
    """
    Builds the cadet utility graph for a particular cadet
    """

    # Print statement
    if printing is None:
        printing = self.printing

    # Adjust instance plot parameters
    self._reset_functional_parameters(p_dict)

    # Build the chart
    afccp.visualizations.charts.CadetUtilityGraph(self)

display_results_graph(p_dict={}, printing=None)

Builds the AFSC Results graphs

Source code in afccp/main.py
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
def display_results_graph(self, p_dict={}, printing=None):
    """
    Builds the AFSC Results graphs
    """

    # Print statement
    if printing is None:
        printing = self.printing

    # Adjust instance plot parameters
    self._reset_functional_parameters(p_dict)
    self.mdl_p = afccp.data.support.determine_afsc_plot_details(self, results_chart=True)

    # Error handling
    if self.mdl_p['results_graph'] == 'Solution Comparison':
        self._error_checking('Solutions')
        chart_type = 'Comparison'
    else:
        self._error_checking('Solution')
        chart_type = 'Solution'

    # Determine which chart to create
    if self.mdl_p["macro_chart_kind"] == "AFSC Chart":

        # Initialize the AFSC Chart object
        afsc_chart = afccp.visualizations.charts.AFSCsChart(self)

        # Construct the specific chart
        return afsc_chart.build(chart_type=chart_type, printing=printing)

    elif self.mdl_p["macro_chart_kind"] == "Accessions Group":

        # Initialize the AFSC Chart object
        acc_chart = afccp.visualizations.charts.AccessionsGroupChart(self)

        # Construct the specific chart
        return acc_chart.build(chart_type=chart_type, printing=printing)

generate_results_slides(p_dict={}, printing=None)

Method to generate the results slides for a particular problem instance with solution

Source code in afccp/main.py
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
def generate_results_slides(self, p_dict={}, printing=None):
    """
    Method to generate the results slides for a particular problem instance with solution
    """

    if printing is None:
        printing = self.printing

    if printing:
        print("Generating results slides...")

    # Adjust instance plot parameters
    self._reset_functional_parameters(p_dict)
    self._error_checking('Solution')

    # Call the function to generate the slides
    if afccp.globals.use_pptx:
        afccp.visualizations.slides.generate_results_slides(self)
    else:
        print('PPTX library not installed.')

    if printing:
        print('Done.')

generate_comparison_slides(p_dict={}, printing=None)

Method to generate the results slides for a particular problem instance with solution

Source code in afccp/main.py
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
def generate_comparison_slides(self, p_dict={}, printing=None):
    """
    Method to generate the results slides for a particular problem instance with solution
    """

    if printing is None:
        printing = self.printing

    if printing:
        print("Generating comparison slides...")

    if 'Comparison Charts' not in os.listdir(self.export_paths['Analysis & Results']):
        raise ValueError("Error. No 'Comparison Charts' folder found in the 'Analysis & Results' folder. You need to"
                         " put all charts you'd like to compile into a slide-deck in this folder.")

    # Adjust instance plot parameters
    self._reset_functional_parameters(p_dict)
    self._error_checking('Solutions')

    # Call the function to generate the slides
    if afccp.globals.use_pptx:
        afccp.visualizations.slides.generate_comparison_slides(self)
    else:
        print('PPTX library not installed.')

    if printing:
        print('Done.')

generate_animation_slides(p_dict={}, printing=None)

Method to generate the animation slides for a particular problem instance and solution iterations

Source code in afccp/main.py
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
def generate_animation_slides(self, p_dict={}, printing=None):
    """
    Method to generate the animation slides for a particular problem instance and solution iterations
    """

    if printing is None:
        printing = self.printing

    if printing:
        print("Generating animation slides...")

    # Manage the solution iterations
    self._manage_bubbles_parameters(p_dict)

    # Call the function to generate the slides
    if afccp.globals.use_pptx:
        # afccp.visualizations.slides.create_animation_slides(self)
        afccp.visualizations.slides.create_animated_presentation(self, num_intro_slides=5)
    else:
        print('PPTX library not installed.')

    if printing:
        print('Done.')

generate_comparison_slide_components(p_dict={}, printing=None)

Method to do all the steps of generating the specific solution comparison charts I want

Source code in afccp/main.py
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
def generate_comparison_slide_components(self, p_dict={}, printing=None):
    """
    Method to do all the steps of generating the specific solution comparison charts I want
    """

    if printing is None:
        printing = self.printing

    if "solution_names" not in p_dict:
        raise ValueError("Error. In order to run this comparison method, the argument 'solution_names' must be "
                         "passed within 'p_dict'. This needs to be a list of solution names.")

    if printing:
        print("Generating comparison charts for the solutions:", p_dict['solution_names'])

    # Create the comparison charts folder if necessary
    if 'Comparison Charts' not in os.listdir(self.export_paths['Analysis & Results']):
        os.mkdir(self.export_paths['Analysis & Results'] + 'Comparison Charts')

    # Adjust instance plot parameters
    self._reset_functional_parameters(p_dict)
    self._error_checking('Solutions')

    # Save all solution comparison charts to the "Comparison Charts" folder
    self.display_all_results_graphs(p_dict, printing)

    # Cadet Utility Histogram
    self.display_utility_histogram(p_dict, folder='Comparison Charts')

    # Create pareto frontier plots
    self.show_pareto_chart(folder='Comparison Charts')  # without solutions
    self.show_pareto_chart(p_dict, folder='Comparison Charts',
                           solution_names=p_dict['solution_names'])  # with solutions

    # Compute similarity matrix and then calculate the similarity plot between all the solutions
    self.compute_similarity_matrix(solution_names=p_dict['solution_names'])
    self.similarity_plot(p_dict, folder='Comparison Charts')

    if printing:
        print('Done.')

display_utility_histogram(p_dict={}, printing=None, folder='Results Charts')

This method plots the cadet utility histogram

Source code in afccp/main.py
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
def display_utility_histogram(self, p_dict={}, printing=None, folder="Results Charts"):
    """
    This method plots the cadet utility histogram
    """

    # Print statement
    if printing is None:
        printing = self.printing
    if printing:
        print("Creating cadet utility histogram...")

    # Adjust instance plot parameters
    self._reset_functional_parameters(p_dict)
    self.mdl_p = afccp.data.support.determine_afsc_plot_details(self, results_chart=True)

    # Evaluate the solutions to get metrics
    if self.mdl_p['solution_names'] is not None:
        self._evaluate_all_solutions(self.mdl_p['solution_names'])

    # Filepath for plot
    filepath = self.export_paths['Analysis & Results'] + folder + "/"

    # Construct the chart
    return afccp.visualizations.charts.cadet_utility_histogram(self, filepath=filepath)

generate_bubbles_chart(p_dict={}, printing=None)

Method to generate the "BubbleChart" figure by calling the BubbleChart class and applying the parameters as specified in the ccp helping functions.

Source code in afccp/main.py
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
def generate_bubbles_chart(self, p_dict={}, printing=None):
    """
    Method to generate the "BubbleChart" figure by calling the BubbleChart class and applying the parameters
    as specified in the ccp helping functions.
    """

    if printing is None:
        printing = self.printing

    # Manage the solution iterations
    self._manage_bubbles_parameters(p_dict)

    # Print updates
    if printing:
        print('Creating Bubbles Chart...')

    # Call the figure object
    bubble_chart = afccp.visualizations.bubbles.BubbleChart(self, printing=printing)
    bubble_chart.main()

    # Only build the animation slides if we're saving iteration frames
    if self.mdl_p['save_iteration_frames']:

        # Generate the slides to go with this
        self.generate_animation_slides(p_dict, printing)