uo.algorithm package
Subpackages
- uo.algorithm.exact package
- uo.algorithm.metaheuristic package
- Subpackages
- Submodules
- uo.algorithm.metaheuristic.metaheuristic module
Metaheuristic
Metaheuristic.additional_statistics_control
Metaheuristic.copy()
Metaheuristic.determine_fields_val()
Metaheuristic.elapsed_seconds()
Metaheuristic.finish_control
Metaheuristic.main_loop()
Metaheuristic.main_loop_iteration()
Metaheuristic.optimize()
Metaheuristic.random_seed
Metaheuristic.should_finish()
Metaheuristic.string_rep()
Metaheuristic.update_additional_statistics_if_required()
random()
SingleSolutionMetaheuristic
random()
PopulationBasedMetaheuristic
random()
MetaheuristicVoid
random()
SingleSolutionMetaheuristicVoid
random()
PopulationBasedMetaheuristicVoid
random()
- Module contents
Submodules
uo.algorithm.algorithm module
The algorithm
module describes the class Algorithm
.
- class uo.algorithm.algorithm.Algorithm(problem: Problem, solution_template: Solution | None, name: str, output_control: OutputControl | None)
Bases:
Optimizer
This class describes Algorithm.
- output_control
The structure that controls output.
- Type:
- Properties:
solution_template (Optional[Solution]): The solution template for the problem to be solved. evaluation (int): The current number of evaluations during algorithm execution. iteration (int): The iteration of metaheuristic execution. iteration_best_found (int): The iteration when the best solution is found.
- __init__(name
str, output_control: OutputControl, problem: Problem, solution_template: Optional[Solution] = None) -> None: Create a new Algorithm instance.
- string_rep(delimiter
str, indentation: int = 0, indentation_symbol: str = ‘’, group_start: str = ‘{’, group_end: str = ‘}’) -> str: String representation of the ‘Algorithm’ instance.
- __format__(spec
str) -> str: Formatted ‘Algorithm’ instance.
- property best_solution: Solution
Property getter for the best solution obtained during metaheuristic execution
- Returns:
best solution so far
- Return type:
- abstract copy()
Copy the current algorithm
- Returns:
new Algorithm instance with the same properties
- Return type:
uo.algorithm.Algorithm
- determine_fields_val(fields_def: list[str], fields_val: list[str]) list[str]
Determines fields values upon fields definition and old values
- property evaluation: int
Property getter for current number of evaluations during algorithm execution
- Returns:
current number of evaluations
- Return type:
- property evaluation_best_found: int
Property getter for the evaluation when the best solution is found
- Returns:
evaluation when the best solution is found
- Return type:
- property iteration: int
Property getter for the iteration of metaheuristic execution
- Returns:
iteration
- Return type:
- property iteration_best_found: int
Property getter for the iteration when the best solution is found
- Returns:
iteration when the best solution is found
- Return type:
- property solution_template: Solution | None
Property getter for the solution template for the problem to be solved
- Returns:
solution template for the problem to be solved
- Return type:
Solution
- string_rep(delimiter: str, indentation: int = 0, indentation_symbol: str = '', group_start: str = '{', group_end: str = '}') str
String representation of the ‘Algorithm’ instance
- Parameters:
delimiter (str) – delimiter between fields
indentation (int, optional, default value 0) – level of indentation
indentation_symbol (str, optional, default value '') – indentation symbol
group_start (str, optional, default value '{') – group start string
group_end (str, optional, default value '}') – group end string
- Returns:
string representation of instance that controls output
- Return type:
uo.algorithm.output_control module
The output_control
module describes the class OutputControl
.
- class uo.algorithm.output_control.OutputControl(output_file: TextIOWrapper | None = None, fields: str = 'iteration, evaluation, "step_name", best_solution.string_representation(), best_solution.fitness_value, best_solution.objective_value, best_solution.is_feasible', moments: str = 'after_algorithm')
Bases:
object
This class determine where the output generated during execution of the
uo.algorithm.Algorithm
instance will be written- copy()
Copy the current output control
- Returns:
new OutputControl instance with the same properties
- Return type:
- property fields: str
Property getter for fields_definitions property
- Returns:
comma-separated string with list of fields for output
- Return type:
- property moments: str
Property getter for moments property
- Returns:
comma-separated list of moments for output
- Return type:
- property output_file: TextIOWrapper
Property getter for output file
- Returns:
output file to which algorithm will write
- Return type:
TextIOWrapper
- string_rep(delimiter: str, indentation: int = 0, indentation_symbol: str = '', group_start: str = '{', group_end: str = '}') str
String representation of the target solution instance
- Parameters:
delimiter (str) – delimiter between fields
indentation (int, optional, default value 0) – level of indentation
indentation_symbol (str, optional, default value '') – indentation symbol
group_start (str, optional, default value '{') – group start string
group_end (str, optional, default value '}') – group end string
- Returns:
string representation of instance that controls output
- Return type:
- property write_after_algorithm: bool
Property getter for property write_after_algorithm
- Returns:
should write to the output after algorithm execution
- Return type:
- property write_after_evaluation: bool
Property getter for property write_after_evaluation
- Returns:
should write to the output after evaluation
- Return type:
- property write_after_iteration: bool
Property getter for property write_after_iteration
- Returns:
should write to the output after algorithm iteration
- Return type:
- property write_after_step_in_iteration: bool
Property getter for property write_after_step_in_iteration
- Returns:
should write to the output after step in iteration
- Return type:
- property write_before_algorithm: bool
Property getter for property write_before_algorithm
- Returns:
should write to the output prior to algorithm execution
- Return type:
- property write_before_evaluation: bool
Property getter for property write_before_evaluation
- Returns:
should write to the output prior to evaluation
- Return type: