Browse Source

Extended lp solver factory interface

Former-commit-id: 437e62619d
tempestpy_adaptions
sjunges 9 years ago
parent
commit
b007d45543
  1. 25
      src/utility/solver.cpp
  2. 3
      src/utility/solver.h

25
src/utility/solver.cpp

@ -133,28 +133,37 @@ namespace storm {
}
std::unique_ptr<storm::solver::LpSolver> LpSolverFactory::create(std::string const& name) const {
storm::solver::LpSolverType lpSolver = storm::settings::generalSettings().getLpSolver();
switch (lpSolver) {
std::unique_ptr<storm::solver::LpSolver> LpSolverFactory::create(std::string const& name, storm::solver::LpSolverTypeSelection solvT) const {
storm::solver::LpSolverType t;
if(solvT == storm::solver::LpSolverTypeSelection::FROMSETTINGS) {
t = storm::settings::generalSettings().getLpSolver();
} else {
t = convert(solvT);
}
switch (t) {
case storm::solver::LpSolverType::Gurobi: return std::unique_ptr<storm::solver::LpSolver>(new storm::solver::GurobiLpSolver(name));
case storm::solver::LpSolverType::Glpk: return std::unique_ptr<storm::solver::LpSolver>(new storm::solver::GlpkLpSolver(name));
default: return std::unique_ptr<storm::solver::LpSolver>(new storm::solver::GurobiLpSolver(name));
}
}
std::unique_ptr<storm::solver::LpSolver> LpSolverFactory::create(std::string const& name) const {
return LpSolverFactory::create(name, storm::solver::LpSolverTypeSelection::FROMSETTINGS);
}
std::unique_ptr<storm::solver::LpSolver> GlpkLpSolverFactory::create(std::string const& name) const {
return std::unique_ptr<storm::solver::LpSolver>(new storm::solver::GlpkLpSolver(name));
return LpSolverFactory::create(name, storm::solver::LpSolverTypeSelection::Glpk);
}
std::unique_ptr<storm::solver::LpSolver> GurobiLpSolverFactory::create(std::string const& name) const {
return std::unique_ptr<storm::solver::LpSolver>(new storm::solver::GurobiLpSolver(name));
return LpSolverFactory::create(name, storm::solver::LpSolverTypeSelection::Gurobi);
}
std::unique_ptr<storm::solver::LpSolver> getLpSolver(std::string const& name) {
std::unique_ptr<storm::solver::LpSolver> getLpSolver(std::string const& name, storm::solver::LpSolverTypeSelection solvType) {
std::unique_ptr<storm::utility::solver::LpSolverFactory> factory(new LpSolverFactory());
return factory->create(name);
return factory->create(name, solvType);
}
template class SymbolicLinearEquationSolverFactory<storm::dd::DdType::CUDD, double>;
template class SymbolicMinMaxLinearEquationSolverFactory<storm::dd::DdType::CUDD, double>;
template class SymbolicGameSolverFactory<storm::dd::DdType::CUDD>;

3
src/utility/solver.h

@ -112,6 +112,7 @@ namespace storm {
* @return A pointer to the newly created solver.
*/
virtual std::unique_ptr<storm::solver::LpSolver> create(std::string const& name) const;
virtual std::unique_ptr<storm::solver::LpSolver> create(std::string const& name, storm::solver::LpSolverTypeSelection solvType) const;
};
class GlpkLpSolverFactory : public LpSolverFactory {
@ -124,7 +125,7 @@ namespace storm {
virtual std::unique_ptr<storm::solver::LpSolver> create(std::string const& name) const override;
};
std::unique_ptr<storm::solver::LpSolver> getLpSolver(std::string const& name);
std::unique_ptr<storm::solver::LpSolver> getLpSolver(std::string const& name, storm::solver::LpSolverTypeSelection solvType = storm::solver::LpSolverTypeSelection::FROMSETTINGS) ;
}
}
}

Loading…
Cancel
Save