<<

A Brief Introduction to Mathematical Optimization in Julia (Part 1) What is Julia? And why should I care?

Carleton Coffrin Advanced Network Initiative https://lanl-ansi.github.io/

Managed by Triad National Security, LLC for the U.S. Department of Energy’s NNSA

LA-UR-21-20278 Warning: This is not a technical talk! 9/25/2019 Ja__aae. What is Julia?

• A “new” developed at MIT • nearly 10 years old (appeared around 2012)

• Julia is a high-level, high-performance, dynamic programming language • free and open source

• The Creator’s Motivation • build the next-generation of programming language for and computational science • Solve the “two-language problem” (you havee:///Ue/cae/Dad/Ja__aae. to choose between 1/1 performance and implementation simplicity) Who is using Julia?

Julia is much more than an academic curiosity!

See https://juliacomputing.com/ Why Julia?

Application9/25/2019 Ja__aae. Needs Data Scince Numerical Scripting Automation

9/25/2019 Thin-Border-Logo-Te

Julia Data Differential Equations

e:///Ue/cae/Dad/Ja__aae. 1/1

Deep Learning

Mathematical Optimization

High Performance

hps://camo.gihbserconen.com/31d60f762b44d0c3ea47cc16b785e042104a6e03/68747470733a2f2f7777772e6a756c69616f70742e6f72672f696d616765732f6a7 1/1

Sounds too good to be true…

How fast is Julia, really?

See https://julialang.org/benchmarks/

Free and Open Source Matters

• License requirements hold back potential research insights and impact

• Almost all numerical can benefit from cluster computing • 10-100x faster feedback in development • Increase the the problem size considered by 10-100x • Increases the number of problems tested by 10-100x

• Some impacts on my work • Finding interesting counter examples (e.g., multi-contingencies) • Validation of very time consuming (e.g. OBBT) • Solving SCOPF problems in APRA-e’s Grid Competition Why should you care about Julia?

Could dramatically impact your research

Three Likely Possibilities

1) increased research productivity

2) transform the types of experiments you can consider

3) research prototypes ≈ production ready code Lets look at some Julia Matrices in Julia b = [5, 6] # col. vector using SparseArrays

A = [1 2; 3 4] # matrix # I = [1, 2, 3, 1, 3] x = A \ b # solve A*x = b J = [1, 2, 3, 3, 1] V = [1, 1, 1,-1.5,-1.5] # complex numbers v = [1+0im 1+0.3im] Φ = sparse(I,J,V) Y = [3+6.0im 1+3.0im; 1-3.0im 2+4.0im] # sparse Φ*ω = b solve p = V*Y ω = Φ \ [1.0, 2.0, 3.0] Data Analytics in Julia

] add CSV ] add DataFrames using CSV using DataFrames data = CSV.read("data.csv", data = CSV.read("data.csv", NamedTuple) DataFrame) data[1] # column 1, vector data.col1 # column 1, vector data[2][3] # col 2, row 3 data.col2[3] # col 2, row 3 sum(data[1]) sum(data.col1) … gdf = groupby(data, :col1) cdf = combine(gdf, :col2 => sum) Optimization in Julia

] add JuMP, add Ipopt optimize!(m) using JuMP, Ipopt termination_status(m) m = Model(Ipopt.Optimizer) objective_value(m) @variable(m, 0 <= θ <= 10) value.([θ, x, y]) @variable(m, 0 <= x <= 10) @variable(m, -1 <= y <= 1)

@objective(m, Min, θ*x + θ*y + x*y) @constraint(m, x+y <= 5) Want to Learn More?

• “Julia language: a concise tutorial” • https://syl1.gitbook.io/julia-language-a-concise-tutorial/

• JuMP Tutorials • https://github.com/jump-dev/JuMPTutorials.jl

• LANL Grid Science Tutorials (more in Part 2!) • https://github.com/lanl-ansi/tutorial-grid-science Thanks!

What do you want to know about Julia?