emp support in jump - juliaopt.org · solveemp(mopec) storage of emp problems 19...

26
EMP support in JuMP Olivier Huber & Michael C. Ferris WID — University of Wisconsin–Madison June 29, 2018

Upload: nguyenkhanh

Post on 22-Oct-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

EMP support in JuMP

Olivier Huber & Michael C. Ferris

WID — University of Wisconsin–Madison

June 29, 2018

Page 2: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Outline 2

1 What is Extended Mathematical Programming (EMP)

2 EMP solver

3 Modeling of EMP problems in JuMP

Page 3: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Extended Mathematical Programming 3

What is EMP?EMP (Extended Mathematical Programming) is a framework to modeloptimization problem that do not fit into “classical” optimization problemvia simple annotations

EMP in GAMS

- Multi-players problems (MOPEC): (Generalized) Nash Equilibrium- Complementarity Problems and Variational Inequalities- Bilevel Problems (MPEC)- Multistage stochastic programming, Disjunctive Programs

Page 4: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Motivation for EMP support 4

Motivations & Goals for designing a tool

- Ease of use for non-experts: the modeler uses simple annotations- The model is augmented/transformed programmatically- Provide different schemes for solving the problem- Pass/Exploit the structure of the problem (feasible set)- No errors/typos during the reformulation- Allow for easy comparisons between schemes

Page 5: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Julia Packages 5

JAMSDWriter.jl: MPB Solver

- Loosely based on AmplNLWriter.jl

- Standard LQP/NLP solver- Translate the EMP data structure

EMP.jl: modeling package

- Equilibrium support- Optimal Value Function (OVF) support

Page 6: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

VI background 6

VI of the first kindF : Rn → Rn, Z convex subset of Rn. Find z ∈ Z such that

〈F (z), z − y〉 ≥ 0 ∀y ∈ Z

If F = ∇f or F = (∇xL,−∇λL), VI stems from an optimization problem

Normal cone operator: NK(x) := {d | 〈y − x, d〉 ≤ 0 ∀y ∈ K}.

x

NK (x)

K

dd ∈ NK(x) V I(F,K) ≡ 0 ∈ F (z) +NK(z)

Complementary Problem 0 ≤ x ⊥ F (x) ≥ 0 ≡ 0 ∈ F (x) +NRn+

(x)where x ⊥ F (x) ≡ xTF (x) = 0

Page 7: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

(Generalized) Nash Equilibrium Problem [(G)NEP] 7

For each agent i: xi is the decision variable, x−i is the other variables

minimizexi

fi(xi, x−i)

subject to gi(xi, x−i) ∈ Ki

Ki convex cone (Rn+, Rn−, {0}, SOC, . . . )

example of coupling constraints

- shared resources among agents:∑Ni=1 xi ≤ u

- strategic decisions

I No hierarchy between players, (otherwise MPECs or EPECs)I An example of a VI agent: market clearing conditions

0 ≤ supply− demand ⊥ price ≥ 0

Page 8: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

(Generalized) Nash Equilibrium Problem [(G)NEP] 7

For each agent i: xi is the decision variable, x−i is the other variables

minimizexi

fi(xi, x−i)

subject to gi(xi, x−i) ∈ Ki

Ki convex cone (Rn+, Rn−, {0}, SOC, . . . )

example of coupling constraints

- shared resources among agents:∑Ni=1 xi ≤ u

- strategic decisions

I No hierarchy between players, (otherwise MPECs or EPECs)I An example of a VI agent: market clearing conditions

0 ≤ supply− demand ⊥ price ≥ 0

Page 9: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Solution methodology for GNEP 8

MOPEC is solved by simultaneously solving all the KKT systems

First Order Optimality Conditions under CQ

minimizexi

fi(xi, x−i)

subject to gi(xi, x−i) ∈ Ki

=⇒∇xi

fi(xi, x−i) + 〈∇xigi(xi, x−i), λ〉 = 0

K∗i 3 λi ⊥ gi(xi, x−i) ∈ Ki

- Resulting MCP: X 3 z ⊥ F (z) ∈ X∗

- X is a simply bounded set- F is non-monotone in general- PATH or PATHAVI can solve many NEP instances (GNEP morechallenging)

Page 10: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Solution methodology for GNEP 8

MOPEC is solved by simultaneously solving all the KKT systems

First Order Optimality Conditions under CQ

minimizexi

fi(xi, x−i)

subject to gi(xi, x−i) ∈ Ki

=⇒∇xi

fi(xi, x−i) + 〈∇xigi(xi, x−i), λ〉 = 0

K∗i 3 λi ⊥ gi(xi, x−i) ∈ Ki

- Resulting MCP: X 3 z ⊥ F (z) ∈ X∗

- X is a simply bounded set- F is non-monotone in general- PATH or PATHAVI can solve many NEP instances (GNEP morechallenging)

Page 11: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Optimal Value Function 9

Problem typeObjective function

minimizex

f(x) + ρ(F (x))

subject to g(x) ≤ 0

or Constraint

minimizex

f(x)

subject to g(x) ≤ 0

ρ(F (x)) ≤ α

ρ(v) := supu∈U〈G(v), u〉 − k(u)

G(v) := Bv + b , k is convex, U polyhedral Aravkin et al. [2013]

Page 12: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Quadratic Support (QS) examples 10

Fitting Examples: apply ρ to F (x) Aravkin et al. [2013]`1 `2 Huber Hinge Loss

U [−1, 1]m 0 [−λ, λ]m [0, 1]m

Q 0 12I

12I 0

G(y) y y y y − ε

and more: soft Hinge,Vapnik, Hubnik, elasticnet

Huber loss function

Page 13: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Quadratic Support (QS) examples 10

Fitting Examples: apply ρ to F (x) Aravkin et al. [2013]`1 `2 Huber Hinge Loss

U [−1, 1]m 0 [−λ, λ]m [0, 1]m

Q 0 12I

12I 0

G(y) y y y y − ε

and more: soft Hinge,Vapnik, Hubnik, elasticnet

Huber loss function

Page 14: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Coherent Risk Measure 11

Coherent Risk Measure Examples Shapiro et al. [2009]

- Expected value: E[Z] = σ{pk}(Z)- Upper CVaR (AV@R, expected shortfall): CVaR1−α(z) = σD(α)(Z)

with D(α) :={y ∈

∏k

[0, α−1] | E[y] = 1}

- Algebra of support function: λE[z] + (1− λ)CVaR1−α(z) is thesupport function of λ{pk}+ (1− λ)D(α)

Page 15: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Solution methods 12

Saddle-point reformulationGame with payoff function: L(x, y) = f(x) + yTG(F (x))− k(y)

minx∈X

L(x, y) maxy∈Y

L(x, y)

Dual problem (QP)Find a minimization problem with the same objective function value

Conjugate reformulation

I ρ (Fenchel) conjugate of k + δU : ρ(u) = infu=u1+u2

k∗(u1) + σU (u2)

I k(u) = uTQu = ‖LTu‖2 (Q psd)

ρ(F (x)) = infs

12‖s‖

22 + σU (F (x)− Ls)

Page 16: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

EMP solver 13

Model mEMPinfo

Model m′EMPinfo′

Julia

GAMS

AMPL

EquilibriumSolver

GAMS

Julia

AMPL

Model transformations

Value propagations

The model representation inside the EMP solver is independent of anymodel language

Page 17: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

EMP info storage: mathematical programm 14

Optimization Problem definition

- Mathematical Programm (MP) is the basic building block- The optimization problem is described by a graph- Graph with 2 types of nodes: MP or Equilibrium (collection of MPs)- Examples: bilevel, MPEC, EPEC, MOPEC

- Easy extraction of subproblems (splitting methods (diag, Gauss-Seidel))- Fix variable values, simply expressions.

Page 18: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

EMP info storage: mathematical programm 14

Optimization Problem definition

- Mathematical Programm (MP) is the basic building block- The optimization problem is described by a graph- Graph with 2 types of nodes: MP or Equilibrium (collection of MPs)- Examples: bilevel, MPEC, EPEC, MOPEC

- Easy extraction of subproblems (splitting methods (diag, Gauss-Seidel))- Fix variable values, simply expressions.

Page 19: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

min

min

Bilevel

min

VI (NCP)

MPCC

min

VI

MPEC

min

Equil

MPEC

Page 20: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Example II 16

min min min

Equil

EPEC

Page 21: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

EMP.jl internals 17

Model object

- JuMP container for variables and equations- list of Mathematic Programms- list of Equilibriums- list of equations (for global indices)- list of special variables

Mathematical Programm (MP)

- variables and equations indices- complementary information (0 ≤ F (x) ⊥ x ≥ 0)- objective variable / objective equation / sense- MP in MP- equilibriums in MP

Page 22: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

EMP.jl API example I 18

mopec = EMP.Model()

ag = MathPrgm(mopec)mkt = MathPrgm(mopec)

EquilibriumProblem(mopec, [ag, mkt])

n = 3

@variableMP(mkt, y >= 0)@variableMP(ag, x[1:n] >= 0)@variableMP(mkt, p[1:n] >= 0)

JuMP.fix(p[2], 1.)JuMP.setvalue(x[1:n], ones(n))

vipair(mkt, [b[i] + ATmat[i]*y - x[i] for i=1:n], p)vipair(mkt, sum(-ATmat[i]*p[i] for i=1:n), y)

@constraintMP(ag, sum(p[i]*x[i] for i=1:n) <= sum(p[i]*b[i] for i=1:n) )@NLobjectiveMP(ag, :Max, sum(s[i] * log(x[i]) for i=1:n))

solveEMP(mopec)

Page 23: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Storage of EMP problems 19

Monolitic approach

- A unique container for variables and equations- the variables and equations are assigned to a MP⊕ Easy to defined shared variables or equations challenges in modeling: what is a natural way to create the partition?

MP-based approach

- Each MP has its own JuMP Model- The collection of MP in the graph defines the optimition problem⊕ ownership is trivial shared variables/equations are difficult to define consistency of the whole model needs to be checked Global indices for variables and equations

Page 24: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Future work 20

EMP solver

- Add automatic/symbolic differentiation support- Add ability to use Julia to solve the optimization problemhttps://github.com/mlubin/cmpb

EMP.jl

- User-defined OVF functions- Define UI/API for hierarchical optimization problems

Page 25: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

Bibliography I 21

A. Y. Aravkin, J. V. Burke, and G. Pillonetto. Sparse/robust estimation andkalman smoothing with nonsmooth log-concave densities: modeling,computation, and theory. Journal of Machine Learning Research, 14(1):2689–2728, 2013.

R. T. Rockafellar. Lagrange multipliers and optimality. SIAM Review, 35(2):183–238, 1993.

R. T. Rockafellar. Extended nonlinear programming. In G. Di Pillo andF. Giannessi, editors, Nonlinear Optimization and Applications 2, pages381–399. Springer, 2000.

A. Shapiro, D. Dentcheva, and A. Ruszczyński. Lectures on StochasticProgramming. Modeling and Theory. SIAM Publishing, Philadelphia,Pennsylvania, 2009.

Page 26: EMP support in JuMP - juliaopt.org · solveEMP(mopec) Storage of EMP problems 19 Monoliticapproach-Auniquecontainerforvariablesandequations-thevariablesandequationsareassignedtoaMP

AFW ’16 Electricity Generation example 22

- Electricity generation example with CVaR ( · ) in the objective function- Equilibrium problem with 3 agents and 10 scenarios- VI (MCP) and conjugate better than dual QP (primal)

5 10 15 20 25

init value

101

102

103

104

105

itera

tions

primal mcp conjugate