This example shows how to instantiate a sequence of merit values based on a component-by-component sequence of lattice definitions, and how to use signals in order to interrupt the computation of a weighted figure of merit when its value has become too large.
This example shows how to instantiate a sequence of merit values based on a component-by-component sequence of lattice definitions, and how to use signals in order to interrupt the computation of a weighted figure of merit when its value has become too large.
#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/PAlphaTilde.h"
#include "latbuilder/Accumulator.h"
#include "latbuilder/Storage.h"
#include "latbuilder/Functor/binary.h"
#include "latbuilder/MeritFilterList.h"
#include "latbuilder/MeritSeq/CBC.h"
#include "latbuilder/GenSeq/GeneratingValues.h"
#include "latbuilder/GenSeq/Creator.h"
#include "latbuilder/Functor/MinElement.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(); }
bool onProgress(Real merit) const
{ return merit <= m_bestMerit; }
void onAbort(const LatDef& lat) const
{ std::cout << "rejected:" << std::endl << lat; }
void onMinUpdated(const Real& bestMerit)
{ m_bestMerit = bestMerit; }
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;
auto weights = unique<LatticeTester::ProductWeights>();
weights->setDefaultWeight(0.7);
typedef ProjDepMerit::CoordUniform<Kernel::PAlphaTilde> ProjDep;
WeightedFigureOfMerit<ProjDep, Functor::Sum> figure(2, std::move(weights), ProjDep(2));
std::cout << "figure of merit: " << figure << std::endl;
*/
Observer<LA> obs;
cbc.evaluator().onProgress().connect(boost::bind(&Observer<LA>::onProgress, &obs, _1));
cbc.evaluator().onAbort().connect(boost::bind(&Observer<LA>::onAbort, &obs, _1));
minElement.
onMinUpdated().connect(boost::bind(&Observer<LA>::onMinUpdated, &obs, _1));
while (
cbc.baseLat().dimension() < dimension) {
std::cout << "CBC search for dimension: " << (baseDim + 1) << std::endl;
std::cout <<
"base lattice: " << std::endl <<
cbc.baseLat();
std::cout <<
"base merit value: " <<
cbc.baseMerit() << std::endl;
std::cout <<
"new projections: " <<
cbc.projections() << std::endl;
auto meritSeq =
cbc.meritSeq(baseDim == 0 ? genSeq0 : genSeq);
auto filteredSeq = filters.
apply(meritSeq);
obs.reset();
auto best = minElement(filteredSeq.begin(), filteredSeq.end(), 0);
std::cout <<
"BEST LATTICE: " << std::endl <<
cbc.baseLat() <<
"Merit value: " << *best << std::endl;
}
}
int main()
{
SET_PATH_TO_LATNETBUILDER_FOR_EXAMPLES();
test(Storage<LatticeType::POLYNOMIAL, EmbeddingType::UNILEVEL, Compress::NONE>(PolynomialFromInt(115)), dim);
*/
return 0;
}
This file contains a global variable PATH_TO_LATNETBUILDER_DIR which should always equal the path to ...
Indexed sequence of generating values: -For ordinary lattices: integers coprime with a specified modu...
Definition GeneratingValues.h:48
Definition of a rank-1 lattice.
Definition LatDef.h:40
List of filters for merit values.
Definition MeritFilterList.h:176
Seq< MERITSEQ > apply(MERITSEQ meritSeq) const
Applies the filters to the input sequence meritSeq of merit values.
Definition MeritFilterList.h:243
Figure of merit based on the spectral test.
Definition Spectral.h:46
Lattice size parameter.
Definition SizeParam.h:30
Storage policy.
Definition Storage.h:114
CBC< LR, ET, GENSEQ > cbc(LatDef< LR, ET > baseLat, GENSEQ genSeq)
Creates a CBC lattice sequence.
Definition CBC.h:148
CBC< LR, ET, COMPRESS, PLO, PROJDEP, ACC > cbc(Storage< LR, ET, COMPRESS, PLO > storage, const WeightedFigureOfMerit< PROJDEP, ACC > &figure)
Creates a CBC algorithm.
Definition CBC.h:221
LatBuilder namespace.
Definition libtut_lat.dox:17
size_t Dimension
Scalar integer type for dimension.
Definition Types.h:53
double Real
Scalar floating-point type.
Definition Types.h:44
Minimum element functor.
Definition MinElement.h:35
const OnMinUpdated & onMinUpdated() const
Minimum-updated signal.
Definition MinElement.h:145
static result_type create(const SizeParam< LR, L > &sizeParam, ARGS &&... t)
Creates a new sequence object.
Definition Creator.h:43
Lattice traits.
Definition Types.h:92