modules.solvers.solver.Solver
- class Solver(name: str = None)
Bases:
Core,ABCThe solver is responsible for finding feasible and high-quality solutions of the formulated problem, i.e., of the defined objective function.
- __init__(name: str = None)
Constructor method.
- Parameters:
name -- Name used to identify this QUARK module. If not specified class name will be used as default.
Methods
__init__([name])Constructor method.
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.
get_submodule(option)Submodule is instantiated according to the information given in self.sub_options.
postprocess(input_data, config, **kwargs)The actual solving process is done here, using the device which is provided by the device submodule and the problem data provided by the parent module.
preprocess(input_data, config, **kwargs)Essential method for the benchmarking process.
run(mapped_problem, device_wrapper, config, ...)This function runs the solving algorithm on a mapped problem instance and returns a solution.
- 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
- 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]
The actual solving process is done here, using the device which is provided by the device submodule and the problem data provided by the parent module.
- Parameters:
input_data -- Data passed to the run function of the solver
config -- Solver config
kwargs -- Optional keyword arguments
- Returns:
Output and time needed
- preprocess(input_data: any, config: dict, **kwargs) tuple[any, float]
Essential method for the benchmarking process. This is always executed before traversing down to the next module, passing the data returned by this function.
- Parameters:
input_data -- Data for the module, comes from the parent module if that exists
config -- Config for the module
kwargs -- Optional keyword arguments
- Returns:
The output of the preprocessing and the time it took to preprocess
- abstract run(mapped_problem: any, device_wrapper: any, config: any, **kwargs) tuple[any, float, dict]
This function runs the solving algorithm on a mapped problem instance and returns a solution.
- Parameters:
mapped_problem -- A representation of the problem that the solver can solve
device_wrapper -- A device the solver can leverage for the algorithm
config -- Settings for the solver such as hyperparameters
kwargs -- Optional additional settings
- Returns:
Solution, the time it took to compute it and some optional additional information