ccvm_solver#
- class CCVMSolver(device)[source]#
Bases:
ABC
The base class for all solvers. This class should not be used directly; one of the subclasses should be used.
- Parameters:
device (DeviceType) – The device that the solver will use to solve the problem.
- get_scaling_factor(q_matrix)[source]#
Uses a default calculation to determine the amount by which the problem coefficients should be scaled. The value may differ depending on the solver, as some solvers have different scaling multipliers.
- Parameters:
q_matrix (torch.tensor) – The Q matrix describing the BoxQP problem
- Returns:
- The recommended scaling factor to be use to scale the problem for
this solver.
- Return type:
float
- property is_tuned#
True if the current solver parameters were set by the tune() function.
- Type:
bool
- machine_energy(machine: str, machine_parameters: dict | None = None)[source]#
Calculates the average energy consumed by the specified hardware for a given problem size.
- Parameters:
machine (str) – The type of machine to calculate the average energy consumption.
machine_parameters (dict) – Parameters of the machine. Defaults to None.
- Raises:
ValueError – If the given machine is not a valid machine type.
ValueError – If there is a mismatch between the solver and the machine type.
- Returns:
- A callable function that calculates the average energy consumption
of the solver based on the given machine type.
- Return type:
Callable
- machine_time(machine: str, machine_parameters: dict | None = None)[source]#
Calculates the average time spent during the simulation by the specified hardware for a given problem size.
- Parameters:
machine (str) – The type of machine for which to calculate the average time for simulating a single instance.
machine_parameters (dict) – Parameters of the machine. Defaults to None.
- Raises:
ValueError – If the given machine is not a valid machine type.
ValueError – If there is a mismatch between the solver and the machine type.
- Returns:
- A callable function that calculates the average time taken by the
solver during simulation of a single instance on the given machine type.
- Return type:
Callable
- property parameter_key#
The parameters that will be used by the solver when solving the problem.
Note
Setting this parameter after calling tune() will overwrite tuned parameters.
This method should be overwritten by the subclass to ensure that the docstrings in the final documentation are personalized for the subclassed solver.
The setter for this parameter must also be implemented in the subclass.
- Returns:
The parameter key.
- Return type:
dict
- abstract tune()[source]#
Determines the best parameters for the solver to use by adjusting each parameter over a number of iterations on the problems in the given set of problems instances. The parameter_key attribute of the solver will be updated with the best parameters found. Input parameters to this function are specific to each solver.