From a figure of merit, one can construct various tasks:
- evaluation tasks; or
- search tasks.
Task is the abstract class which describes the various tasks which can be executed by NetBuilder.
Evaluation tasks
Evaluation tasks only require a digital net and a figure of merit to be constructed. Basically, they wrap the previous example in a Task.
To create a task we first instantiate a figure of merit:
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);
Then we create the net to evaluate and we instantiate the task:
std::cout << "JoeKuo Sobol' net in dimension 15 with 2^15 points" << std::endl;
auto task = std::make_unique<Eval>(std::move(net), std::move(figure));
The task is now ready to be executed:
task->execute();
std::cout << "Merit value: " << task->meritValue() << std::endl;
It is possible to reuse the same Eval task to evaluate the merit value of another net. We just need to create that net and to pass it to the task by the reset
member function.
std::cout << "JoeKuo Sobol' net in dimension 15 with 2^15 points" << std::endl;
task->reset(std::move(net));
task->execute();
std::cout << "Merit value: " << task->meritValue() << std::endl;
The complete example can be found in tutorial/NetEval.cc.
Search tasks
Search is the abstract class which is implemented by all the search variants. It requires two template parameters : the NetConstruction and the EmbeddingType of the search.
Exhaustive searches
Exhaustive searches require the dimension and the size parameter of the net, and also a figure of merit. To create such a search, we first create these three elements:
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);
typedef typename NetConstructionTraits<NetConstruction::SOBOL>::SizeParameter SizeParameter;
SizeParameter size(10);
Then, we can instantiate the task:
auto task = std::make_unique<ExhaustiveSearch<NetConstruction::SOBOL, EmbeddingType::UNILEVEL>>(s, size, std::move(figure));
std::cout << task->format();
Finally, it remains to execute the task and output its results:
task->execute();
std::cout << "Best net: " << task->bestNet().format() << std::endl;
std::cout << "Merit value: " << task->bestMeritValue() << std::endl;
The complete example can be found in tutorial/NetSearchExhaustive.cc.
Random searches
Random searches are very similar to exhaustive searches. When creating such a task, we only need to add the number of random samples which are examined by the search:
auto task = std::make_unique<RandomSearch<NetConstruction::SOBOL, EmbeddingType::UNILEVEL>>(s, size, std::move(figure), 100);
std::cout << task->format();
Here the search is a random search with 100 random samples. The complete example can be found in tutorial/NetSearchRandom.cc.
CBC searches
Each CBC search has a template template parameter EXPLORER
which describes the exploration policy. The possible policies are the full-CBC (FullCBCExplorer), the random-CBC (RandomCBCExplorer) and the mixed-CBC (MixedCBCExplorer) explorers.
A CBCSearch is constructed with the same parameters as an ExhaustiveSearch, plus an explorer instance.
Let first define the usual search parameters. To change a little bit from Sobol' nets and \(\mathcal P_2\), we will search for polynomial lattice rules with good projection-dependent t-value merit.
auto weights = std::make_unique<LatticeTester::ProductWeights>(.7);
auto projDepMerit = std::make_unique<TValueProjMerit<EmbeddingType::UNILEVEL>>(3);
auto figure = std::make_unique<WeightedFigureOfMerit<TValueProjMerit<EmbeddingType::UNILEVEL>>>(std::numeric_limits<Real>::infinity(), std::move(weights), std::move(projDepMerit));
typedef typename NetConstructionTraits<NetConstruction::POLYNOMIAL>::SizeParameter SizeParameter;
FullCBCExplorer
For a full-CBC search, we use the following explorer and task:
auto explorer = std::make_unique<FullCBCExplorer<NetConstruction::POLYNOMIAL, EmbeddingType::UNILEVEL>>(s, size);
auto task = std::make_unique<CBCSearch<NetConstruction::POLYNOMIAL, EmbeddingType::UNILEVEL, FullCBCExplorer>>(s, size, std::move(figure), std::move(explorer));
RandomCBCExplorer
For a random-CBC search, we use the following explorer and task:
auto explorer = std::make_unique<RandomCBCExplorer<NetConstruction::POLYNOMIAL, EmbeddingType::UNILEVEL>>(s, size, 70);
auto task = std::make_unique<CBCSearch<NetConstruction::POLYNOMIAL, EmbeddingType::UNILEVEL, RandomCBCExplorer>>(s, size, std::move(figure), std::move(explorer));
For each coordinate, the search algorithm will examine 70 random possibilities.
MixedCBCExplorer
For a mixed-CBC search, we use the following explorer and task:
auto explorer = std::make_unique<MixedCBCExplorer<NetConstruction::POLYNOMIAL, EmbeddingType::UNILEVEL>>(s, size, 3, 70);
auto task = std::make_unique<CBCSearch<NetConstruction::POLYNOMIAL, EmbeddingType::UNILEVEL, MixedCBCExplorer>>(s, size, std::move(figure), std::move(explorer));
For the 3 first coordinates, the search will use the full-CBC algorithm. Then, for each remaining coordinate, it will examine 70 random possibilities.
The task is always executed in the same fashion:
std::cout << task->format();
task->execute();
std::cout << "Best net: " << task->bestNet().format() << std::endl;
std::cout << "Merit value: " << task->bestMeritValue() << std::endl;
The complete example can be found in tutorial/NetSearchCBC.cc.