public double value(Path path)
        {
            int n = path.length() - 1;

            Utils.QL_REQUIRE(n > 0, () => "the path cannot be empty");

            double averagePrice;
            double product = runningProduct_;
            int    fixings = n + pastFixings_;

            if (path.timeGrid().mandatoryTimes()[0].IsEqual(0.0))
            {
                fixings += 1;
                product *= path.front();
            }
            // care must be taken not to overflow product
            double maxValue = double.MaxValue;

            averagePrice = 1.0;
            for (int i = 1; i < n + 1; i++)
            {
                double price = path[i];
                if (product < maxValue / price)
                {
                    product *= price;
                }
                else
                {
                    averagePrice *= Math.Pow(product, 1.0 / (double)fixings);
                    product       = price;
                }
            }
            averagePrice *= Math.Pow(product, 1.0 / fixings);
            return(discount_ * payoff_.value(averagePrice));
        }