modules.applications.optimization.optimization.Optimization
- class Optimization(application_name: str)
Bases:
Application,ABCOptimization Module for QUARK, is used by all Optimization applications.
- __init__(application_name: str)
Constructor method.
Methods
__init__(application_name)Constructor method.
evaluate(solution)Checks how good the solution is.
generate_problem(config)Creates a concrete problem and returns it.
Gets the application.
Gets the list of available options.
get_available_submodules(option)If the module has submodules depending on certain options, this method should adjust the submodule_options accordingly.
get_default_submodule(option)Given an option string by the user, this returns a submodule.
get_depending_parameters(option, config)If the module has parameters depending on certain options, this method should return the parameters for the given option.
Returns the parameters for a given module.
Returns the required pip packages for this module.
Returns the unit of the evaluation.
get_submodule(option)Submodule is instantiated according to the information given in self.sub_options.
postprocess(input_data, config, **kwargs)For optimization problems, we process the solution here, then validate and evaluate it.
preprocess(input_data, config, **kwargs)For optimization problems, we generate the actual problem instance in the preprocess function.
process_solution(solution)Most of the time the solution has to be processed before it can be validated and evaluated.
save(path, iter_count)Saves the concrete problem.
validate(solution)Checks if the solution is a valid solution.
visualize_solution(processed_solution, path)Creates visualizations of a processed and validated solution and writes them to disk.
- abstract evaluate(solution: any) tuple[float, float]
Checks how good the solution is.
- Parameters:
solution -- Provided solution
- Returns:
Tuple with the evaluation and the time it took to create it
- abstract generate_problem(config: dict) any
Creates a concrete problem and returns it.
- Parameters:
config -- Configuration for problem creation
- Returns:
Generated problem
- get_application() any
Gets the application.
- Returns:
self.application
- get_available_submodule_options() list
Gets the list of available options.
- Returns:
List of module options
- get_available_submodules(option: list) list
If the module has submodules depending on certain options, this method should adjust the submodule_options accordingly.
- Parameters:
option -- List of chosen options
- Returns:
List of available submodules
- abstract get_default_submodule(option: str) Core
Given an option string by the user, this returns a submodule.
- Parameters:
option -- String with the chosen submodule
- Returns:
Module of type Core
- get_depending_parameters(option: str, config: dict) dict
If the module has parameters depending on certain options, this method should return the parameters for the given option.
- Parameters:
option -- The chosen option
config -- Current config dictionary
- Returns:
The parameters for the given option
- abstract get_parameter_options() dict
Returns the parameters for a given module.
Should always be in this format:
{ "parameter_name":{ "values":[1, 2, 3], "description":"How many nodes do you need?" }, "parameter_name_2":{ "values":["x", "y"], "description":"Which type of problem do you want?" } }
- Returns:
Available settings for this application
- static get_requirements() list
Returns the required pip packages for this module. Optionally, version requirements can be added.
- Returns:
List of dictionaries
- abstract get_solution_quality_unit() str
Returns the unit of the evaluation.
- Returns:
String with the unit
- get_submodule(option: str) Core
Submodule is instantiated according to the information given in self.sub_options. If self.sub_options is None, get_default_submodule is called as a fallback.
- Parameters:
option -- String with the options
- Returns:
Instance of a module
- postprocess(input_data: any, config: dict, **kwargs) tuple[any, float]
For optimization problems, we process the solution here, then validate and evaluate it.
- Parameters:
input_data -- Data which should be evaluated for this optimization problem
config -- Config for the problem creation
kwargs -- Optional additional arguments
- Returns:
Tuple with results and the postprocessing time
- preprocess(input_data: any, config: dict, **kwargs) tuple[any, float]
For optimization problems, we generate the actual problem instance in the preprocess function.
- Parameters:
input_data -- Input data (usually not used in this method)
config -- Config for the problem creation
kwargs -- Optional additional arguments
- Returns:
Tuple with output and the preprocessing time
- process_solution(solution: any) tuple[any, float]
Most of the time the solution has to be processed before it can be validated and evaluated. This might not be necessary in all cases, so the default is to return the original solution.
- Parameters:
solution -- Proposed solution
- Returns:
Tuple with processed solution and the execution time to process it
- abstract save(path: str, iter_count: int) None
Saves the concrete problem.
- Parameters:
path -- Path of the experiment directory for this run
iter_count -- The iteration count
- abstract validate(solution: any) tuple[bool, float]
Checks if the solution is a valid solution.
- Parameters:
solution -- Proposed solution
- Returns:
Bool value if solution is valid and the time it took to validate the solution
- visualize_solution(processed_solution: any, path: str) None
Creates visualizations of a processed and validated solution and writes them to disk. Override if applicable. Default is to do nothing.
- Parameters:
processed_solution -- A solution that was already processed by
process_solution()path -- File path for the plot
- Returns:
None