openjij.utils#

Submodules#

Functions#

convert_response(response)

residual_energy(response, ref_energy)

Calculate redisual energy from measure energy

se_lower_tts(tts, success_prob, computation_time, p_r, ...)

param success_prob:

success probability.

se_residual_energy(response, ref_energy)

Calculate redisual energy's standard error from measure energy

se_success_probability(response, solutions[, ...])

Calculate success probability's standard error from openjij.response

se_upper_tts(tts, success_prob, computation_time, p_r, ...)

param success_prob:

success probability.

solver_benchmark(solver, time_list[, solutions, args, ...])

Calculate 'success probability', 'TTS', 'Residual energy','Standard Error' with computation time

success_probability(response, solutions[, ref_energy, ...])

Calculate success probability from openjij.response

time_to_solution(success_prob, computation_time, p_r)

param success_prob:

success probability.

Package Contents#

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

Calculate redisual energy from measure energy

Parameters:
  • response (openjij.Response) – response from solver (or sampler).

  • ref_energy (float) – the reference energy (usually use the ground energy)

Returns:

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

Return type:

float

openjij.utils.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 τlog(1pr)/log(1ps)\tau * \log(1-pr)/\log(1-ps) ‘s standard error which pr is thereshold probability, ps is success probability and tautau is computation time.

Return type:

float

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

Calculate redisual energy’s standard error from measure energy

Parameters:
  • response (openjij.Response) – response from solver (or sampler).

  • ref_energy (float) – the reference energy (usually use the ground energy)

Returns:

redisual energy’s standard error from measure energy

Return type:

float

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

Calculate success probability’s standard error from openjij.response

Parameters:
  • response (openjij.Response) – response from solver (or sampler).

  • solutions (list[int]) – true solutions.

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.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 τlog(1pr)/log(1ps)\tau * \log(1-pr)/\log(1-ps) ‘s standard error which pr is thereshold probability, ps is success probability and tautau is computation time.

openjij.utils.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

Parameters:
  • solver (callable) – returns openjij.Response, and solver has arguments ‘time’ and ‘**args’

  • time_list (list)

  • solutions (list(list(int)), list(int)) – true solution or list of solution (if solutions are degenerated).

  • args (dict) – Arguments for solver.

  • p_r (float) – Thereshold probability for time to solutions.

  • ref_energy (float) – The ground (reference to calculate success probability and the residual energy) energy.

  • measure_with_energy (bool) – use a energy as measure for success

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.success_probability(response, solutions, ref_energy=0, measure_with_energy=False)[source]#

Calculate success probability from openjij.response

Parameters:
  • response (openjij.Response) – response from solver (or sampler).

  • solutions (list[int]) – true solutions.

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.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 τlog(1pr)/log(1ps)\tau * \log(1-pr)/\log(1-ps) which pr is thereshold probability, ps is success probability and tautau is computation time.

Return type:

float