@Override
public Lattice tree(final TimeGrid grid) {
final TermStructureFittingParameter phi = new TermStructureFittingParameter(termstructureConsistentModel.termStructure());
final ShortRateDynamics numericDynamics = (new Dynamics(phi, a(), sigma()));
final TrinomialTree trinomial = new TrinomialTree(numericDynamics.process(), grid, true);
final ShortRateTree numericTree = null;//new ShortRateTree(trinomial, numericDynamics, grid);
final TermStructureFittingParameter.NumericalImpl impl = (TermStructureFittingParameter.NumericalImpl) (phi.implementation());
impl.reset();
double /* @Real */value = 1.0;
final double /* @Real */vMin = -50.0;
final double /* @Real */vMax = 50.0;
for (int /* @Size */i = 0; i < (grid.size() - 1); i++) {
final double /* @Real */discountBond = termstructureConsistentModel.termStructure().currentLink().discount(grid.at(i + 1));
final double /* @Real */xMin = trinomial.underlying(i, 0);
final double /* @Real */dx = trinomial.dx(i);
final Helper finder = new BlackKarasinski.Helper(i, xMin, dx, discountBond, numericTree);
final Brent s1d = new Brent();
s1d.setMaxEvaluations(1000);
value = s1d.solve(finder, 1e-7, value, vMin, vMax);