Skip to content

Commit

Permalink
fix dangling ref
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Oct 19, 2023
1 parent ec1c2da commit b80821c
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions src/cpp/multisolver_interface/SolverFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,26 @@ SolverFactory::SolverFactory() {

SolverAbstract::Ptr SolverFactory::create_solver(
const std::string &solver_name, const SOLVER_TYPE solver_type) const {
auto log_manager = SolverLogManager("");
return create_solver(solver_name, solver_type, log_manager);
if (solver_name == "") {
throw InvalidSolverNameException(solver_name, LOGLOCATION);
}
#ifdef XPRESS
else if (solver_name == XPRESS_STR) {
return std::make_shared<SolverXpress>();
}
#endif
#ifdef COIN_OR
if (solver_name == COIN_STR && solver_type == SOLVER_TYPE::CONTINUOUS) {
return std::make_shared<SolverClp>();
} else if (solver_name == COIN_STR && solver_type == SOLVER_TYPE::INTEGER) {
return std::make_shared<SolverCbc>();
}
#endif
else {
throw InvalidSolverNameException(solver_name, LOGLOCATION);
}
}

SolverAbstract::Ptr SolverFactory::create_solver(
const std::string &solver_name, const SOLVER_TYPE solver_type,
SolverLogManager &log_manager) const {
Expand All @@ -36,11 +53,29 @@ SolverAbstract::Ptr SolverFactory::create_solver(
#endif
return create_solver(solver_name, log_manager);
}

SolverAbstract::Ptr SolverFactory::create_solver(
const std::string &solver_name) const {
auto log_manager = SolverLogManager("");
return create_solver(solver_name, log_manager);
if (solver_name == "") {
throw InvalidSolverNameException(solver_name, LOGLOCATION);
}
#ifdef XPRESS
else if (solver_name == XPRESS_STR) {
return std::make_shared<SolverXpress>();
}
#endif
#ifdef COIN_OR
else if (solver_name == CLP_STR) {
return std::make_shared<SolverClp>();
} else if (solver_name == CBC_STR) {
return std::make_shared<SolverCbc>();
}
#endif
else {
throw InvalidSolverNameException(solver_name, LOGLOCATION);
}
}

SolverAbstract::Ptr SolverFactory::create_solver(
const std::string &solver_name, SolverLogManager &log_manager) const {
if (solver_name == "") {
Expand Down

0 comments on commit b80821c

Please sign in to comment.