예제 #1
0
Teuchos::RCP<LOCA::MultiContinuation::AbstractStrategy>
LOCA::MultiContinuation::Factory::create(
      const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
      const Teuchos::RCP<Teuchos::ParameterList>& stepperParams,
      const Teuchos::RCP<LOCA::MultiContinuation::AbstractGroup>& grp,
      const Teuchos::RCP<LOCA::MultiPredictor::AbstractStrategy>& pred,
      const vector<int>& paramIDs)
{
  string methodName = "LOCA::MultiContinuation::Factory::create()";
  Teuchos::RCP<LOCA::MultiContinuation::AbstractStrategy> strategy;

  // Get name of strategy
  const string& name = strategyName(*stepperParams);

  if (name == "Natural")
    strategy = 
      Teuchos::rcp(new LOCA::MultiContinuation::NaturalGroup(globalData,
							     topParams,
							     stepperParams,
							     grp,
							     pred,
							     paramIDs));

  else if (name == "Arc Length")
    strategy = 
      Teuchos::rcp(new LOCA::MultiContinuation::ArcLengthGroup(
							      globalData,
							      topParams,
							      stepperParams,
							      grp,
							      pred,
							      paramIDs));
  else if (name == "User-Defined") {

    // Get name of user-defined strategy
    string userDefinedName = stepperParams->get("User-Defined Name",
							 "???");
    if ((*stepperParams).INVALID_TEMPLATE_QUALIFIER
	isType< Teuchos::RCP<LOCA::MultiContinuation::AbstractStrategy> >(userDefinedName))
      strategy = (*stepperParams).INVALID_TEMPLATE_QUALIFIER
	get< Teuchos::RCP<LOCA::MultiContinuation::AbstractStrategy> >(userDefinedName);
    else
       globalData->locaErrorCheck->throwError(
				       methodName,
				       "Cannot find user-defined strategy: " + 
				       userDefinedName);
  }
  else
    globalData->locaErrorCheck->throwError(
				      methodName,
				      "Invalid continuation method: " + 
				      name);

  return strategy;
}
예제 #2
0
 void
 checkValidity(std::string parameters, bool isCorrect)
 {
   Name strategyName(Name(AsfStrategy::getStrategyName()).append(parameters));
   if (isCorrect) {
     BOOST_CHECK_NO_THROW(make_unique<AsfStrategy>(forwarder, strategyName));
   }
   else {
     BOOST_CHECK_THROW(make_unique<AsfStrategy>(forwarder, strategyName), std::invalid_argument);
   }
 }
예제 #3
0
Teuchos::RCP<LOCA::Eigensolver::AbstractStrategy>
LOCA::Eigensolver::Factory::create(
       const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
       const Teuchos::RCP<Teuchos::ParameterList>& eigenParams)
{
  std::string methodName = "LOCA::Eigensolver::Factory::create()";
  Teuchos::RCP<LOCA::Eigensolver::AbstractStrategy> strategy;

  // Get name of strategy
  const std::string& name = strategyName(*eigenParams);

  if (name == "Default")
    strategy =
      Teuchos::rcp(new LOCA::Eigensolver::DefaultStrategy(globalData,
                              topParams,
                              eigenParams));
  else if (name == "Anasazi") {
#ifdef HAVE_LOCA_ANASAZI
    strategy =
      Teuchos::rcp(new LOCA::Eigensolver::AnasaziStrategy(globalData,
                              topParams,
                              eigenParams));
#else
    globalData->locaErrorCheck->throwError(methodName,
                       "Anasazi strategy requested, but LOCA was not configured with Anasazi support enabled.");
#endif
  }
  else if (name == "User-Defined") {

    // Get name of user-defined strategy
    std::string userDefinedName = eigenParams->get("User-Defined Name",
                               "???");
    if ((*eigenParams).INVALID_TEMPLATE_QUALIFIER
    isType< Teuchos::RCP<LOCA::Eigensolver::AbstractStrategy> >(userDefinedName))
      strategy = (*eigenParams).INVALID_TEMPLATE_QUALIFIER
    get< Teuchos::RCP<LOCA::Eigensolver::AbstractStrategy> >(userDefinedName);
    else
       globalData->locaErrorCheck->throwError(
                       methodName,
                       "Cannot find user-defined strategy: " +
                       userDefinedName);
  }
  else
    globalData->locaErrorCheck->throwError(
                      methodName,
                      "Invalid eigensolver strategy: " +
                      name);

  return strategy;
}
예제 #4
0
Teuchos::RCP<LOCA::TurningPoint::MooreSpence::SolverStrategy>
LOCA::TurningPoint::MooreSpence::SolverFactory::create(
       const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
       const Teuchos::RCP<Teuchos::ParameterList>& solverParams)
{
  string methodName = 
    "LOCA::TurningPoint::MooreSpence::SolverFactory::create()";
  Teuchos::RCP<LOCA::TurningPoint::MooreSpence::SolverStrategy> strategy;

  // Get name of strategy
  const string& name = strategyName(*solverParams);

  if (name == "Salinger Bordering")
    strategy = 
      Teuchos::rcp(new LOCA::TurningPoint::MooreSpence::SalingerBordering(
								globalData,
								topParams,
								solverParams));

  else if (name == "Phipps Bordering")
    strategy = 
      Teuchos::rcp(new LOCA::TurningPoint::MooreSpence::PhippsBordering(
								globalData,
								topParams,
								solverParams));

  else if (name == "User-Defined") {

    // Get name of user-defined strategy
    string userDefinedName = solverParams->get("User-Defined Name",
							"???");
    if ((*solverParams).INVALID_TEMPLATE_QUALIFIER
	isType< Teuchos::RCP<LOCA::TurningPoint::MooreSpence::SolverStrategy> >(userDefinedName))
      strategy = (*solverParams).INVALID_TEMPLATE_QUALIFIER
	get< Teuchos::RCP<LOCA::TurningPoint::MooreSpence::SolverStrategy> >(userDefinedName);
    else
       globalData->locaErrorCheck->throwError(
				       methodName,
				       "Cannot find user-defined strategy: " + 
				       userDefinedName);
  }
  else
    globalData->locaErrorCheck->throwError(
				      methodName,
				      "Invalid bordered solver strategy: " + 
				      name);

  return strategy;
}
예제 #5
0
Teuchos::RCP<LOCA::StepSize::AbstractStrategy>
LOCA::StepSize::Factory::create(
       const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
       const Teuchos::RCP<Teuchos::ParameterList>& stepsizeParams)
{
  string methodName = "LOCA::StepSize::Factory::create()";
  Teuchos::RCP<LOCA::StepSize::AbstractStrategy> strategy;

  // Get name of strategy
  const string& name = strategyName(*stepsizeParams);

  if (name == "Constant")
    strategy = 
      Teuchos::rcp(new LOCA::StepSize::Constant(globalData,
						topParams,
						stepsizeParams));
  else if (name == "Adaptive")
    strategy = 
      Teuchos::rcp(new LOCA::StepSize::Adaptive(globalData,
						topParams,
						stepsizeParams));
  else if (name == "User-Defined") {

    // Get name of user-defined strategy
    string userDefinedName = stepsizeParams->get("User-Defined Name",
							  "???");
    if ((*stepsizeParams).INVALID_TEMPLATE_QUALIFIER
	isType< Teuchos::RCP<LOCA::StepSize::AbstractStrategy> >(userDefinedName))
      strategy = (*stepsizeParams).INVALID_TEMPLATE_QUALIFIER
	get< Teuchos::RCP<LOCA::StepSize::AbstractStrategy> >(userDefinedName);
    else
       globalData->locaErrorCheck->throwError(
				       methodName,
				       "Cannot find user-defined strategy: " + 
				       userDefinedName);
  }
  else
    globalData->locaErrorCheck->throwError(
				      methodName,
				      "Invalid step size control strategy: " + 
				      name);

  return strategy;
}
예제 #6
0
void CStrategyInfoDlg::OnStopStrategy()
{
	CMainFrame * pMainFrame = gpMainFrame;
	char szname[64];
	
	POSITION pos = m_listStrategyInfo.GetFirstSelectedItemPosition();
	m_listSeletcItem.clear();
	while(pos)
	{
		int CirItem = m_listStrategyInfo.GetNextSelectedItem(pos);
		m_listSeletcItem.push_back(CirItem);
	}
	if(m_nRSelItem == -1) return; 
	if(m_listSeletcItem.size() >=1 ){
		list<int> ::iterator it ;
		for(it = m_listSeletcItem.begin(); it != m_listSeletcItem.end(); ++it)// list
		{
			memset(szname, 0, sizeof(szname));
			m_listStrategyInfo.GetItemText((*it), 0 ,szname , 64);

			CString strName = szname;
			int pos = strName.Find("_");
			if (pos <= 0)
				return;
			strName = strName.Mid(0, pos);

			string strategyName(szname);
			TStrategyInfo* ret = FindSGstatemap(strategyName);
			if (ret == NULL)
				return;

			//stop this strategy
			if ( ret->dts != NULL) ret->dts->stop();
			ret->tStrategyUI.sgstate = STOP;

			m_listStrategyInfo.SetItem((*it),1,LVIF_TEXT,"已停止", 0, 0, 0,0);
			
		}
	}
	m_listSeletcItem.clear();
}
예제 #7
0
void CStrategyInfoDlg::SetMenuState(int nItem, CMenu*   pPopup)
{
	char szStrategyName[32];
	memset(szStrategyName, 0, sizeof(szStrategyName));
	m_listStrategyInfo.GetItemText(nItem, 0, szStrategyName, sizeof(szStrategyName));
	string strategyName(szStrategyName);
	TStrategyInfo* ret = FindSGstatemap(strategyName);
	if (ret == NULL)
	{
		pPopup->EnableMenuItem(0,MF_BYPOSITION|MF_GRAYED);
		pPopup->EnableMenuItem(1,MF_BYPOSITION|MF_GRAYED);
		pPopup->EnableMenuItem(3,MF_BYPOSITION|MF_GRAYED);
		pPopup->EnableMenuItem(4,MF_BYPOSITION|MF_GRAYED);
		return;
	}
	switch(ret->tStrategyUI.sgstate) {
	case WORK://开始
		pPopup->EnableMenuItem(0,MF_BYPOSITION|MF_ENABLED);
		pPopup->EnableMenuItem(1,MF_BYPOSITION|MF_GRAYED);
		pPopup->EnableMenuItem(3,MF_BYPOSITION|MF_GRAYED);
		pPopup->EnableMenuItem(4,MF_BYPOSITION|MF_GRAYED);
		break;
	case STOP://停止
		pPopup->EnableMenuItem(0,MF_BYPOSITION|MF_GRAYED);
		pPopup->EnableMenuItem(1,MF_BYPOSITION|MF_ENABLED);
		pPopup->EnableMenuItem(3,MF_BYPOSITION|MF_ENABLED);
		pPopup->EnableMenuItem(4,MF_BYPOSITION|MF_ENABLED);

		break;
	default:
		pPopup->EnableMenuItem(0,MF_BYPOSITION|MF_GRAYED);
		pPopup->EnableMenuItem(1,MF_BYPOSITION|MF_GRAYED);
		pPopup->EnableMenuItem(3,MF_BYPOSITION|MF_GRAYED);
		pPopup->EnableMenuItem(4,MF_BYPOSITION|MF_GRAYED);
		break;
	}
}
Teuchos::RCP<LOCA::MultiPredictor::AbstractStrategy>
LOCA::MultiPredictor::Factory::create(
       const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
       const Teuchos::RCP<Teuchos::ParameterList>& predictorParams)
{
  string methodName = "LOCA::MultiPredictor::Factory::create()";
  Teuchos::RCP<LOCA::MultiPredictor::AbstractStrategy> strategy;

  // Get solver sublist
  Teuchos::RCP<Teuchos::ParameterList> solverParams = 
    topParams->getSublist("Linear Solver");

  // Get name of strategy
  const string& name = strategyName(*predictorParams);

  if (name == "Constant")
    strategy = 
      Teuchos::rcp(new LOCA::MultiPredictor::Constant(globalData,
						      predictorParams));

  else if (name == "Tangent")
    strategy = 
      Teuchos::rcp(new LOCA::MultiPredictor::Tangent(globalData,
						     predictorParams,
						     solverParams));
  else if (name == "Secant")
    strategy = 
      Teuchos::rcp(new LOCA::MultiPredictor::Secant(globalData,
						    topParams,
						    predictorParams));
  else if (name == "Random")
    strategy = 
      Teuchos::rcp(new LOCA::MultiPredictor::Random(globalData,
						    predictorParams));
  else if (name == "Restart")
    strategy = 
      Teuchos::rcp(new LOCA::MultiPredictor::Restart(globalData,
						    predictorParams));

  else if (name == "User-Defined") {

    // Get name of user-defined strategy
    string userDefinedName = predictorParams->get("User-Defined Name",
							   "???");
    if ((*predictorParams).INVALID_TEMPLATE_QUALIFIER
	isType< Teuchos::RCP<LOCA::MultiPredictor::AbstractStrategy> >(userDefinedName))
      strategy = (*predictorParams).INVALID_TEMPLATE_QUALIFIER
	get< Teuchos::RCP<LOCA::MultiPredictor::AbstractStrategy> >(userDefinedName);
    else
       globalData->locaErrorCheck->throwError(
				       methodName,
				       "Cannot find user-defined strategy: " + 
				       userDefinedName);
  }
  else
    globalData->locaErrorCheck->throwError(
				      methodName,
				      "Invalid predictor strategy: " + 
				      name);

  return strategy;
}
예제 #9
0
Teuchos::RCP<LOCA::EigenvalueSort::AbstractStrategy>
LOCA::EigenvalueSort::Factory::create(
	const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
	const Teuchos::RCP<Teuchos::ParameterList>& eigenParams)
{
  string methodName = "LOCA::EigenvalueSort::Factory::create()";
  Teuchos::RCP<LOCA::EigenvalueSort::AbstractStrategy> strategy;

  // Get name of strategy
  const string& name = strategyName(*eigenParams);

  if (name == "LM")
    strategy = 
      Teuchos::rcp(new LOCA::EigenvalueSort::LargestMagnitude(globalData,
							      eigenParams));

  else if (name == "LR")
    strategy = 
      Teuchos::rcp(new LOCA::EigenvalueSort::LargestReal(globalData,
							 eigenParams));

  else if (name == "LI")
    strategy = 
      Teuchos::rcp(new LOCA::EigenvalueSort::LargestImaginary(globalData,
							      eigenParams));

  else if (name == "SM")
    strategy = 
      Teuchos::rcp(new LOCA::EigenvalueSort::SmallestMagnitude(globalData,
							       eigenParams));

  else if (name == "SR")
    strategy = 
      Teuchos::rcp(new LOCA::EigenvalueSort::SmallestReal(globalData,
							  eigenParams));

  else if (name == "SI")
    strategy = 
      Teuchos::rcp(new LOCA::EigenvalueSort::SmallestImaginary(globalData,
							       eigenParams));

  else if (name == "CA")
    strategy = 
      Teuchos::rcp(new LOCA::EigenvalueSort::LargestRealInverseCayley(
							       globalData,
							       eigenParams));
  
  else if (name == "User-Defined") {

    // Get name of user-defined strategy
    string userDefinedName = 
      eigenParams->get("User-Defined Sorting Method Name",
				"???");
    if ((*eigenParams).INVALID_TEMPLATE_QUALIFIER
	isType< Teuchos::RCP<LOCA::EigenvalueSort::AbstractStrategy> >(userDefinedName))
      strategy = (*eigenParams).INVALID_TEMPLATE_QUALIFIER
	get< Teuchos::RCP<LOCA::EigenvalueSort::AbstractStrategy> >(userDefinedName);
    else
       globalData->locaErrorCheck->throwError(
			     methodName,
			     "Cannot find user-defined sorting strategy: " + 
			     userDefinedName);
  }
  else
    globalData->locaErrorCheck->throwError(
				      methodName,
				      "Invalid sorting strategy: " + 
				      name);

  return strategy;
}