openjij
Framework for the Ising model and QUBO.
|
Sparse graph: two-body intereactions with O(1) connectivity The Hamiltonian is like. More...
#include <sparse.hpp>
Public Types | |
using | Interactions = std::unordered_map< std::pair< Index, Index >, FloatType, utility::PairHash > |
interaction type | |
using | value_type = FloatType |
float type | |
Public Member Functions | |
Sparse (std::size_t num_spins, std::size_t num_edges) | |
Sparse constructor. | |
Sparse (std::size_t num_spins) | |
Sparse delegate constructor. | |
Sparse (const json &j, std::size_t num_edges) | |
Sparse constructor (from nlohmann::json) | |
Sparse (const json &j) | |
Sparse constructor (from nlohmann::json) | |
Sparse (const Sparse< FloatType > &)=default | |
Sparse copy constructor. | |
Sparse (Sparse< FloatType > &&)=default | |
Sparse move constructor. | |
const Nodes & | adj_nodes (Index ind) const |
list of adjacent nodes | |
std::size_t | get_num_edges () const |
get number of edges | |
FloatType | calc_energy (const Spins &spins) const |
calculate total energy | |
FloatType | calc_energy (const Eigen::Matrix< FloatType, Eigen::Dynamic, 1, Eigen::ColMajor > &spins) const |
FloatType | energy (const Spins &spins) const |
calculate total energy | |
FloatType | energy (const Eigen::Matrix< FloatType, Eigen::Dynamic, 1, Eigen::ColMajor > &spins) const |
FloatType & | J (Index i, Index j) |
access J_{ij} | |
const FloatType & | J (Index i, Index j) const |
access J_{ij} | |
FloatType & | h (Index i) |
access h_{i} (local field) | |
const FloatType & | h (Index i) const |
access h_{i} (local field) | |
![]() | |
Graph (std::size_t num_spins) | |
Graph constructor. | |
template<typename RandomNumberEngine > | |
const Spins | gen_spin (RandomNumberEngine &random_numder_engine) const |
generate spins randomly. | |
template<typename RandomNumberEngine > | |
const Binaries | gen_binary (RandomNumberEngine &random_numder_engine) const |
generate spins randomly. | |
std::size_t | get_num_spins () const noexcept |
get number of spins | |
std::size_t | size () const noexcept |
get number of spins | |
Private Member Functions | |
bool | set_adj_node (Index from, Index to) |
add adjacent node from "from" Index to "to" Index | |
Private Attributes | |
Interactions | _J |
interactions (the number of intereactions is num_spins*(num_spins+1)/2) | |
std::size_t | _num_edges |
the uppder limit of the number of edges per site | |
std::vector< Nodes > | _list_adj_nodes |
the list of the indices of adjacent nodes | |
Sparse graph: two-body intereactions with O(1) connectivity The Hamiltonian is like.
\[ H = \sum_{i<j}J_{ij} \sigma_i \sigma_j + \sum_{i}h_{i} \sigma_i \]
FloatType | floating-point type |
using openjij::graph::Sparse< FloatType >::Interactions = std::unordered_map<std::pair<Index, Index>, FloatType, utility::PairHash> |
interaction type
float type
|
inline |
Sparse constructor.
num_spins | number of spins |
num_edges | number of edges |
|
inlineexplicit |
Sparse delegate constructor.
num_spins | number of spins |
|
inline |
Sparse constructor (from nlohmann::json)
j | JSON object |
num_edges | number of edges |
References openjij::graph::Sparse< FloatType >::h(), openjij::graph::Sparse< FloatType >::J(), and openjij::graph::json_parse().
Sparse constructor (from nlohmann::json)
j | JSON object |
|
default |
Sparse copy constructor.
|
default |
Sparse move constructor.
|
inline |
list of adjacent nodes
ind | Node index |
References openjij::graph::Sparse< FloatType >::_list_adj_nodes, and openjij::graph::json_parse().
Referenced by openjij::utility::gen_matrix_from_graph().
|
inline |
References openjij::graph::Sparse< FloatType >::energy(), and openjij::graph::json_parse().
|
inline |
calculate total energy
spins |
References openjij::graph::Sparse< FloatType >::energy().
Referenced by openjij::declare_Sparse().
|
inline |
References openjij::graph::Sparse< FloatType >::energy(), openjij::graph::Graph::get_num_spins(), and openjij::graph::json_parse().
|
inline |
calculate total energy
spins |
References openjij::graph::Graph::get_num_spins(), openjij::graph::Sparse< FloatType >::h(), openjij::graph::Sparse< FloatType >::J(), and openjij::graph::json_parse().
Referenced by openjij::graph::Sparse< FloatType >::calc_energy(), openjij::graph::Sparse< FloatType >::calc_energy(), and openjij::graph::Sparse< FloatType >::energy().
|
inline |
get number of edges
References openjij::graph::Sparse< FloatType >::_num_edges.
access h_{i} (local field)
i | Index i |
References openjij::graph::Sparse< FloatType >::_J, openjij::graph::Graph::get_num_spins(), openjij::graph::json_parse(), and openjij::graph::Sparse< FloatType >::set_adj_node().
Referenced by openjij::graph::Chimera< FloatType >::Chimera(), openjij::declare_Sparse(), openjij::graph::Sparse< FloatType >::energy(), openjij::utility::gen_matrix_from_graph(), openjij::graph::Square< FloatType >::h(), openjij::graph::Square< FloatType >::h(), openjij::graph::Chimera< FloatType >::h(), openjij::graph::Chimera< FloatType >::h(), openjij::graph::Sparse< FloatType >::Sparse(), and openjij::graph::Square< FloatType >::Square().
|
inline |
access h_{i} (local field)
i | Index i |
References openjij::graph::Sparse< FloatType >::_J, openjij::graph::Graph::get_num_spins(), and openjij::graph::json_parse().
|
inline |
access J_{ij}
i | Index i |
j | Index j |
References openjij::graph::Sparse< FloatType >::_J, openjij::graph::Graph::get_num_spins(), openjij::graph::json_parse(), and openjij::graph::Sparse< FloatType >::set_adj_node().
Referenced by openjij::graph::Chimera< FloatType >::Chimera(), openjij::graph::Chimera< FloatType >::Chimera(), openjij::declare_Sparse(), openjij::graph::Sparse< FloatType >::energy(), openjij::utility::gen_matrix_from_graph(), openjij::graph::Square< FloatType >::J(), openjij::graph::Square< FloatType >::J(), openjij::graph::Chimera< FloatType >::J(), openjij::graph::Chimera< FloatType >::J(), openjij::graph::Sparse< FloatType >::Sparse(), openjij::graph::Square< FloatType >::Square(), and openjij::graph::Square< FloatType >::Square().
access J_{ij}
i | Index i |
j | Index j |
References openjij::graph::Sparse< FloatType >::_J, openjij::graph::Graph::get_num_spins(), and openjij::graph::json_parse().
|
inlineprivate |
add adjacent node from "from" Index to "to" Index
from | "from" Index |
to | "to" Index |
References openjij::graph::Sparse< FloatType >::_list_adj_nodes, openjij::graph::Sparse< FloatType >::_num_edges, openjij::graph::Graph::get_num_spins(), openjij::graph::json_parse(), and openjij::graph::Sparse< FloatType >::set_adj_node().
Referenced by openjij::graph::Sparse< FloatType >::h(), openjij::graph::Sparse< FloatType >::J(), and openjij::graph::Sparse< FloatType >::set_adj_node().
|
private |
interactions (the number of intereactions is num_spins*(num_spins+1)/2)
Referenced by openjij::graph::Sparse< FloatType >::h(), openjij::graph::Sparse< FloatType >::h(), openjij::graph::Sparse< FloatType >::J(), and openjij::graph::Sparse< FloatType >::J().
|
private |
the list of the indices of adjacent nodes
Referenced by openjij::graph::Sparse< FloatType >::adj_nodes(), and openjij::graph::Sparse< FloatType >::set_adj_node().
|
private |
the uppder limit of the number of edges per site
Referenced by openjij::graph::Sparse< FloatType >::get_num_edges(), and openjij::graph::Sparse< FloatType >::set_adj_node().