This example shows how to instantiate a weighted figure of merit and perform a search for the best Korobov lattice.
#include "latbuilder/WeightedFigureOfMerit.h"
#include "latticetester/ProductWeights.h"
#include "latticetester/CoordinateSets.h"
#include "latbuilder/ProjDepMerit/Spectral.h"
#include "latticetester/NormaBestLat.h"
#include "latbuilder/ProjDepMerit/CoordUniform.h"
#include "latbuilder/Kernel/PAlphaPLR.h"
#include "latbuilder/Accumulator.h"
#include "latbuilder/Storage.h"
#include "latbuilder/Functor/binary.h"
#include "latbuilder/LatSeq/Korobov.h"
#include "latbuilder/GenSeq/GeneratingValues.h"
#include "latbuilder/TextStream.h"
#include <iostream>
#include <limits>
using TextStream::operator<<;
template <typename T, typename... ARGS>
std::unique_ptr<T> unique(ARGS&&... args)
{ return std::unique_ptr<T>(new T(std::forward<ARGS>(args)...)); }
template<LatticeType LA>
class Observer {
public:
Observer() { reset(); }
void reset() { m_bestMerit = std::numeric_limits<Real>::infinity(); }
const LatDef& bestLat() {
return m_bestLat; }
const Real bestMerit() {
return m_bestMerit; }
{
std::cout << lat;
std::cout << "Merit: " << merit;
if (merit < m_bestMerit) {
std::cout << " <-- best";
m_bestMerit = merit;
m_bestLat = lat;
}
std::cout << std::endl;
}
private:
};
template <LatticeType LA, EmbeddingType L, Compress C>
{
auto weights = unique<LatticeTester::ProductWeights>();
weights->setDefaultWeight(0.7);
std::cout << "figure of merit: " << figure << std::endl;
storage.sizeParam(),
Coprime(storage.sizeParam().modulus()),
dimension
);
1, latSeq.latDimension(),
0, latSeq.latDimension() - 1
);
std::cout << "projections: " << allProjections << std::endl;
auto initialMerit = storage.createMeritValue(0.0);
auto eval = figure.evaluator(storage);
Observer<LA> obs;
for (const auto& lat : latSeq) {
auto merit =
eval(lat, allProjections, initialMerit);
obs.observe(lat, merit);
}
std::cout << "BEST LATTICE: " << std::endl << obs.bestLat() << "Merit value: " << obs.bestMerit() << std::endl;
}
int main()
{
SET_PATH_TO_LATNETBUILDER_FOR_EXAMPLES();
return 0;
}