openjij.utils package

Submodules

openjij.utils.benchmark module

openjij.utils.benchmark.residual_energy(response, ref_energy)[source]

Calculate redisual energy from measure energy :param response: response from solver (or sampler). :type response: openjij.Response :param ref_energy: the reference energy (usually use the ground energy) :type ref_energy: float

Returns

Residual energy which is defined as \(\langle E \rangle - E_0\) (\(\langle...\rangle\) represents average, \(E_0\) is the reference energy (usually use the ground energy)).

Return type

float

openjij.utils.benchmark.se_lower_tts(tts, success_prob, computation_time, p_r, se_success_prob)[source]
Parameters
  • success_prob (float) – success probability.

  • computation_time (float) –

  • p_r (float) – thereshold probability to calculate time to solution.

Returns

time to solution \(\tau * \log(1-pr)/\log(1-ps)\) ‘s standard error which pr is thereshold probability, ps is success probability and \(tau\) is computation time.

Return type

float

openjij.utils.benchmark.se_residual_energy(response, ref_energy)[source]

Calculate redisual energy’s standard error from measure energy :param response: response from solver (or sampler). :type response: openjij.Response :param ref_energy: the reference energy (usually use the ground energy) :type ref_energy: float

Returns

redisual energy’s standard error from measure energy

Return type

float

openjij.utils.benchmark.se_success_probability(response, solutions, ref_energy=0, measure_with_energy=False)[source]

Calculate success probability’s standard error from openjij.response :param response: response from solver (or sampler). :type response: openjij.Response :param solutions: true solutions. :type solutions: list[int]

Returns

Success probability’s standard error.

  • When measure_with_energy is False, success is defined as getting the same state as solutions.

  • When measure_with_energy is True, success is defined as getting a state which energy is below reference energy

Return type

float

openjij.utils.benchmark.se_upper_tts(tts, success_prob, computation_time, p_r, se_success_prob)[source]
Parameters
  • success_prob (float) – success probability.

  • computation_time (float) –

  • p_r (float) – thereshold probability to calculate time to solution.

Returens:

float: time to solution \(\tau * \log(1-pr)/\log(1-ps)\) ‘s standard error which pr is thereshold probability, ps is success probability and \(tau\) is computation time.

openjij.utils.benchmark.solver_benchmark(solver, time_list, solutions=[], args={}, p_r=0.99, ref_energy=0, measure_with_energy=False, time_name='execution_time')[source]

Calculate ‘success probability’, ‘TTS’, ‘Residual energy’,’Standard Error’ with computation time :param solver: returns openjij.Response, and solver has arguments ‘time’ and ‘**args’ :type solver: callable :param time_list: :type time_list: list :param solutions: true solution or list of solution (if solutions are degenerated). :type solutions: list(list(int)), list(int) :param args: Arguments for solver. :type args: dict :param p_r: Thereshold probability for time to solutions. :type p_r: float :param ref_energy: The ground (reference to calculate success probability and the residual energy) energy. :type ref_energy: float :param measure_with_energy: use a energy as measure for success :type measure_with_energy: bool

Returns

dictionary which has the following keys:

  • time: list of compuation time

  • success_prob list of success probability at each computation time

  • tts: list of time to solusion at each computation time

  • residual_energy: list of residual energy at each computation time

  • se_lower_tts: list of tts’s lower standard error at each computation time

  • se_upper_tts: list of tts’s upper standard error at each computation time

  • se_success_prob: list of success probability’s standard error at each computation time

  • se_residual_energy: list of residual_energy’s standard error at each computation time

  • info (dict): Parameter information for the benchmark

Return type

dict

openjij.utils.benchmark.success_probability(response, solutions, ref_energy=0, measure_with_energy=False)[source]

Calculate success probability from openjij.response :param response: response from solver (or sampler). :type response: openjij.Response :param solutions: true solutions. :type solutions: list[int]

Returns

Success probability.

  • When measure_with_energy is False, success is defined as getting the same state as solutions.

  • When measure_with_energy is True, success is defined as getting a state which energy is below reference energy

Return type

float

openjij.utils.benchmark.time_to_solution(success_prob, computation_time, p_r)[source]
Parameters
  • success_prob (float) – success probability.

  • computation_time (float) –

  • p_r (float) – thereshold probability to calculate time to solution.

Returns

time to solution \(\tau * \log(1-pr)/\log(1-ps)\) which pr is thereshold probability, ps is success probability and \(tau\) is computation time.

Return type

float

openjij.utils.decorator module

openjij.utils.decorator.deprecated_alias(**aliases)[source]
openjij.utils.decorator.disabled(func)[source]
openjij.utils.decorator.rename_kwargs(func_name, kwargs, aliases)[source]

openjij.utils.graph_utils module

openjij.utils.graph_utils.chimera_to_ind(r: int, c: int, z: int, L: int)[source]

[summary]

Parameters
  • r (int) – row index

  • c (int) – column index

  • z (int) – in-chimera index (must be from 0 to 7)

  • L (int) – height and width of chimera-units (total number of spins is \(L \times L \times 8\))

Raises

ValueError – [description]

Returns

corresponding Chimera index

Return type

int

openjij.utils.graph_utils.qubo_to_ising(mat: numpy.ndarray)[source]

inplace-convert numpy matrix from qubo to ising.

Parameters

mat (np.ndarray) – numpy matrix

openjij.utils.res_convertor module

openjij.utils.res_convertor.convert_response(response)[source]

openjij.utils.time_measure module

Module contents