LatNet Builder Manual  2.0.1-11
Software Package for Constructing Highly Uniform Point Sets
tutorial/NetSearchCBC.cc

This example shows how to instantiate an CBCSearch task to search for the best merit using a CBC algorithm.

// This file is part of LatNet Builder.
//
// Copyright (C) 2012-2018 Pierre L'Ecuyer and Universite de Montreal
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <iostream>
#include <memory>
#include "netbuilder/FigureOfMerit/WeightedFigureOfMerit.h"
#include "netbuilder/FigureOfMerit/TValueProjMerit.h"
#include "netbuilder/Task/CBCSearch.h"
#include "netbuilder/Task/FullCBCExplorer.h"
#include "netbuilder/Task/RandomCBCExplorer.h"
#include "netbuilder/Task/MixedCBCExplorer.h"
#include "latticetester/ProductWeights.h"
#include "Path.h"
using namespace NetBuilder;
using namespace NetBuilder::FigureOfMerit;
using namespace NetBuilder::Task;
int main(int argc, char** argv)
{
SET_PATH_TO_LATNETBUILDER_FOR_EXAMPLES();
{
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));
SizeParameter size = PolynomialFromInt(1033);
Dimension s = 5;
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));
std::cout << task->format();
task->execute();
std::cout << "Best net: " << task->bestNet().format() << std::endl;
std::cout << "Merit value: " << task->bestMeritValue() << std::endl;
}
{
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));
SizeParameter size = PolynomialFromInt(1033);
Dimension s = 5;
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));
std::cout << task->format();
task->execute();
std::cout << "Best net: " << task->bestNet().format() << std::endl;
std::cout << "Merit value: " << task->bestMeritValue() << std::endl;
}
{
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));
SizeParameter size = PolynomialFromInt(1033);
Dimension s = 5;
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));
std::cout << task->format();
task->execute();
std::cout << "Best net: " << task->bestNet().format() << std::endl;
std::cout << "Merit value: " << task->bestMeritValue() << std::endl;
}
}