Example #1
0
 /// Initialize this instance using the specified configuration property tree
 void configure(utility::Configuration::CursorPtr theprops)
 {
   if (theprops) {
     p_configCursor = theprops->getCursor(this->p_key);
   }
   this->p_configure(p_configCursor);
   p_isConfigured = true;
 }
Example #2
0
// -------------------------------------------------------------
// Optimizer::p_preconfigure
// -------------------------------------------------------------
void
Optimizer::p_preconfigure(utility::Configuration::CursorPtr theprops)
{
  parallel::Communicator comm(p_impl->communicator());
  std::string key(p_impl->configurationKey());
  utility::Configuration::CursorPtr p = theprops->getCursor(key);
  std::string solver;
  solver = p->get("Solver", solver);

  if (!solver.empty()) {
    p_setImpl(NULL);
    if (solver == "GLPK") {
#if defined(HAVE_GLPK)
      p_setImpl(new GLPKOptimizerImplementation(comm));
#else
      throw gridpack::Exception("GLPK Optimizer not supported"); 
#endif
    } 
    if (solver == "CPLEX") {
#if defined(HAVE_CPLEX)
      p_setImpl(new CPlexOptimizerImplementation(comm));
#else
      throw gridpack::Exception("CPLEX Optimizer not supported"); 
#endif
    } 
    if (solver == "Julia") {
      p_setImpl(new JuliaOptimizerImplementation(comm));
    }
    if (solver == "LPFile") {
      p_setImpl(new LPFileOptimizerImplementation(comm));
    }
    if (!p_impl) {
      std::string s("Unknown ptimizer solver type \"");
      s += solver;
      s += "\"";
      throw gridpack::Exception(s); 
    }
  }
}