Browse Source

solver settings now within solver, minmax refactored to share common variables

Former-commit-id: b3c78ae038
tempestpy_adaptions
sjunges 9 years ago
parent
commit
97c24fe229
  1. 19
      src/solver/MinMaxLinearEquationSolver.cpp
  2. 32
      src/solver/SolverSelectionOptions.cpp
  3. 20
      src/solver/SolverSelectionOptions.h
  4. 28
      src/utility/ExtendSettingEnumWithSelectionField.h
  5. 11
      test/functional/solver/MinMaxTechniqueSelectionTest.cpp

19
src/solver/MinMaxLinearEquationSolver.cpp

@ -0,0 +1,19 @@
#include "MinMaxLinearEquationSolver.h"
#include "src/settings/SettingsManager.h"
#include "src/settings/modules/GeneralSettings.h"
#include <cstdint>
namespace storm {
namespace solver {
AbstractMinMaxLinearEquationSolver::AbstractMinMaxLinearEquationSolver(double precision, bool relativeError, uint_fast64_t maximalIterations, bool trackPolicy, MinMaxTechniqueSelection prefTech) :
precision(precision), relative(relativeError), maximalNumberOfIterations(maximalIterations), trackPolicy(trackPolicy)
{
if(prefTech == MinMaxTechniqueSelection::FROMSETTINGS) {
useValueIteration = (storm::settings::generalSettings().getMinMaxEquationSolvingTechnique() == storm::solver::MinMaxTechnique::ValueIteration);
} else {
useValueIteration = (prefTech == MinMaxTechniqueSelection::ValueIteration);
}
}
}
}

32
src/solver/SolverSelectionOptions.cpp

@ -0,0 +1,32 @@
#include "src/solver/SolverSelectionOptions.h"
namespace storm {
namespace solver {
std::string toString(MinMaxTechnique m) {
switch(m) {
case MinMaxTechnique::PolicyIteration:
return "policy";
case MinMaxTechnique::ValueIteration:
return "value";
}
}
std::string toString(LpSolverType t) {
switch(t) {
case LpSolverType::Gurobi:
return "Gurobi";
case LpSolverType::Glpk:
return "Glpk";
}
}
std::string toString(EquationSolverType t) {
switch(t) {
case EquationSolverType::Native:
return "Native";
case EquationSolverType::Gmmxx:
return "Gmmxx";
}
}
}
}

20
src/solver/SolverSelectionOptions.h

@ -0,0 +1,20 @@
#ifndef SOLVERSELECTIONOPTIONS_H
#define SOLVERSELECTIONOPTIONS_H
#include "src/utility/ExtendSettingEnumWithSelectionField.h"
namespace storm {
namespace solver {
ExtendEnumsWithSelectionField(MinMaxTechnique, PolicyIteration, ValueIteration)
ExtendEnumsWithSelectionField(LpSolverType, Gurobi, Glpk)
ExtendEnumsWithSelectionField(EquationSolverType, Native, Gmmxx)
}
}
#endif

28
src/utility/ExtendSettingEnumWithSelectionField.h

@ -0,0 +1,28 @@
#ifndef EXTENDSETTINGENUMWITHSELECTIONFIELD_H
#define EXTENDSETTINGENUMWITHSELECTIONFIELD_H
#include <string>
#include <cassert>
#define ExtendEnumsWithSelectionField( NAME, ...) \
enum class NAME : int { __VA_ARGS__ }; \
enum class NAME##Selection : int { __VA_ARGS__, FROMSETTINGS }; \
std::string toString(NAME); \
inline NAME convert(NAME##Selection e) { \
assert(e != NAME##Selection::FROMSETTINGS); \
return static_cast< NAME >(e); \
} \
inline std::string toString(NAME##Selection e) { \
if(e == NAME##Selection::FROMSETTINGS) { \
return "[from settings]"; \
}\
else { \
return toString(convert(e)); \
} \
}
#endif /* EXTENDSETTINGENUMWITHSELECTIONFIELD_H */

11
test/functional/solver/MinMaxTechniqueSelectionTest.cpp

@ -0,0 +1,11 @@
#include "gtest/gtest.h"
#include "src/solver/MinMaxLinearEquationSolver.h"
TEST( MinMaxTechnique, Simple ) {
storm::solver::MinMaxTechniqueSelection ts = storm::solver::MinMaxTechniqueSelection::PolicyIteration;
storm::solver::MinMaxTechnique t = storm::solver::MinMaxTechnique::PolicyIteration;
ASSERT_EQ(convert(ts), t);
}
Loading…
Cancel
Save