{'fraction_non_alphanumeric': 0.031923464249748235, 'fraction_numerical': 0.009013091641490433, 'mean_word_length': 4.586779184247539, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Stochastic optimization for dynamic pricing

We consider the problem of supply and demand balancing that is stated as a minimization problem for the total expected revenue function describing the behavior of both consumers and suppliers. In the considered market model we assume that consumers follow the discrete choice demand model, while suppliers are equipped with some quantity adjustment costs. The resulting optimization problem is smooth and convex making it amenable for application of efficient optimization algorithms with the aim of automatically setting prices for online marketplaces. We propose to use stochastic gradient methods to solve the above problem. We interpret the stochastic oracle as a response to the behavior of a random market participant, consumer or supplier. This allows us to interpret the considered algorithms and describe a suitable behavior of consumers and suppliers that leads to fast convergence to the equilibrium in a close to the real marketplace environment.


Introduction
With the development of platforms for online trading and services provision, the problem of dynamic pricing becomes more and more urgent. The environment of online marketplaces and financial services raises the question of establishing the most relevant prices for the items presented, and in such cases, relevance is understood as the possibility of market clearing, i.e. balancing supply and demand.
There are various approaches to finding equilibrium prices. In this paper, we consider an approach based on the characterization of the market state by a potential function of total expected revenue, similar to the function of total excessive revenue from [13]. In [9], the authors, using this approach, analyze the case in which consumers follow a discrete choice model with imperfect behavior introduced by random noise in the assessment of utility, and suppliers seek to maximize their profit, taking into account the quantity adjustment costs. This paper substantiates the convexity of the used potential as a function of prices. Hence, it follows that there are prices that minimize the potential, and it turns out that this minimum satisfies the condition of market clearing.
Thus, if there is an intermediary responsible for the formation of prices, it only needs to build a sequence of price values leading to a minimum. At the same time, it seeks to use the smallest possible amount of observations of market participants. Note that the introduced formulation is very convenient for applying the results of optimization theory to find the optimal prices. Indeed, the function under consideration is to be minimized and it simultaneously includes the characteristics of both consumers and suppliers, although in the classical game-theoretic approach the opposition of the interests of these parties leads through the Nash equilibrium scheme to minimax problems. Nevertheless, it turns out to be possible to propose exactly the potential function that describes the whole system and reduces its dynamic to only tendency to an extreme point, similar to physical systems. On the other hand, the considered function has the form of a sum including together the terms that characterize the behavior of both parties and each agent. This means that we can consider both consumers and suppliers as the same market participants and uniformly take into account their interests, without distinguishing between their types. Together, the described advantages lead to the ability to use the developments of convex optimization to find methods for constructing a sequence of prices, and analyze them in terms of the oracle complexity, which in this setting means the number of observations of the agents' behavior.
In this paper, continuing the ideas of [9], the problem of finding equilibrium prices is posed in a stochastic setting, and the number of observations of the intermediary for single market participants is determined as a measure of the effectiveness of the method for solving this problem. Section 2 describes the problem statement and introduces the stochastic oracle for considered function to optimize. Section 3 discusses various algorithms for stochastic convex optimization, proposes theoretical estimates of the efficiency of the algorithms, and describes the practical advantages of each of them. Section 4 generalizes the stochastic setting for the case of an infinite number of consumers, which makes it possible to take into account the previously unobserved consumers, and describes the algorithms for this setting. Section 5 considers a special case of the problem with zero quantity of the adjustment costs, in which the potential loses its smoothness property, and proposes several approaches to get around this difficulty. Section 6 shows the results of modeling of the behavior of the proposed algorithms for a synthetic problem and demonstrates the improvement in the efficiency of the methods, which can be achieved by considering the stochastic formulation of the problem, in comparison with the dynamics from [9].

Problem statement
Let us imagine the marketplace environment. There are a number of suppliers (for example, shops) and a number of consumers (buyers). And every supplier offers some products (goods) in the assortment. Products are grouped by their type, every group contains some alternatives. In turn, every consumer can choose to buy one of the alternatives, guided by its subjective utility and price (with some element of randomness). For reasons of increasing profit, suppliers can change the assortment, taking into account the costs of these changes themselves. We use the corresponding mathematical models for the consumer and the supplier, and characterize them by the values of expected surplus and maximal revenue, respectively. Summing these terms up we obtain the function of total expected revenue. It describes the current imbalance in the market system. Its minimum corresponds to the prices at which the market is cleared. This means that we can formulate an optimization problem for finding equilibrium prices.
Let us consider such an optimization problem (in a simplified form) for the case of n product alternatives divided into m disjoint groups G i ⊂ {1, ..., n}, S suppliers with convex costs functions c s : R n + → R + , closed and convex sets of capacity constraints Y s ⊂ R n + , typical suppliesŷ s ∈ Y s and quantity adjustment costs equal to −Γ s · y −ŷ s 2 2 for some parameter Γ s > 0, D consumers with matrix A = {a id > 0} n,D 1,1 of alternatives subjective utility for each of them, and prices vector p: where π s (p) = max is the maximal revenue of supplier with taking into account costs c s (·) and quantity adjustment costs parametrized by Γ s for given prices, and demand model with noise and for corresponding nested logit distribution [7], with some correlation parameters 0 < µ j ≤ 1. We can also provide an explicit expression for the gradient of the introduced objective function: where y s (p) is the optimal solution of the optimization problem (2) (by Demyanov-Danskin theorem [2]), and are the probabilities to choose certain alternative by the consumer 3 .
To use optimization methods for dynamic pricing we can utilize that f is of the form of sum. If the number of suppliers S and consumers D is big, evaluation of all the term in both sums is too expensive in term of working time and algorithmic complexity. But if we randomly pick up only one of (S + D) terms at iteration, computing resources are used much more sparingly, which leads to faster operation of the algorithm. So, considering only one term of sum from (3), we introduce the stochastic gradient oracle: Note, that the use of stochastic oracle is very natural. Indeed, using the gradient dynamics of prices from [9], we evaluate all of the terms in (4) at iteration, i.e. it is necessary to consider the behaviour of all the consumers and suppliers to make one step of dynamic. But in practice we cannot guarantee that we collect all this information in short time (consumers may be impermanent, so the waiting time may be arbitrarily long). At the same time, the decisions of consumers and suppliers are not rigidly connected: we can observe some number of consumer's sales daily (represented by x d (·)), and much less often and independently the periodic store assortment changes (represented by y d (·)). Therefore, using the dynamics with stochastic oracle in the form of (4) we can immediately take into account newly observed behaviour and make iteration, that is now cheap both in computation and in the required downtime. However, in real-life environment we alsp cannot estimate the probability of customer's choice, represented by the vector x d (p) included in second case of (4). We can obtain only some single sales, those are in fact the random samples of the form , and we can introduce another, more practical, stochastic gradient oracle for constructing our dynamics: Now, let us clarify properties of the objective function and introduced oracles. In our simplified setting the following result holds: 3 Algorithms and theoretical guarantees

Stochastic gradient descent
Let us consider the simplest dynamic of prices, based on the classical stochastic gradient descent method. A very natural interpretation for this dynamics is that in every iteration we can observe only one of the market participants, supplier or consumer. As soon as participant makes an economical decision (consumer chooses the product or supplier modifies the supply plan), we evaluate the stochastic oracle ∇f i (p t ), and make a step to the equilibrium prices. This dynamic is listed as Algorithm 1. We use the [·] + notation for the positive part function, i.e. for a = [b] + we have a i = max{0, b i }, and denote by i ∼ U{1, ..., S + D} the i.i.d. random variables from discrete uniform distribution.
We analyse this dynamic as the projected stochastic gradient method with Polyak-Ruppert averaging with tunable parameter C > 0 to control the step size of the method. One practical advantage of this method is the robustness to the choice of C: it may be chosen regardless of theoretical value of L. However, the analysis additionally requires the condition of stochastic gradient's boundedness, but due to the smoothness of f we can bound the norm of (4), while the additional randomization in the second case of (5) acts on the standard simplex and therefore is also bounded. Unfortunately, I didn't understand the previous sentence.

Algorithm 1 SGD dynamic
Require: p0 -starting prices values, N -number of iterations, C -parameter to control the step size 1: for t = 0, 1, . . . , N − 1 do 2: i ∼ U{1, ..., S + D} Moreover, to obtain the prices satisfying the suboptimality bound it is sufficient to call ∇f i oracle O 1 ε 2 times.
Therefore, considered SGD dynamic with Polyak-Ruppert averaging obtains convergence rate of O N −1/2 , up to a logarithmic term. This also matches the result from [13].

Adaptive stochastic gradient method
In this section we describe a slightly different AdaGrad [3] dynamics that has a different step size policy. More precisely, the stepsize is chosen based on the stochastic subgradients on the trajectory of the method. This allow the algorithm to adapt to the local information and possibly make longer steps.
Hence the proposed AdaGrad dynamic demonstrates convergence rate of the order O N −1/2 . This asymptotic is similar to that for SGD dynamic, but in practice such a simple modification of the step size allows to discernibly improve the convergence rate. At the same time, the step size hyperparameter η is still free and it allows to manually tune the algorithm for the best practical efficiency.

The case of infinite number of consumers
In general, the total expected revenue framework considered in [9] allows one to describe not only the individual consumers, but also the groups of consumers with close behavior. At the same time, their model covers only the setting of finite number of agents, which may be not completely practical. Indeed, if the number of agents is huge or new agents can enter the marketplace as time goes, it makes sense to consider the limit when the number of agents tends to infinity. This leads to a general, non-finite-sum objective given as an expectation.
To be more specific, we consider that consumers are represented by a random variable with some unknown distribution, i.e. d ∼ D. Then the characteristic vector (a id ) n i=1 is also random. To maintain the property of market clearing at optimal prices we also assume that the number of suppliers is infinite and that they are represented by another random variable, i.e. s ∼ S. The next step is to take the limit in (1) and make transition to expectation w.r.t. distributions D, S instead of sums. For the sake of normalization we introduce the parameter 0 < β < 1 that is equal to the fraction of suppliers among all market participants. Informally, β = lim (S+D)→∞ S/(S + D).
In this way, considering function 1 S+D f (p) instead of f (p) and taking the limit as (S + D) → ∞, we have the new optimization problem in the form of expectation: Note, that to preserve the convergence properties of the SGD dynamic considered in Section 3.1 it is sufficient just to generalize the used stochastic oracle (5) to the proposed setting by defining Thus, to generate the stochastic gradient, we first with probability β choose to choose among suppliers or with probability 1 − β we choose to choose among consumers. Then, in the former case we sample supplier from the distribution S and in the latter case we sample consumer from the distribution D. Finally, for the chosen agent the stochastic gradient is defined as in (5). Since problem (6) is a general stochastic optimization problem, we can apply Algorithm 1 and obtain the dynamic listed as Algorithm 3. Its interpretation is quite similar to that of Algorithm 1: at the every iteration we observe the behaviour of one market participant, consumer or supplier, and change the prices in a proper way. As in the SGD dynamic, samplings d ∼ D, s ∼ S and switching w.p. β are provided by natural flow of participants, we assume that information about participants decisions arrives uniformly. Since Lemma 1 and the conditions of Theorem 1 still hold, the convergence rate of dynamic below is similar to the one given in Theorem 1.

The case of zero quantity adjustment costs
In this section we return to the setting of Section 2 and consider the limiting case when in (2) Γ s = 0. In this case there is no typical supplyŷ s and all the necessary information about the costs incurred by the supplier is set by the function c s (·). In this case there is no guarantee that the function f in (1) is smooth (cf. Lemma 1) and the algorithms have to be properly modified to guarantee the convergence. This section is devoted to such modifications.

Mirror descent dynamic
Stochastic mirror descent (SMD) [5,10,11] is widely used and theoretically optimal algorithm for stochastic convex non-smooth optimization problems. We consider here a particular case of the SMD dynamic with Euclidean proximal setup, in which it looks quite similar to SGD dynamic, but uses a different step size policy. SMD dynamic is listed below as Algorithm 4.

Algorithm 4 SMD dynamic
Require: p0 -starting prices values, N -number of iterations, C -parameter to control step size 1: for t = 0, 1, . . . , N − 1 do 2: i ∼ U{1, ..., S + D} Theoretical guarantee below utilizes the Lipschitz continuity of function f , more precisely the boundedness of the stochastic gradient norm. Considering the expression (3), we can bound the first term by applying some economic reasoning, namely that the supply is always limited or scarcity principle [1]. The second term is also bounded since all x d are probability vectors and belong to the standard simplex. Stochastic gradient given by (5) is bounded by the same reason.
Moreover, to obtain the prices satisfying the suboptimality bound it is sufficient to call ∇f i oracle O 1 ε 2 times.
So, the described SMD dynamic has convergence rate of O N −1/2 in nonsmooth case that takes place if Γ s = 0 for some s. This bound matches that of the SGD dynamic from Theorem 1.

Dual smoothing
The special structure of the function π s (p) in (2) allows us to use the Nesterov's smoothing technique [12]. The idea is, in the case when Γ s = 0, to replace the −Γ s · y −ŷ s 2 2 term in (2) with the synthetic penalty −η · y − y 0 2 2 , where η = ε/(2R 2 ) for some fixed target suboptimality ε and R such that y * − y 0 2 ≤ R. With this substitution for all s, following the argumentation of Lemma 1, we have that the modified function f η has Lipschitz-continuous gradient with constant At the same time, if we minimize f η up to accuracy ε 2 , i.e. we have for some p that then it holds that It means that we can obtain the solution of the problem (1) satisfying the target suboptimality bound by optimizing the modified function f η that is smooth and therefore allows us to apply some of the methods described in previous sections. Note that the transition from non-smooth setting to the smooth one with the described approach is not free in terms of convergence rate due to the dependence of the constant L on the target suboptimality ε.

Numerical experiments
In this section, we focus on the problem (1), which is motivated by important applications to offering smart pricing options by online marketplaces and management of demand and supply by such financial intermediaries like brokers [9].
We provide the results of our numerical experiments, which are performed on a PC with processor Intel Core i7-8650U 1.9 GHz using pure Python 3.7.3 (without C code) under managing OS Windows 10 (64-bits). Numpy.float128 data type with precision 1e − 18 and with max element ≈ 1.19e + 4932 is used. Random seed is set to 17.
We compare Algorithm 1 and Algorithm 2 with pricing dynamics 4.2 and 4.4 from [9] on the problem (1) with the following settings: number of suppliers S = 5, number of consumers D = 10, number of products n = 20, number of groups m = 5. Γ s is chosen like 10 −4 (some small value that affects to convergence of pricing schemes from [9]). We generated also S vectorsŷ s from uniform distribution U[0.01, 2] of size n. Initialization point p is chosen from uniform distribution U[0.01, 5] of size n, but it is scaled by the maximum element. Matrix A consists of columns with each one is drawn from uniform distribution And µ values are drawn i.i.d. from uniform distribution U[0.1, 1] of size m.
During the experiments we store objective suboptimality and number of oracle calls for each algorithm at every iteration. The results are presented on the Figure 1. As we can see from the Figure 1, there is almost no difference between accelerated and non-accelerated pricing schemes from [9] and that the stochastic algorithms converge to the optimal value much faster than accelerated gradient method with respect to chosen parameters.

Conclusion
We propose a stochastic version of the formulation of the problem of finding equilibrium prices by minimizing the potential function of total expected revenue, proposed in a deterministic form in [9]. Thanks to the introduction of the stochastic oracle, we analyze and interpret in terms of observing the real-life marketplace environment several dynamics based on the efficient stochastic gradient optimization methods. We also analyze the case of a non-smooth potential function in the case of zero quantity adjustment costs. In addition, we propose a generalized setting allowing an infinite number of market participants and equally suitable application of optimization methods. Numerical experiments show that stochastic methods turn out to be discernibly more efficient in comparison with full-gradient dynamics.