29 std::vector<Time> exerciseTimes,
30 ext::shared_ptr<FdmMesher> mesher,
31 ext::shared_ptr<FdmInnerValueCalculator> calculator,
33 : exerciseTimes_(
std::move(exerciseTimes)),
mesher_(
std::move(mesher)),
39 for (
const auto& iter : *
mesher_->layout()) {
40 if (iter.coordinates()[1] == 0U) {
43 if (iter.coordinates()[0] == 0U) {
50 const std::vector<Time>::const_iterator iter
59 y_.begin(),
y_.end(), m);
62 "inconsistent array dimensions");
64 for (
const auto& iter : *
mesher_->layout()) {
65 const std::vector<Size>& coor = iter.coordinates();
66 const Real x =
x_[coor[0]];
72 const Real sellPrice = interpl(x,
y-maxWithDraw);
75 const Real buyPrice = interpl(x,
y+maxInject);
78 Real currentValue = std::max(a[iter.index()],
79 std::max(buyPrice - price*maxInject,
80 sellPrice + price*maxWithDraw));
83 auto yIter = std::upper_bound(
y_.begin(),
y_.end(),
y - maxWithDraw);
85 while (yIter !=
y_.end() && *yIter <
y + maxInject) {
87 const Real change = *yIter -
y;
88 const Real storagePrice(interpl(x, *yIter));
90 currentValue = std::max(currentValue,
91 storagePrice - change*price);
96 retVal[iter.index()] = currentValue;
bilinear interpolation between discrete points
1-D array used in linear algebra.
const_iterator end() const
Size size() const
dimension of the array
const_iterator begin() const
bilinear interpolation between discrete points
const std::vector< Time > exerciseTimes_
const ext::shared_ptr< FdmMesher > mesher_
const ext::shared_ptr< FdmInnerValueCalculator > calculator_
void applyTo(Array &a, Time t) const override
FdmSimpleStorageCondition(std::vector< Time > exerciseTimes, ext::shared_ptr< FdmMesher > mesher, ext::shared_ptr< FdmInnerValueCalculator > calculator, Real changeRate)
Matrix used in linear algebra.
const_iterator begin() const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
const ext::shared_ptr< CEVCalculator > calculator_
memory layout of a fdm linear operator
simple storage step condition
const ext::shared_ptr< FdmMesher > mesher_
Real Time
continuous quantity with 1-year units