openjij
Framework for the Ising model and QUBO.
Loading...
Searching...
No Matches
openjij::utility Namespace Reference

Classes

struct  get_base_class
 meta function for linear-searching base class of "derived_class" from the variadic template list (head_base_class ... tail_base_class). More...
 
struct  get_base_class< derived_class, base_class >
 meta function for linear-searching base class of "derived_class" from the variadic template list (head_base_class ... tail_base_class). More...
 
struct  get_eigen_matrix_type
 get Eigen Matrix type from Graph Type More...
 
struct  get_eigen_matrix_type< graph::Dense< FloatType >, Options >
 get Eigen Matrix type from Graph Type More...
 
struct  get_eigen_matrix_type< graph::Sparse< FloatType >, Options >
 get Eigen Matrix type from Graph Type More...
 
struct  IndexHash
 Hash struct of IndexType. More...
 
struct  IndexPairHash
 Hash struct of std::pair<IndexType>. More...
 
struct  IndexVectorHash
 Hash struct of std::vector<AnyIndexType>. More...
 
struct  is_same_template
 check if two template template parameters are the same. More...
 
struct  is_same_template< T, T >
 check if two template template parameters are the same. More...
 
struct  PairHash
 hash class for std::pair More...
 
struct  Schedule
 schedule struct More...
 
struct  UnionFind
 
struct  UpdaterParameter
 updater parameter for monte carlo simulation More...
 
struct  UpdaterParameter< system::classical_constraint_system >
 updater paramter for classical ising model with a single constraint More...
 
struct  UpdaterParameter< system::classical_system >
 updater parameter for classical ising system More...
 
struct  UpdaterParameter< system::transverse_field_system >
 updater paramter for transverse ising model More...
 
struct  VectorHash
 Hash struct of std::vector<T>. More...
 
class  Xorshift
 xorshift random generator for c++11 random More...
 

Typedefs

using AnyTupleType = std::vector< std::variant< std::int32_t, std::string > >
 Vector type of integer and string.
 
using IndexType = std::variant< std::int32_t, std::string, AnyTupleType >
 The index type of binary variables.
 
using ClassicalUpdaterParameter = UpdaterParameter< system::classical_system >
 ClassicalUpdaterParameter alias.
 
using ClassicalConstraintUpdaterParameter = UpdaterParameter< system::classical_constraint_system >
 ClassicalUpdaterParameter alias.
 
using TransverseFieldUpdaterParameter = UpdaterParameter< system::transverse_field_system >
 TransverseFieldUpdaterParameter alias.
 
template<typename SystemType >
using ScheduleList = std::vector< Schedule< SystemType > >
 schedule list alias
 
using ClassicalScheduleList = ScheduleList< system::classical_system >
 ClassicalScheduleList alias.
 
using TransverseFieldScheduleList = ScheduleList< system::transverse_field_system >
 TransverseFieldScheduleList alias.
 
using ClassicalConstraintScheduleList = ScheduleList< system::classical_constraint_system >
 ClassicalConstraintScheduleList alias.
 

Enumerations

enum class  TemperatureSchedule { LINEAR , GEOMETRIC }
 

Functions

template<typename ForwardIterator , typename T >
void make_geometric_progression (ForwardIterator first, ForwardIterator last, T value, T ratio)
 
template<typename FloatType , int Options = Eigen::ColMajor>
static Eigen::Matrix< FloatType, Eigen::Dynamic, 1, Options > gen_vector_from_std_vector (const graph::Spins &init_spin)
 generate Eigen Vector from std::vector
 
template<typename FloatType , int Options = Eigen::ColMajor>
static Eigen::Matrix< FloatType, Eigen::Dynamic, Eigen::Dynamic, Options > gen_matrix_from_trotter_spins (const std::vector< graph::Spins > &trotter_spins)
 generate Eigen Matrix from TrotterSpins
 
template<int Options = Eigen::ColMajor, typename FloatType >
static Eigen::Matrix< FloatType, Eigen::Dynamic, Eigen::Dynamic, Options > gen_matrix_from_graph (const graph::Dense< FloatType > &graph)
 generate Eigen Dense Matrix from Dense graph
 
template<int Options = Eigen::ColMajor, typename FloatType >
static Eigen::SparseMatrix< FloatType, Options > gen_matrix_from_graph (const graph::Sparse< FloatType > &graph)
 generate Eigen Sparse Matrix from Sparse graph
 
template<class C_key , class C_value , class Hash >
void insert_or_assign (std::unordered_map< C_key, C_value, Hash > &um, const C_key &key, const C_value &val)
 Insert or assign a element of unordered_map (for C++14 or C++11)
 
template<typename T , typename... Args>
std::unique_ptr< T > make_unique (Args &&...args)
 make_unique function
 
ClassicalScheduleList make_classical_schedule_list (double beta_min, double beta_max, std::size_t one_mc_step, std::size_t num_call_updater)
 helper function for making classical schedule list with geometric series of inverse temperatures.
 
TransverseFieldScheduleList make_transverse_field_schedule_list (double beta, std::size_t one_mc_step, std::size_t num_call_updater)
 helper function for making transverse field system schedule list with arithmetic sequence of annealing schedule (s)
 
ClassicalConstraintScheduleList make_classical_constraint_schedule_list (double lambda, double beta_min, double beta_max, std::size_t one_mc_step, std::size_t num_call_updater)
 helper function for making classical constraint schedule list with geometric series of inverse temperatures (with constraint parameter fixed).
 
template<typename SystemType >
ScheduleList< SystemType > make_schedule_list (const std::vector< std::pair< typename UpdaterParameter< SystemType >::Tuple, std::size_t > > &tuplelist)
 helper function for making schedulelist from list of tuples
 
template<typename FloatType >
std::vector< FloatTypeGenerateLinearBetaSchedule (const FloatType beta_min, const FloatType beta_max, const std::int32_t num_sweeps)
 Generate linear temperature schedule.
 
template<typename FloatType >
std::vector< FloatTypeGenerateGeometricBetaSchedule (const FloatType beta_min, const FloatType beta_max, const std::int32_t num_sweeps)
 Generate geometric temperature schedule.
 
template<typename FloatType >
std::vector< FloatTypeGenerateBetaList (const TemperatureSchedule schedule_type, const FloatType beta_min, const FloatType beta_max, const std::int32_t num_sweeps)
 Generate temperature schedule from specific schedule.
 

Variables

template<typename FloatType >
const FloatType THRESHOLD = 0.00000001
 

Typedef Documentation

◆ AnyTupleType

using openjij::utility::AnyTupleType = typedef std::vector<std::variant<std::int32_t, std::string> >

Vector type of integer and string.

◆ ClassicalConstraintScheduleList

◆ ClassicalConstraintUpdaterParameter

◆ ClassicalScheduleList

ClassicalScheduleList alias.

◆ ClassicalUpdaterParameter

◆ IndexType

using openjij::utility::IndexType = typedef std::variant<std::int32_t, std::string, AnyTupleType>

The index type of binary variables.

◆ ScheduleList

template<typename SystemType >
using openjij::utility::ScheduleList = typedef std::vector<Schedule<SystemType> >

schedule list alias

Template Parameters
SystemTypesystem type

◆ TransverseFieldScheduleList

◆ TransverseFieldUpdaterParameter

Enumeration Type Documentation

◆ TemperatureSchedule

Enumerator
LINEAR 

Linear cooling.

GEOMETRIC 

Geometric cooling.

Function Documentation

◆ gen_matrix_from_graph() [1/2]

template<int Options = Eigen::ColMajor, typename FloatType >
static Eigen::Matrix< FloatType, Eigen::Dynamic, Eigen::Dynamic, Options > openjij::utility::gen_matrix_from_graph ( const graph::Dense< FloatType > &  graph)
inlinestatic

generate Eigen Dense Matrix from Dense graph

Template Parameters
OptionsEigen Options (RowMajor or ColMajor)
FloatType
Parameters
graph
Returns
generated Eigen Dense Matrix (graph.get_num_spins()+1 x graph.get_num_spins()+1)

References openjij::graph::Graph::get_num_spins(), openjij::graph::Dense< FloatType >::h(), and openjij::graph::Dense< FloatType >::J().

Here is the call graph for this function:

◆ gen_matrix_from_graph() [2/2]

template<int Options = Eigen::ColMajor, typename FloatType >
static Eigen::SparseMatrix< FloatType, Options > openjij::utility::gen_matrix_from_graph ( const graph::Sparse< FloatType > &  graph)
inlinestatic

generate Eigen Sparse Matrix from Sparse graph

Template Parameters
OptionsEigen Options (RowMajor or ColMajor)
FloatType
Parameters
graph
Returns
generated Eigen Sparse Matrix (graph.get_num_spins()+1 x graph.get_num_spins()+1)

References openjij::graph::Sparse< FloatType >::adj_nodes(), openjij::graph::Graph::get_num_spins(), openjij::graph::Sparse< FloatType >::h(), and openjij::graph::Sparse< FloatType >::J().

Here is the call graph for this function:

◆ gen_matrix_from_trotter_spins()

template<typename FloatType , int Options = Eigen::ColMajor>
static Eigen::Matrix< FloatType, Eigen::Dynamic, Eigen::Dynamic, Options > openjij::utility::gen_matrix_from_trotter_spins ( const std::vector< graph::Spins > &  trotter_spins)
inlinestatic

generate Eigen Matrix from TrotterSpins

Template Parameters
FloatType
OptionsEigen Options (RowMajor or ColMajor)
Parameters
trotter_spins
Returns
generated Eigen Matrix (trotter_spins[0].size()+1 x trotter_spins.size())

◆ gen_vector_from_std_vector()

template<typename FloatType , int Options = Eigen::ColMajor>
static Eigen::Matrix< FloatType, Eigen::Dynamic, 1, Options > openjij::utility::gen_vector_from_std_vector ( const graph::Spins init_spin)
inlinestatic

generate Eigen Vector from std::vector

Template Parameters
FloatType
OptionsEigen Options (RowMajor or ColMajor)
Parameters
init_spin
Returns
generated Eigen Vector (init_spin.size()+1 x 1)

◆ GenerateBetaList()

template<typename FloatType >
std::vector< FloatType > openjij::utility::GenerateBetaList ( const TemperatureSchedule  schedule_type,
const FloatType  beta_min,
const FloatType  beta_max,
const std::int32_t  num_sweeps 
)

Generate temperature schedule from specific schedule.

Template Parameters
FloatTypeFloating point type
Parameters
schedule_typeThe type of temperature schedule
beta_minThe minimum value of inverse temperature
beta_maxThe maximum value of inverse temperature
num_sweepsThe number of sweeps
Returns
Temperature schedule

References GenerateGeometricBetaSchedule(), GenerateLinearBetaSchedule(), GEOMETRIC, and LINEAR.

Referenced by openjij::sampler::SASampler< ModelType >::TemplateSampler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateGeometricBetaSchedule()

template<typename FloatType >
std::vector< FloatType > openjij::utility::GenerateGeometricBetaSchedule ( const FloatType  beta_min,
const FloatType  beta_max,
const std::int32_t  num_sweeps 
)

Generate geometric temperature schedule.

Template Parameters
FloatTypeFloating point type
Parameters
beta_minThe minimum value of inverse temperature
beta_maxThe maximum value of inverse temperature
num_sweepsThe number of sweeps
Returns
Geometric temperature schedule

Referenced by GenerateBetaList().

Here is the caller graph for this function:

◆ GenerateLinearBetaSchedule()

template<typename FloatType >
std::vector< FloatType > openjij::utility::GenerateLinearBetaSchedule ( const FloatType  beta_min,
const FloatType  beta_max,
const std::int32_t  num_sweeps 
)

Generate linear temperature schedule.

Template Parameters
FloatTypeFloating point type
Parameters
beta_minThe minimum value of inverse temperature
beta_maxThe maximum value of inverse temperature
num_sweepsThe number of sweeps
Returns
Linear temperature schedule

Referenced by GenerateBetaList().

Here is the caller graph for this function:

◆ insert_or_assign()

template<class C_key , class C_value , class Hash >
void openjij::utility::insert_or_assign ( std::unordered_map< C_key, C_value, Hash > &  um,
const C_key &  key,
const C_value &  val 
)
inline

Insert or assign a element of unordered_map (for C++14 or C++11)

Template Parameters
C_key
C_value
Hash
Parameters
um
key
val

◆ make_classical_constraint_schedule_list()

ClassicalConstraintScheduleList openjij::utility::make_classical_constraint_schedule_list ( double  lambda,
double  beta_min,
double  beta_max,
std::size_t  one_mc_step,
std::size_t  num_call_updater 
)

helper function for making classical constraint schedule list with geometric series of inverse temperatures (with constraint parameter fixed).

Parameters
lambdaconstraint paraemeters
beta_min
beta_max
one_mc_step
num_call_updater
Returns
generated schedule list

Referenced by PYBIND11_MODULE().

Here is the caller graph for this function:

◆ make_classical_schedule_list()

ClassicalScheduleList openjij::utility::make_classical_schedule_list ( double  beta_min,
double  beta_max,
std::size_t  one_mc_step,
std::size_t  num_call_updater 
)

helper function for making classical schedule list with geometric series of inverse temperatures.

Parameters
beta_mininitial (minimal) value of beta
beta_maxfinal (maximal) value of beta
one_mc_stepnumber of mc step for each temperature
num_call_updaternumber of updater calls
Returns
generated list

Referenced by PYBIND11_MODULE().

Here is the caller graph for this function:

◆ make_geometric_progression()

template<typename ForwardIterator , typename T >
void openjij::utility::make_geometric_progression ( ForwardIterator  first,
ForwardIterator  last,
value,
ratio 
)

◆ make_schedule_list()

template<typename SystemType >
ScheduleList< SystemType > openjij::utility::make_schedule_list ( const std::vector< std::pair< typename UpdaterParameter< SystemType >::Tuple, std::size_t > > &  tuplelist)

helper function for making schedulelist from list of tuples

Template Parameters
SystemType
Parameters
tuplelist
Returns

◆ make_transverse_field_schedule_list()

TransverseFieldScheduleList openjij::utility::make_transverse_field_schedule_list ( double  beta,
std::size_t  one_mc_step,
std::size_t  num_call_updater 
)

helper function for making transverse field system schedule list with arithmetic sequence of annealing schedule (s)

Parameters
betainverse temperature
one_mc_stepnumber of mc step for each temperature
num_call_updaternumber of updater calls
Returns

Referenced by PYBIND11_MODULE().

Here is the caller graph for this function:

◆ make_unique()

template<typename T , typename... Args>
std::unique_ptr< T > openjij::utility::make_unique ( Args &&...  args)

make_unique function

Template Parameters
T
...Args
Parameters
...args
Returns
unique_ptr

Variable Documentation

◆ THRESHOLD

template<typename FloatType >
const FloatType openjij::utility::THRESHOLD = 0.00000001