Skip to content

Commit

Permalink
added varying initial guess in NoxSolver again.
Browse files Browse the repository at this point in the history
  • Loading branch information
qichenghua authored and OpenModelica-Hudson committed Jul 18, 2017
1 parent ec62f80 commit 1799036
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions SimulationRuntime/cpp/Solver/Nox/Nox.cpp
Expand Up @@ -220,6 +220,31 @@ void Nox::solve()
numberofhomotopytries++;
}

//try varying initial guess
int VaryInitGuess=0;
while((_iterationStatus==CONTINUE) && (VaryInitGuess<std::pow(2,_dimSys))){
modify_y(VaryInitGuess);
if(BasicNLSsolve()==NOX::StatusTest::Converged){
_iterationStatus=DONE;
}else{
bool EvalAfterSolveFailed2=false;
_algLoop->setReal(_y);
try{
_algLoop->evaluate();
}catch(const std::exception & ex){
EvalAfterSolveFailed2=true;
std::cout << "EvalAfterSolveFailed2" << std::endl;
}
//&& is important here, since CheckWhetherSolutionIsNearby(_y) throws an error if EvalAfterSolveFailed=true.
if((!EvalAfterSolveFailed2) && (CheckWhetherSolutionIsNearby(_y))){
_algLoop->setReal(_y);
_algLoop->evaluate();
_iterationStatus=DONE;
}
}
VaryInitGuess++;
}




Expand Down

0 comments on commit 1799036

Please sign in to comment.