SolverParameters.cpp 1.33 KB
Newer Older
Dmitry Bagaev's avatar
fix  
Dmitry Bagaev committed
1
#include "SolverInterface.h"
2

3
#if defined(USE_SOLVER)
4 5
namespace INMOST {

6 7 8 9
    SolverParameters::SolverParameters(std::string solverName, std::string solverPrefix, std::string internalFile)
            : solverName(solverName),
              solverPrefix(solverPrefix),
              internalFile(internalFile) {}
Dmitry Bagaev's avatar
Dmitry Bagaev committed
10

11 12 13 14
    SolverParameters::SolverParameters(const SolverParameters &other) : solverName(other.solverName),
                                                                        solverPrefix(other.solverPrefix),
                                                                        internalFile(other.internalFile),
                                                                        parameters(other.parameters) {
Dmitry Bagaev's avatar
Dmitry Bagaev committed
15 16 17 18 19
    }


    SolverParameters::~SolverParameters() {}

20 21 22 23 24 25 26 27 28 29 30 31 32
    void SolverParameters::SetInnerParametersFromFile(const std::string &file, SolverInterface *solver) {
        char line[4096];
        char parameterName[4096];
        char parameterValue[4096];
        FILE *databaseFile = fopen(file.c_str(), "r");
        if (!databaseFile) return;
        while (!feof(databaseFile) && fgets(line, 4096, databaseFile)) {
            if (line[0] == '#') continue;
            sscanf(line, "%s %s", parameterName, parameterValue);
            solver->SetParameter(parameterName, parameterValue);
        }
    }

33
}
34
#endif //USE_SOLVER