WorksMathematics
Statistical and Optimization Models for Generating Electricity in Energy Markets
Abstract
Electricity generation has become a remunerative avenue for new investments, particularly in the area of renewable energy resources. This paper introduces a framework for integrating statistical methods with optimization modeling to improve decision support in electricity generation. The analysis begins by evaluating the success of mini-grid projects installed across the globe using both a probit and a Bayesian hierarchical model to estimate the probability of project success. Furthermore, we provide a multi-resource optimization framework for determining the optimal profit in electricity generation while reducing carbon emissions in production facilities. We also analyze the impact of a battery energy storage system and bidding behavior in the Alberta electricity market by constructing a mixed-integer self-scheduling model that determines optimal charging and discharging strategies. Numerical experiments show how storage systems can enhance energy arbitrage profitability and influence market clearing prices. Finally, we propose a Stochastic Dynamic Programming (SDP) model to maximize profit in electricity generation while accounting for price volatility. Integrating statistical methods with optimization-based modeling reveals great value in achieving more effective, profitable, and clean energy systems.
Introduction
The availability of sustainable and clean energy in the world is one of society’s most important challenges. According to Ember [1], solar power alone met 75% of the net increase in electricity demand in 2026 and together with wind, these two sources met almost all (99%) of the global demand growth. In Canada, the reliability and affordability of energy is needed for the development of a robust Canadian economy - for example, energy costs are the third largest cost for mining operation (see for example [2]). To increase availability of energy and reduce costs, energy providers will need to look at alternative energy sources. Increasingly, this means producing energy from alternative sources, such as renewable energy sources, locally.
The purpose of this paper is to provide a model which will help small produces namely private or community based producers to enter the energy market by being able to predict how to produce and store energy in a way that will minimize costs and maximize profits. Large producers may also gain strategic advantage as storage systems, particularly battery storage systems (BESS) lower operating costs, reduce reliance on expensive peaking units, and improve overall system reliability, making them a powerful tool for modern energy producers navigating increasingly variable electricity markets.
Both small and large energy producers benefit from local energy generation. Local energy generation refers to the production of electrical power close to where it is consumed rather than relying on large, centralized power plants. Local energy generation often relies on distributed renewable sources like solar panels and wind turbines, supported by energy storage systems and coordinated through microgrids. Microgrids operates similar to the utility grid but are located near energy-consuming areas, thus reducing the burden on the utility grid. Instead of connecting all the power generation sources directly to the utility grid, microgrids operate within a grid of generators and renewable energy sources.
The novelty of this research is two-fold and first entails providing a comparison of statistical and optimization methods for maximizing profit in electricity generating. Our methods utilize fossil fuel, natural gas and renewables in generating electricity. Next we propose a stochastic dynamic programming approach to model a battery energy storage system and maximize profit.
The statistical method implemented in this paper, begins by extending the work done by Durand and Sahinyazan [3] in determining factors that influence the success of mini-grid projects installed across the globe. For their results, factors such as Ownership, particularly Community Ownership and Storage emerge as statistically significant predictors of the success of a renewable mini-grid project. Furthermore, we compare the results of a Probit regression model to a Bayesian hierarchical model in determining factors that influence project success. Results indicate, that the Bayesian model is suitable in capturing the underlying probability of a project being successful.
Second, we explore optimization methods for maximizing profit and minimizing costs in electricity generation and propose a mixed integer programming model towards a battery storage system. Our model decides hour-by-hour to charge/discharge in order to maximize profit, consistent with Alberta’s market participation rules. In addition to energy storage systems balancing the supply and demand of electricity, they can also reduce carbon emissions as stored renewable energy displaces fossil fuels during peak demand thus enabling reliable clean power. Furthermore, battery energy storage systems provide opportunities for energy arbitrage and take advantage of hourly off and on peak electricity prices by buying and storing electricity at times when prices are low, and then selling it back to the grid when the price of electricity is greater.
Moreover, optimization frameworks for battery energy storage systems have been proposed in [4, 5, 6]. The impact of providing energy arbitrage by energy storage systems in various electricity markets has been shown to be both a price-maker and price-taker [7, 8, 9, 10] with various statistical and optimization models being proposed in [3, 11, 12, 13, 14].
Third, we implement a dynamic programming model to maximize the profit in electricity generation while also accounting for the volatility of prices. Preliminary results indicate the dynamic programming model as a promising method when compared against the mixed-integer programming model for generating profit.
The remainder of this paper is summarized as follows. After a brief review of the related methods in § 2, we present in § 3, a comparison of a Probit and Bayesian model in determining factors that influence the success of a mini-grid installed across the globe. In § 4, we discuss mathematical models for maximizing profit in electricity generation and analyze the impact of a battery energy storage problem in storing energy and minimizing costs in § 5. In § 7 we propose SDP as a novel approach for maximizing profit in battery energy storage systems and the potential of models for capturing price volatility. Preliminary results indicate the dynamic programming model as a promising method when compared against the mixed-integer programming model. Finally we summarize and conclude in § 9 and discuss directions for our future work in § 10.
Related Work
Statistical and optimization models for electricity generation have been studied in various research [11, 12, 13, 14]. The statistical models deal in detail with explanatory variables for electricity price fluctuations whereas the finance models focus on the stochastic part of the price change. For example, in [11] a Bayesian regression model is employed to model the wholesale electricity market and in [12], a weather model using regression analysis is presented to predict the demand for the electricity supply system. The financial models in [13, 14], focus on capturing the volatility of prices in the Alberta electricity market. Moreover, Barlow [13] and Ware [14] propose diffusion models and Polynomial maps respectively to model the spikes and capture the volatility in prices. Additionally, Jarrow, Protter and Sezer [15] propose a credit risk model for a class of diffusion processes where the market observes the firm’s asset value when it crosses certain levels and interprets it as a significant change for the firm to make a public announcement.
Optimization models for electricity generation have also been studied in [16, 17]. Two-stage optimization modeling frameworks are proposed in [18, 19] for generating electricity given products, such as diesel generations and renewables. In [19], the electricity demand is assumed to be independently and identically distributed and the optimal investment strategy is determined using a multi-dimensional news vendor model. Moreover, an optimization framework for a price-maker energy storage system is developed in [17] which involves coordinating charging and discharging of an energy storage system in a nodal electricity market. Further optimization models for electricity markets are proposed in the following papers [20, 21]. In these papers, the problem is formulated as a bi-level optimization problem, consisting of bidding strategy and market clearing problems in the upper and lower levels. In [20] a single firm-model is proposed and is formulated as a Mathematical Program with Equilibrium Constraints (MPEC) with a parameter-dependent spatial price equilibrium problem as the inner problem. In [21] a binary expansion (BE) solution to the strategic bidding problem under uncertainty in short-term electricity markets is presented. The BE scheme is used to transform the products of variables in the nonlinear bidding problem into a mixed integer linear programming formulation.
In [6] a multistage stochastic programming (SP) model is formulated whose objective is to minimize the expected total energy costs incurred within a microgrid over a finite planning horizon. In this model, the demand, renewable supply and prices are all modeled as random variables. Furthermore, in [5], a stochastic optimization configuration model for the energy storage system is constructed. The expected revenue of the optimal configuration was found to be higher than the scheme with a fixed probability distribution model. Additionally, in [4], a global battery capacity optimization method for existing buildings based on the historical load is proposed for maximizing the annualized net revenue. Results show that the proposed method can effectively identify the global optimal capacity of the battery energy storage system for the buildings and caused an annual reduction in the electricity bills.
Stochastic dynamic programming have been applied to battery storage problems in various research [22, 23, 24, 25, 26]. The model in [22] considered the problem of operating a battery storage unit in a home with a rooftop solar photovoltaic (PV) system so as to minimize expected long-run electricity costs under uncertain electricity usage, PV generation, and electricity prices. Their model also incorporated approximate cost-to-go functions. In [23] a two-stage stochastic programming problem is formulated where the joint operation of wind with photovoltaic power systems has an energy storage device. The optimal bids and the energy flow in the battery are the first-stage variables and the energy flow is the second stage variable of the problem. In [24], the price arbitrage problem is formulated using stochastic dynamic programming and real-time prices are modeled as a Markov process. Results indicate that the proposed method captures 50% to 90% of arbitrage profit compared to perfect price forecasts. Another multi-stage stochastic programming model is proposed in [25] where the objective function comprises two terms: (1) the expected profit of the renewable energy owner and (2) the CVaR (conventional value at risk) multiplied by a weighting factor , which controls the degree of risk aversion of the renewable energy owner. Furthermore, in [26] battery storage optimization strategies are evaluated by comparing various stochastic dual dynamic programming (SDDP) model configurations against a linear programming (LP) benchmark mode. To the best of our knowledge, statistical and optimization methods including dynamic programming and stochastic dynamic programming have never been applied to a battery energy storage problem as done in our case.
Mini-grids in Electricity Generation
A Bayesian Hierarchical Model
First we begin by extending the work done by Duand and Sahinyazan [3] in determining factors that influence the success of a mini-grid project. Our proposed methods includes the following Bayesian hierarchical model with a bernoulli response. Consider to be the outcome of minigrid project , and write , where is the probability of project being successful. The covariates are and , in the model. The model is presented below:
Now :
now the shape of the posterior is proportional to the likelihood,
where
and solving for gives
We apply a Bayesian approach to the model in Eq. (1) and let be our parameters of interest. In specifying the conjugate prior for the Bernoulli distribution, the beta distribution, is utilized. If and has an equal likelihood of being observed that is, and then the beta distribution is uniform. Therefore we define the following priors for each parameter as
There are a number of R packages available for the posterior estimation of this Bayesian hierarchical model. In this paper we implement the RJAGS package which uses the Markov chain Monte–Carlo sampling (MCMC) algorithm [27]. The MCMC samples are generated by the coda function package in rjags. N.iter was set as 10,000 with 2 chains to allow for adequate convergence and mixing of the chains to provide a good approximation to the posterior.
The Metropolis Algorithm or MCMC algorithm is applied to the scenario of flipping a coin N times and observing p heads (success or failure of a project). For a simplistic hierarchical model, the bernoulli likelihood function is applied and proceeds as follows:
Arbitrary start at an initial value of (in the valid range), denoted by .
Generate a proposed candidate and denote the proposed value of the parameter as .
Compute the probability of moving to the proposed value, specifically expressed as:
4.
If the proposed value , happends to land outside of the permissible bounds of , the prior and /or likelihood is set to zero.
Accept the proposed parameter value if a random value is sampled from a [0, 1] uniform distribution is less than the probability of moving to a new location and the proposed parameter value and tally the current value again.
Repeat the above steps until a sufficiently representative sample has been generated
Probit Regression Model
Here, for comparison, we specify a probit model with a binary outcome as follows:
where, is the cumulative distribution function of the standard normal distribution.
It maps any real number to a probability , as it represents the cumulative distribution function of the standard normal distribution.
Data Analysis
The data comprises of 104 mini-grid installations and pilot projects in rural areas across the world. The data related to each project can be found in [3] and is manually encoded from a vast collection of primary documentation, including scientific publications, reports and databases from government, public utilities, regulators and rural electrification agencies, grey literature such as NGO, donor and development agency report, case studies, portfolios of private developers and news articles.
| Variable | Description |
| Project Success (Independent) | Project success is encoded as 0–1. Mini-grid infrastructure in working conditions. |
| Project Capital Cost per Capita (PCCC) (Independent) | One-time fixed costs incurred for the purchase of equipment, installation, and connection costs. |
| Ownership | Categorical variable over four mini-grid ownership models: public-owned, private-owned, public-private partnership (PPP), and community-based. |
| Technology Type | Indicator variable for each of the common mini-grid renewable technologies: solar, hydro, wind, and biomass. |
| Region | Observations from 39 countries. |
| Renewable Proportion (Renew) | Continuous variable representing the proportion of renewable sources in the total installed capacity. |
| Storage | Indicator variable signifying projects with a battery or flywheel component. |
| Demand Management System (DM) | Indicator variable included in the model. |
| System Capacity per Capita (SCPC) | Total system generation capacity installed per capita in megawatts. |
Table 1. Description of Variables Used in the Model
Experimental Details
A probit regression model is fitted to the data to capture the probability of success/failure on a mini-grid project. Additionally, the probit regression model and Bayesian models are used to predict the probit regression coefficients. A comparison of the results is provided in the Table 5 and Figure 1 below:
| Obs | Probit (A) | Bayesian (B) |
| 1 | 0.7599321 | 0.7751 |
| 2 | 0.9210254 | 0.9158 |
| 3 | 0.9519128 | 0.9512 |
| 4 | 0.7339135 | 0.7183 |
| 5 | 0.7367891 | 0.7491 |
| 6 | 0.9223107 | 0.9235 |
| 7 | 0.9210254 | 0.9158 |
| 8 | 0.9223107 | 0.9235 |
| 9 | 0.9223107 | 0.9235 |
| 10 | 0.9223107 | 0.9235 |
| 11 | 0.9210254 | 0.9158 |
Table 5. Probit and Bayesian Predicted Probabilities

Figure 1. Plot of predictive probabilities between Bayesian and probit model
| Obs | Probit (A) | Bayesian (B) |
| 12 | 0.4676312 | 0.4677 |
| 13 | 0.7339135 | 0.7183 |
| 14 | 0.7367891 | 0.7491 |
| 15 | 0.9223107 | 0.9235 |
| 16 | 0.9210254 | 0.9158 |
| 17 | 0.9210254 | 0.9158 |
| 18 | 0.9210254 | 0.9158 |
| 19 | 0.9210254 | 0.9158 |
| 20 | 0.9223107 | 0.9235 |
| 21 | 0.7367891 | 0.7491 |
| 22 | 0.9928770 | 0.9875 |
| 23 | 0.7339135 | 0.7183 |
| 24 | 0.9928770 | 0.9875 |
| 25 | 0.9928770 | 0.9875 |
| 26 | 0.9519128 | 0.9512 |
| 27 | 0.9210254 | 0.9158 |
| 28 | 0.9210254 | 0.9158 |
| 29 | 0.9928770 | 0.9875 |
| 30 | 0.7599321 | 0.7751 |
| 31 | 0.7599321 | 0.7751 |
| 32 | 0.9210254 | 0.9158 |
| 33 | 0.9210254 | 0.9158 |
| 34 | 0.9210254 | 0.9158 |
| 35 | 0.9210254 | 0.9158 |
| 36 | 0.9210254 | 0.9158 |
| 37 | 0.9928770 | 0.9875 |
| 38 | 0.9519128 | 0.9512 |
| 39 | 0.9519128 | 0.9512 |
| 40 | 0.9210254 | 0.9158 |
| 41 | 0.9223107 | 0.9235 |
| 42 | 0.9928770 | 0.9875 |
| 43 | 0.7599321 | 0.7751 |
| 44 | 0.9519128 | 0.9512 |
| 45 | 0.9928770 | 0.9875 |
| 46 | 0.9223107 | 0.9235 |
| 47 | 0.9519128 | 0.9512 |
| 48 | 0.9210254 | 0.9158 |
| 49 | 0.4676312 | 0.4677 |
| 50 | 0.9519128 | 0.9512 |
| 51 | 0.7367891 | 0.7491 |
| 52 | 0.9519128 | 0.9512 |
| 53 | 0.9210254 | 0.9158 |
| 54 | 0.9519128 | 0.9512 |
| 55 | 0.7599321 | 0.7751 |
Table 9.
| Obs | Probit (A) | Bayesian (B) |
| 56 | 0.7339135 | 0.7183 |
| 57 | 0.7339135 | 0.7183 |
| 58 | 0.7339135 | 0.7183 |
| 59 | 0.7339135 | 0.7183 |
| 60 | 0.7339135 | 0.7183 |
| 61 | 0.7367891 | 0.7491 |
| 62 | 0.7367891 | 0.7491 |
| 63 | 0.9519128 | 0.9512 |
| 64 | 0.7367891 | 0.7491 |
| 65 | 0.7367891 | 0.7491 |
| 66 | 0.7339135 | 0.7183 |
| 67 | 0.7339135 | 0.7183 |
| 68 | 0.9210254 | 0.9158 |
| 69 | 0.9223107 | 0.9235 |
| 70 | 0.7367891 | 0.7491 |
| 71 | 0.7367891 | 0.7491 |
| 72 | 0.7367891 | 0.7491 |
| 73 | 0.7367891 | 0.7491 |
| 74 | 0.7367891 | 0.7491 |
| 75 | 0.7339135 | 0.7183 |
| 76 | 0.7339135 | 0.7183 |
| 77 | 0.7599321 | 0.7751 |
| 78 | 0.9928770 | 0.9875 |
| 79 | 0.9928770 | 0.9875 |
| 80 | 0.9928770 | 0.9875 |
| 81 | 0.4676312 | 0.4677 |
| 82 | 0.9223107 | 0.9235 |
| 83 | 0.7367891 | 0.7491 |
| 84 | 0.9519128 | 0.9512 |
| 85 | 0.9210254 | 0.9158 |
| 86 | 0.9928770 | 0.9875 |
| 87 | 0.9928770 | 0.9875 |
| 88 | 0.9928770 | 0.9875 |
| 89 | 0.9928770 | 0.9875 |
| 90 | 0.9928770 | 0.9875 |
| 91 | 0.9928770 | 0.9875 |
| 92 | 0.9928770 | 0.9875 |
| 93 | 0.9928770 | 0.9875 |
| 94 | 0.9928770 | 0.9875 |
| 95 | 0.9928770 | 0.9875 |
| 96 | 0.9519128 | 0.9512 |
| 97 | 0.7367891 | 0.7491 |
| 98 | 0.9519128 | 0.9512 |
| 99 | 0.9519128 | 0.9512 |
Table 10.
| Obs | Probit (A) | Bayesian (B) |
| 100 | 0.9519128 | 0.9512 |
| 101 | 0.7367891 | 0.7491 |
| 102 | 0.7367891 | 0.7491 |
| 103 | 0.9519128 | 0.9512 |
| 104 | 0.9519128 | 0.9512 |
Table 1 (PDF p. 10).

Figure 2. Histogram showing the number of successful projects
Results and Discussion
Figure 3 demonstrates a scatter plot of the predicted values of the probit model and Bayesian model. The scatter points indicate how closely both models match for each observation. The fitted regression line shows the overall trend and positive linear relationship.

Figure 3. Scatter plot showing how closely the two models agree for each observation
Table 2 illustrates the regression results for the probit model from the variables listed in Table 1. The model is given below as:
| Term | Estimate | Std. Error | z value | Pr(> |z|) |
| (Intercept) | -0.3031 | 1.8127 | -0.167 | 0.8672 |
| Ownershipcommunity | 1.4984 | 0.6542 | 2.290 | 0.0220* |
| Ownershipppp | -0.9197 | 0.6338 | -1.451 | 0.1468 |
| Ownershipprivate | 0.4847 | 0.5065 | 0.957 | 0.3386 |
| Storage | 1.0926 | 0.4509 | 2.423 | 0.0154* |
| DM | -0.4162 | 0.5421 | -0.768 | 0.4426 |
| RegionAmericas | -0.5201 | 0.5504 | -0.945 | 0.3447 |
| RegionAsiaPacific | -0.5758 | 0.4656 | -1.237 | 0.2162 |
| Renew | -0.7922 | 0.7554 | -1.049 | 0.2943 |
| PCCC | 0.1247 | 0.1129 | 1.105 | 0.2693 |
Table 2. Probit regression coefficients full Model. Signif. codes: 0 “***” 0.001 “**” 0.01 “*” 0.05 “.” 0.1 “ ” 1
As demonstrated in Table 2, Community Ownership and Storage emerge as statistically significant predictors of project success.
Table 3, Table 4 and Figure 1 display the results of the Probit and Bayesian model considering Community Ownership and Storage. If we look into the mechanism, we will observed that the probit model adequately estimates the model parameters. Based on these results, we build the following reduced probit regression model based on project success ().
| Variable | Estimate | Std. Error | z value | Pr(> |z|) |
| Intercept | 0.624692 | 0.332237 | 1.880 | 0.0601 . |
| Ownership_community | 1.038997 | 0.544251 | 1.909 | 0.0563 . |
| Ownership_ppp | -0.705918 | 0.530820 | -1.330 | 0.1836 |
| Ownership_private | 0.008785 | 0.411627 | 0.021 | 0.9830 |
| Storage | 0.787310 | 0.369150 | 2.1332 | 0.0329 |
Table 3. Probit Regression Coefficients. Significance codes: *** ** * . ; not significant
| Variable | Mean | SD | Naive SE | Time Series SE |
| Intercept | 2.1679 | 4.71838 | 0.0746041 | 0.8832710 |
| Ownership_community | 1.3081 | 4.70988 | 0.0744697 | 0.8474668 |
| Ownership_ppp | -2.3204 | 4.7450 | 0.0750254 | 0.8360369 |
| Ownership_private | -1.0051 | 4.73934 | 0.0749356 | 0.8750269 |
| Storage | 1.5752 | 0.74131 | 0.0117212 | 0.0124255 |
Table 4. Emperical Mean and Standard deviation for Bayesian Model. Significance codes: *** ** * . ; not significant
From the probit model results we see that the probability of success increases with both Community Ownership and Storage. Furthermore, from their p values 0.0220 and 0.0154 Community Ownership and Storage emerge as statistically significant predictors of project success. Thus the probit regression model is recommended as a method to determine the probability of success of a project given various factors and covariates.
For the bayesian analysis, we ran the MCMC algorithm for 10,0000 iterations with thin=100 (or every hundredth draw). Convergence was assessed from traceplots ensuring that the chains mixed well. Table 4 shows the posterior mean for all the parameters with a 95% Bayesian credible intervals. The main goal is to estimate the coefficients of the model via simulating posterior samples. The mean posterior densities closely match the estimates determined by the probit regression model. To evaluate the predictions, we make use of the SEs as shown in Table 4. According to Table 4, the SE are extremely small, reflecting high precision under the bayesian framework.
Table 5 and Figure 1 show a comparison between the probit and Bayesian model. Fitting the probit regression model to the dataset using the function glm in R is a frequentist way of analyzing this dataset, while the Bayesian hierarchical linear model is the bayesian approach. We compare the point estimates of both methods via SE’s and predictions. The naive SE is the standard error of the mean captures simulation error of the mean rather than the posterior uncertainty. While the Time Series Standard Error (TSSE) (or Monte Carlo SE) accounts for autocorrelation by using the effective sample size. The Naive SE underestimates uncertainty due to autocorrelation, whereas TSSE provides a better measure of MCMC estimation error
Also based on the model predictions seen in Figure 1, both the probit and the Bayesian models are suited to handling probabilities. In conclusion, the probit model captures the significant relationship between the project success and its covariates, Community Ownership and Storage and its predictive performance is closely related to the Bayesian model. Bayesian methods are useful when the data is scarce and particularly for handling latent variables, in our case the probability of a mini-project being successful.
Mathematical Optimization Methods in Electricity generation
In this section, we provide a multi-resource optimization method for determining the optimal profit and minimizing the cost of electricity generation and transmission while reducing carbon emissions. Mathematically, investment models, in electricity production facilities are naturally formulated as optimization models constrained by other optimization models. A general instance of such a model is given by the following:
Problem ((1.1a-1.1c)) is the upper level problem while problems ((13)) - ((14)) are the lower level problems. The upper-level problem is the investment problem, which seeks to identify the investment decisions that maximize profit, while the lower-level problems represent market-clearing conditions.
Multi-Resource Investment Problems
Minimizing electricity generation costs while reducing carbon emissions can be formulated as a multi-resource investment problem, where a firm must allocate resources to produce products across time periods. In this setting, the single product is electricity, which can be generated using two resources: diesel purchases and a renewable capacity generator. A two-stage optimization model is applied where in the first stage, a nonnegative vector of capacity levels , can be chosen representing the diesel purchase and renewable generator capacity respectively, before observing the actual energy demand, , and before the renewable energy supply is known. In the second stage, a vector of dispatch quantities can be determined. The second stage problem with dual variables can be written as follows:
subject to
The first-stage problem is defined as:
Solving this problem involves partitioning the uncertainty space into six regions in each of which the optimal second-stage dispatch decisions and the dual variables have the same structure.
First, we choose a non-negative vector of capacity levels
representing diesel purchase and renewable generator capacity. The demand is a continuous nonnegative random variable written as
and the renewable supply is realized as
For the second stage problem,
subject to
and the dispatch-vector is given by:
The first-stage problem is given by
The Demand Space is partitioned as follows: For , the regions are given by:
We consider the dual to the second stage optimization problem
In calculating the expectation by conditioning on the demand, of renewable supply , we get,
Using this result, Table 6 and the steps in the Harrison and Van Mieghem [19] journal, the equation below is obtained by taking the partial derivative of the Lagrangian function w.r.t to the two capacity decision variables and with vector for (also complementary slackness condition) of the first stage problem.
| Partition for | ||
Table 6. Partitioning of the demand space
The KKT conditions also ensure an optimal solution . Thus we have,
The demand space is partitioned into three regions as shown in Table 6. For Region 1, , the renewables alone meet the demand, for Region 2, , implies that the renewables are insufficient and diesel is also used to meet the demand and Region 3 indicates the share where even diesel plus renewables together are not enough, to meet the demand. The share or probability of each region is determined by integration. For example, the probability of can be found by considering the following:
Thus,
Case :
Case :
If, , and we have
where the capacities are found by solving Equation (19) (using software for example, Wolfram Mathematica).
Two stage multi-resource investment models are invaluable as they help mirror, energy systems. In the first stage capacity decisions are known, these are investment decisions and made before the demand or renewable availability is known. In the second second stage dispatch decisions, are made after uncertainty is realized. The two-stage structure also reveal how capacity choices and influence the probability of operating in different regions: fully renewable supply, diesel-supported supply, or shortage. This leads to solutions that are more robust, economically efficient, and align with how real systems behave when facing variability and risk.
Battery Energy Storage System and its effect in Electricity Generation
Another method for maximizing the profit and minimizing the cost from electricity generation while reducing carbon emissions is through battery energy storage systems. Moreover, an optimal sized battery energy storage system can help maximize the benefits of the power both generated from PV systems and diesel sources while being financially economical. In this section, we propose a mixed-integer programming approach which decides hour-by-hour to charge/discharge in order to maximize profit, consistent with Alberta’s market participation rules. The optimization problem is developed in a similar manner to that described in [17]
Data
The data is in the form of a csv file indicating Day, Hour Ending, Price Quantity and Dispatched. The market in Alberta has a price cap of CAD $1000, and a price floor of $0. Producers are obliged to offer all of their available capacity into the market, but are under no obligation to ensure that prices correspond to variable cost. An example bid stack, from March 1 2010 is shown in Figure 4.

Figure 4. Bidstack on March 1st 2010
As demonstrated in Figure 4 the shape of this curve varies from hour to hour and the steps represent the price offered by generators for a quantity of power in a particular hour. The flat lines reflect cheaper prices however between 600,000-700,000MW and a vertical line indicating a drastic increase in the price.
Figure 5 and Figure 6 show how the electricity prices vary throughout the day on January 1st, hour ending 1 and for all 24 hours throughout the day on September 1 2010 respectively. Not surprisingly, price increases with quantity as higher demand requires more expensive sources of electricity. There’s a notable steep price jump between roughly 600,000 MW and 800,000 MW, suggesting that during these hours, the grid needed to tap into much costlier electricity sources to meet demand. Beyond 800,000 MW, prices often exceeded $500/MWh and even approaching $1000/MWh, indicating extreme scarcity or reliance on expensive peaking power plants. As shown in Figure 6 each blue curve represents one hour of the day and the shape and spread of the curves imply variability in supply conditions across the day, also indicating that the market participants submit their offers strategically depending on the market conditions.

Figure 5. January 1 hour ending 1

Figure 6. September 1, 24 hour
Figure Figure 7 shows the GPQC and DPQC for hour ending 20 on January 1st 2010. For the GPQC each horizontal segment represents a block of generation capacity offered at a fixed price. This is a supply curve and as more MW are dispatched, the price increases in steps, this reflects marginal cost bidding by generators. The DPQC is a demand curve and shows how much consumers bid for electricity in blocks, with higher willingness to pay for initial MW and lower for additional consumption.

Figure 7. Hour ending 20- Charging and Discharging Blocks
Battery Energy Storage Systems
Using GPQCs and DPQCs as input data we develop we develop a self-scheduling formulation in which the price is a variable and is a function of the charging or discharging quantities. Next, using this framework we determine bidding strategies and assess the economic feasility of the energy storage systems providing opportunities for energy arbitrage in the Alberta electricity market.
Optimization Model
List Of symbols
Day index,
Hour index,
Charge/discharge block index
Set of days
Set of hours
Set of piecewise-linear blocks
Decision Variables:
binary, select discharge block at
continuous, discharge quantity within block at
binary, select charge block at
continuous, charge quantity within block at
state of charge at
Parameters:
price of discharge block at
price of charge block at
quantity of discharge block at
quantity of charge block at
operating cost per hour
charge efficiency (e.g., 0.7)
initial state of charge (e.g., 100 MWh)
The Objective Function and Constraints
Maximize net profit:
Constraints
with initial condition:
and bounds:
According to Table 7, the battery supplies energy during its discharging hours, for example during hours ending 1, 2 and 6. During these hours, the prices decrease, benefitting customers. However during the battery’s charging hours the battery the prices increase. Table 8 shows the block details for the optimization problem with the profit or Gurobi objective value was found to be $8351.22
| Hour | SoC (MWh) | Mode | Electricity (MWh) | Price ($/MWh) |
| 01 | 36.00 | Discharge | 64.00 | 57.25 |
| 02 | 0.00 | Discharge | 36.00 | 57.24 |
| 03 | 0.00 | Idle | 0.00 | 0.00 |
| 04 | 0.00 | Idle | 0.00 | 0.00 |
| 05 | 100.00 | Charge | 142.86 | 28.73 |
| 06 | 0.00 | Discharge | 100.00 | 45.00 |
| 07 | 0.00 | Idle | 0.00 | 0.00 |
| 08 | 154.70 | Charge | 221.00 | 16.40 |
| 09 | 85.70 | Discharge | 69.00 | 29.56 |
| 10 | 286.60 | Charge | 287.00 | 14.60 |
| 11 | 400.00 | Charge | 162.00 | 15.15 |
| 12 | 400.00 | Idle | 0.00 | 0.00 |
| 13 | 304.00 | Discharge | 96.00 | 43.97 |
| 14 | 304.00 | Idle | 0.00 | 0.00 |
| 15 | 400.00 | Charge | 137.14 | 29.56 |
| 16 | 400.00 | Idle | 0.00 | 0.00 |
| 17 | 400.00 | Idle | 0.00 | 0.00 |
| 18 | 312.00 | Discharge | 88.00 | 66.86 |
| 19 | 216.00 | Discharge | 96.00 | 55.06 |
| 20 | 146.00 | Discharge | 70.00 | 57.19 |
| 21 | 31.00 | Discharge | 115.00 | 49.00 |
| 22 | 31.00 | Idle | 0.00 | 0.00 |
| 23 | 31.00 | Idle | 0.00 | 0.00 |
| 24 | 0.00 | Discharge | 31.00 | 47.91 |
Table 7. Battery Operation Schedule for 2010-01-01
| Hour | Mode | Block | Electricity (MWh) | Price ($/MWh) |
| 01 | Discharge | 2 | 64.00 | 57.25 |
| 02 | Discharge | 2 | 36.00 | 57.24 |
| 05 | Charge | 1 | 142.86 | 28.73 |
| 06 | Discharge | 2 | 100.00 | 45.00 |
| 08 | Charge | 2 | 221.00 | 16.40 |
| 09 | Discharge | 2 | 69.00 | 29.56 |
| 10 | Charge | 2 | 287.00 | 14.60 |
| 11 | Charge | 1 | 162.00 | 15.15 |
| 13 | Discharge | 2 | 96.00 | 43.97 |
| 15 | Charge | 1 | 137.14 | 29.56 |
| 18 | Discharge | 2 | 88.00 | 66.86 |
| 19 | Discharge | 2 | 96.00 | 55.06 |
| 20 | Discharge | 2 | 70.00 | 57.19 |
| 21 | Discharge | 2 | 115.00 | 49.00 |
| 24 | Discharge | 2 | 31.00 | 47.91 |
Table 8. Charge and Discharge Block Details for 1 January 2010
Dynamic Programmming towards the Battery Storage Problem
The novelty in this research is two-fold. First we provide a comparison of statistical and optimization methods for maximizing profit while minimizing cost and reducing carbon emission in electricity generation. Next we propose a novel approach based on stochastic dynamic programming towards the battery storage problem for electricity generation. To our knowledge, such a comparison has never been done before in this context.
Stochastic dynamic programming has become a powerful tool when applied to a variety of problems (see [28, 29, 30, 31, 32, 33] and the one-armed bandit processes was formulated as a stochastic process using a Bayesian approach and solved using dynamic programming by Wang and Bickis in [34]. A dynamic programming formulation towards battery energy storage operators have been studied in various research [35]. However these research is still different to the approach proposed in this paper. In [35] the authors propose a stochastic dynamic programming model that accounts for the amount of energy stored in a battery at the beginning and the end of an hour. The objective function maximizes the revenue function based on the resource/energy level, prices/bids and number of charge/discharge cycles and using approximate dynamic programming to solve the problem. programming towards the battery energy
In this research, we adopt a SDP formulation towards the Battery Storage problem in order to optimize profit in an energy market. Our implementaiton is as follows:
Let denote the maximum expected return for a -stage problem and assign vectors as the state vector of the system on state space and vector as the control decision vector on action space . Where - the number of charging blocks and the number of discharging blocks.
If we let denote the number of stages and denote the number of stages to go, the problem involves maximizing the following expected cost over a finite number of stages .
We observe that the optimal allocation to the problem given by,
To find the optimal allocation for the optimization problem (30), we start by defining value functions, . The value functions are a sequence of functions , defined by the following:
At the last stage , , .
At time , , the function is defined by
where is the expected cost or reward in regard to states and action .
At time , the value function is
Therefore the optimal policy is given by
The optimality of Equation (31) is illustrated if we define the cost-to-go function by
then where the equality holds if
.
The system dynamics depends on the state-action pair at current stage and probabilities :
where . The Bellman recursion is then
An Implementation of Stochastic Dynamic Programming to Battery Storage problems
In this section, we propose a stochastic dynamic programming approach to model a battery energy storage system and maximize profit in electricity generation. Energy markets, particularly electricity markets inherently have probabilistic prices due to volatile renewable energy, demand shift and grid congesting, requiring sophisticated probabilitic forecasting, hedging and optimal trading strategies. Methods for predicting the uncertainty in prices vary and include Polynomial mapping and Deep Learninng methods. This research proposes a novel SDP approach to account for the uncertainty in prices associated with the while maximizing profit and revenue in electricity generation.
Stochastic Dynamic Programming Model
For finite horizon stochastic problems, the optimality equations at time are given by:
which is equivalent to solving the following, known as Bellman’s optimality equations:
where is the state variable, in this case the state of charge and the price at time , and summarizes past information useful for solving future states, is the control or decision variable, that is whether to charge or discharge , and is a random parameter capturing the uncertainty of the prices
Given the value function as the optimal expected value, then the optimization problem with stages remaining can be written as:
where,
and
with the last stage as:
Example without incoporating the stochastic nature of prices
Consider a toy example involving hours as the time given and blocks. The discharging and charging price per hour at time and step is given by , and respectively. The corresponding values are , , , with initial conditions, , . The reward function is calculated as .
For time , suppose the battery is in state and that is, neither charging nor discharging. Using and . Therefore,
For time , and , , ,
Therefore,
For time , and , , , , ,
The maximum value is found by evaluating all possible feasible actions. That is, all possible discharge and charge amounts over all possible values and outcomes. The dynamic programming model can also incorporate the stochastic nature of prices as done in several papers (see for example [36] and [35]).
Discussion
The results of § 3 indicate the probit and Bayesian model suited for determining the probability of a mini-grid project being successful and handling probabilities. The probit model captures the significant relationship between project success and its covariates, Community Ownership and Storage and its predictive performance is closely related to the Bayesian model. Bayesian methods are useful when the data is scarce and particularly for handling latent variables, such as the probability of a mini-project being successful in this case.
Sections 4 focuses on the mathematical optimization model for minimizing cost in generating electricity while reducing carbon emissions. In particular, a two-stage multi-resource investment model is described in § 4 where capacities are chosen before the uncertainty is revealed. In the first stage, investment decisions are made for different types of capacities—typically a reliable but costly resource, for example diesel and a cheaper renewable resource, whose availability is uncertain. In the second stage, after the demand and availability are realized, resources are allocated to meet the demand, and a penalty is paid for any unmet demand. The model naturally divides the demand space into different regions. The expected cost combines the probability of each region when the renewables alone meet the demand, when the renewables alone are insufficient and diesel is used and when diesel and renewables are still insufficient to meet the demand. This captures the trade-off between upfront capacity investments for diesel and renewable purchases ( and ) and the chance that, later on, demand is high or availability is low, forcing expensive penalty costs.
Sections 5 and 6 introduce battery energy storage systems as another method for maximizing profit and minimizing the cost in electricity generation while reducing carbon emissions. In § 5, we propose a mixed-integer programming approach which decides hour-by-hour to charge or discharge in order to maximize profit, consistent with Alberta’s market participation rules. The battery successfully executes a daily arbitrage strategy, that is, charging when prices are relatively low and discharging when prices are high. The battery’s value is not just in daily smoothing, but in capturing rare price spikes and dampens this spike by discharging during peak price hours. Thus, consumers pay less, and the system benefits from price stability.
§ 7 implements a dynamic programming framework for optimizing battery storage operations in which the uncertainty in electricity prices can be incorporated. The state variable (or state of charge ) summarizes all relevant past information, the control variable represents charging or discharging decisions, and captures price uncertainty. The volatility of electricity prices for the SDP model can be evaluated using different methods. In this paper, we illustrate the effect of a dynamic programming model applied to a battery energy storage system and leave the stochastic component of prices to be incorporated in future research
Conclusion
This paper introduces a statistical and optimization modeling framework to examine decision-making strategies in modern energy systems. First, a Bayesian hierarchical model is compared with a probit model on 104 mini-grids installed across the globe to highlight the strengths of statistical modeling and provide insights into the success of mini-grid projects in electricity generation. Second, a deterministic mixed-integer optimization model is developed which maximizes profit while reducing carbon emissions. Results indicate that battery systems can execute effective arbitrage strategies that is, charging when prices are relatively low, discharging when prices are high.
Furthermore, we propose a dynamic programming modeling framework to the battery energy storage system. Preliminary results indicate that dynamic programming method offers a promising alternative to mixed-integer programming, particularly in volatile electricity markets. In a follow-up paper we will explore methods for capturing the volatility and provide extensive experimental results.
The results highlighted in this paper emphasize the importance of integrating statistical and optimization methods towards energy systems. By accounting for uncertainty, these frameworks support more resilient decision-making efforts. Future research may entail incorporating further statistical, probabilistic and optimization based methods towards extensive research in developing effective, clean, reliable energy systems.
Acknowledgments
I gratefully acknowledge that this research was supported in part by the Pacific Institute for the Mathematical Sciences. Many thanks also to my postdoctoral Supervisors at the University of Calgary for the data and their guidance during this time.
References
- [1]Ember: Global electric review (2026)
- [2]Environment and Climate Change Canada: National inventory report 1990–2023: Greenhouse gas sources and sinks in canada. Technical report, Environment and Climate Change Canada, Ottawa, ON (2025). https://www.canada.ca/en/environment-climate-change/services/climate-change/greenhouse-gas-emissions/sources-sinks-executive-summary-2025.html
- [3]Duran, A.S., Sahinyazan, F.G.: An analysis of renewable mini-grid projects for rural electrification. Socio-Economic Planning Sciences 77, 100999 (2021) https://doi.org/10.1016/j.seps.2020.100999
- [4]Su, L., Gang, W., Liu, M., Ling, Z., Zhang, Y., Dong, S.: A capacity optimization method for the battery energy storage system based on historical electricity data of existing buildings. Energy Reports 13, 6132–6147 (2025) https://doi.org/10.1016/j.egyr.2025.05.060
- [5]Zhang, D., Ma, Y., Liu, J., Jiang, S., Chen, Y., Wang, L., Zhang, Y., Li, M.: Stochastic optimization method for energy storage system configuration considering self-regulation of the state of charge. Sustainability 14(1), 553 (2022) https://doi.org/10.1103/PhysRevD.99.12350
- [6]Bhattacharya, A., Kharoufeh, J.P., Zeng, B.: Managing energy storage in microgrids: A multistage stochastic programming approach. IEEE transactions on smart grid 9(1), 483–496 (2018)
- [7]Walawalkar, R., Apt, J., Mancini, R.: Economics of electric energy storage for energy arbitrage and regulation in new york. 35(4), 2558–68
- [8]AESO: Historical Market Data: Pool Price. Available online (2014)
- [9]Carlson, C.: Wind and energy storage: potential market opportunities in alberta. Alberta Innovates Technology Futures (2012)
- [10]Siohansi, R., Denholm, P., Jenkin, T., Weiss, J.: Estimating the value of electricity storage in pjm: arbitrage and some welfare effects. Energy Econ 31(2) (2009)
- [11]Smith, M., Kohn, R., Mathur, S.K.: Bayesian semiparametric regression. Journal of business research 49(3), 229–244 (2000)DOI
- [12]Hyde, O., Hodnett, P.F.: An adaptable automated procedure for short-term electricity load forecasting. IEEE transactions on power systems 12(1), 84–94 (1997)DOI
- [13]Barlow, M.T.: A diffusion model for electricity prices. Mathematical finance 12(4), 287–298 (2002)
- [14]Ware, A.: Polynomial processes for power prices 26, 453–474 https://doi.org/10.1080/1350486X.2020.1715808
- [15]Jarrow, R., Protter, P., Sezer, D.: Credit risk models. Finance Stoch 11, 195–212 (2007)
- [16]Han, J.-H., Ahn, Y.-C., Lee, I.-B.: A multi-objective optimization model for sustainable electricity generation and co2 mitigation (ecgm) infrastructure design considering economic profit and financial risk. Applied energy 95, 186–195 (2012)DOI
- [17]Shafee, S., Dehkordi, P., Zareipour, H., Knight, A.: An economic assessment of a pricemaker energy storage facility in the alberta electricity market. Energy (Oxford) 111, 537–547 (2016)
- [18]He, J., Wu, Y., Yong, X., Tan, Q., Liu, F.: Bi-level optimization of a near-zero-emission integrated energy system considering electricity-hydrogen-gas nexus: A two-stage framework aiming at economic and environmental benefits. Energy conversion and management 274, 116–434 (2022)DOI
- [19]Harrison, J.M., Van Mieghem, J.A.: Multi-resource investment strategies: Operational hedging under demand uncertainty. European journal of operational research 113(1), 17–29 (1999)DOI
- [20]Hobbs, B.F., Metzler, C.B., Pang, J.-S.: Strategic gaming analysis for electric power systems: An mpec approach. IEEE Transactions on Power Systems 15(2), 638–645 (2000) https://doi.org/10.1109/59.867153 . Cited by: 712
- [21]Pereira, M.V., Granville, S., Fampa, M.H.C., Dix, R., Barroso, L.A.: Strategic bidding under uncertainty: A binary expansion approach. IEEE Transactions on Power Systems 20(1), 180–188 (2005) https://doi.org/10.1109/TPWRS.2004.840397 . Cited by: 221
- [22]Zhang, N., Leibowicz, B., Hanasusanto, G.: Optimal residential battery storage operations using robust data-driven dynamic programming. IEEE transactions on smart grid 11(2), 1771–1780 (2020)DOI
- [23]Gomes, I.L.R., Pousinho, H.M.I., Melício, R., Mendes, V.M.F.: Stochastic coordination of joint wind and photovoltaic systems with energy storage in day-ahead market. Energy (Oxford) 124, 310–320 (2017)DOI
- [24]Zheng, N., Jaworski, J., Xu, B.: Arbitraging variable efficiency energy storage using analytical stochastic dynamic programming. IEEE transactions on power systems 37(6), 4785–4795 (2022)DOI
- [25]Erdinç, O., Erdinç, O.: Optimization in Renewable Energy Systems : Recent Perspectives, 1st edition edn. Gale eBooks. Butterworth-Heinemann, an imprint of Elsevier, Cambridge, Massachusetts (2017 - 2017)
- [26]Chanpiwat, P., Oliveira, F., Gabriel, S.A.: Integrated operational planning of battery storage systems for improved efficiency in residential community energy management using multistage stochastic dual dynamic programming: A finnish case study. Energies (Basel) 18(13), 3560 (2025)DOI
- [27]Gilks, W., Richardson, S., Spiegelhalter, D.: Markov chain monte carlo in practice. Chapman and Hall CRC (1996)
- [28]Hosein, P., Lawrence, T.: Stochastic dynamic programming model for revenue optimization in social networks. 2015 IEEE 11th International Conference on Wireless and Mobile Computing, Networking and Communications (WiMob), 378–383 (2015)DOI
- [29]Wu, H.-H., Küçükyavuz, S.: A two-stage stochastic programming approach for influence maximization in social networks. Comput. Optim. Appl (3), 563–595 (2018) https://doi.org/10.1007/s10589-017-9958-x
- [30]Rahaman, I., Hosein, P.: On the problem of multi-staged impression allocation in online social networks, 65–84 (2018) https://doi.org/10.1007/978-3-319-89932-9_4
- [31]Lawrence, T., Hosein, P.: Stochastic dynamic programming heuristics for influence maximization- revenue optimization. Int J Data Sci Anal 8, 1–14 (2018)DOI
- [32]Ross, S.: Introduction to stochastic dynamic programming (1983)
- [33]Verweij, B.: The sample average approximation method applied to stochastic routing problems: A computational study. Comput. Optim. Appl 24, 298–333 (2003) https://doi.org/10.1023/A:1021814225969
- [34]Wang, X., Bickis, M.: One-armed bandit models with continuous and delayed responses. Math Meth Oper Res 58, 209–219 (2003)DOI
- [35]Jiang, D.R., Powell, W.B.: Optimal hour-ahead bidding in the real-time electricity market with battery storage using approximate dynamic programming. INFORMS J. on Computing 27(3), 525–543 (2015) https://doi.org/10.1287/ijoc.2015.0640
- [36]Nowotarski, J., Rafal, W.: Computing electricity spot price prediction intervals using quantile regression and forecast averaging. Comput Stat, 791–803 (2015)DOI