Commit 169bbdad authored by Dmitry Bagaev's avatar Dmitry Bagaev
Browse files

WIP: Noop optimizer added & some fixes

parent c0216a20
......@@ -167,7 +167,7 @@ int main(int argc, char **argv) {
if (rank == 0) std::cout << "Solving with " << solverName << std::endl;
TTSP::OptimizationParameter tau("tau", {1e-3, 3e-3, 5e-3, 7e-3, 1e-2, 3e-2, 5e-2, 6e-2, 7e-2, 8e-2, 9e-2, 1e-1, 2e-1, 3e-1}, 1e-3);
TTSP::OptimizationParameter tau("tau", {3e-2, 5e-2, 6e-2, 7e-2, 8e-2, 9e-2, 1e-1, 2e-1, 3e-1, 5e-1, 7e-1, 9e-1}, 1e-3);
TTSP::OptimizationParameters parameters;
parameters.push_back(std::make_pair(tau, 1e-3));
......
add_subdirectory(default)
add_subdirectory(bruteforce)
add_subdirectory(alternating)
......
......@@ -66,7 +66,7 @@ namespace TTSP {
OptimizerInterface(space, 10), current_handler_index(0) {
const OptimizationParameters &parameters = space.GetParameters();
handlers.reserve(space.GetParameters().size());
for (auto parameter : space.GetParameters()) {
for (const auto &parameter : space.GetParameters()) {
handlers.emplace_back(AlternatingParameterHandler(parameter.first));
}
}
......
......@@ -18,7 +18,7 @@ namespace TTSP {
class AlternatingParameterHandler {
private:
const OptimizationParameter parameter;
const OptimizationParameter &parameter;
std::size_t direction;
std::size_t current_index;
public:
......
set(SOURCE ${SOURCE}
${CMAKE_CURRENT_SOURCE_DIR}/ttsp_default.cpp)
set(HEADER ${HEADER}
${CMAKE_CURRENT_SOURCE_DIR}/ttsp_default.h)
set(HEADER ${HEADER} PARENT_SCOPE)
set(SOURCE ${SOURCE} PARENT_SCOPE)
\ No newline at end of file
//
// Created by bvdmitri on 31.01.19.
//
#include "ttsp_default.h"
namespace TTSP {
NoopOptimizer::NoopOptimizer(const OptimizationParametersSpace &space) : OptimizerInterface(space, 1) {}
OptimizationParameterPoints NoopOptimizer::MakeOptimizationIteration(INMOST::Solver &solver, INMOST::Sparse::Matrix &matrix,
INMOST::Sparse::Vector &RHS) {
const OptimizationParameters &parameters = space.GetParameters();
OptimizationParameterPoints output(parameters.size());
std::transform(parameters.begin(), parameters.end(), output.begin(), [&](const OptimizationParametersEntry &entry) {
return std::make_pair(entry.first.GetName(), entry.first.GetDefaultValue());
});
return output;
}
NoopOptimizer::~NoopOptimizer() {}
}
\ No newline at end of file
//
// Created by bvdmitri on 31.01.19.
//
#ifndef INMOST_TTSP_DEFAULT_H
#define INMOST_TTSP_DEFAULT_H
#include <Source/Solver/ttsp/ttsp.h>
namespace TTSP {
class NoopOptimizer : public OptimizerInterface {
public:
NoopOptimizer(const OptimizationParametersSpace &space);
OptimizationParameterPoints MakeOptimizationIteration(INMOST::Solver &solver, INMOST::Sparse::Matrix &matrix,
INMOST::Sparse::Vector &RHS) override;
virtual ~NoopOptimizer();
};
}
#endif //INMOST_TTSP_DEFAULT_H
\ No newline at end of file
......@@ -2,6 +2,7 @@
// Created by bvdmitri on 04.02.19.
//
#include <Source/Solver/ttsp/optimizers/default/ttsp_default.h>
#include <Source/Solver/ttsp/optimizers/bruteforce/ttsp_bruteforce.h>
#include <Source/Solver/ttsp/optimizers/alternating/ttsp_alternating.h>
#include "ttsp.h"
......@@ -265,6 +266,7 @@ namespace TTSP {
std::vector<std::string> OptimizerInterface::getAvailableOptimizers() {
std::vector<std::string> available;
available.push_back("noop");
available.push_back("bruteforce");
available.push_back("alternating");
......@@ -272,6 +274,7 @@ namespace TTSP {
}
OptimizerInterface *OptimizerInterface::getOptimizer(const std::string &type, const OptimizationParametersSpace &space) {
if (type == "noop") return new NoopOptimizer(space);
if (type == "bruteforce") return new BruteforceOptimizer(space);
if (type == "alternating") return new AlternatingOptimizer(space);
return nullptr;
......
#include <utility>
//
// Created by bvdmitri on 04.02.19.
//
......@@ -239,7 +241,7 @@ namespace TTSP {
OptimizationParametersSpace space;
OptimizerProperties properties;
public:
OptimizerInterface(const OptimizationParametersSpace &space, std::size_t buffer_capacity) : space(space), results(buffer_capacity) {};
OptimizerInterface(OptimizationParametersSpace space, std::size_t buffer_capacity) : space(std::move(space)), results(buffer_capacity) {};
bool Solve(INMOST::Solver &solver, INMOST::Sparse::Matrix &matrix, INMOST::Sparse::Vector &RHS, INMOST::Sparse::Vector &SOL,
GetPreconditionerTimeFromSolverLambda preconditioner_time = OptimizerInterface::DefaultGetPreconditionerTime,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment