LatNet Builder Manual
2.0.1-11
Software Package for Constructing Highly Uniform Point Sets
|
This tutorial explains how to transform a sequence of merit values using filters, and how to combine the merit values of individual levels in the case of embedded lattices.
Here we build on the example from CBC Construction for Coordinate-Uniform Figures of Merit by normalizing the merit values and by applying a low-pass filter.
We add a normalizer to our MeritFilterList instance with:
This Norm::Normalizer instance uses the bound on the \(\mathcal P_\alpha\) discrepancy derived in [31] implemented by Norm::PAlphaSL10. Then, we add a low-pass filter to reject candidate lattice with a normalized merit value larger than unity:
Also note how we've changed the output instruction to:
Here, best
is an iterator on the sequence of filtered merit values filteredSeq
, best.base()
is an iterator on the unfiltered merit values meritSeq
, and best.base()
.base() is an iterator on the underlying sequence of lattice definitions. Finally, we must create a Storage instance:
The complete code for this example can be found in tutorial/FilteredCBC.cc.
The example in tutorial/FilteredRCBC.cc shows how to implement random CBC construction with filtered merit values. We use the same normalization and low-pass filters as in Normalization and Low-Pass. We want to try samples
independent random values for each component of the generating vector, excluding those that are rejected by the low-pass filter. This means that we don't know in advance the total number of values per coordinate to be tried. So, we first configure an infinite sequence of random integers:
We also replace std::min_element
with the Functor::MinElement functor:
Next, we use signals to stop the search after samples
random integers have passed through the low-pass filter:
The Functor::MinElement functor visits every element between the two iterators filteredSeq.begin()
and filteredSeq.end()
sequentially. The Functor::MinElement::onStart() signal is emitted, before it starts iterating through the elements. Every time a new element is visited, the Functor::MinElement::onElementVisited() signal is emitted; if a function connected to this signal returns false
, the functor aborts its iteration and returns the minimum value observed so far. We use this feature to stop iterating through our infinite sequence of random integers. The MeritFilterList::onReject() signal is emitted whenever one of the filters rejects a candidate lattice (by returning false
). The new Observer
class is designed to keep track of the number of accepted candidate lattices and of the total number of candidate lattices tried, as:
Note that Observer::onElementVisited()
increases both the accepted count m_count
and the total count m_totalCount
, whereas Observer::onReject()
decreases only m_count
. Finally, we output the number of accepted and the total number candidate lattices:
The output of this example is:
figure of merit: Coordinate Uniform with Kernel: P2 Weights: ProductWeights([], default=0.7) Norm type: 2 filters: Embedding type: Unilevel Unilevel filters: normalizer: PAlphaSL10, low-pass CBC search for dimension: 1 base lattice: Ordinary Lattice - Modulus = 257 - Generating vector = [] base merit value: 0 BEST LATTICE: Ordinary Lattice - Modulus = 257 - Generating vector = [1] Merit value: 0.0105903 15 accepted / 15 tried CBC search for dimension: 2 base lattice: Ordinary Lattice - Modulus = 257 - Generating vector = [1] base merit value: 3.48667e-05 BEST LATTICE: Ordinary Lattice - Modulus = 257 - Generating vector = [1, 76] Merit value: 0.0346885 15 accepted / 17 tried CBC search for dimension: 3 base lattice: Ordinary Lattice - Modulus = 257 - Generating vector = [1, 76] base merit value: 0.00125208 BEST LATTICE: Ordinary Lattice - Modulus = 257 - Generating vector = [1, 76, 96] Merit value: 0.175129 15 accepted / 15 tried
Constructing embedded lattices requires combining the merit values associated to each nested level into a single compound merit value. The example in tutorial/FilteredCBC.cc shows how to do this by building on the example from Normalization and Low-Pass.
We need to change the scalar filters to filters that apply to the merit value of each individual level by replacing Real with RealVector:
Note that the normalizer needs per-level weights for multilevel figures of merit, which we all set to the inverse of the number of levels (power + 1
) here:
Next, we configure the combiner as a sum of the normalized values across all levels:
We also need change the storage type to Storage<EmbeddingType::MULTILEVEL>:
This example outputs:
figure of merit: Coordinate Uniform with Kernel: P2 Weights: ProductWeights([], default=0.7) Norm type: 2 filters: Embedding type: Unilevel Unilevel filters: normalizer: PAlphaSL10, low-pass CBC search for dimension: 1 base lattice: Ordinary Lattice - Modulus = 256 - Generating vector = [] base merit value: 0 BEST LATTICE: Ordinary Lattice - Modulus = 256 - Generating vector = [1] Merit value: 0.00379617 CBC search for dimension: 2 base lattice: Ordinary Lattice - Modulus = 256 - Generating vector = [1] base merit value: 3.51396e-05 BEST LATTICE: Ordinary Lattice - Modulus = 256 - Generating vector = [1, 99] Merit value: 0.0160699 CBC search for dimension: 3 base lattice: Ordinary Lattice - Modulus = 256 - Generating vector = [1, 99] base merit value: 0.00123717 BEST LATTICE: Ordinary Lattice - Modulus = 256 - Generating vector = [1, 99, 27] Merit value: 0.0874655 figure of merit: Coordinate Uniform with Kernel: P2 Weights: ProductWeights([], default=0.7) Norm type: 2 filters: Embedding type: Multilevel Combiner: Sum Multilevel filters: normalizer: PAlphaSL10, low-pass CBC search for dimension: 1 base lattice: Ordinary Lattice - Modulus = 2^8 - Generating vector = [] base merit value: [0, 0, 0, 0, 0, 0, 0, 0, 0] BEST LATTICE: Ordinary Lattice - Modulus = 2^8 - Generating vector = [1] Merit value: 0.0622623 CBC search for dimension: 2 base lattice: Ordinary Lattice - Modulus = 2^8 - Generating vector = [1] base merit value: [2.30291, 0.575727, 0.143932, 0.0359829, 0.00899573, 0.00224893, 0.000562233, 0.000140558, 3.51396e-05] BEST LATTICE: Ordinary Lattice - Modulus = 2^8 - Generating vector = [1, 45] Merit value: 0.187022 CBC search for dimension: 3 base lattice: Ordinary Lattice - Modulus = 2^8 - Generating vector = [1, 45] base merit value: [9.9092, 4.46607, 1.9866, 0.551031, 0.23438, 0.0762869, 0.0158076, 0.00575074, 0.00166391] BEST LATTICE: Ordinary Lattice - Modulus = 2^8 - Generating vector = [1, 45, 69] Merit value: 0.302157
Notice that the base merit value is now a vector of per-level merit values.