Skip to content

CadetCareerProblem – Solution Generation & Algorithms Methods

generate_random_solution(p_dict={}, printing=None)

Generate random solution by assigning cadets to AFSCs that they're eligible for

Source code in afccp/main.py
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
def generate_random_solution(self, p_dict={}, printing=None):
    """
    Generate random solution by assigning cadets to AFSCs that they're eligible for
    """
    if printing is None:
        printing = self.printing

    if printing:
        print('Generating random solution...')

    # Reset instance model parameters
    self._reset_functional_parameters(p_dict)

    # Generate solution
    solution = {'method': 'Random',
        'j_array': np.array([np.random.choice(self.parameters['J^E'][i]) for i in self.parameters['I']])}

    # Determine what to do with the solution
    self._solution_handling(solution)

    return solution

rotc_rated_board_original(p_dict={}, printing=None)

Source code in afccp/main.py
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
def rotc_rated_board_original(self, p_dict={}, printing=None):
    if printing is None:
        printing = self.printing

    # Reset instance model parameters
    self._reset_functional_parameters(p_dict)

    # Get the solution we need
    solution = afccp.solutions.algorithms.rotc_rated_board_original(self, printing=printing)

    # Determine what to do with the solution
    self._solution_handling(solution)

    return solution

allocate_ots_candidates_original_method(p_dict={}, printing=None)

Source code in afccp/main.py
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
def allocate_ots_candidates_original_method(self, p_dict={}, printing=None):
    if printing is None:
        printing = self.printing

    # Reset instance model parameters
    self._reset_functional_parameters(p_dict)

    # Get the solution we need
    solution = afccp.solutions.algorithms.allocate_ots_candidates_original_method(self, printing=printing)

    # Determine what to do with the solution
    self._solution_handling(solution)

    return solution

soc_rated_matching_algorithm(p_dict={}, printing=None)

This is the Hospitals/Residents algorithm that matches or reserves cadets to their Rated AFSCs depending on the source of commissioning (SOCs).

Source code in afccp/main.py
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
def soc_rated_matching_algorithm(self, p_dict={}, printing=None):
    """
    This is the Hospitals/Residents algorithm that matches or reserves cadets to their Rated AFSCs depending on the
    source of commissioning (SOCs).
    """
    if printing is None:
        printing = self.printing

    # Reset instance model parameters
    self._reset_functional_parameters(p_dict)

    # Get the solution and solution iterations we need
    combined, reserves, matches = afccp.solutions.algorithms.soc_rated_matching_algorithm(
        self, soc=self.mdl_p['soc'], printing=printing)

    # Determine what to do with the solution(s)
    for solution in [reserves, matches, combined]:
        self._solution_handling(solution, printing=False)  # Don't want print updates for this

    return solution

classic_hr(p_dict={}, printing=None)

This method solves the problem instance using the classical "Hospital/Residents" algorithm

Source code in afccp/main.py
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
def classic_hr(self, p_dict={}, printing=None):
    """
    This method solves the problem instance using the classical "Hospital/Residents" algorithm
    """
    if printing is None:
        printing = self.printing

    # Reset instance model parameters
    self._reset_functional_parameters(p_dict)

    # Get the solution we need
    solution = afccp.solutions.algorithms.classic_hr(self, printing=printing)

    # Determine what to do with the solution
    self._solution_handling(solution)

    return solution