LatNet Builder Manual
2.0.1-11
Software Package for Constructing Highly Uniform Point Sets
|
Iterating through a sequence of lattice definitions and evaluating a figure of merit for each element, as in Weighted Figures of Merit, is a common task when searching for good lattice parameters.
LatBuilder abstracts out this process by providing sequences of (computed) merit values.
The example in tutorial/MeritSeqCBC.cc improves on the example from A Simple Example Using CBC Construction.
The base lattice and its merit value are managed by MeritSeq::CBC, so we can remove the declarations of baseLat
and initialMerit
, and introduce:
In the CBC loop, we instantiate the sequence of merit values with:
Because the elements of meritSeq
are of the abstract type MeritValue, we need to convert them to the Real type using an empty list of merit value filters declared as:
and applied with:
Such a filter list can also be used to combine the merit values of individual levels in the case of embedded lattices (see Filters and Combiners). Then, we replace the minimization loop with a call to std::min_element:
and notify the CBC instance that we have found our best lattice for the current dimension:
Here, best
is an iterator on the filteredSeq
sequence, and best.base()
is an iterator on corresponding element of the underlying meritSeq
sequence. The output of this example is:
figure of merit: Projection Dependent Merit: spectral^1 (symmetric) - Accumulator: Max Norm Type: 2 Weights: ProductWeights([], default=0.7) CBC search for dimension: 1 base lattice: Ordinary Lattice - Modulus = 256 - Generating vector = [] base merit value: 0 new projections: [{0}] BEST LATTICE: Ordinary Lattice - Modulus = 256 - Generating vector = [1] Merit value: 0.7 CBC search for dimension: 2 base lattice: Ordinary Lattice - Modulus = 256 - Generating vector = [1] base merit value: 0.7 new projections: [{1}, {0,1}] BEST LATTICE: Ordinary Lattice - Modulus = 256 - Generating vector = [1, 15] Merit value: 0.7 CBC search for dimension: 3 base lattice: Ordinary Lattice - Modulus = 256 - Generating vector = [1, 15] base merit value: 0.7 new projections: [{2}, {0,2}, {1,2}, {0,1,2}] BEST LATTICE: Ordinary Lattice - Modulus = 256 - Generating vector = [1, 15, 39] Merit value: 0.746627
To improve on the above example by using signals, we can reintroduce the Observer
class from A Improved Example Using Signals. We also need to notify the Observer
class when a new minimum value is updated, with a few changes:
So, instead of using std::min_element
, we use Functor::MinElement and connect its Functor::MinElement::onMinUpdated() signal to Observer::onMinUpdated()
:
Then replace the call to std::min_element()
with:
Also note the call to Observer::reset()
to initialize the best observed merit value before using minElement
. The resulting code can be found in tutorial/MeritSeqCBCSignals.cc .
Figures of merit in a coordinate-uniform form can be evaluated more efficiently than the general weighted figures of merit. Here, we consider the case of the weighted \(\mathcal P_\alpha\) discrepancy for ordinary lattices, and the case of the weighted \(\mathcal P_{\alpha,PLR}\) for polynomial lattices. by adapting the code from CBC Construction . First, we replace the WeightedFigureOfMerit instance with an instance of CoordUniformFigureOfMerit: For ordinary lattices:
For polynomial lattices:
The type of weights must be specified as a template argument because a different evaluation algorithm is used for different types of weights. Then, we replace the MeritSeq::CBC instance with a MeritSeq::CoordUniformCBC instance:
The MeritSeq::CoordUniformInnerProd template argument specifies that we want to use a standard inner product during CBC exploration. The complete example can be found in tutorial/MeritSeqCoordUniform.cc.
Here, we modify the example from CBC Construction for Coordinate-Uniform Figures of Merit in order to use the fast CBC method, which is implemented only with coordinate-uniform figures of merit. First, we need to replace MeritSeq::CoordUniformInnerProd with MeritSeq::CoordUniformInnerProdFast:
The fast CBC algorithm requires a special ordering of the generator values, so we also need to replace:
with:
Note that instantiating GenSeq::CyclicGroup requires the number of points to be an integer power of a prime base. Then, we modify the instantiation of meritSeq
accordingly:
The complete example can be found in tutorial/MeritSeqFastCBC.cc.
In LatBuilder, sequences of merit values for non-CBC exploration methods are available only as a wrapper of the CBC exploration applied independently to each lattice definition, by replacing the sequences of candidate lattice definitions by singletons that contain only the candidate lattice being currently examined. CBC exploration can thus output only this one lattice, together with its merit value. This enables the efficient computation algorithms used in the coordinate-uniform case with standard CBC.
The example in tutorial/MeritSeqNonCBC.cc illustrates how to transform the CBC search from CBC Construction for Coordinate-Uniform Figures of Merit into a Korobov search. First, we create an instance of MeritSeq::LatSeqOverCBC and a sequence of Korobov lattice definitions:
Then, the whole CBC loop is replaced with the execution of the Korobov search: