@@ -14,7 +14,7 @@ using NamedGraphs.PartitionedGraphs:
1414 unpartitioned_graph,
1515 which_partition
1616using SimpleTraits: SimpleTraits, Not, @traitfn
17- using NDTensors: NDTensors
17+ using NDTensors: NDTensors, Algorithm
1818
1919function default_cache_construction_kwargs (alg:: Algorithm"bp" , ψ:: AbstractITensorNetwork )
2020 return (; partitioned_vertices= default_partitioned_vertices (ψ))
8080function default_message_update_alg (bp_cache:: BeliefPropagationCache )
8181 return Algorithm (" contract" ; normalize= true , sequence_alg= " optimal" )
8282end
83- function set_kwargs (alg:: Algorithm"contract" )
84- normalize = get (alg. kwargs, :normalize , true )
85- sequence_alg = get (alg. kwargs, :sequence_alg , " optimal" )
83+ default_normalize (:: Algorithm"contract" ) = true
84+ default_sequence_alg (:: Algorithm"contract" ) = " optimal"
85+ function set_default_kwargs (alg:: Algorithm"contract" )
86+ normalize = get (alg. kwargs, :normalize , default_normalize (alg))
87+ sequence_alg = get (alg. kwargs, :sequence_alg , default_sequence_alg (alg))
8688 return Algorithm (" contract" ; normalize, sequence_alg)
8789end
88- function set_kwargs (alg:: Algorithm"adapt_update" )
89- return Algorithm (" adapt_update" ; adapt= alg. kwargs. adapt, alg= set_kwargs (alg. kwargs. alg))
90+ function set_default_kwargs (alg:: Algorithm"adapt_update" )
91+ return Algorithm (
92+ " adapt_update" ; adapt= alg. kwargs. adapt, alg= set_default_kwargs (alg. kwargs. alg)
93+ )
9094end
91- function set_kwargs (alg:: Algorithm"bp" , bp_cache:: BeliefPropagationCache )
92- verbose = get (alg. kwargs, :verbose , false )
95+ default_verbose (:: Algorithm"bp" ) = false
96+ default_tol (:: Algorithm"bp" ) = nothing
97+ function set_default_kwargs (alg:: Algorithm"bp" , bp_cache:: BeliefPropagationCache )
98+ verbose = get (alg. kwargs, :verbose , default_verbose (alg))
9399 maxiter = get (alg. kwargs, :maxiter , default_bp_maxiter (bp_cache))
94100 edge_sequence = get (alg. kwargs, :edge_sequence , default_bp_edge_sequence (bp_cache))
95- tol = get (alg. kwargs, :tol , nothing )
101+ tol = get (alg. kwargs, :tol , default_tol (alg) )
96102 return Algorithm (" bp" ; verbose, maxiter, edge_sequence, tol)
97103end
98104
0 commit comments