Skip to content

Commit cc9e314

Browse files
committed
QPR-11360 set upper and lower limits for solver
1 parent f115e58 commit cc9e314

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

ql/experimental/credit/randomdefaultmodel.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <ql/experimental/credit/randomdefaultmodel.hpp>
2222
#include <ql/math/solvers1d/brent.hpp>
23+
#include <ql/math/solvers1d/bisection.hpp>
2324
#include <utility>
2425

2526
using namespace std;
@@ -73,8 +74,16 @@ namespace QuantLib {
7374

7475
if (dts->defaultProbability(tmax) < p)
7576
pool_->setTime(name, tmax+1);
76-
else{
77-
pool_->setTime(name, Brent().solve(Root(dts,p),accuracy_,0.0,tmax));
77+
else {
78+
try {
79+
Brent brent;
80+
brent.setLowerBound(0.0);
81+
brent.setUpperBound(tmax);
82+
pool_->setTime(name, brent.solve(Root(dts,p),accuracy_, tmax/2.0, 1));
83+
}
84+
catch(...){
85+
pool_->setTime(name, Bisection().solve(Root(dts,p), accuracy_, tmax/2.0, 0.0, tmax));
86+
}
7887
}
7988
}
8089
}

0 commit comments

Comments
 (0)