solving large-scale nlp problems with jump and knitro

23
Solving large-scale NLP problems with JuMP and Knitro Fran¸ cois PACAUD June 25, 2019 1/17

Upload: others

Post on 16-Oct-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Solving large-scale NLP problems with JuMP and Knitro

Solving large-scale NLP problems

with JuMP and Knitro

Francois PACAUD

June 25, 2019

1/17

Page 2: Solving large-scale NLP problems with JuMP and Knitro

Introduction

Who am I?

• Currently optimization engineer at Artelys

• Working on the development of Knitro

And Artelys?

• A french PME (about 70 employees)

• Specialized in the optimization of energy systems

What could you expect from this talk?

• No math!

• Short presentation of the solver Knitro

• Feedbacks & thoughts on developing a wrapper based on MOI

• Of course, a case study with a benchmark! :)

2/17

Page 3: Solving large-scale NLP problems with JuMP and Knitro

When Knitro met JuMP

Page 4: Solving large-scale NLP problems with JuMP and Knitro

Knitro?

minx

f (x) xL ≤ x ≤ xU , cL ≤ c(x) ≤ cU

• Generic non-linear optimization (NLP) solver

• Based on interior-point algorithms

• Extension to Mixed Integer Non-linear optimization (MINLP)by using Branch & Bound

• Other interesting features:

• Second order cone programming (SOCP)

• Complementarity constraints

• Non-linear least squares (and by extension non-linear equations)

• Derivative free optimization (finite differences)

Cover a broad range of optimization problems!

3/17

Page 5: Solving large-scale NLP problems with JuMP and Knitro

Knitro timeline

• Development started in 2001 at Northwestern University

• Originated by Richard Waltz (former PhD student of Jorge Nocedal)

• Development first backed by Ziena Optimization

• 2015: Ziena bought by Artelys

• ...

• 2018: new incremental API for Knitro

• 2018: major update in Knitro.jl!

4/17

Page 6: Solving large-scale NLP problems with JuMP and Knitro

Knitro timeline

• Development started in 2001 at Northwestern University

• Originated by Richard Waltz (former PhD student of Jorge Nocedal)

• Development first backed by Ziena Optimization

• 2015: Ziena bought by Artelys

• ...

• 2018: new incremental API for Knitro

• 2018: major update in Knitro.jl!

4/17

Page 7: Solving large-scale NLP problems with JuMP and Knitro

Recent development in 2018

Developments of MathOptInterface (MOI)

MOI . a d d v a r i a b l e ( model , . . . )

Release of Knitro 11.0, with new procedural API

KN add var ( kc )

Perfect match!

5/17

Page 8: Solving large-scale NLP problems with JuMP and Knitro

Specifying NLP models in generic modelers

Specifying gradients ∇f (x), Jacobians ∇c(x)

and Hessians ∇2f (x) +∑m

i=1 λi∇2ci (x) to the solver?

• Rely heavily on automatic differentiation!

• Generic numerical problem, different solution (AMPL, Casadi)

• JuMP: relies on its own implementation of ForwardDiff.jl

(graph coloring approach)

6/17

Page 9: Solving large-scale NLP problems with JuMP and Knitro

Feedbacks on implementing Knitro.jl

• Knitro.jl originally developed by JuliaOpt

(credits to Yeesian Ng and Miles Lubin)

• Previous version of Knitro.jl worked with MathProgBase

• Porting Knitro.jl to MOI:

• Incremental API efficiently wrapped with MOI

(thanks to a well-studied design!)• But ...

• knitroampl: written in pure C on top of ASL

• MOI: issues with Julia’s garbage collector (finalizer)

Non-deterministic segfaults during development...

7/17

Page 10: Solving large-scale NLP problems with JuMP and Knitro

Feedbacks on implementing Knitro.jl

• Knitro.jl originally developed by JuliaOpt

(credits to Yeesian Ng and Miles Lubin)

• Previous version of Knitro.jl worked with MathProgBase

• Porting Knitro.jl to MOI:

• Incremental API efficiently wrapped with MOI

(thanks to a well-studied design!)• But ...

• knitroampl: written in pure C on top of ASL

• MOI: issues with Julia’s garbage collector (finalizer)

Non-deterministic segfaults during development...

7/17

Page 11: Solving large-scale NLP problems with JuMP and Knitro

Feedbacks on implementing Knitro.jl

• Knitro.jl originally developed by JuliaOpt

(credits to Yeesian Ng and Miles Lubin)

• Previous version of Knitro.jl worked with MathProgBase

• Porting Knitro.jl to MOI:

• Incremental API efficiently wrapped with MOI

(thanks to a well-studied design!)• But ...

• knitroampl: written in pure C on top of ASL

• MOI: issues with Julia’s garbage collector (finalizer)

Non-deterministic segfaults during development...

7/17

Page 12: Solving large-scale NLP problems with JuMP and Knitro

Leveraging JuliaOpt in Knitro’s development

Knitro’s development benefits from JuliaOpt community.

• Add new functions in Knitro’s API to improve MOI support

• Add MINLPTests.jl to Knitro’s continuous integration

• Integration of new benchmarks with MathOptFormat.jl

8/17

Page 13: Solving large-scale NLP problems with JuMP and Knitro

Use-cases

Page 14: Solving large-scale NLP problems with JuMP and Knitro

NLP? What for?

• Optimal control

• Chemical engineering (Grossman, Biegler, Waechter,...)

• Optimal power flow (OPF)

• Economics

• Machine learning (see [Bottou, Curtis, Nocedal 2018])

Focus here on OPF!

9/17

Page 15: Solving large-scale NLP problems with JuMP and Knitro

Introducing PowerModels.jl

Optimal Power Flow in a nutshell:

• Electrical engineering problem:

• Given resistances, generations and demands...

• ... find optimal dispatch of power flows in the electrical network

• Different ways to frame as an optimization problem

• Difficult NLP problems

PowerModels.jl allows to formulate OPF problems with JuMP

• Developed by Carleton Coffrin at Los Alamos National Laboratory

• Lot of flexibility!

10/17

Page 16: Solving large-scale NLP problems with JuMP and Knitro

Benchmarking Knitro with the PGLIB benchmark

Objective: solving the PGLIB benchmark with Knitro

• Large-scale problems (up to 80,000 variables)

Suitable for a benchmark!

• Instances of PGLIB prove to be challenging

Running Knitro on the PGLIB benchmark, we observed

• Performance in Julia were first much worsed than in Ampl/Matlab

• Instability: HSL MA27 and HSL MA57 give different results...

11/17

Page 17: Solving large-scale NLP problems with JuMP and Knitro

Results

We compare

OLD: Knitro.jl + MathProgBase

NEW: Knitro.jl + MathOptInterface

1 2 3 4 5 6 7 8Performance ratio

0.0

0.2

0.4

0.6

0.8

1.0

Prob

lem

s sol

ved

NEWOLD

100 101 102

log CPU time (s)

0.0

0.2

0.4

0.6

0.8

1.0

Prob

lem

s sol

ved

NEWOLD

Code available in https://github.com/frapac/Knitro-Zoo/opf/

12/17

Page 18: Solving large-scale NLP problems with JuMP and Knitro

Extension

Some ideas to move forward...

• Challenge: implementing Security constraints OPF (MINLP &

complementarity constraints) inside a Benders decomposition

• Add supports of NLP constraints/objective in StructJuMP.jl

13/17

Page 19: Solving large-scale NLP problems with JuMP and Knitro

Going onward

Page 20: Solving large-scale NLP problems with JuMP and Knitro

Contributing to JuMP?

• Callbacks?

• Implement Complementarity Constraints in MOI/JuMP?

• Implement non-linear least-squares in MOI/JuMP?

• NLP: first class support planned for JuMP 2.0

Other promising projects:

• Optim.jl

• JuliaSmoothOptimizers.jl

14/17

Page 21: Solving large-scale NLP problems with JuMP and Knitro

State of AD in 2019

• Currently JuMP still relies on a specific version of ForwardDiff.jl

• Recent buzz around AD:

https://julialang.org/blog/2019/01/fluxdiffeq

• Lots of development is ongoing:

• Cassette.jl

• Nabla.jl

• Zygote.jl

15/17

Page 22: Solving large-scale NLP problems with JuMP and Knitro

Still looking for difficult (MI)NLP problems!

• Lots of benchmarks in GAMS/AMPL formats

• We believe the community will benefit from established benchmark

built on top of JuMP

• Some very promising ideas related to MathOptFormat.jl

16/17

Page 23: Solving large-scale NLP problems with JuMP and Knitro

Wrapping it alltogethers

• Implementing a wrapper for a solver in Julia allows

to understand lot of stuffs

• Next tutorial: solving MINLP problems with Knitro

• Artelys is recruiting (internship & CDI)!

[email protected]

https://www.artelys.com/fr/carrieres

17/17