The world faces significant challenges from climate change [25]. A rise in carbon emissions increases the risk of severe impacts on the world such as rising sea levels, heat waves and tropical cyclones [25]. A survey [7] showed that 97% of scientific literature concurs that the recent change in climate is anthropogenic. High carbon emitting electricity generation sources such as coal and natural gas currently produce 65% of global electricity, whereas low-carbon sources such as wind, solar, hydro and nuclear provide 35% [3]. Hence, to bring about change and reach carbon-neutrality, a transition in the electricity mix is required. Due to the long construction times, operating periods and high costs of power plants, investment decisions can have long term impacts on future electricity supply [4]. Governments and society, therefore, have a role in ensuring that the negative externalities of emissions are priced into electricity generation. This is most likely to be achieved via carbon tax and regulation to influence electricity market players such as generation companies (GenCos). Decisions made in an electricity markets may have unintended consequences due to their complexity. A method to test hypothesis before they are implemented would therefore be useful. Simulation is often used to increase understanding as well as to reduce risk and reduce uncertainty. Simulation allows practitioners to realise a physical system in a virtual model. In this context, a model is defined as an approximation of a system through the use of mathematical formulas and algorithms. Through simulation, it is possible to test a system where real life experimentation would not be practical due to reasons such as prohibitively high costs, time constraints or risk of detrimental impacts. This has the dual benefit of minimising the risk of real decisions in the physical system, as well as allowing practitioners to test less risk-averse strategies. Agent-based modelling (ABM) is a class of computational simulation models composed of autonomous, interacting agents and model the dynamics of a system. Due to the numerous and diverse actors involved in electricity markets, ABMs have been utilised in this field to address phenomena such as market power [30]. This paper presents ElecSim, an open-source ABM that simulates GenCos in a wholesale electricity market. ElecSim models each GenCo as an independent agent and electricity demand. An electricity market facilitates trades between the two. GenCos make bids for each of their power plants. Their bids are based on the generator's short run marginal cost (SRMC) [28], which excludes capital and fixed costs. The electricity market accepts bids in cost order, also known as merit-order dispatch. GenCos invest in power plants based on expected profitability. ElecSim is designed to provide quantitative advice to policy makers, allowing them to test policy outcomes under different scenarios. They are able to modify a script to realise a scenario of their choice. It can also be used by energy market developers who can test new electricity sources or policy types, enabling the modelling of changing market conditions. The contribution of this paper is a new open-source framework with example scenarios of varying carbon taxes. We provide curated data, and improve realism via Monte-Carlo sampling. Section 2 is a literature review. Section 3 details the model and assumptions made, and Section 4 provides performance metrics and validation. Section 5 details our results. We conclude the work in Section 6. Open Source

Long-Term Investment

Country Generalisability

Table 1: Features of electricity market ABM tools. Live experimentation of physical processes is often not practical. The costs of real life experimentation can be prohibitively high, and can require significant time in order to fully ascertain the longterm trends. There is also a risk that changes can have detrimental impacts and lead to risk-averse behaviour. These factors are true for electricity markets, where decisions can have long term impacts. Simulation, however, can be used for rapidly prototyping ideas. The simulation is parametrised by real world data and phenomena. Through simulation, the user is able to assess the likelihoods of outcomes under certain scenarios and parameters [23]. Energy models can typically be classified as top-down macroeconomic models or bottom-up techno-economic models [2]. Topdown models typically focus on behavioural realism with a focus on macro-economic metrics. They are useful for studying economywide responses to policies [14], for example MARKAL-MACRO [9] and LEAP [16]. Bottom-up models represent the energy sector in detail, and are written as mathematical programming problems [10]. It is possible to further categorise bottom-up models into optimisation and simulation models. Optimisation energy models minimise costs or maximise welfare, defined as the material and physical well-being of people [20]. Examples of optimisation models are MARKAL/TIMES [9] and MESSAGE [34]. However, electricity market liberalisation in many western democracies has changed the framework conditions. Centralised, monopolistic, decision making entities have given way to multiple heterogeneous agents acting for their own best interest [26]. Policy options must therefore be used to encourage changes to attain a desired outcome. It is proposed that these complex agents are modelled using ABMs due to their non-deterministic nature. Traditional centralised optimisation models are not designed to describe a system which is out of equilibrium. Optimisation models assume perfect foresight and risk neutral investments with no regulatory uncertainty. The core dynamics which emerge from equilibrium remain a black-box. For example, the model assumes a target will be reached, and does not provide information for which this is not the case. Reasons for this could be investment cycles which move the model away from equilibrium [4]. A number of ABM tools have emerged over the years to model electricity markets: SEPIA [15], EMCAS [6], NEMSIM [1], AMES [35], GAPEX [5], PowerACE [32], EMLab [4] and MACSEM [29]. Table 1 shows that these do not suit the needs of an open source, long-term market model. We will demonstrate that Monte-Carlo sampling of parameters is also required to increase realism. There have been a number of recent studies using ABMs which focus on electricity markets, however they often utilize ad-hoc tools which are designed for a particular application [13,22,33].
ElecSim, however, has been built for re-use and reproducibility. The survey [36] cites that many of these tools do not release source code or parameters, which is a problem that ElecSim seeks to address. Table 1 contains six columns: tool name, whether the tool is open source or not, whether they model long-term investment in electricity infrastructure, and the markets they model. We determine how the stochasticity of real life is modelled, and determine whether the model is generalisable to different countries. An open source toolkit is important for reproducibility, transparency and lowering barriers to entry. It enables users to expand the model to their requirements and respective country. The modelling of long-term investment enables scenarios to emerge, and enable users to model investment behaviour. We demonstrate that the use of a Monte-Carlo method improves results. SEPIA [15] is a discrete event ABM which utilises Q-learning to model the bids made by GenCos. SEPIA models plants as being always on, and does not have an independent system operator (ISO), which in an electricity market, is an independent non-profit organization for coordinating and controlling of regular operations of the electric power system and market [38]. SEPIA does not model a spot market, instead focusing on bilateral contracts. As opposed to this, ElecSim has been designed with a merit-order, spot market in mind. As shown in Table 1, SEPIA does not include a long-term investment mechanism. EMCAS [6] is a closed source ABM. EMCAS investigates the interactions between physical infrastructures and economic behaviour of agents. However, ElecSim focuses on the dynamics of the market, and provides a simplified, transparent model of market operation, whilst maintaining robustness of results. NEMSIM [12] is an ABM that represents Australia's National Electricity Market (NEM). Participants are able to grow and change over time using learning algorithms. NEMSIM is non-generalisable to other electricity markets, unlike ElecSim. AMES [35] is an ABM specific to the US Wholesale Power Market Platform and therefore not generalizable for other countries. GAPEX [5] is an ABM framework for modelling and simulating power exchanges . GAPEX utilises an enhanced version of the reinforcement technique Roth-Erev [31] to consider the presence of affine total cost functions. However, neither of these model the long-term dynamics for which ElecSim is designed. PowerACE [32] is a closed source ABM of electricity markets that integrates short-term daily electricity trading and long-term investment decisions. PowerACE models the spot market, forward market and a carbon market. Similarly to ElecSim, PowerACE initialises GenCos with each of their power plants. However, as can be seen in Table 1, unlike ElecSim, PowerACE does not take into account stochasticity of price risks in electricity markets [26]. EMLab [4] is an open-source ABM toolkit for the electricity market. Like PowerACE, EMLab models an endogenous carbon market, however, they both differ from ElecSim by not taking into account stochasticity in the electricity markets, such as in outages, fuel prices and operating costs. After correspondence with the authors, however, we were unable to run the current version. MACSEM [29] has been used to probe the effects of market rules and conditions by testing different bidding strategies. MACSEM does not model long term investments or stochastic inputs. As can be seen from Table 1, none of the tools fill each of the characteristics we have defined. We therefore propose ElecSim to contribute an open source, long-term, stochastic investment model. ElecSim is made up of five fundamental parts: the agents, which are split up into demand and GenCos; power plants; a Power Exchange, which controls an electricity spot market; and the data for parametrisation. A schematic of ElecSim is displayed in Figure 1. Data parametrisation. ElecSim contains a configuration file and a collection of data sources for parametrisation. These data sources contain information such as historical fuel prices, historical plant availability, wind and solar capacity. The configuration file allows for rapid changes to test different hypothesis and scenarios, and points to the different data sources. The configuration file enables one to change the demand growth and shape, future fuel and carbon prices, capital costs, plant availability, investment costs and simulation time. Demand Agent. The demand agent is a simplified representation of aggregated demand in a country. The demand is represented as a load duration curve (LDC). An LDC is an arrangement of all load levels in descending order of magnitude. Each year, the demand agent changes each of the LDC segments proportionally. As per Chappin et al. [4], we modelled the LDC of electricity demand with twenty segments. Twenty segments enabled us to capture the variation in demand throughout the year to a high degree of accuracy, whilst reducing computational complexity. Generation Company Agents. The GenCos have two main functions. Investing in power plants and making bids to sell their generation capacity. We will first focus on the buying and selling of electricity, and then cover the investment algorithm. The power exchange runs every year, accepting the lowest bids until supply meets demand. Once this condition is met, the spot price or system marginal price (SMP) is paid to all generators regardless of their initial bid. Generators are motivated to bid their SRMC, to ensure that their generator is being utilised, and reduce the risk of overbidding. Investment. Investment in power plants is made based upon a net present value (NPV) calculation. NPV is a summation of the present value of a series of present and future cash flow. NPV provides a method for evaluating and comparing investments with cash flows spread over many years, making it suited for evaluating power plants which have a long lifetime. Equation 1 is the calculation of NPV, where t is the year of the cash flow, i is the discount rate, N is total number of periods, or lifetime of power plant, and R t is the net cash flow at time t.

A discount rate set by a GenCo's weighted average cost of capital (WACC) is often used [21].
WACC is the rate that a company is expected to pay on average for its stock and debt. Therefore to achieve a positive NPV, an income larger than the WACC is required. However, a higher WACC is often selected to adjust for varying risk profiles, opportunity costs and rates of return. To account for these differences we sample from a Gaussian distribution, giving us sufficient variance whilst deviating from the expected price. To calculate the NPV, future market conditions must be considered. For this, each GenCo forecasts N years into the future, which we assume is representative of the lifetime of the plant. As in the real world, GenCos have imperfect information, and therefore must forecast expected demand, fuel prices, carbon price and electricity sale price. This is achieved by fitting functions to historical data. Each GenCo is different in that they will use differing historical time periods of data for forecasting. Fuel and carbon price are forecast using linear regression. Demand, however, is forecast using an exponential function, which considers compounded growth. Linear regression is used if an exponential function is found to be sub-optimal. This forecasted data is then used to simulate a market N years into the future using the electricity market algorithm. We simulate a market based on the expected bids -based on SRMC -that every operating power plant will make. This includes the removal of plants that will be past their operating period, and the introduction of plants that are in construction or pre-development stages. There may be scenarios where demand is forecast to grow significantly, and limited investments have yet been made to meet that demand. The expected price, would be that of lost load. Lost load is defined as the price customers would be willing to pay to avoid disruption in their electricity supply. To avoid GenCos from estimating large profits, and under the assumption that further power plant investments will be made, the lost load price is replaced with a predicted electricity price using linear regression based on prices at lower points of the demand curve. If zero segments of demand are met, then the lost load price is used to encourage investment. Once this data has been forecasted, the NPV can be calculated. GenCos must typically provide a certain percentage of upfront capital, with the rest coming from investors in the form of stock and shares or debt (WACC). The percentage of upfront capital can be customised by the user in the configuration file. The GenCos then invest in the power plants with the highest NPV. Power Plant Parameters. Costs form an important element of markets and investment, and publicly available data for power plant  Users are able to initialise costs relevant to their particular country by providing detailed cost parameters. They can also provide an average cost per MWh produced over the lifetime of a plant, known as levelised cost of electricity (LCOE). The parameters used to initialise the power plants are detailed in this section. Periods have units of years and costs in £/MW unless otherwise stated: Efficiency (η) is defined as the percentage of energy from fuel that is converted into electrical energy (%). Operating period (OP) is the total period in which a power plant is in operation. Pre-development period (P D ) and pre-development costs (P C ) include the time and costs for pre-licensing, technical and design, as well as costs incurred due to regulatory, licensing and public enquiry. The construction period (C D ) and construction costs (C C ) are incurred during the development of the plant, excluding network connections. The infrastructure costs (I C ) are the costs incurred by the developer in connecting the plant to the electricity or gas grid (£). Fixed operation & maintenance costs (F C ) are costs incurred in operating the plant that do not vary based on output. Variable operation & maintenance (V C ) costs are incurred in operating the plant that depend on generator output [24]. Precise data is not available for every plant size. Linear interpolation is used to estimate individual prices between known points. When the plant to be estimated falls outside of the range of known data points, the closest power plant is used. We experimented with extrapolation but this would often lead to unrealistic costs. If specific parameters are not known the LCOE can be used for parameter estimation, through the use of linear optimisation. Constraints can be set by the user, enabling, for example, varying operation and maintenance costs per country as a fraction of LCOE. To fully parametrise power plants, availability and capacity factors are required. Availability is the percentage of time that a power plant can produce electricity. This can be reduced by forced or planned outages. We integrate historical data to model improvements in reliability over time. The capacity factor is the actual electrical energy produced over a given time period divided by the maximum possible electrical energy it could have produced. The capacity factor can be impacted by regulatory constraints, market forces and resource availability. For example, higher capacity factors are common for photovoltaics in the summer, and lower in winter. To model the intermittency of wind and solar power we allow them to contribute only a certain percentage of their total capacity (nameplate capacity) for each load segment. This percentage is based upon empirical wind and solar capacity factors. In this calculation we consider the correlation between demand and renewable resources. We are unable to model short-term storage due to ElecSim taking a single time-step per year. When initialised, V C is selected from a uniform distribution, with the ability for the user to set maximum percentage increase or decrease. A uniform distribution was chosen to capture the large deviations that can occur in V C , especially over a long time period. Fuel price is controlled by the user, however, there is inherent volatility in fuel price.
To take into account this variability, an ARIMA [37] model was fit to historical gas and coal price data. The standard deviation of the residuals was used to model the variance in price that a GenCo will buy fuel in a given year. This considers differences in chance and hedging strategies. Figure 2 demonstrates the simulation and how it co-ordinates runs. The world contains data and brings together GenCos, the Power Exchange and demand. The investment decisions are based on future demand and costs, which in turn influence bids made. Exogenous variables include fuel and CO 2 prices as well as demand growth. Once the data is initialised, the world calls on the Power Exchange to operate the yearly electricity spot market. The world also settles the accounts of the GenCos, by paying bids, and removing operating and capital costs as well as loans and dividends. Validation. Validation of models is important to ascertain that the output is accurate. However, it should be noted that these longterm simulations are not predictions of the future, rather possible outcomes based upon certain assumptions. Jager posits that a certain outcome or development path, captured by empirical data, might have developed in a completely different direction due to chance. However, the processes that emerge from a model should be realistic and in keeping with expected behaviour [19]. We begin by comparing the price duration curve in the year 2018. Figure 3 shows the N2EX Day Ahead Auction Prices of the UK [11], the Monte-Carlo simulated electricity prices, and the non Monte-Carlo electricity price throughout the year 2018. Fuel prices varying throughout a year, as does V C and WACC. WACC is sampled from a Gaussian distribution with a standard deviation of ±3%. V C is sampled from a uniform distribution between 30% and 200% of the     [11]. We ran the initialisation of the model 40 times to capture the price variance. Outliers were removed as on a small number of occasions large jumps in prices at peak demand occurred which deviated from the mean. We did this, as although this does occur in real life, it occurs at a smaller fraction of the time than 5% of the year (modelled LDC), therefore the results would be unreasonably skewed for the highest demand segment. Figure 3 demonstrates very little variance in the non-stochastic case. This is due to the fact that combined cycle gas turbines (CCGTs) set the spot price. These CCGTs have little variance between one another as they were calibrated using the same dataset. By adding stochasticity of fuel prices and operation and maintenance prices, a curve that more closely resembles the actual data occurs. The stochastic curve, however, does not perfectly fit the real data, which may be due to higher variance in fuel prices and historical differences in operation and maintenance costs between power plants. One method of improving this would be fitting the data used to parametrise to the curve. Table 2 shows performance metrics of the stochastic and nonstochastic runs versus the actual price duration curve . The stochastic implementation, improves the mean absolute error (MAE) of the non-stochastic case by 52.5%. By observing the processes that emerge from the long-term scenarios, we can see that carbon price and investment in renewable generation are positively correlated, as would be expected. The highest NPV calculations were for onshore wind and CCGT plants. This is realistic for the United Kingdom, where subsidies are required for other forms of generation such as coal and nuclear. Performance. We used Figure 4 shows the running time for ElecSim with varying installed capacity. We varied demand between 2GW and 320GW to see the effect of different sized countries on running time. The makeup of the electricity mix was achieve through stratified sampling of the UK electricity mix. The results show a linear time complexity. Here we present example scenario runs using ElecSim. We vary the carbon tax and grow or reduce total electricity demand. This enables us to observe the effects of carbon tax on investment. In this paper we have presented scenarios where electricity demand decreases 1% per year, due to the recent trend in the UK. For the first scenario run displayed, we have approximated the predictions by the UK Government, where carbon tax increases linearly from £18 to £200 by 2050 [8]. Figure 5a demonstrates a significant increase in gas turbines in the first few years, followed by a decrease, with onshore wind increasing. Figure 5b displays a run with a £40 carbon tax. This run demonstrates a higher share of onshore wind than in the previous scenario. These runs demonstrate that a consistent, but relatively low carbon tax can have a larger impact in the uptake of renewable energy than increasing carbon tax over a long time frame. We hypothesise that an early carbon tax affects the long-term dynamics of the market for many years. We, therefore, suggest early action on carbon tax to transition to a low-carbon energy supply

Liberalised electricity markets with many heterogenous players are suited to be modelled with ABMs. ABMs incorporate imperfect information as well as heterogeneous actors. ElecSim models imperfect information through forecasting of electricity demand and future fuel and electricity prices. This leads to agents taking risk on their investments, and model market conditions more realistically. We demonstrated that increasing carbon tax can lead to an increase in investment of low-carbon technologies. We showed that early decisions have a long-term impact on the energy mix. Our future work includes comparing agent-learning techniques, using multi-agent reinforcement learning algorithms to allow agents  to learn in a non-static environment. We propose the integration of a higher temporal and spatial resolution to model changes in daily demand, as well as capacity factors by region, and transmission effects. This will allow us to model that demand is met at all times and not just on average. Table 3 shows a sample of modern power plant costs, and Table 4 displays a sample of historic power plant costs.
The parameters for both of these tables are explained in Section 3 Table 5 displays summary statistics for each scenario run. It demonstrates the demand and whether it increases or decreases and by the percentage of change. Carbon tax price is in £ per tonne of CO 2 , and also the year range in which the summary statistics apply. We then split the low carbon and traditional generation into two groups. Traditional generation contains gas, coal and nuclear power plants, whereas the low carbon group contains photovoltaic as well as offshore and onshore wind turbines. "mean" stands for the arithmetic mean, "std" stands for standard deviation, and min and max are the minimum and maximum values respectively. mean V C price, whilst fuel price is sampled from the residuals of an ARIMA model fit on historical data. The N2EX Day Ahead Market is a day ahead market run by Nord Pool AS. Nord Pool AS runs the largest market for electrical energy in Europe, measured in volume traded and in market share