modules.applications.mapping.Mapping
- class Mapping(name: str = None)
Bases:
Core,ABCThis module translates the input data and problem specification from the parent module, e.g., the application into a mathematical formulation suitable the submodule, e.g., a solver.
- __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.
map(problem, config)Maps the given problem into a specific format suitable for the submodule, e.g., a solver.
postprocess(input_data, config, **kwargs)Reverse transformation/mapping from the submodule's format to the mathematical formulation suitable for the parent module.
preprocess(input_data, config, **kwargs)Maps the data to the correct target format.
reverse_map(solution)Maps the solution back to the original problem.
- 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
- abstract map(problem: any, config: dict) tuple[any, float]
Maps the given problem into a specific format suitable for the submodule, e.g., a solver.
- Parameters:
config -- Instance of class Config specifying the mapping settings
problem -- Problem instance which should be mapped to the target representation
- Returns:
Mapped problem and the time it took to map it
- postprocess(input_data: any, config: dict, **kwargs) tuple[any, float]
Reverse transformation/mapping from the submodule's format to the mathematical formulation suitable for the parent module.
- Parameters:
input_data -- Data which should be reverse-mapped
config -- Config of the reverse mapping
kwargs -- Optional keyword arguments
- Returns:
Tuple with reverse-mapped problem and the time it took to map it
- preprocess(input_data: any, config: dict, **kwargs) tuple[any, float]
Maps the data to the correct target format.
- Parameters:
input_data -- Data which should be mapped
config -- Config of the mapping
kwargs -- Optional keyword arguments
- Returns:
Tuple with mapped problem and the time it took to map it
- reverse_map(solution: any) tuple[any, float]
Maps the solution back to the original problem. This might not be necessary in all cases, so the default is to return the original solution. This might be needed to convert the solution to a representation needed for validation and evaluation.
- Parameters:
solution -- Solution provided by submodule, e.g., the Solver class
- Returns:
Reverse-mapped solution and the time it took to create it