Skip to content

CadetCareerProblem – Data Visualizations Methods

display_data_graph(p_dict={}, printing=None)

This method plots different aspects of the fixed parameters of the problem instance.

Source code in afccp/main.py
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
def display_data_graph(self, p_dict={}, printing=None):
    """
    This method plots different aspects of the fixed parameters of the problem instance.
    """

    # 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)

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

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

display_all_data_graphs(p_dict={}, printing=None)

This method runs through all the different versions of graphs we have and saves them to the corresponding folder.

Source code in afccp/main.py
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
def display_all_data_graphs(self, p_dict={}, printing=None):
    """
    This method runs through all the different versions of graphs we have and saves
    them to the corresponding folder.
    """
    if printing is None:
        printing = self.printing

    if printing:
        print("Saving all data graphs to the corresponding folder...")

    # Regular Charts
    charts = []
    for graph in ["Average Utility", "USAFA Proportion", "Average Merit", "AFOCD Data", "Eligible Quota"]:
        p_dict["data_graph"] = graph
        charts.append(self.display_data_graph(p_dict, printing=printing))

    # Cadet Preference Analysis Charts
    p_dict["data_graph"] = "Cadet Preference Analysis"
    for version in range(1, 8):
        p_dict["version"] = str(version)
        charts.append(self.display_data_graph(p_dict, printing=printing))

    return charts

show_value_function(p_dict={}, printing=None)

This method plots a specific AFSC objective value function

Source code in afccp/main.py
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
def show_value_function(self, p_dict={}, printing=None):
    """
    This method plots a specific AFSC objective value function
    """

    if printing is None:
        printing = self.printing

    # Shorthand
    p, vp = self.parameters, self.value_parameters

    # Reset instance model parameters
    self._reset_functional_parameters(p_dict)
    self.mdl_p = afccp.data.support.determine_afsc_plot_details(self)
    ip = self.mdl_p  # More shorthand

    if printing:
        print('Creating value function chart for objective ' + ip['objective'] + ' for AFSC ' + ip['afsc'])

    # Determine AFSC and objective shown in this chart
    j, k = np.where(p["afscs"] == ip["afsc"])[0][0], np.where(vp["objectives"] == ip["objective"])[0][0]

    # ValueFunctionChart specific parameters
    vfc = ip['ValueFunctionChart']
    vfc['x_label'] = afccp.globals.obj_label_dict[ip['objective']]  # Get x label for this objective

    # Value Function specific coordinates to plot
    if vfc['x_pt'] is not None:
        vfc['y_pt'] = afccp.solutions.handling.value_function(vp['a'][j][k], vp['f^hat'][j][k], vp['r'][j][k],
                                                              vfc["x_pt"])

    # Determine x and y arrays
    if ip['smooth_value_function']:
        x_arr = (np.arange(1001) / 1000) * vp['a'][j][k][vp['r'][j][k] - 1]
        y_arr = np.array([afccp.solutions.handling.value_function(
            vp['a'][j][k], vp['f^hat'][j][k], vp['r'][j][k], x) for x in x_arr])
    else:
        x_arr, y_arr = vp['a'][j][k], vp['f^hat'][j][k]

    # Title and filepath for this value function!
    vfc['title'] = ip['afsc'] + ' ' + ip['objective'] + ' Value Function'
    vfc['filepath'] = self.export_paths['Analysis & Results'] + \
                      'Value Functions/' + self.data_name + ' ' + vfc['title'] + ' (' + self.vp_name + ').png'

    # Create and return the chart
    return afccp.visualizations.charts.ValueFunctionChart(x_arr, y_arr, vfc)

display_weight_function(p_dict={}, printing=None)

This method plots the weight function used for either cadets or AFSCs

Source code in afccp/main.py
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
def display_weight_function(self, p_dict={}, printing=None):
    """
    This method plots the weight function used for either cadets or AFSCs
    """

    if printing is None:
        printing = self.printing

    # Reset instance model parameters
    self._reset_functional_parameters(p_dict)
    self.mdl_p = afccp.data.support.determine_afsc_plot_details(self)

    # Make the folder
    if 'Value Parameters' not in os.listdir(self.export_paths['Analysis & Results']):
        os.mkdir(self.export_paths['Analysis & Results'] + 'Value Parameters')

    if printing:
        if self.mdl_p["cadets_graph"]:
            print("Creating cadet weight chart...")
        else:
            print("Creating AFSC weight chart...")

    # Build the chart
    chart = afccp.visualizations.charts.individual_weight_graph(self)

    if printing:
        chart.show()

    return chart