This example shows how to instantiate figures of merit and evaluated them for a digital net.
#include <iostream>
#include <memory>
#include "netbuilder/JoeKuo.h"
#include "netbuilder/FigureOfMerit/TValue.h"
#include "netbuilder/FigureOfMerit/CoordUniformFigureOfMerit.h"
#include "latticetester/ProductWeights.h"
#include "latbuilder/Kernel/PAlphaPLR.h"
int main(int argc, char** argv)
{
SET_PATH_TO_LATNETBUILDER_FOR_EXAMPLES();
{
std::cout << "Computing the t-value..." << std::endl;
auto figure = std::make_unique<TValue<EmbeddingType::UNILEVEL>>();
std::cout << figure->format() << std::endl;
auto evaluator = figure->evaluator();
std::cout << "Merit value: " << (*evaluator)(net) << std::endl << std::endl;
}
{
std::cout << "Computing the P2..." << std::endl;
unsigned int alpha = 2;
auto weights = std::make_unique<LatticeTester::ProductWeights>(.7);
auto figure = std::make_unique<CoordUniformFigureOfMerit<LatBuilder::Kernel::PAlphaPLR, EmbeddingType::UNILEVEL>>(std::move(weights), kernel);
std::cout << figure->format() << std::endl;
auto evaluator = figure->evaluator();
std::cout << "Standard way:" << std::endl;
std::cout << "Merit value: " << (*evaluator)(net) << std::endl;
std::cout << "CBC-way:" << std::endl;
for(
Dimension coord = 0; coord < net.dimension(); ++coord)
{
evaluator->prepareForNextDimension();
std::cout << "Begin coordinate: " << coord + 1 << "/" << net.dimension() << std::endl;
merit = evaluator->operator()(net, coord, merit);
std::cout << "Partial merit value: " << merit << std::endl;
evaluator->lastNetWasBest();
}
std::cout << "Merit value: " << (*evaluator)(net) << std::endl;
}
}