rollo.input_validation
Contents
rollo.input_validation
Module Contents
- class rollo.input_validation.InputValidation(input_dict)
The InputValidation class contains methods to read and validate the JSON ROLLO input file to ensure the user defined all key parameters. If the user did not, ROLLO raises an exception to tell the user which parameters are missing.
- input
rollo json input file as a dict
- Type
dict
- add_all_defaults(self)
Goes through the entire input_dict and adds default inputs if they are missing from the input_dict
- Parameters
input_dict (dict) – input file dict
- Returns
reloaded_input_dict – input file dict with additional missing default inputs
- Return type
dict
- default_check(self, input_dict, variable, default_val)
Checks if a single variable is missing from a dict, and adds a default value if it is
- Parameters
input_dict (dict) – input file dict
variable (str) – variable name
default_val (any type accepted) – default input for that variable (can be str, float, dict, etc.)
- Returns
input_dict – input file dict with additional missing default input defined by parameters of this function
- Return type
dict
- validate(self)
Validates the input dictionary and throws errors if the input file does not meet rollo input file rules.
- validate_algorithm(self, input_algorithm, input_evaluators)
Validates the “algorithm” segment of the JSON input file
- validate_algorithm_operators(self, operator_type, input_algorithm)
Validates the genetic algorithm operators
- Parameters
operator_type (str) – types are selection, mutation, and mating
input_algorithm (dict) – algorithm sub-dictionary from input file
- validate_constraints(self, input_constraints, input_evaluators)
Validates the constraints segment of the JSON input file
- Parameters
input_constraints (dict) – constraints sub-dictionary from input file
input_evaluators (dict) – evaluators sub-dictionary from input file
- validate_ctrl_vars(self, input_ctrl_vars)
Validates the control variables segment of the JSON input file
- Parameters
input_ctrl_vars (dict) – control variables sub-dictionary from input file
- validate_evaluators(self, input_evaluators)
Validates the evaluators segment of the JSON input file
- Parameters
input_evaluators (dict) – evaluators sub-dictionary from input file
- validate_if_in_list(self, input_strings, accepted_strings)
Checks if strings are in a defined list of strings and returns a boolean
- Parameters
input_strings (list of str) – list of variable names to check
accepted_strings (list of str) – list of variable names to check against
- Returns
in_list (bool) – boolean indicating if all input_strings are in accepted_strings
which_strings (list) – list of variables from input_strings that are not in accepted_strings
- validate_in_list(self, variable, accepted_variables, name)
Checks if a variable is in a list of accepted variables
- Parameters
variable (str) – name of variable to check
accepted_variables (list of str) – name of variables to check against
name (str) – parameter name
- validate_correct_keys(self, dict_to_validate, key_names, optional_key_names, variable_type)
Runs a try except routine for to check if all key names are in the dict_to_validate and ensure no unwanted keys are defined
- Parameters
dict_to_validate (dict) – dict to validate
key_names (list of str) – names of required keys
optional_key_names (list of str) – names of optional keys
variable_type (str) – parameter name