30 std::vector<Time> exerciseTimes,
31 ext::shared_ptr<FdmMesher> mesher,
32 ext::shared_ptr<FdmInnerValueCalculator> calculator,
34 : exerciseTimes_(
std::move(exerciseTimes)),
mesher_(
std::move(mesher)),
40 for (
const auto& iter : *
mesher_->layout()) {
41 if (iter.coordinates()[1] == 0U) {
44 if (iter.coordinates()[0] == 0U) {
60 y_.begin(),
y_.end(), m);
63 "inconsistent array dimensions");
65 for (
const auto& iter : *
mesher_->layout()) {
66 const std::vector<Size>& coor = iter.coordinates();
67 const Real x =
x_[coor[0]];
73 const Real sellPrice = interpl(x,
y-maxWithDraw);
76 const Real buyPrice = interpl(x,
y+maxInject);
79 Real currentValue = std::max({
81 Real(buyPrice - price*maxInject),
82 Real(sellPrice + price*maxWithDraw)
86 auto yIter = std::upper_bound(
y_.begin(),
y_.end(),
y - maxWithDraw);
88 while (yIter !=
y_.end() && *yIter <
y + maxInject) {
90 const Real change = *yIter -
y;
91 const Real storagePrice(interpl(x, *yIter));
93 currentValue = std::max(currentValue,
94 storagePrice - change*price);
99 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