Skip to content

Energy Analytics and Optimization

PSR uses Julia for energy market simulation, analytics and planning
For PSR, switching to Julia:
  • Increased speed and productivity
  • Reduced time to market
  • Reduced investment optimization model code from 40,000 lines of code to 4,000 lines of code, and reduced SDDP model code from 120,000 lines of code to 14,000 lines of code
  • Saved time and money
  • Helped eliminate bugs
  • Made it easier to find and correct errors

PSR is a global electricity and natural gas consulting, analytics and technology firm with a presence in more than 70 countries around the world. They develop and license analytical tools for planning and energy market simulation using multistage stochastic optimization techniques.

PSR Optimization Engineer Joaquim Dias Garcia explains:

Each country in which we operate has its own regulations and demands, and each organization we work with has its own customization requirement, so our ability to be nimble and faster to market gives us a distinct competitive advantage. Our ability to add new solutions and new methodologies using Julia, with rapid testing, provides the fastest time to value for PSR and our customers.

PSR has been using Julia since 2015, before Julia v0.4. Our most frequent use of Julia is for optimization models. We use Julia’s JuMP optimization package for our commercial models, including optimizing power system operation with the stochastic dual dynamic programming algorithm (SDDP model), expansion planning using large-scale decomposition models (OPTGEN model) and optimal power flow software with non-linear programming (OPTFLOW model). We use Julia for daily tasks, research and software development, including probabilistic tools relying on Monte Carlo simulations, Fourier Analysis and GPUs.

Julia with JuMP allows us to use a high-level, high performance language for numerical computing and daily tasks. With Julia + JuMP, sketching an optimization model and bringing it to production is a single task which solves a lot of our ‘two-language’ problem. Because many stochastic programming algorithms and probabilistic methods used by PSR are suitable for parallelization, we took advantage of Julia’s inherent parallelism. The good interface with MPI and GPUs provide a lot of possibilities and flexibility.

Currently we deploy on AWS. Julia fits very well in this framework. We usually develop code on Windows with serial processing and test and deploy on Linux with parallel processing.

Historically, we have used Fortran, C/C++, Python, R and Mosel, so the good interoperability between Julia, C and Fortran lets us use a lot of legacy code and increases our productivity.

Julia makes it surprisingly easy to write simple and transparent code. Most of the time the code is so clear that writing explanatory comments is completely unnecessary.

Our investment optimization model originally built in Fortran had around 40 thousand lines of code. In Julia, there are only 4 thousand lines of code – a 90% reduction in code. Our SDDP model was reduced 88% from 120 thousand to 14 thousand lines of code.

Julia enables very fast development of optimization models. Many new ideas that used to take days or weeks to test are now tested in a few hours. In future, we expect to use features like programming GPUs and migrate more of our code to Julia.

What’s more, PSR isn’t just a Julia user – they are also contributors active in the JuliaOpt (Julia optimization) community. PSR developed the wrapper Xpress.jl, and has contributed to KNITRO.jl, MathProgBase.jl, Gurobi.jl, GLPKMathProgInterface.jl, JuMP.jl and MathOptInterface.jl, from design to programming.