# Built-in graphs

Following is the list of the graph models which are provided with the module. After loading the RRRMC module, they can be constructed like in this example:

julia> X = RRRMC.GraphRRG(10, 3)

Note that for models which involve randomness in the constructor you may want to set the random seed with Random.seed! before calling the constructor, for reproducibility purposes.

## Basic spin glass models

### Random regular graphs

RRRMC.RRG.GraphRRGType
GraphRRG(N::Integer, K::Integer, LEV = (-1,1)) <: DiscrGraph

A DiscGraph implementing a random regular graph with N spins and connectivity K. Note: N*K must be even. Also, the graph generator uses the pairing model method by Bollobás, with a cutoff on the number of restarts, and thus it may occasionally fail if K is large.

The interactions are extracted at random from LEV, which must be a Tuple of Reals. No external fields.

source
RRRMC.RRG.GraphRRGNormalType
GraphRRGNormal(N::Integer, K::Integer) <: SimpleGraph{Float64}

A SimpleGraph implementing a random regular graph with N spins and connectivity K. Note: N*K must be even. Also, the graph generator uses the pairing model method by Bollobás, with a cutoff on the number of restarts, and thus it may occasionally fail if K is large.

Same as GraphRRG, but the interactions are extracted from a normal distribution with unit variance.

source
RRRMC.RRG.GraphRRGNormalDiscretizedType
GraphRRGNormalDiscretized(N::Integer, K::Integer, LEV) <: DoubleGraph{DiscrGraph,Float64}

A DoubleGraph implementing a random regular graph with N spins and connectivity K. Note: N*K must be even. Also, the graph generator uses the pairing model method by Bollobás, with a cutoff on the number of restarts, and thus it may occasionally fail if K is large.

The interactions are extracted from a normal distribution with unit variance, and are then discretized using the values in LEV, which must be a Tuple of Reals. No external fields.

Same as GraphRRGNormal, but it works differently when used with rrrMC.

source

### Edwards-Anderson graphs

RRRMC.EA.GraphEAType
GraphEA(L::Integer, D::Integer, LEV = (-1,1)) <: DiscrGraph

An Edwards-Anderson DiscrGraph: spins are arranged on a square lattice of size L in D dimensions (i.e. there are $L^D$ total spins), with periodic boundary conditions.

The interactions are extracted at random from LEV, which must be a Tuple of Reals. No external fields.

source
RRRMC.EA.GraphEANormalType
GraphEANormal(L::Integer, D::Integer) <: SimpleGraph{Float64}

An Edwards-Anderson SimpleGraph: spins are arranged on a square lattice of size L in D dimensions (i.e. there are $L^D$ total spins), with periodic boundary conditions.

Same as GraphEA, but the interactions are extracted from a normal distribution with unit variance.

source
RRRMC.EA.GraphEANormalDiscretizedType
GraphEANormalDiscretized(L::Integer, D::Integer, LEV) <: DoubleGraph{DiscrGraph,Float64}

An Edwards-Anderson DoubleGraph: spins are arranged on a square lattice of size L in D dimensions (i.e. there are $L^D$ total spins), with periodic boundary conditions.

The interactions are extracted at random from a normal distribution with unit variance, and are then discretized using the values in LEV, which must be a Tuple of Reals. No external fields.

Same as GraphEANormal, but works differently when used with rrrMC.

source

### p-spin

RRRMC.PSpin3.GraphPSpin3Type
GraphPSpin3(N::Integer, K::Integer) <: DiscrGraph{Int}

A DiscrGraph implementing a $p$-spin regular graph with $p=3$. N is the number of spins, and must be divisible by $3$; K is the connectivity. All interactions are set to $J=1$.

source

### Sherrington-Kirkpatrick graphs

RRRMC.SK.GraphSKType
GraphSK(N::Integer) <: SimpleGraph{Float64}

A SimpleGraph implementing a Sherrington-Kirkpatrick fully-connected Ising model with N spins and random binary interactions ($J ∈ \{-1/√N,1/√N\}$) and no external fields.

Same as GraphSKNormal, but with binary interactions.

source
RRRMC.SK.GraphSKNormalType
GraphSK(N::Integer) <: SimpleGraph{Float64}

A SimpleGraph implementing a Sherrington-Kirkpatrick fully-connected Ising model with N spins and random interactions extracted from a normal distribution with zero mean and $1/N$ variance, and no external fields.

Same as GraphSK, but with Gaussian interactions.

source

### Binary Neural Networks

RRRMC.PercStep.GraphPercStepType
GraphPercStep(N::Integer, P::Integer) <: SimpleGraph{Int}

A SimpleGraph implementing a single-layer binary perceptron with N binary ($±1$) synapses, trained on P random i.i.d. $±1$ patterns.

The energy of the model is computed as the number of misclassified patterns.

source
RRRMC.PercLinear.GraphPercLinearType
GraphPercLinear(N::Integer, P::Integer) <: SimpleGraph{Float64}

A SimpleGraph implementing a single-layer binary perceptron with N binary ($±1$) synapses, trained on P random i.i.d. $±1$ patterns.

The energy of the model is computed for each pattern as the minimum number of weights which need to be flipped in order to satisfy that pattern.

source
RRRMC.PercXEntr.GraphPercXEntrType
GraphPercXEntr(N::Integer, P::Integer, λ::Float64) <: SimpleGraph{Float64}

A SimpleGraph implementing a single-layer binary perceptron with N binary ($±1$) synapses, trained on P random i.i.d. $±1$ patterns.

The energy of the model is computed for each pattern using the cross-entropy loss (with a λ parameter: $\log(1 + \exp(-2λ σ⋅ξ / √N))$.

source
RRRMC.CommStep.GraphCommStepType
GraphCommStep(K1::Integer, K2::Integer, P::Integer; fc = false) <: SimpleGraph{Int}

A SimpleGraph implementing a two-layer binary committee machine with K2 hidden units, where each hidden unit has K1 binary ($±1$) synapses, trained on P random i.i.d. $±1$ patterns. The output of each hidden unit is computed through a step function $sign(x)$. Both K1 and K2 must be odd. The default is to generate a tree-like machine, but it can be made fully-connected with the argument fc=true.

The energy of the model is computed as the number of misclassified patterns.

source
RRRMC.CommReLU.GraphCommReLUType
GraphCommReLU(K1::Integer, K2::Integer, P::Integer; fc = false) <: SimpleGraph{Int}

A SimpleGraph implementing a two-layer binary committee machine with K2 hidden units, where each hidden unit has K1 binary ($±1$) synapses, trained on P random i.i.d. $±1$ patterns. The output of each hidden unit is computed through a ReLU function $max(0,x)$, and then half of the K2 units have a negative weight associated to their output. Both K1 and K2 must be even. The default is to generate a tree-like machine, but it can be made fully-connected with the argument fc=true.

The energy of the model is computed as the number of misclassified patterns.

source
RRRMC.CommQu.GraphCommQuType
GraphCommQu(K1::Integer, K2::Integer, P::Integer; fc = false) <: SimpleGraph{Int}

A SimpleGraph implementing a two-layer binary committee machine with K2 hidden units, where each hidden unit has K1 binary ($±1$) synapses, trained on P random i.i.d. $±1$ patterns. The output of each hidden unit is computed through a quadratic function $x^2$, and then half of the K2 units have a negative weight associated to their output. Both K1 and K2 must be even. The default is to generate a tree-like machine, but it can be made fully-connected with the argument fc=true.

The energy of the model is computed as the number of misclassified patterns.

source

### SAT

RRRMC.SAT.GraphSATType

GraphSAT(N::Integer, α::Real, K::Integer)

A DiscrGraph implementing a random K-SAT graph with N spins and αN clauses.

The energy of the model is the number of violated clauses.

source

## Quantum models with transverse fields

RRRMC.QT.GraphQuantType
GraphQuant(N::Integer, M::Integer, Γ::Float64, β::Float64, Gconstr, args...) <: DoubleGraph

A DoubleGraph which implements a quantum Ising spin model in a transverse magnetic field, using the Suzuki-Trotter transformation. This allows to model the quantum transverse field case for any classical Ising model previously defined. This kind of graph can be simulated efficiently with rrrMC.

N is the number of spins, M the number of Suzuki-Trotter replicas, Γ the transverse field, β the inverse temperature. GConstr is the (classical) graph constructor, and args the arguments to the contructor.

See also Qenergy and transverse_mag.

source

## Robust Ensemble models

RRRMC.RE.GraphRobustEnsembleType
GraphRobustEnsemble(N::Integer, M::Integer, γ::Float64, β::Float64, Gconstr, args...) <: DoubleGraph

A DoubleGraph which implements a "Robust Ensemble" model, given any other Ising model previously defined. This kind of graph can be simulated efficiently with rrrMC.

N is the number of spins, M the number of replicas, γ the interaction strength, β the inverse temperature. GConstr is the (original) graph constructor, and args the arguments to the contructor.

This is similar to GraphLocalEntropy, but the reference configuration is traced out.

See also REenergies.

source

## Local Entropy models

RRRMC.LE.GraphLocalEntropyType
GraphLocalEntropy(N::Integer, M::Integer, γ::Float64, β::Float64, Gconstr, args...) <: DoubleGraph

A DoubleGraph which implements a "Local Entropy" model, given any other Ising model previously defined. This simulates a replicated system in which each replica interacts with an extra "reference" configuration. This kind of graph can be simulated efficiently with rrrMC.

N is the number of spins, M the number of replicas, γ the interaction strength, β the inverse temperature. GConstr is the (original) graph constructor, and args the arguments to the contructor.

This is similar to GraphRobustEnsemble, but the reference is simulated explicitly.

See also LEenergies and cenergy.

source
RRRMC.TLE.GraphTopologicalLocalEntropyType
GraphTopologicalLocalEntropy(N::Integer, M::Integer, γ::Float64, λ::Float64, β::Float64, Gconstr, args...) <: DoubleGraph

A DoubleGraph which implements a "Local Entropy" model, given any other Ising model previously defined. This simulates a replicated system in which each replica interacts with an extra "reference" configuration. This kind of graph can be simulated efficiently with rrrMC.

N is the number of spins, M the number of replicas, γ the interaction strength of the replicas with the reference, λ is the topological interaction strenght, β the inverse temperature. GConstr is the (original) graph constructor, and args the arguments to the contructor.

This is similar to GraphLocalEntropy, but with the additional topological interaction.

See also TLEenergies and cenergy.

source

## Mixed models

RRRMC.Mixed.GraphMixedType
GraphMixed(graphs::AbstractGraph...)

A SimpleGraph mixing 2 or more base graphs into a single model. The energy function of a mixed graph is just the sum of the energy functions of the individual graphs in graphs.

***Usage Example***:

X = RRRMC.GraphMixed(RRRMC.GraphRRG(10, 3),
RRRMC.GraphSK(10))

X = RRRMC.GraphMixed(RRRMC.GraphSK(31),
RRRMC.GraphPercStep(31, 30),
RRRMC.GraphSAT(31, 3, 4.2))
source

## Models with additional fields

RRRMC.AddFields.GraphAddFieldsType
GraphAddFields(fields::Vector, g::AbstractGraph) <: DoubleGraph

A DoubleGraph that implements a model in which additional fields are added to the graph g. The additional fields can then be taken care of efficiently with rrrMC.

source
RRRMC.AddFields.GraphAddSubFieldsType
GraphAddSubFields(fields::Vector, g::AbstractGraph) <: DoubleGraph

A DoubleGraph that implements a model in which the given fields are added and subtracted to the graph g. The fields can then be taken care of efficiently with rrrMC.

source

## Trivial models used for testing and debugging

RRRMC.Empty.GraphEmptyType
GraphEmpty(N::Integer) <: SimpleGraph{Int}

A trivial SimpleGraph type with N free, non-interacting spins. (The energy is always 0.)

Only useful for testing/debugging purposes.

source
RRRMC.TwoSpin.GraphTwoSpinType
GraphTwoSpin() <: DiscrGraph{Int}

A trivial DiscrGraph type with 2 spins inteacting ferromagnetically ($J=1$), without fields.

Only useful for testing/debugging purposes.

source
RRRMC.ThreeSpin.GraphThreeSpinType
GraphThreeSpin() <: DiscrGraph{Int}

A trivial DiscrGraph type with 3 spins, ferromagnetic interactions ($J=1$), no fields, and periodic boundary conditions.

Only useful for testing/debugging purposes.

source
RRRMC.Fields.GraphFieldsType
GraphFields(N::Integer, LEV::Tuple = (1,)) <: DiscrGraph

A simple DiscrGraph type with N non-interacting variables, each of which is subject to a local field. The fields are extracted at random from LEV, which must be a Tuple of Reals.

Mostly useful for testing/debugging purposes.

source
RRRMC.Fields.GraphFieldsNormalDiscretizedType
GraphFieldsNormalDiscretized(N::Integer, LEV::Tuple) <: DoubleGraph{Float64,GraphFields}

A simple DoubleGraph type with N non-interacting variables, each of which is subject to a local field. The fields are extracted independently from a normal distribution with unit variance, and then are discretized using the values in LEV, which must be a Tuple of Reals.

Mostly useful for testing/debugging purposes.

source
RRRMC.Ising1D.GraphIsing1DType
GraphIsing1D(N::Integer) <: DiscrGraph{Int}

A simple 1-dimensional DiscrGraph type with N spins, antiferromagnetic interactions ($J=-1$), contstant fields ($h=1$), and periodic boundary conditions.

Mostly useful for testing/debugging purposes.

source