Beispiel #1
0
 def exec_sampling():
     for _ in range(num_reads):
         _exec_time, state = measure_time(hubo_simulated_annealing)(
             bhom, init_state, schedule, var_type=var_type)
         execution_time.append(_exec_time)
         response.states.append(state)
         response.energies.append(bhom.calc_energy(state))
Beispiel #2
0
        def exec_sampling():
            previous_state = _generate_init_state()
            for _ in range(self.iteration):
                if reinitilize_state:
                    sa_system.reset_spins(_generate_init_state())
                else:
                    sa_system.reset_spins(previous_state)

                _exec_time = measure_time(simulated_annealing)(sa_system)

                execution_time.append(_exec_time)
                previous_state = cxxjij.result.get_solution(sa_system)
                states.append(previous_state)
                energies.append(model.calc_energy(
                    previous_state,
                    need_to_convert_from_spin=True))
Beispiel #3
0
 def exec_sampling():
     # import pdb
     # pdb.set_trace()
     previous_state = _generate_init_state()
     for _ in range(self.iteration):
         if reinitilize_state:
             sqa_system.reset_spins(_generate_init_state())
         else:
             sqa_system.reset_spins(previous_state)
         _exec_time = measure_time(sqa_algorithm)(sqa_system)
         execution_time.append(_exec_time)
         # trotter_spins is transposed because it is stored as [Spin ​​space][Trotter].
         # [-1] is excluded because it is a tentative spin of s = 1 for convenience in SQA.
         q_state = self._post_process4state(
             sqa_system.trotter_spins[:-1].T)
         q_energies.append(
             [model.calc_energy(state,
                                need_to_convert_from_spin=True)
              for state in q_state])
         q_states.append(q_state.astype(np.int))