You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This algorithm optimizes the given index set (in this case `[1, 2, 3, 4, 5]`) by searching for a maximum absolute value, alternating through the dimensions. If no starting point is given, `[1, 1, ...]` is used.
119
119
120
+
## Combing TCI2 and global pivot search
121
+
The main algorithm for adding new pivots in TCI2 is the 2-site algorithm, which is local.
122
+
The 2-site algorithm alone may miss some regions with high interpolation error.
123
+
124
+
The current TCI2 implementation provides the combination of the 2-site algorithm and a global search algorithm to find such regions.
125
+
This functionality is activated by default.
126
+
In the function [`crossinterpolate2`](@ref), we alternate between a 2-site-update sweep and a global pivot insertion.
127
+
After a 2-site-update sweep, we search for index sets with high interpolation errors (> the given tolerance multiplied by the parameter `tolmarginglobalsearch`) and add them to the TCI2 object, and then we continue with a 2-site-update sweep.
128
+
129
+
The number of initial points used in one global search is controlled by the parameter `nsearchglobalpivot`.
130
+
You may consider increasing this number if the global search is not effective (check the number of pivots found and timings of the global search by setting `verbosity` to a higher value!).
131
+
The maximum number of global pivots inserted at once is controlled by the parameter `maxnglobalpivot`.
132
+
133
+
A rare failure case is that the global search find the index sets with high interpolation errors, but the 2-site algorithm fails to add these pivots into the TCI2 object.
134
+
This will end up adding the same index sets in the next global search, leading to an endless loop.
135
+
120
136
## Estiamte true interpolation error by random global search
121
-
Since the TCI update algorithms are local, the true interpolation error is not known. However, the error can be estimated by global searches. This is implemented in the function `estimatetrueerror`:
137
+
Since most of the TCI update algorithms are local, the true interpolation error is not known. However, the error can be estimated by global searches. This is implemented in the function [`estimatetrueerror`](@ref):
Copy file name to clipboardExpand all lines: src/tensorci2.jl
+16-80Lines changed: 16 additions & 80 deletions
Original file line number
Diff line number
Diff line change
@@ -214,7 +214,7 @@ function addglobalpivots2sitesweep!(
214
214
pivotsearch::Symbol=:full,
215
215
verbosity::Int=0,
216
216
ntry::Int=10,
217
-
strictlynested::Bool=true
217
+
strictlynested::Bool=false
218
218
)::Intwhere {F,ValueType}
219
219
ifany(length(tci) .!=length.(pivots))
220
220
throw(DimensionMismatch("Please specify a pivot as one index per leg of the MPS."))
@@ -606,9 +606,9 @@ end
606
606
normalizeerror::Bool=true,
607
607
ncheckhistory=3,
608
608
maxnglobalpivot::Int=5,
609
-
nsearchglobalpivot::Int=0,
609
+
nsearchglobalpivot::Int=5,
610
610
tolmarginglobalsearch::Float64=10.0,
611
-
strictlynested::Bool=true
611
+
strictlynested::Bool=false
612
612
) where {ValueType}
613
613
614
614
Perform optimization sweeps using the TCI2 algorithm. This will sucessively improve the TCI approximation of a function until it fits `f` with an error smaller than `tolerance`, or until the maximum bond dimension (`maxbonddim`) is reached.
@@ -629,7 +629,7 @@ Arguments:
629
629
- `normalizeerror::Bool` determines whether to scale the error by the maximum absolute value of `f` found during sampling. If set to `false`, the algorithm continues until the *absolute* error is below `tolerance`. If set to `true`, the algorithm uses the absolute error divided by the maximum sample instead. This is helpful if the magnitude of the function is not known in advance. Default: `true`.
630
630
- `ncheckhistory::Int` is the number of history points to use for convergence checks. Default: `3`.
631
631
- `maxnglobalpivot::Int` can be set to `>= 0`. Default: `5`.
632
-
- `nsearchglobalpivot::Int` can be set to `>= 0`. Default: `0`.
632
+
- `nsearchglobalpivot::Int` can be set to `>= 0`. Default: `5`.
633
633
- `tolmarginglobalsearch` can be set to `>= 1.0`. Seach global pivots where the interpolation error is larger than the tolerance by `tolmarginglobalsearch`. Default: `10.0`.
634
634
- `strictlynested::Bool` determines whether to preserve partial nesting in the TCI algorithm. Default: `false`.
635
635
- `checkbatchevaluatable::Bool` Check if the function `f` is batch evaluatable. Default: `false`.
@@ -655,7 +655,7 @@ function optimize!(
655
655
normalizeerror::Bool=true,
656
656
ncheckhistory::Int=3,
657
657
maxnglobalpivot::Int=5,
658
-
nsearchglobalpivot::Int=0,
658
+
nsearchglobalpivot::Int=5,
659
659
tolmarginglobalsearch::Float64=10.0,
660
660
strictlynested::Bool=false,
661
661
checkbatchevaluatable::Bool=false
@@ -704,10 +704,11 @@ function optimize!(
704
704
sweepstrategy=sweepstrategy,
705
705
fillsitetensors=true
706
706
)
707
-
if verbosity >0&&length(globalpivots) >0
708
-
nrejections =length([p for p in globalpivots ifabs(evaluate(tci, p) -f(p)) > abstol])
707
+
if verbosity >0&&length(globalpivots) >0&&mod(iter, loginterval) ==0
708
+
abserr = [abs(evaluate(tci, p) -f(p)) for p in globalpivots]
709
+
nrejections =length(abserr .> abstol)
709
710
if nrejections >0
710
-
println(" Rejected $(nrejections) global pivots added in the previous iteration")
711
+
println(" Rejected $(nrejections) global pivots added in the previous iteration, errors are $(abserr)")
711
712
flush(stdout)
712
713
end
713
714
end
@@ -776,7 +777,7 @@ function sweep2site!(
776
777
sweepstrategy::Symbol=:backandforth,
777
778
pivotsearch::Symbol=:full,
778
779
verbosity::Int=0,
779
-
strictlynested::Bool=true,
780
+
strictlynested::Bool=false,
780
781
fillsitetensors::Bool=true
781
782
) where {ValueType}
782
783
invalidatesitetensors!(tci)
@@ -850,9 +851,9 @@ end
850
851
normalizeerror::Bool=true,
851
852
ncheckhistory=3,
852
853
maxnglobalpivot::Int=5,
853
-
nsearchglobalpivot::Int=0,
854
+
nsearchglobalpivot::Int=5,
854
855
tolmarginglobalsearch::Float64=10.0,
855
-
strictlynested::Bool=true
856
+
strictlynested::Bool=false
856
857
) where {ValueType,N}
857
858
858
859
Cross interpolate a function ``f(\mathbf{u})`` using the TCI2 algorithm. Here, the domain of ``f`` is ``\mathbf{u} \in [1, \ldots, d_1] \times [1, \ldots, d_2] \times \ldots \times [1, \ldots, d_{\mathscr{L}}]`` and ``d_1 \ldots d_{\mathscr{L}}`` are the local dimensions.
@@ -873,9 +874,9 @@ Arguments:
873
874
- `normalizeerror::Bool` determines whether to scale the error by the maximum absolute value of `f` found during sampling. If set to `false`, the algorithm continues until the *absolute* error is below `tolerance`. If set to `true`, the algorithm uses the absolute error divided by the maximum sample instead. This is helpful if the magnitude of the function is not known in advance. Default: `true`.
874
875
- `ncheckhistory::Int` is the number of history points to use for convergence checks. Default: `3`.
875
876
- `maxnglobalpivot::Int` can be set to `>= 0`. Default: `5`.
876
-
- `nsearchglobalpivot::Int` can be set to `>= 0`. Default: `0`.
877
+
- `nsearchglobalpivot::Int` can be set to `>= 0`. Default: `5`.
877
878
- `tolmarginglobalsearch` can be set to `>= 1.0`. Seach global pivots where the interpolation error is larger than the tolerance by `tolmarginglobalsearch`. Default: `10.0`.
878
-
- `strictlynested::Bool=true` determines whether to preserve partial nesting in the TCI algorithm. Default: `true`.
879
+
- `strictlynested::Bool=false` determines whether to preserve partial nesting in the TCI algorithm. Default: `true`.
879
880
- `checkbatchevaluatable::Bool` Check if the function `f` is batch evaluatable. Default: `false`.
0 commit comments