openjij
Framework for the Ising model and QUBO.
|
Class for executing simulated annealing. More...
#include <sa_sampler.hpp>
Public Member Functions | |
SASampler (const ModelType &model) | |
Constructor for SASampler class. | |
void | SetNumSweeps (const std::int32_t num_sweeps) |
Set the number of sweeps. | |
void | SetNumReads (const std::int32_t num_reads) |
Set the number of samples. | |
void | SetNumThreads (const std::int32_t num_threads) |
Set the number of threads in the calculation. | |
void | SetBetaMin (const ValueType beta_min) |
Set the minimum inverse temperature. | |
void | SetBetaMax (const ValueType beta_max) |
Set the minimum inverse temperature. | |
void | SetBetaMinAuto () |
Set the minimum inverse temperature automatically. | |
void | SetBetaMaxAuto () |
Set the maximum inverse temperature automatically. | |
void | SetUpdateMethod (const algorithm::UpdateMethod update_method) |
Set update method used in the state update. | |
void | SetRandomNumberEngine (const algorithm::RandomNumberEngine random_number_engine) |
Set random number engine for updating initializing state. | |
void | SetTemperatureSchedule (const utility::TemperatureSchedule schedule) |
Set the cooling schedule. | |
const ModelType & | GetModel () const |
Get the model. | |
std::int32_t | GetNumSweeps () const |
Get the number of sweeps. | |
std::int32_t | GetNumReads () const |
Get the number of reads. | |
std::int32_t | GetNumThreads () const |
Get the number of threads. | |
ValueType | GetBetaMin () const |
Get the minimum inverse temperature. | |
ValueType | GetBetaMax () const |
Get the maximum inverse temperature. | |
algorithm::UpdateMethod | GetUpdateMethod () const |
Get the update method used in the state update. | |
algorithm::RandomNumberEngine | GetRandomNumberEngine () const |
Get the random number engine for updating and initializing state. | |
utility::TemperatureSchedule | GetTemperatureSchedule () const |
Get the temperature schedule. | |
std::uint64_t | GetSeed () const |
Get the seed to be used in the calculation. | |
const std::vector< typename ModelType::IndexType > & | GetIndexList () const |
const std::vector< std::vector< VariableType > > & | GetSamples () const |
Get the samples. | |
std::vector< ValueType > | CalculateEnergies () const |
void | Sample () |
Execute sampling. | |
void | Sample (const std::uint64_t seed) |
Execute sampling. | |
Private Types | |
using | ValueType = typename ModelType::ValueType |
The value type. | |
using | VariableType = typename ModelType::VariableType |
The variable type. | |
Private Member Functions | |
template<typename RandType > | |
std::vector< std::pair< typename RandType::result_type, typename RandType::result_type > > | GenerateSeedPairList (const typename RandType::result_type seed, const std::int32_t num_reads) const |
template<class SystemType , class RandType > | |
void | TemplateSampler () |
Private Attributes | |
const ModelType | model_ |
The model. | |
std::int32_t | num_sweeps_ = 1000 |
The number of sweeps. | |
std::int32_t | num_reads_ = 1 |
The number of reads (samples). | |
std::int32_t | num_threads_ = 1 |
The number of threads in the calculation. | |
ValueType | beta_min_ = 1 |
The start inverse temperature. | |
ValueType | beta_max_ = 1 |
The end inverse temperature. | |
algorithm::UpdateMethod | update_method_ = algorithm::UpdateMethod::METROPOLIS |
The update method used in the state update. | |
algorithm::RandomNumberEngine | random_number_engine_ = algorithm::RandomNumberEngine::XORSHIFT |
Random number engine for updating and initializing state. | |
utility::TemperatureSchedule | schedule_ = utility::TemperatureSchedule::GEOMETRIC |
Cooling schedule. | |
std::uint64_t | seed_ = std::random_device()() |
The seed to be used in the calculation. | |
std::vector< std::vector< VariableType > > | samples_ |
The samples. | |
Class for executing simulated annealing.
ModelType | The type of models. |
|
private |
The value type.
|
private |
The variable type.
|
inline |
Constructor for SASampler class.
model | The model. |
|
inline |
|
inlineprivate |
|
inline |
Get the maximum inverse temperature.
References openjij::sampler::SASampler< ModelType >::beta_max_.
|
inline |
Get the minimum inverse temperature.
References openjij::sampler::SASampler< ModelType >::beta_min_.
|
inline |
References openjij::sampler::SASampler< ModelType >::model_.
|
inline |
|
inline |
Get the number of reads.
References openjij::sampler::SASampler< ModelType >::num_reads_.
|
inline |
Get the number of sweeps.
References openjij::sampler::SASampler< ModelType >::num_sweeps_.
|
inline |
Get the number of threads.
References openjij::sampler::SASampler< ModelType >::num_threads_.
|
inline |
Get the random number engine for updating and initializing state.
References openjij::sampler::SASampler< ModelType >::random_number_engine_.
|
inline |
|
inline |
Get the seed to be used in the calculation.
References openjij::sampler::SASampler< ModelType >::seed_.
|
inline |
Get the temperature schedule.
References openjij::sampler::SASampler< ModelType >::schedule_.
|
inline |
Get the update method used in the state update.
References openjij::sampler::SASampler< ModelType >::update_method_.
|
inline |
Execute sampling.
Seed to be used in the calculation will be set automatically.
References openjij::sampler::SASampler< ModelType >::Sample().
Referenced by openjij::sampler::SASampler< ModelType >::Sample().
|
inline |
Execute sampling.
seed | The seed to be used in the calculation. |
References openjij::algorithm::MT, openjij::algorithm::MT_64, openjij::sampler::SASampler< ModelType >::num_reads_, openjij::sampler::SASampler< ModelType >::random_number_engine_, openjij::sampler::SASampler< ModelType >::samples_, openjij::sampler::SASampler< ModelType >::seed_, and openjij::algorithm::XORSHIFT.
|
inline |
Set the minimum inverse temperature.
beta_max | The minimum inverse temperature, which must be larger than zero. |
References openjij::sampler::SASampler< ModelType >::beta_max_.
|
inline |
Set the maximum inverse temperature automatically.
References openjij::sampler::SASampler< ModelType >::beta_max_, and openjij::sampler::SASampler< ModelType >::model_.
|
inline |
Set the minimum inverse temperature.
beta_min | The minimum inverse temperature, which must be larger than zero. |
References openjij::sampler::SASampler< ModelType >::beta_min_.
|
inline |
Set the minimum inverse temperature automatically.
References openjij::sampler::SASampler< ModelType >::beta_min_, and openjij::sampler::SASampler< ModelType >::model_.
|
inline |
Set the number of samples.
num_reads | The number of samples, which must be larger than zero. |
References openjij::sampler::SASampler< ModelType >::num_reads_.
|
inline |
Set the number of sweeps.
num_sweeps | The number of sweeps, which must be larger than zero. |
References openjij::sampler::SASampler< ModelType >::num_sweeps_.
|
inline |
Set the number of threads in the calculation.
num_threads | The number of threads in the calculation, which must be larger than zero. |
References openjij::sampler::SASampler< ModelType >::num_threads_.
|
inline |
Set random number engine for updating initializing state.
random_number_engine | The random number engine. |
References openjij::sampler::SASampler< ModelType >::random_number_engine_.
|
inline |
Set the cooling schedule.
schedule | The cooling schedule. |
References openjij::sampler::SASampler< ModelType >::schedule_.
|
inline |
Set update method used in the state update.
update_method | The update method. |
References openjij::sampler::SASampler< ModelType >::update_method_.
|
inlineprivate |
References openjij::sampler::SASampler< ModelType >::beta_max_, openjij::sampler::SASampler< ModelType >::beta_min_, openjij::utility::GenerateBetaList(), openjij::sampler::SASampler< ModelType >::model_, openjij::sampler::SASampler< ModelType >::num_reads_, openjij::sampler::SASampler< ModelType >::num_sweeps_, openjij::sampler::SASampler< ModelType >::samples_, openjij::sampler::SASampler< ModelType >::schedule_, openjij::sampler::SASampler< ModelType >::seed_, and openjij::sampler::SASampler< ModelType >::update_method_.
|
private |
|
private |
|
private |
The model.
Referenced by openjij::sampler::SASampler< ModelType >::CalculateEnergies(), openjij::sampler::SASampler< ModelType >::GetIndexList(), openjij::sampler::SASampler< ModelType >::GetModel(), openjij::sampler::SASampler< ModelType >::SetBetaMaxAuto(), openjij::sampler::SASampler< ModelType >::SetBetaMinAuto(), and openjij::sampler::SASampler< ModelType >::TemplateSampler().
|
private |
The number of reads (samples).
Referenced by openjij::sampler::SASampler< ModelType >::CalculateEnergies(), openjij::sampler::SASampler< ModelType >::GetNumReads(), openjij::sampler::SASampler< ModelType >::Sample(), openjij::sampler::SASampler< ModelType >::SetNumReads(), and openjij::sampler::SASampler< ModelType >::TemplateSampler().
|
private |
The number of sweeps.
Referenced by openjij::sampler::SASampler< ModelType >::GetNumSweeps(), openjij::sampler::SASampler< ModelType >::SetNumSweeps(), and openjij::sampler::SASampler< ModelType >::TemplateSampler().
|
private |
The number of threads in the calculation.
Referenced by openjij::sampler::SASampler< ModelType >::GetNumThreads(), and openjij::sampler::SASampler< ModelType >::SetNumThreads().
|
private |
Random number engine for updating and initializing state.
Referenced by openjij::sampler::SASampler< ModelType >::GetRandomNumberEngine(), openjij::sampler::SASampler< ModelType >::Sample(), and openjij::sampler::SASampler< ModelType >::SetRandomNumberEngine().
|
private |
|
private |
|
private |
The seed to be used in the calculation.
Referenced by openjij::sampler::SASampler< ModelType >::GetSeed(), openjij::sampler::SASampler< ModelType >::Sample(), and openjij::sampler::SASampler< ModelType >::TemplateSampler().
|
private |
The update method used in the state update.
Referenced by openjij::sampler::SASampler< ModelType >::GetUpdateMethod(), openjij::sampler::SASampler< ModelType >::SetUpdateMethod(), and openjij::sampler::SASampler< ModelType >::TemplateSampler().