How to use the openjij.sampler.measure_time function in openjij

To help you get started, we’ve selected a few openjij examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenJij / OpenJij / examples / python / sample_model.py View on Github external
def exec_sampling():
            previous_state = _init_state()
            for _ in range(self.iteration):
                if reinitilize_state:
                    sqa_system.reset_spins(_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))
github OpenJij / OpenJij / examples / python / sample_model.py View on Github external
        @measure_time
        def exec_sampling():
            previous_state = _init_state()
            for _ in range(self.iteration):
                if reinitilize_state:
                    sqa_system.reset_spins(_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)