-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
134 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
default_environment_algorithm() = "exact" | ||
|
||
function environment( | ||
ψ::AbstractITensorNetwork, | ||
vertices::Vector; | ||
alg=default_environment_algorithm(), | ||
kwargs..., | ||
) | ||
return environment(Algorithm(alg), ψ, vertices; kwargs...) | ||
end | ||
|
||
function environment( | ||
::Algorithm"exact", | ||
ψ::AbstractITensorNetwork, | ||
verts::Vector; | ||
contraction_sequence_alg="optimal", | ||
kwargs..., | ||
) | ||
ψ_reduced = Vector{ITensor}(subgraph(ψ, setdiff(vertices(ψ), verts))) | ||
sequence = contraction_sequence(ψ_reduced; alg=contraction_sequence_alg) | ||
return ITensor[contract(ψ_reduced; sequence, kwargs...)] | ||
end | ||
|
||
function environment( | ||
::Algorithm"bp", | ||
ψ::AbstractITensorNetwork, | ||
vertices::Vector; | ||
(cache!)=nothing, | ||
partitioned_vertices=default_partitioned_vertices(ψ), | ||
update_cache=isnothing(cache!), | ||
cache_update_kwargs=default_cache_update_kwargs(cache!), | ||
) | ||
if isnothing(cache!) | ||
cache! = Ref(BeliefPropagationCache(ψ, partitioned_vertices)) | ||
end | ||
|
||
if update_cache | ||
cache![] = update(cache![]; cache_update_kwargs...) | ||
end | ||
|
||
return environment(cache![], vertices) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters