Optimization Techniques II: Discrete and Functional Optimization 9782759831654

This book in two volumes provides an overview of continuous, discrete and functional optimization techniques. This secon

129 32 10MB

English Pages 476 Year 2023

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Preface
Introduction
Table of contents
1. Mixed linear programming
2. Discrete optimization
3. Functional optimization
4. Optimal control
5. Numerical methods in optimal control
Index
Short bibliography
Recommend Papers

Optimization Techniques II: Discrete and Functional Optimization
 9782759831654

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

Current Natural Sciences

_____________

Max CERF

Optimization Techniques II Discrete and Functional Optimization

Printed in France EDP Sciences – ISBN(print): 978-2-7598-3163-0 – ISBN(ebook): 978-2-7598-3165-4 DOI: 10.1051/978-2-7598-3163-0 All rights relative to translation, adaptation and reproduction by any means whatsoever are reserved, worldwide. In accordance with the terms of paragraphs 2 and 3 of Article 41 of the French Act dated March 11, 1957, “copies or reproductions reserved strictly for private use and not intended for collective use” and, on the other hand, analyses and short quotations for example or illustrative purposes, are allowed. Otherwise, “any representation or reproduction – whether in full or in part – without the consent of the author or of his successors or assigns, is unlawful” (Article 40, paragraph 1). Any representation or reproduction, by any means whatsoever, will therefore be deemed an infringement of copyright punishable under Articles 425 and following of the French Penal Code. © Science Press, EDP Sciences, 2023

I would like to express my sincere thanks to the people who helped me to produce this book, especially: France Citrini for having accepted the publication of the book by EDP Sciences; Sophie Hosotte and Magalie Jolivet for their assistance in the editorial process; Thomas Haberkorn for his verification of scientific content, and for the countless numerical tricks he shared with me; Emmanuel Trélat for his preface, proofreading and presentation advices, and also for our long-standing collaboration and the expertise I have acquired owing to him; Claude Blouvac† my high school teacher who set me on the path of mathematics in 1982 and who would have been very happy to see this book.

Preface

Algorithms are omnipresent in our modern world. They show us the optimal routes, prevent and assess risks, provide forecasts, anticipate or assist our decisions. They have become an essential part of our daily lives. These algorithms are mostly based on optimization processes and consist in minimizing or maximizing a criterion under certain constraints, thus indicating feasible and intelligent solutions, allowing us to plan a process to be carried out in the best possible way. There are many different optimization methods, based on various heuristics, sometimes simple and intuitive, sometimes more elaborate and requiring fine mathematical developments. It is through this jungle of algorithms, resulting from decades of research and development, that Max Cerf guides us with all his expertise, his intuition and his pragmatism. Max Cerf has been a Senior engineer at ArianeGroup for 30 years. As a recognized specialist in trajectography, he designs and optimizes spacecraft trajectories under multiple constraints. He has thus acquired and developed a comprehensive knowledge of the best algorithms in continuous optimization, discrete optimization (on graphs) and optimal control. He is also an exceptional teacher, with a real talent for explaining complicated concepts in a clear and intuitive way. With this double book, he offers an invaluable guide to the non-specialist reader who wishes to understand or solve optimization problems in the most efficient way possible. Emmanuel Trélat, Sorbonne University, Paris

Introduction

Mathematical optimization has undergone a continuous development since the Second World War and the advent of the first computers. Facing the variety of available algorithms and software, it is sometimes difficult for a non-specialist to find his way around. The aim of this two-volume book is to provide an overview of the field. It is intended for students, teachers, engineers and researchers who wish to acquire a general knowledge of mathematical optimization techniques. Optimization aims to control the inputs (variables) of a system, process or model to obtain the desired outputs (constraints) at the best cost. Depending on the nature of the inputs to be controlled, a distinction is made between continuous, discrete or functional optimization. Continuous optimization (chapters 1 to 5 of Volume I) deals with real variable problems. Chapter 1 presents the optimality conditions for differentiable functions and the numerical calculation of derivatives. Chapters 2, 3 and 4 give an overview of gradient-free, unconstrained and constrained optimization methods. Chapter 5 is devoted to continuous linear programming, with the simplex and interior point methods. Discrete optimization (chapters 1 and 2 of Volume II) deals with integer variable problems. Chapter 1 deals with mixed-variable linear programming by cutting or tree methods. Chapter 2 presents an overview of combinatorial problems, their modelling by graphs and specific algorithms for path, flow or assignment problems. Functional optimization (chapters 3 to 5 of Volume II) deals with infinite dimension problems. The input to be controlled is a function and no longer a finite number of variables. Chapter 3 introduces the notions of functional and calculus of variations. Chapter 4 presents optimal control problems and optimality conditions. Chapter 5 is devoted to numerical methods (integration of differential equations, direct and indirect methods). In each chapter, the theoretical developments and the demonstrations are limited to the essentials. The algorithms are accompanied by detailed examples to facilitate their understanding.

Table of contents 1. Mixed linear programming 1.1

1.2

1.3

1.4

1.5

1.6

Formulation 1.1.1 Mixed-variable linear problem 1.1.2 Linearization techniques 1.1.3 Reduction techniques Cutting methods 1.2.1 Cut on a variable 1.2.2 Cut on the cost 1.2.3 Gomory’s method 1.2.4 Integral cut 1.2.5 Mixed cut Tree methods 1.3.1 Implicit enumeration 1.3.2 Separation 1.3.3 Evaluation 1.3.4 Exploration strategy Applications 1.4.1 Travelling salesman problem 1.4.2 Assignment problem 1.4.3 Coloring problem 1.4.4 Flow problem 1.4.5 Knapsack problem Quadratic problem 1.5.1 Tree method 1.5.2 Convexification 1.5.3 Quadratic assignment problem Conclusion 1.6.1 The key points 1.6.2 To go further

1 2 2 4 10 12 12 14 15 21 23 31 31 31 33 51 58 58 62 66 68 71 73 73 75 80 81 81 82

2. Discrete optimization

83

2.1

84 84

Combinatorial problem 2.1.1 Graph

2.2

2.3

2.4

2.5

2.6

2.7

2.1.2 Route in a graph 2.1.3 Complexity Path problem 2.2.1 Ford's algorithm 2.2.2 Bellman's algorithm 2.2.3 Dijkstra's algorithm 2.2.4 A* algorithm 2.2.5 Demoucron and Floyd’s algorithm Scheduling problem 2.3.1 PERT method 2.3.2 MPM method 2.3.3 Margins Flow problem 2.4.1 Ford-Fulkerson algorithm 2.4.2 Roy-Busacker-Gowen algorithm Assignment problem 2.5.1 Equivalent flow problem 2.5.2 Hungarian method 2.5.3 Theoretical justification Heuristics 2.6.1 Stacking problem 2.6.2 Bin packing problem 2.6.3 Set covering problem 2.6.4 Coloring problem 2.6.5 Travelling salesman problem Conclusion 2.7.1 The key points 2.7.2 To go further

87 91 95 95 98 107 110 124 128 129 132 136 138 138 144 149 149 152 159 163 164 165 166 168 172 175 175 175

3. Functional optimization

177

3.1

178 178 178 179 180 181 184 184 196

3.2

Formulation 3.1.1 Functional 3.1.2 Neighborhood 3.1.3 Variation 3.1.4 Minimum 3.1.5 Standard problem Optimality conditions 3.2.1 Weak minimum necessary conditions 3.2.2 Weak minimum sufficient conditions

3.3

3.4

3.5

3.6

3.2.3 Corner necessary conditions 3.2.4 Strong minimum necessary conditions 3.2.5 Summary Constraints 3.3.1 Final constraint 3.3.2 Integral constraint 3.3.3 Path constraint Canonical form 3.4.1 Change of variables 3.4.2 Canonical variables 3.4.3 Hamilton-Jacobi-Bellman equation 3.4.4 Application to mechanics Dynamic system 3.5.1 State formulation 3.5.2 Stability 3.5.3 Linear system 3.5.4 Two-point boundary value problem Conclusion 3.6.1 The key points 3.6.2 To go further

205 214 218 219 219 226 232 234 234 237 241 244 248 248 250 256 264 267 267 267

4. Optimal control

269

4.1

270 270 272 281 292 304 304 311 315 323 333 337 337 338 341 346 352

4.2

4.3

Optimality conditions 4.1.1 Control problem 4.1.2 Principle of the minimum 4.1.3 Variational method 4.1.4 Two-point boundary value problem Constraints 4.2.1 Terminal constraints 4.2.2 Interior constraints 4.2.3 Path constraints 4.2.4 Quadratic-linear problem 4.2.5 Robust control Extremals 4.3.1 Definitions 4.3.2 Abnormal extremal 4.3.3 Singular extremal 4.3.4 Neighboring extremals 4.3.5 State feedback control

4.4

4.5

4.3.6 Hamilton-Jacobi-Bellman equation Optimality conditions of second order 4.4.1 Auxiliary minimum problem 4.4.2 Sufficient conditions of minimum 4.4.3 Singular arcs Conclusion 4.5.1 The key points 4.5.2 To go further

356 362 362 368 372 389 389 390

5. Numerical methods in optimal control

391

5.1

392 393 396 398 398 405 411 415 418 419 420 423 423 424 426 429 431 431 433 440 440 450 455 455 455

5.2

5.3

5.4

5.5

5.6

5.7

Transcription 5.1.1 Differential equations 5.1.2 Direct and indirect methods Runge-Kutta methods 5.2.1 Quadrature formulas 5.2.2 Error analysis 5.2.3 Order conditions 5.2.4 Embedded methods Adams methods 5.3.1 Adams-Bashford methods 5.3.2 Adams-Moulton methods Collocation methods 5.4.1 Collocation conditions 5.4.2 Collocation points 5.4.3 Collocation of degree 3 5.4.4 Collocation of degree 5 Direct methods 5.5.1 Discretization 5.5.2 Variational approach Indirect methods 5.6.1 Shooting method 5.6.2 Variational approach Conclusion 5.7.1 The key points 5.7.2 To go further

Index Bibliography

Mixed linear programming

1

1. Mixed linear programming Mixed linear programming concerns linear problems where some variables are real and others are integer or binary. Many practical problems can be formulated as a mixed linear problem. The solution methods are mainly based on the simplex algorithm. Section 1 deals with the problem formulation. Linearization techniques transform a nonlinear real-variable problem into an equivalent linear mixed-variable problem that is easier to solve. Reduction techniques reduce the size of the problem by fixing variables and eliminating constraints. These pre-processing stages speed up the numerical solution. Section 2 presents the cutting methods, which consist in solving the relaxed problem in real variables and then adding constraints to force an integer solution. These cutting constraints progressively reduce the feasible domain. They can be generated by different approaches. For large problems, the number of cuts can become prohibitive and these methods are generally used in addition to tree methods. Section 3 presents tree search methods that explore the tree of possible combinations. The exploration consists in progressively fixing the binary or integer variables and estimating the best possible solution resulting from this choice. The estimation can be obtained quickly thanks to the properties of the dual simplex algorithm. With an exploration strategy adapted to the problem, it is possible to obtain the optimal integer solution by exploring only a small fraction of the set of possible combinations. Section 4 presents applications of mixed linear programming to classical problems: travelling salesman, assignment, coloring, flow, knapsack. Although these problems can be solved efficiently by dedicated algorithms, the linear formulation remains interesting because it allows to easily add constraints specific to the problem to be solved. Section 5 presents mixed quadratic programming. Tree search methods are applied in the same way as in linear programming, provided that the relaxed problem is made convex so that it can be solved safely and quickly.

2

Optimization techniques

1.1 Formulation This section introduces the standard formulation of a mixed-variable linear problem, the linearization techniques for nonlinear problems and the reduction techniques for eliminating variables and/or constraints before solving.

1.1.1 Mixed-variable linear problem The standard form of a mixed-variable linear problem (LPM) is as follows. Ax = b  min z = cT x s.t.  x j  , j  JE x  x j  0 , j  JC 

, A

mn

, b

m

, c

n

(1.1)

The vector x n represents the n variables of the problem: - the indexes JE correspond to integer variables; - the indexes JC correspond to positive real (also called continuous) variables. The relaxed problem associated with problem (1.1) is obtained by considering all variables as real (we say that the integrity constraints are relaxed).

Ax = b min z = cT x s.t.  x x j  0 , j  JE JC

(1.2)

Since the relaxed problem is less constrained than the integer problem, its solution is better and it provides a lower bound of the minimum cost of problem (1.1). It is tempting to solve the relaxed problem and then round up the variables that must be integers. But, this rounded solution may be non-feasible or very far from the true mixed-variable solution as the example 1-1 shows.

Example 1-1: Solution of the relaxed and the mixed problem (from [R5]) Consider the problem in integer variables:

min z = −10x1 − 11x2 s.t. 10x1 + 12x 2  59

x1 ,x2

 x = 5.9 → z = −59 . The relaxed solution is:  1  x2 = 0 x = 1 → z = −54 (found by enumeration). The integer solution is:  1  x2 = 4

Mixed linear programming

3

Let us try to round up the relaxed solution: x = 6 → z = −60 . • the closest integer point would be:  1  x2 = 0 •

This point is not feasible (the inequality constraint is not satisfied); x = 5 → z = −50 . the closest feasible integer point is:  1  x2 = 0

This rounded point is far from the exact integer solution, although close in cost. Figure 1-1 shows the constraint (solid line), the relaxed solution C, the integer solution E and the level line of the cost function through the integer solution E.

Figure 1-1: Relaxed and integer solution.

In some cases, it is useful to reformulate the problem in binary variables. Any integer variable x bounded between 0 and m can be replaced by p + 1 binary variables (y0 , y1, , yp ) corresponding to the binary writing of x.

x = yp yp−1...y1y0 = yp 2p + yp−1 2p−1 + ... + y1 21 + y0 20

with m  2p+1

binary

For binary variables, we will note in the following: U = 0 ; 1 .

(1.3)

4

Optimization techniques

The solution of a continuous linear problem is a vertex of the constraint polytope, m associated with one of the possible Cn bases (Volume I, section 5.1.2). This simple characterization of the solution allows the construction of efficient solution algorithms such as the simplex or interior point methods. With mixed variables, the solution lies inside the constraint polytope and it does not admit a simple characterization. For these so-called NP-complete problems, there is no polynomial time solution algorithm. It is therefore important to simplify the problem by the techniques presented in section 1.1.2.

1.1.2 Linearization techniques Some nonlinear expressions can be linearized at the cost of additional variables and constraints. These reformulations allow mixed linear programming algorithms to be applied to initially nonlinear problems. This section based on reference [R1] presents the basic techniques. Product of two binary variables The product of two binary variables s and t is linearized by introducing an additional real variable f and four inequality constraints.



sU f = s.t with tU

is equivalent to

f  s f  t s + t − f  1  f  0

Verification: all possible combinations of s and t are examined: • •

f  0 f  t 0f 0 f =0 case s = 0     ; t − f 1 0  t 1 t  U , t free  f  0 case t = 0  calculations similar to the case s = 0 above;





f  1 f  1 s =1 • case    1 f 1  f =1 . t =1 2 − f 1  f  0 The value of f is equal to the product of s and t in all cases.



(1.4)

Mixed linear programming

5

Product of a binary variable and a bounded real variable The product of a binary variable s and a real variable x comprised between xL and xU is linearized by introducing a real variable f and four inequality constraints. s  U  f = s.x with  x    xL  x  x U

is equivalent to

f  f f   f

 s.xU  x − (1 − s).xL  x − (1 − s).xU  s.xL

(1.5)

Verification: all possible values of s are examined:

f  0 f  x − xL 0  f  0 • case s = 0      f  x − xU  x − x U  f  x − xL  f  0 f  x U f  x x  f  x • case s = 1      f x  xL  f  x U  f  xL The value of f is either 0 or x depending on the value of s.

f = 0  x  x  x free ; U  L

f = x  x  x  x free . U  L

Linear approximation of a bounded real variable A real variable x comprised between 0 and xU can be approximated within  by a linear combination of m binary variables (si )i=1 to m of the form: m

x   2i−1 si i =1

x   with (si )i=1 to m  U , m = E  log2 U  + 1   

(1.6)

Verification

x x The variable E   is integer and less than 2m because x  xU and log2 U  m.   m x i −1 It is written in binary as: E   =  2 si .    i=1 m x i −1 Let us note: y = E   =  2 si .    i =1

6

Optimization techniques

This variable y is a linear combination of the binary variables (si )i=1 to m and it

x−y x x−y x = − E   0  1  0  x − y   .     The variable y is therefore an approximation of x within . satisfies:

Discrete-valued variable or function A variable x taking a set of m discrete values x1 ; ;xm  can be replaced by m binary variables (si )i=1 to m and an equality constraint. m

x =  xisi

with

i =1

m

s

i

i =1

(1.7)

= 1 , si  U

The constraint imposes that only one of the variables si is 1, giving x the value xi. f (x) taking a set of m discrete values f1 ; ;fm  Similarly, a function f : x  can be replaced by m binary variables (si )i=1 to m and an equality constraint. m

f(x) =  fisi

m

s = 1 , s  U

with

i =1

i =1

i

(1.8)

i

Variable either worth zero or above a threshold Suppose that the real variable x takes either the value 0 or any value comprised between xL and xU. These constraints are linearized by introducing a binary variable s and two inequality constraints. x = 0  or  0  xL  x  x U

is equivalent to

 x  s.xL   x  s.xU s  U

Verification: all possible values of s are examined: •

case s = 0 



x0 x0

 x = 0;

 x  xL case s = 1    xL  x  x U .  x  xU The value of x is either 0 or between x L and xU depending on the value of s. •

(1.9)

Mixed linear programming

7

Integer variables taking distinct values Suppose that two integer variables x and y are bounded and must take different values. These constraints are linearized by introducing a binary variable s and four inequality constraints. x  y   x, y    x  xU , y  yU

is equivalent to

 x  y + 1 − (yU + 1).s   y  x + 1 − (x U + 1).(1 − s)  x  xU , y  yU , s  U 

(1.10)

Verification: all possible values of s are examined:





 x  y (because x, y are integers) x  y + 1  case s = 0   y  x − xU → always satisfied, because y  0 and x  x U ;  x  xU , y  yU → always satisfied, because x  0 and y  yU  x  y − yU  case s = 1   y  x + 1  y  x (because x, y are integers) .  x  xU , y  yU

The values of x and y are different, with x  y if s = 0 , or x  y if s = 1 .

Variable belonging to the union of intervals Suppose that the real variable x must belong to the union of m intervals.

x  [a1;b1 ] [a2 ;b2 ] ... [am ;bm ] with a1  b1  a2  b2  ...  am  bm

(1.11)

These constraints are linearized by introducing m binary variables (si )i=1 to m and 2m + 1 inequality constraints. x

m i =1

[ai , bi ]

is equivalent to

 x  aisi + a1 (1 − si )   x  bisi + bn (1 − si ) m  si = 1 , (si )i=1 to m  U   i=1

(1.12)

Verification The sum constraint imposes that only one of the variables s i is 1, all the others being 0. Let j be the number of the non-zero variable.

8

Optimization techniques

Let us look at the consequences for the constraints (1.12): x  a j    a j  x  bj ; • sj = 1  x  bj

 x  a1 si = 0 , i  j    a1  x  bn → always satisfied .  x  bn We have thus x [a j ;bj ] for the interval selected by sj. •

Satisfying p constraints among m Suppose that p constraints: gi (x)  0 must be satisfied among m and that the functions gi are bounded: x , gi (x)  gUi . These constraints are linearized by introducing m binary variables (si )i=1 to m and m + 1 inequality constraints.

( gi (x)  0 )i=1 to m

gi (x)  si .gUi  is equivalent to  m si  m − p , (si )i=1 to m  U  i =1

(1.13)

Verification The constraint on the sum of si requires that at least p variables si are zero: • case sj = 0  gi (x)  0 ;

case sj =1  gi (x)  gUi . We obtain p constraints satisfied among the m inequality constraints. •

Implication between constraints Consider two inequality constraints on functions of real variables.

f (x)  a g(y)  b

with x , fL  f (x) with y , g(y)  gU

(1.14)

The function f is lower bounded, the function g is upper bounded. The constraints (1.14) are linked by the implication: "If f (x)  a , then g(y)  b ", which linearizes by introducing a binary variable s and two inequality constraints.

( f(x)  a

f(x)  a + (fL − a).s   g(y)  b ) is equivalent to g(y)  b + (gU − b).(1 − s) s  U

(1.15)

Mixed linear programming

9

Verification The implication means that: either f (x)  a and g(y) has a free value, or g(y)  b and f (x) has a free value. • case s = 0  f (x)  a and g(y)  gU ; • case s =1  g(y)  b and fL  f (x) . This gives us one or the other of the two possibilities associated to the implication.

Maximum of m bounded functions Suppose that the function f is defined as the maximum of m bounded functions. The common upper bound of these functions is denoted gU . f (x) = max gi (x) i =1,...,m

with x , gLi  gi (x)  gU

(1.16)

This expression for f is linearized by introducing m binary variables (si )i=1 to m , one real variable f and 2m + 1 inequality constraints.

 f  gi (x) + si (gU − gLi ) f (x) = max gi (x) f  g (x) i =1,...,m (1.17) is equivalent to  m i  x , gLi  gi (x)  gU  si = m − 1 , (si )i=1 to m  U  i=1

Verification The sum constraint imposes that only one of the variables s i is 0, all the others being 1. Let j be the number of the zero variable. Let us look at the consequences for the constraints (1.17): f  g j (x)    f = g j (x) ; • sj = 0 f  g j (x)

f  gi (x) + (gU − gLi ) si = 1 , i  j    gi (x)  f . f  gi (x) We have ( f  gi (x) )i=1 to m with equality f = gj (x) for the function number j. •

10

Optimization techniques

Minimum of m bounded functions Suppose that the function f is defined as the minimum of m bounded functions. The common lower bound of these functions is denoted gL . f (x) = min gi (x) i =1,...,m

with x , gL  gi (x)  gUi

(1.18)

This expression for f is linearized by introducing m binary variables (si )i=1 to m , one real variable f and 2m + 1 inequality constraints.  f  gi (x) − si (gUi − gL ) f (x) = min gi (x) f  g (x) i =1,...,m (1.19) is equivalent to  m i  x , gL  gi (x)  gUi  si = m − 1 , (si )i=1 to m  U  i=1

Verification The sum constraint imposes that only one of the variables s i is 0, all the others being 1. Let j be the number of the zero variable: f  g j (x)    f = g j (x) ; • sj = 0 f  g j (x)

f  gi (x) − (gUi − gL ) si = 1 , i  j    f  gi (x) . f  gi (x) We have ( f  gi (x) )i=1 to m with equality f = gj (x) for the function number j. •

1.1.3 Reduction techniques A mixed linear problem usually has a large number of variables and constraints. A preliminary analysis can allow fixing some variables and/or eliminating some constraints. This section, inspired by reference [R1], presents the usual techniques for reducing the problem size. Bounds on the variables Let us assume that the variable x  inequality constraint of the form g(x) =  a jx j + ai xi  b ji

n

is bounded: xL  x  xU and consider an (1.20)

Mixed linear programming

11

By calculating the minimum value of g on variables other than xi

gL = min g(x) =  a jxUj +  a jxLj xLj  x j  xUj ji

a j 0 ji

a j 0 ji

(1.21)

we can derive bounds on the variable xi due to the inequality constraint (1.20).

b − gL  if ai  0  xi  a i (1.22) ai xi  b −  a jx j  b − gL   b − gL ji  xi  if ai  0 ai  By proceeding in this way for all pairs (variable−inequality constraint), we can tighten the bounds xL , xU on all variables. This treatment should preferably be carried out before the search for bounds on the constraints presented below. Bounds on the constraints Let us consider a linear function: g(x) = aT x . If the variable x  n is bounded: xL  x  xU , we can calculate the extreme values that the function g can take.

g(x) =  a jx j j

gL = min g(x) =  a jxUj +  a jxLj xL  x  x U  a j 0 a j 0   g(x) =  a jxLj +  a jxUj gU = xmax L  x  xU a j 0 a j 0 

(1.23)

These extreme values are used to check before solving whether a constraint on g is feasible, infeasible or redundant: • an equality constraint: g(x) = aT x = b is feasible if gL  b  gU ; •

an inequality constraint: g(x) = aT x  b is feasible if gL  b ;



an inequality constraint: g(x) = aT x  b is redundant if gU  b .

If a constraint is detected as infeasible, the problem has no solution. A constraint detected as redundant can be removed. Fixing binary variables By alternately setting each binary variable to 0 and then to 1, and calculating the bound on the constraints as above, we can detect certain infeasibilities that will allow us to fix the binary variable to 0 or 1. This preliminary variable fixing often allow to significantly reduce the size of the problem before starting to solve it.

12

Optimization techniques

1.2 Cutting methods Cutting methods consist in solving a series of relaxed problems by progressively adding inequality constraints until an integer solution is obtained.

1.2.1 Cut on a variable Consider a linear problem in integer variables, denoted (LPI). Ax = b min z = cT x s.t.  n x x 

(1.24)

The constraints x  n are called integrity constraints. The relaxed problem (LPR) is obtained from (LPI) by replacing the integrity constraints by positivity constraints.

min z = cT x s.t. x



Ax = b x0

(1.25)

This standard linear problem is solved by the simplex method (Volume I, section 5.1). Its solution corresponds to an optimal basis B. The simplex array denoted T represents the canonical form of the problem (LPR) in this basis. xB I T= 0

xN B N b cNT − z −1

→ xB + B−1Nx N = b → cNT x N = z − z

x = b → solution  B  xN = 0

(1.26)

If by chance the basic variables xB are all integer, the problem (LPI) is solved. Assume that the basic variable xi is not an integer. The canonical form (1.26) gives the expression of the basic variables xB in terms of the non-basic variables xN . xi +  aij x j = bi , i  B jN

(1.27)

Remark on the notation The notation N above refers to the set of non-basic indexes, not to be confused with the set of natural numbers.

Mixed linear programming

13

We note respectively E(y) and F(y) , the integer and fractional part of a real y.



E(y)  y  E(y) + 1 , E(y)  F(y) = y − E(y)

(1.28)

Since the variables x must be positive, we deduce from (1.27) the inequality xi +  E(aij )x j  bi

(1.29)

jN

Since the variables x must be integers, the first member of (1.29) must be an integer. The second member of the inequality can then be replaced by the lower whole number without changing the solution set. xi +  E(aij )x j  E(bi )

(1.30)

jN

Let us replace in this inequality the basic variable xi by its canonical expression (1.27) in terms of the non-basic variables xN : xi = bi −  aij x j . jN

By grouping the terms with the fractional part defined by (1.28), we obtain

 F(a )x jN

ij

j

 F(bi )

(1.31)

This inequality constraint is called a cut or truncation on the variable xi . The integer solution of the problem (LPI) must satisfy this new inequality. If the relaxed problem solution xi = bi is not integer, inequality (1.31) is not satisfied, because the non-basic variables are zero (xN = 0) whereas the second member is strictly positive. We can then resume the solution of the relaxed problem by adding the constraint (1.31) in order to exclude the non-integer solution xi = bi . This constraint can be reformulated by introducing a positive slack variable y.

 = F(aij )  0 with  j  = F(bi )  0 Returning to (1.30), the new constraint takes the form −TN xN + y = −

(1.32)

xi +  E(aij )x j + y = E(bi )

(1.33)

jN

which shows that the new variable y is necessarily integer (because the other terms are all integers). Section 1.2.3 explains how to add this constraint into the simplex algorithm starting from the basis solution already found.

14

Optimization techniques

1.2.2 Cut on the cost A cut can also be added to the value of the cost if it is to be an integer. Assume that the cost z of the relaxed solution (1.26) is not integer. (1.34)

E(z)  z

The canonical form (1.26) gives the expression of the cost z as a function of the non-basic variables xN . z −  cj x j = z

(1.35)

jN

Since the variables x must be positive, we deduce from (1.35) the inequality z −  E(cj )x j  z

(1.36)

jN

Since the variables x and the cost z must be integers, the first member of (1.36) must be an integer greater than z . If z is not an integer, the second member can be replaced by the higher whole number without changing the solution set. z −  E(cj )x j  E(z) + 1

(1.37)

jN

Let us replace in this inequality the cost z by its canonical expression (1.35) as a function of the non-basic variables xN : z = z +  cjx j . jN

By grouping the terms with the fractional part defined by (1.28), we obtain

 F(c )x j

jN

j

 1 − F(z)

(1.38)

This inequality constraint is a cut or truncation on the cost. If the relaxed problem cost z = z is not integer, the inequality (1.38) is not satisfied, because the nonbasic variables are zero whereas the second member is strictly positive. We can then resume the solution the relaxed problem by adding the constraint (1.38) to exclude the previous solution. This constraint can be reformulated by introducing a positive slack variable y.  = F(cj )  0 (1.39) −TN xN + y = − with  j  = 1 − F(z)  0 Returning to (1.37), the new constraint takes the form z −  E(cj )x j − y = E(z) + 1 jN

(1.40)

which shows that the new variable y is necessarily integer (because the other terms are all integers).

Mixed linear programming

15

1.2.3 Gomory’s method A cut on a variable or on the cost adds to the relaxed problem a new integer variable y and a new equality constraint (1.32) or (1.39) of the form (1.41)

−TN xN + y = −

The previous relaxed problem has been solved by the simplex method (Volume I, section 5.1.4). Its canonical form in the optimal basis B gives the simplex array T. xB I T= 0

xN B N b cNT − z −1

 x = b  0 , xN = 0 → solution  B  cN  0

(1.42)

Let us add the new variable y and the new constraint (1.41) to the simplex array.

xB

y

I T' = 0

0 1

0

0

xN B−1N b − TN − cNT

(1.43)

−z

We observe that the new problem is directly in canonical form in the basis formed x = b  0 by the variables (xB , y) . The corresponding basis solution is:  B .  y = −  0 The variable y is negative, because the previous relaxed solution does not satisfy the added cutting constraint. The base (xB , y) is therefore not primal-feasible. On the other hand, it is dual-feasible, as the reduced costs are positive: cN  0 . We can therefore apply the dual simplex algorithm (Volume I, section 5.1.8) directly from the base (xB , y) and the array T'.

Figure 1-2: Gomory’s method.

16

Optimization techniques

Gomory's method (1958) shown in figure 1-2 consists in solving the initial relaxed problem by the primal simplex algorithm. If the relaxed solution is not integer, a cutting constraint is added and the new problem is solved by the dual simplex algorithm. The addition of a cut is repeated until an integer solution is obtained. Example 1-2 illustrates the application of Gomory's method to the solution of a linear problem in integer variables.

Example 1-2: Gomory’s method

 3x1 + 2x2  6  = − min z x s.t. Consider the linear problem: −3x1 + 2x2  0 2 x1 ,x2  x1  , x2  This problem is put into standard form by adding 2 slack variables x3 , x4 . Since the inequality constraints have only integer terms, the variables x3 , x4 are also integer.  3x1 + 2x2 + x3 = 6  min z = − x2 s.t. −3x1 + 2x2 + x4 = 0 (problem P0) x1 ,x2  x1 , x2 , x3 , x4  x3 ,x4 The first stage is to solve the relaxed problem P 0r obtained by replacing integrity constraints with positivity constraints. Stage 0: solving the relaxed problem P0r by the primal simplex Initial array of P0r Basis: (x3 , x4 )

x = 6 Basis solution:  3  x4 = 0 The problem is directly in canonical form in the primal-feasible basis (x3 , x4 ) . We solve the relaxed problem P0r by the primal simplex algorithm.

Mixed linear programming

17

Pivoting 1: x4  x2 New basis: (x3 , x2 )

x = 6 Basis solution:  3  x2 = 0 Pivoting 2: x3  x1 New basis: (x1,x2 )

 x1 = 1  Basis solution:  3  x2 = 2 The solution of the relaxed problem P 0r is obtained. This solution is not integer 3 because of x2 . The next stage is to generate a cut excluding the solution x2 = , 2 and then solve the new relaxed problem with the cutting constraint. Stage 1: solving the relaxed problem P1r with a cut on x2 To generate a cut on x2 , we start from the solution array of the problem P0r. 1 1 3 The 2nd row gives x2 as a function of (x3 , x4 ) : x2 + x3 + x4 = (equality E1) 4 4 2 An inequality is generated from (E1). 1 1 3 (E1 )  x2 + E   x3 + E   x4  E    x2  1 4 4 2 1 1 3 Substituting x2 given by (E1), we obtain: − x3 − x4  1 − 4 4 2 1 1 1 which is rewritten with a slack variable x5 : − x3 − x4 + x5 = − (cut C1) 4 4 2 The new relaxed problem P1r is formed from P0r to which we add the variable x5 and the constraint C1. The simplex array of P1r is formed from the solution array of P0r by adding a column for x5 and a row for C1.

18

Optimization techniques

Initial array of P1r Basis: (x1, x2 , x5 ) Basis solution:  x1 = 1   x2 = 3/ 2  x5 = −1/ 2 The problem is directly in canonical form in the basis (x1, x2 , x5 ) .

This basis is not primal-feasible (x5  0) , but it is dual-feasible (positive reduced costs). We solve the relaxed problem P 1r by the dual simplex algorithm. Recall that the dual pivoting consists in choosing: - as entering variable the first negative basic variable:

be  0 , e  B ;

- as leaving variable the first non-basic variable to cancel: s → max jN aej 0

cNj aej

.

Pivoting 1: x5  x3

New basis: (x1, x2 , x3 ) Basis solution:  x1 = 2 / 3   x2 = 1  x3 = 2 The solution of the relaxed problem P 1r is obtained. This solution is not integer 2 because of x1 . The next stage is to generate a cut excluding the solution x1 = , 3 and then solve the new relaxed problem with the cutting constraint. Stage 2: solving the relaxed problem P2r with a cut on x1 To generate a cut on x1 , we start from the solution array of the problem P1r . 1 2 2 The 1st row gives x1 as a function of (x4 , x5 ) : x1 − x4 + x5 = (equality E2) 3 3 3 An inequality is generated from (E2).  1 2 2 (E2 )  x1 + E  −  x4 + E   x5  E    x1 − x4  0  3 3 3

Mixed linear programming

19

2 2 2 − x4 − x5  0 − 3 3 3 2 2 2 which is rewritten with a slack variable x6 : − x4 − x5 + x6 = − (cut C2) 3 3 3 Substituting x1 given by (E2), we obtain:

The new relaxed problem P2r is formed from P1r to which we add the variable x6 and the constraint C2. The simplex array of P2r is formed from the solution array of P1r by adding a column for x6 and a row for C2. Initial array of P2r Basis: (x1, x2 , x3 , x6 ) Basis solution:  x1 = 2 / 3  x2 = 1 x = 2  3  x6 = −2 / 3 The problem is directly in canonical form in the basis (x1, x2 , x3 , x6 ) .

This basis is not primal-feasible (x6  0) , but it is dual- feasible (positive reduced costs). We solve the relaxed problem P2r by the dual simplex algorithm. Pivoting 1: x6  x4 New basis: (x1, x2 , x3 , x4 )

 x1 = 1  x = 1 Basis solution:  2 x =1  3  x4 = 1 We obtain the solution of the relaxed problem P2r. This solution is integer and therefore gives the solution of the problem P 0. Its cost is z = −1 . Figure 1-3 shows the geometric interpretation of the cuts in the space of the original variables (x1,x2 ) . These cuts successively eliminate the non-integer solutions S0 and S1 (table 1-1) to end at the integer solution S2.

20

Optimization techniques

 3x + 2x2  6 Initial problem: min z = − x2 s.t.  1 x1 ,x2 −3x1 + 2x2  0 Cutting equations: - cut C1 :

x2  1 ;

x1 − x4  0  x1 − (3x1 − 2x2 )  0  − x1 + x2  0 .

- cut C2 :

Point S0 S1 S2

x1 1 2/3 1

x2 3/2 1 1

z −3/2 −1 −1

Table 1-1: Successive solutions. Figure 1-3: Cutting constraint effect.

The efficiency of Gomory's method depends on the choice and order of the cuts. If several cuts are possible, we can choose the one that produces the maximum increase in cost at the first pivoting. Let us retrieve the array T' (1.43) obtained by T adding a cut of the form: −N xN + y = − .

xB

y

I T' = 0

0 1

0

0

xN B−1N b − TN − cNT

(1.44)

−z

The variable y is the only negative basic variable. It will leave the basis at the first dual pivoting and be replaced by the first non-basic variable to cancel. cj The entering variable x j is determined by: max . jN − j − 0 j

This pivoting leads to the following cost change.

−z → − z −

cj − j

( − )

 z =

cj j

0

(1.45)

Mixed linear programming

21

This formula gives the cost increase at the first pivoting associated with the chosen cut (values of  ,  ). It can be used to select the most efficient initial cut, although this does not guarantee the final efficiency. If the cut is on the cost, the coefficients  are given by (1.39): j = F(cj ) . Since the entering variable satisfies: j  0 , its reduced cost is non-zero: cj  0 . The increase in cost at the first pivoting is given by

z =

cj j



 = F(cj )  0 with  j  = 1 − F(z)  0

(1.46)

This increase is strictly positive. It can be demonstrated that Gomory's method achieves an integer solution in a finite number of cuts, provided that these cuts induce a strict increase in the cost of the relaxed problem. The cut on the cost fulfils this condition. Despite this theoretical property of convergence, the number of cuts required can be exponential. Furthermore, the method is sensitive to rounding errors. For example, it will be necessary to decide whether a solution such as x = 1.0001 should be considered as integer or requires the addition of a cut. These numerical difficulties make the method ineffective on large problems. On the other hand, the principle of adding cuts is useful as a complement to the tree methods presented in section 1.3. These cuts constrain the relaxed problem and allow us to find better minorants of the optimal cost. Cuts on variables or on the cost are called simple cuts. Depending on the problem, stronger cuts can be generated as shown below.

1.2.4 Integral cut Let us retrieve the integer linear problem (LPI) and assume that the coefficients of the matrices/vectors A, b and c are integers.

Ax = b min z = cT x s.t.  n x x 

with A 

mn

, b

m

, c

n

(1.47)

The solution of the problem in canonical form is

xB = B−1b − B−1NxN

(1.48)

where B is the sub-matrix of A associated with the optimal basis and N is the submatrix of A associated with the non-basic variables xN .

22

Optimization techniques

Since the matrix B has integer coefficients, its determinant d = det(B) is integer 1 and its inverse B−1 is of the form: B−1 = B' , where B' is a matrix with integer d elements. The relaxed problem solution (1.48) is therefore rational of the form

xi = bi −  aijx j = jN

 i −  ij x j , i  B d jN d

(1.49)

where the coefficients ij , i ,d are all integers. Let [y]d be the integer congruent to y modulo d between 0 and d − 1 .

0  [y]d  d − 1 (1.50) with  k  For any integer p that is prime to d, the integer solution of problem (1.47) must satisfy the following inequalities called integral cuts. [y]d  y [d]  y = [y]d + kd

[p ] x jN

ij d

j

 [pi ]d , i  B

(1.51)

Demonstration (see [R15]) The basic variable xi given by (1.49) must take an integer value noted k.   xi = i −  ij x j = k   i −  ijx j = kd d jN d jN

Let us multiply each member by an integer p prime to d: pi −  pij x j = pkd. jN

p = [pi ]d + k1d By expressing pi and pij modulo d:  i , pij = [pij ]d + k2 jd the previous equality yields: [pi ]d −  [pij ]d x j = Kd jN

where K = pk − k1 +  k2 jx j is an integer (because the variables x j are integers). jN

In addition, we have [pi ]d  d − 1  [pi ]d − [pij ]d x j  d − 1  Kd  d − 1  K  0 [p ]  0 jN  ij d

from which the inequality (1.51) can be deduced: [pi ]d −  [pij ]d x j = Kd  0 . jN

Mixed linear programming

23

The basis solution defined by (1.49) is given by

xN = 0 , xi =

i , iB d

(1.52)

If this solution is not integer, then i is not divisible by d and [p i ]d  0 (because p is prime to d). The inequality (1.51) is not satisfied and allows to exclude this non-integer solution. Integral cuts on the cost can be defined in a similar way if the cost is to be integer. The canonical form of the cost is written in rational form

  −  j xj d jN d

z = z −  cjx j = jN

(1.53)

and the resulting cut is similar to (1.51) with (,  j ) replacing (i , ij ) . The integral cuts (1.51) allow to generate a set of inequalities by varying the value of the integer p, that must be prime to d = det(B) . The a priori most efficient cut is the one for which the second member [p i ]d is the largest.

1.2.5 Mixed cut Let us now consider a mixed-variable linear problem (LPM).

Ax = b  min z = c x s.t.  x j  , j  JE x  x j  0 , j  JC  T

, A

mn

, b

m

, c

n

(1.54)

The indices JE correspond to integer variables. The indices JC correspond to positive real (or continuous) variables. The solution of the problem is expressed in the canonical form as xi +  aij x j = bi , i  B

(1.55)

jN

The non-basic variables ( j  N) are split into 4 subsets: - the integer variables are split into J+E and J−E ; - the real variables are split into JC+ and JC− . These subsets are defined according to the signs of the coefficients as follows.

 =  j N

 , F(a )  F(b )

J+E = j  N JE , F(aij )  F(bi ) J−E

JE

ij

i

, JC+ =  j  N JC , aij  0

, JC− =  j  N JC , aij  0

(1.56)

24

Optimization techniques

The solution of problem (1.54) must satisfy the following mixed cuts.

1 − F(aij )

 F(a )x +  F(b ) 1 − F(b ) x jJ−E

ij

j

jJE+

i

i

j

F(bi ) +  aij x j −  aij x j  F(bi ) , i  B JE + − 1 − F(b ) jJC jJC i

(1.57)

Demonstration (see [R15]) Let us first assume that each subset J+E , J−E , JC+ , JC− contains only one non-basic

variable and consider the canonical form of a basic variable x0 , which has to be integer. This canonical form is written as the following equality E 1. x , x , x  x0 + a1x1 + a2 x2 + y1 − y2 = b0 with  0 1 2 and F(a2 ) − F(b0 ) + F(a1 ) + − + − JE JE JE JE JC JC  y1 , y2  0 (equality E1)

 x0 + a1x1 + a2 x2 − y2  b0 because y1  0

 x0 +  E(a1 ) + F(a1 ) x1 + E(a2 ) + 1 − (1 − F(a2 ) ) x2  b0 + y2

 x0 + E(a1 )x1 + E(a2 ) + 1 x2  b0 + y2 + 1 − F(a2 ) x2 because F(a1 )x1  0 The first member of the above inequality is an integer denoted z.

z = x0 + E(a1 )x1 + E(a2 ) + 1 x2 

 z − b0  y2 + 1 − F(a2 ) x2 (inequality I1) If z  E(b0 ) , the inequality I1 is satisfied. Indeed, the first member is negative and the second member is positive because x2  0 , y2  0 . If z  E(b0 ) + 1 , we transform the inequality I1 as follows.

z − E(b0 ) + 1 + 1 − F(b0 )  y2 + 1 − F(a2 ) x2



z −  E(b0 ) + 1 y + 1 − F(a2 )  x2 +1  2 (dividing by 1 − F(b0 ) that is positive) 1 − F(b0 ) 1 − F(b0 )

 z −  E(b0 ) + 1 + 1 

y2 + 1 − F(a2 )  x2 1 − F(b0 )

z −  E(b0 ) + 1 z  E(b0 ) + 1   z −  E(b0 ) + 1 because  1 − F(b0 ) 1 − F(b0 )  1  z  E(b0 ) +

y2 + 1 − F(a2 )  x2 1 − F(b0 )

(inequality I2)

Mixed linear programming

25

Note that I2 established for z  E(b0 ) + 1 is also satisfied for z  E(b0 ) . Let us return to the initial variables: z = x0 + E(a1 )x1 +  E(a2 ) + 1 x2

 x0 + E(a1 )x1 +  E(a2 ) + 1 x2  E(b0 ) +

y2 + 1 − F(a2 )  x2 1 − F(b0 )

 1 − F(a2 )  1  x0 + E(a1 )x1 + E(a2 ) + 1 − y2  E(b0 )  x2 − 1 − F(b0 )  1 − F(b0 )  Let us replace x0 = b0 − a1x1 − a2 x2 − y1 + y2 given by the equality E1.   1 − F(a2 )  1   b0 +  E(a1 ) − a1  x1 + E(a2 ) − a2 + 1 −  x2 − y1 + 1 −  y2  E(b0 ) 1 − F(b0 )    1 − F(b0 )  1 − F(a2 ) F(b0 )  F(a1 )x1 + F(b0 ) x2 + y1 + y2  F(b0 ) (inequality I3) 1 − F(b0 ) 1 − F(b0 ) In the equality E1 considered at the beginning of the demonstration: - y1  0 is a real non-basic variable + aijx j such that aij  0 (set JC+ ); - y2  0 is a real non-basic variable − aijx j such that aij  0 (set JC− ). The inequality I3 thus corresponds well to the inequality (1.57) for the basic variable x0 when each subset J+E , J−E , JC+ , JC− contains only one variable. In the case where the subsets J+E , J−E , JC+ , JC− contain several variables, the previous

demonstration applies identically by replacing the terms in x1 ,x2 , y1 , y2 by the corresponding sums on J+E , J−E , JC+ , JC− . We then obtain the general form (1.57) which applies to each basic variable that must be integer. 1 − F(aij ) F(bi )   F(aij )x j +  F(bi ) x j +  aijx j −  aijx j  F(bi ) , i  B JE − + + − 1 − F(b ) 1 − F(b ) jJE jJE jJC jJC i i

The basis solution defined by (1.49) is given by xN = 0 , xi = bi , i  B

(1.58)

If this solution is not integer, then F(bi )  0 . The inequality (1.51) is not satisfied and allows to exclude this non-integer solution. The mixed cuts (1.57) are defined directly from the simplex array and apply to any mixed-variable linear problem. Example 1-3 compares the efficiency of the simple, integral and mixed cuts.

26

Optimization techniques

Example 1-3: Simple, integral and mixed cuts (from [R15]) Consider the problem: min z = − x1 − x2 x1 ,x2

−6x1 + 4x2  1  6x1 − 8x2  9  s.t.  2x1 + 4x2  13    x1  , x2 

This problem is put into standard form by introducing 3 slack variables x3 , x4 , x5 Since the constraints have only integer terms, the slack variables are also integer. −6x1 + 4x2 + x3 = 1   6x1 − 8x2 + x4 = 9 (problem P0) min z = − x1 − x2 s.t.  x1 ,x2 2x1 + 4x2 + x5 = 13  x3 ,x4 ,x5   x1 , x2 , x3 , x4 , x5  The relaxed problem P0r associated with the problem P0 is solved by the primal simplex. Initial array of P0r Basis: (x3 , x4 , x5 )

x = 1

3 Basis solution:   x4 = 9

  x5 = 13

Pivoting 1: x3  x2 New basis: (x2 , x4 , x5 ) Basis solution:  x2 = 1/ 4   x4 = 11   x5 = 12 Pivoting 2: x5  x1 New basis: (x2 , x4 , x1 ) Basis solution:  x2 = 5 / 2   x4 = 20   x1 = 3/ 2

Mixed linear programming

27

Pivoting 3: x4  x3

New basis: (x2 , x3 , x1 ) Basis solution:  x2 = 3/ 2   x3 = 16   x1 = 7 / 2 The solution of the relaxed problem P0 is not integer because of x1 and x2 . The last simplex array gives the canonical form of the solution in terms of the nonbase variables (x4 , x5 ) .

1 1 7   x1 + 10 x4 + 5 x5 = 2  1 3 3  x2 − x4 + x5 = 20 20 2 

→ equality E1 → equality E2

Figure 1-4 shows in the plane (x1, x2 ) the feasible domain limited by the three constraints and the two axes. The relaxed solution corresponds to the vertex of the polytope located at R. There are 5 integer solutions in the feasible domain (marked by points) and the optimal integer solution is at E. Relaxed solution

 x = 3.5

1 → z = −5 R:   x2 = 1.5

Integer solution

x = 2

1 → z = −4 E:  x  2 =2

Figure 1-4: Relaxed and integer solution. The equalities E1 and E2 are now used to generate successively simple, integral or mixed cuts in order to compare their efficiency.

28

Optimization techniques

Simple cuts Simple cuts are of the form:

 F(a )x jN





ij

j

 F(bi ) .

1 1 1 x4 + x5   x1  3 10 5 2 We add a slack variable and the cutting constraint to the solution array of P0, and then solve the new problem by the dual simplex. x = 3 The new relaxed solution is:  1 → z = −4.75  x2 = 1.75 19 3 1 a cut on x2 yields: x4 + x5   6x1 − 7x2  10 20 20 2 We add a slack variable and the cutting constraint to the solution array of P0, and then solve the new problem by the dual simplex.  x = 3.45 The new relaxed solution is:  1 → z = −4.98  x2 = 1.53 a cut on x1 yields:

These simple cuts are shown in dotted lines in figure 1-5. They reduce the feasible domain very little and improve the relaxed solution only slightly.

Figure 1-5: Simple cuts.

Mixed linear programming

29

Integral cuts Integral cuts are of the form:

[p ] x jN

ij d

j

 [pi ]d with an integer p prime to d.

d is the determinant of the basis matrix B and corresponds to the denominator of the equations E1 or E2 . 1 1 7 • for a cut on x1 : x1 + x4 + x5 = → x4 + 2x5  5 d = 10 . 10 5 2 If we take p = 1 : p = 1 → x4 + 2x5  5  x1  3 . •

We retrieve the previous simple cut that was obtained for x1 ; 1 3 3 for a cut on x2 : x2 − x4 + x5 = → x4 + 17x5  10 d = 20 . 20 20 2 If we take p = 1 : p = 1 → x4 + 17x5  10  2x1 + 3x2  11 .  x = 3,38 The new relaxed solution is:  1 → z = −4,79 .  x2 = 1, 41 If we take p = 3 : p = 3 → 3x4 + 11x5  10  2x1 + x2  8 .  x = 3.17 The new relaxed solution is:  1 → z = −4.83 .  x2 = 1.67

These integral cuts on x2 are shown in dotted lines in figure 1-6. They reduce the feasible domain very little and improve the solution only slightly.

Figure 1-6: Integral cuts.

30

Optimization techniques

Mixed cuts Mixed cuts are of the form:

 F(a )x +  jJE−

ij

j

jJE+

F(bi ) (1 − F(aij ) ) 1 − F(bi )

x j  F(bi ) .

All non-basic variables are integer: JE = 4 , 5 , JC =  .

1 1 7 1 x4 + x5 = → F(a14 ), F(a15 )  F(b1 ) = . 10 5 2 2 1 1 1 J−E = 4 , 5 , J+E =  → x4 + x5   x1  3 10 5 2 We retrieve the previous simple cut that was obtained for x1 ; 1 3 3 1 • cut on x2 : x2 − x4 + x5 = → F(a25 )  F(b2 ) =  F(a24 ) . 20 20 2 2 3 1 1 J−E = 5 , J+E = 4 → x5 + x4   6x1 + 2x2  19 20 20 2  x = 2.5 The new relaxed solution is:  1 → z = −4.5 .  x2 = 2 This mixed cut on x2 is shown in dotted lines in figure 1-7. It restricts the feasible domain much more than the simple or integral cuts and produces therefore a stronger improvement in the relaxed solution. •

cut on x1 :

x1 +

Figure 1-7: Mixed cut.

Mixed linear programming

31

1.3 Tree methods Tree methods explore the set of possible combinations of integer values. The evaluation of relaxed solutions allows for the elimination of subsets and avoids examining the complete tree of possibilities.

1.3.1 Implicit enumeration Consider a linear problem in binary variables, denoted (LPB).

Ax = b min z = cT x s.t.  n x  x  U , U = 0 ; 1

(1.59)

The set of possible combinations X = Un is finite with cardinal Card(X) = 2n . Explicit enumeration consists of evaluating each of the 2n elements of X. This method is guaranteed to find the optimum, but quickly has limitations as the problem size increases. For n = 60 , and evaluating one billion solutions per second, it would take 30 years of computation to obtain the solution. The binary formulation of an integer problem with the decomposition (1.3) leads to thousands of binary variables. Explicit enumeration is then no longer possible. Implicit enumeration consists in partitioning the set X by forming a tree of possibilities (separation stage), and then moving down the tree by eliminating nonoptimal branches (evaluation stage). Elimination reduces the number of possibilities to be examined, while ensuring that the optimal solution is found. These methods are called tree methods or branch and bound methods.

1.3.2 Separation The set X of possibilities is defined by



X = x  Un



(1.60)

Each component of x can take the value 0 or 1. The set X is partitioned into 2 subsets by setting x1 to 0 or 1. This first level partition has 21 subsets noted X0 and X1 .

X0 = x  X , x1 = 0 , X1 = x  X , x1 = 1

(1.61)

32

Optimization techniques

Both subsets X0 , X1 are in turn partitioned into 2 subsets by setting x2 to 0 or 1. This second level partition has 22 subsets noted X00 , X01 , X10 and X11 .

X00 = x  X , x1 = 0 , x2 = 0 , X10 = x  X , x1 = 1 , x2 = 0 X01 = x  X , x1 = 0 , x2 = 1 , X11 = x  X , x1 = 1 , x2 = 1

(1.62)

The partitioning continues until the last variable xn . The final partition at level n has 2n single element subsets. Each element is one of the possible combinations of the set X . Figure 1-8 schematizes the first level partition. The set X is separated into two subsets X0 and X1 : - X is the predecessor or parent of X0 and X1 ; - X0 and X1 are the successors or children of X .

Figure 1-8: First level partition. The successive partitions form a tree structure. Each subset X, X0 ,X1,X10 ,X11, is a vertex (or node) of the tree. The vertices of successive levels are connected by arrows indicating inclusion. The initial set X (corresponding to level 0) is the root of the tree structure. The vertices of level n (containing only 1 element) are the terminal vertices. The tree is composed of n + 1 levels. The level k has 2k vertices. The total number of vertices is 2n+1 − 1 . Figure 1-9 shows a tree structure with 3 binary variables x1 , x2 , x3 .

The eight terminal vertices X000 ,X001,X010 ,X011,X100 ,X101,X110 ,X111 represent the eight possible combinations of values of x1 , x2 , x3 .

Mixed linear programming

33

Figure 1-9: Tree of possibilities. The separation procedure presented above concerns binary variables, which are set to 0 or 1. For an integer variable x j , the procedure consists in choosing an integer threshold j and separating the vertex X into a vertex X− associated with the values x j  j and a vertex X+ associated with the values xj  j + 1 . Each vertex is thus associated with a variation interval of x j which will be reduced as the separations are made. This procedure is more complex to implement than reformulating the problem in binary variables, but it can be much more effective in eliminating possibilities.

1.3.3 Evaluation Let us note z* the optimal cost of the problem (LPB) we are trying to solve.

Ax = b min z = cT x s.t.  n x  x  U , U = 0 ; 1

(1.63)

The optimal cost z* is not known (we are looking for it). Suppose we know a feasible solution of (LPB) of cost za . This binary solution satisfies the constraints. Its cost za is a majorant of the optimal cost z* of (LPB).

34

Optimization techniques

A vertex S of level k in the tree corresponds to the problem (1.63) with the first k variables set to 0 or 1. The problem (LPB)S associated with vertex S has n − k binary variables and its (unknown) optimal cost is denoted zS .

Ax = b  min z = cT x s.t.  x  Un x  x1 , x1 , , xk fixed

(PLB)S

(1.64)

The (LPB)S problem cannot be solved directly in binary variables. However, it is possible to solve the relaxed problem (LPR)S obtained by changing the integrity constraints x j  U into positivity constraints x j  0 .

Ax = b  min z = cT x s.t.  x  0 x  x1 , x1 , , xk fixed

(PLR)S

(1.65) r

This problem is solved by the simplex method. Its cost zS is lower than zS because the relaxed problem (LPR)S is less constrained than the binary problem (LPB)S. r The relaxed cost zS is a minorant of the cost of (LPB)S, but also of all problems derived from (LPB)S by fixing additional variables xk+1,xk+2 ,

. A solution with

r a cost lower than zS cannot be found by exploring the vertices from S. r

Suppose that this relaxed cost zS is greater than the known value za , associated with a feasible solution of (LPB). For any vertex S' derived from S, we have:

z*  za  zSr  zS'

(1.66)

It is then useless to explore the vertices below S, because they cannot give any binary solution with a cost lower than za . We can thus eliminate completely this part of the tree. Any minorant of the problem cost (LPB)S is called the valuation of the vertex S. The efficiency of the evaluation depends on the quality of the minorant. A high minorant favors the elimination of branches from the tree. The evaluation function is usually the relaxed problem cost (RPC)S as above (1.65). This minorant is simple to obtain by the simplex method, and its computation can be accelerated by using the solution of the parent vertex (warm start procedure). Suppose indeed that the relaxed problem of the parent vertex P has been solved by the simplex method. Its canonical form in the optimal basis B is known and

Mixed linear programming

35

it corresponds to the following array. xB I T= 0

xN B N b cNT − z −1

→ xB + B−1NxN = b x = b → solution  B T → cN xN = z − z  xN = 0

(1.67)

The separation of the vertex P consists either in fixing a binary variable or in adding an inequality constraint on an integer variable. Let us examine these two possibilities. Separation on a binary variable Assume that the vertex is separated by setting the binary variable xe to 0 or 1. (1.68)

xe =  with  = 0 or 1

If this variable is in the basis B, we start by forcing a dual pivoting with a nonbasic variable xs . By making the variables xe and xs appear explicitly in the array T (1.67), we have the form

xB I T= 0 0

xe 0 1 0

x N xs B−1N ais aej aes T cN cs

b be −z

(1.69)

Since the basis B is optimal for the parent problem, the reduced costs and the basic variables are all positive. The variable xs for the dual pivoting is chosen by

s → max

cNj aej

for j  N such that aej  0

(1.70)

The reduced costs and basic variables become

cj → cj − cs

aej aes

, bi → bi − be

ais aes

(1.71)

By construction, this dual pivoting keeps the reduced costs positive. On the other hand, the basic variables may become negative, as the purpose of this forced pivot is to move the variable xe out of the basis. After this pivoting, we find ourselves with a dual-feasible basis (positive reduced costs) and the non-basic variable xe which we wish to fix at the value  (0 or 1).

36

Optimization techniques

The resulting array is of the form xB x N xe −1 I B N aie T' = 0 cNT ce

b −z

(1.72)

Next, let us perform the change of variable: x 'e = xe −  . The objective is that the new non-basic variable x 'e is set to 0, which corresponds to its value in the basis solution of the array T'. With this change of variable, the constraints and cost become

xi +  aijx j + aie xe = bi

 xi +  aijx j + aie x'e = bi − aie 

z −  cj x j − ce xe = z

 z −  cj x j − ce x'e = z + ce 

jN j e

jN j e

jN j e

(1.73)

jN j e

We can then form the simplex array with this new canonical form xB xN x 'e I B−1N aie T '' = 0 cNT ce

b − aie  − z + ce

(1.74)

then remove the non-basic variable x 'e which must remain set to 0. This new problem associated to the vertex S (variable xe fixed) is in canonical form in the basis B which is dual-feasible (positive reduced costs). It is therefore ready to be solved by the dual simplex algorithm. Example 1-4 illustrates the separation-evaluation procedure on a binary variable problem.

Example 1-4: Separation-evaluation with binary variables (after [R15]) Consider the linear problem with 6 binary variables

min z = −20x1 − 16x2 − 11x3 − 9x4 − 7x5 − x6

x1 ,x2 ,x3 x4 ,x5 ,x6

 9x + 8x2 + 6x3 + 5x4 + 4x5 + x6  12 s.t.  1  x j = 0 or 1 , j = 1 to 6

Mixed linear programming

37

This problem is of the knapsack type (section 1.4.5).

min z =  cjx j s.t. x jU

j

a x j

j

j

b

The variables are numbered in order of increasing utility (ratios cj/aj). There are 26 = 64 possible combinations. The tree has 7 levels and a total of 27 − 1 = 127 vertices. A tree-search method is applied with a depth exploration strategy: - the vertices are treated in increasing valuation (best vertex first); - the variables are treated in increasing utility (= in their numbered order). Initialization: initial feasible solution The initialization stage aims at building a feasible solution. This is not always possible in a simple way when there are many constraints. For this knapsack problem, we apply a greedy method by taking the variables in order of increasing utility and setting them to 1 if possible (as long as the constraint remains satisfied). This yields the following initial solution: x1 = 1 , x2 = x3 = x4 = x5 = 0 , x6 = 1 whose cost is: za = −21 . This value is a majorant of the cost of the binary problem: z*  za . Iteration 0: vertex X (root of the tree) The relaxed problem associated with the vertex X is min z = −20x1 − 16x2 − 11x3 − 9x4 − 7x5 − x6 x1 ,x2 ,x3 x4 ,x5 ,x6

 9x + 8x2 + 6x3 + 5x4 + 4x5 + x6  12 s.t.  1  x j  0 , j = 1 to 6 3   x1 = 1 , x2 = → z = −26 The solution is:  8  x x x x 0 = = = = 4 5 6  3 This solution is not feasible, as the variable x2 is not binary. The valuation of X is −26. The vertex X is separated by setting the variable x1 to 0 (vertex X0 ) or 1 (vertex X1 ).

38

Optimization techniques

Iteration 1: vertex X0 The relaxed problem associated with the vertex X0 (x1 = 0) is

 8x + 6x3 + 5x4 + 4x5 + x6  12 min z = −16x2 − 11x3 − 9x4 − 7x5 − x6 s.t.  2 x2 ,x3 ,x4  x j  0 , j = 2 to 6 x5 ,x6

2  70  x2 = 1 , x3 =  −23.3 The solution of this problem is:  3 → z=− 3  x x x 0 = = = 5 6  4 This solution is not feasible, as the variable x3 is not binary. The valuation of X0 is −23.3 and it is lower than the reference za = −21 . The vertex is retained. Iteration 1: vertex X1 The relaxed problem associated with the vertex X1 (x1 = 1) is

 8x + 6x3 + 5x4 + 4x5 + x6  12 min z = −16x2 − 11x3 − 9x4 − 7x5 − x6 s.t.  2  x j  0 , j = 2 to 6

x2 ,x3 ,x4 x5 ,x6

This problem has the same solution as the problem of the root vertex X . This is logical, as the relaxed solution of X already gave: x1 = 1 . The valuation of X1 is −26 and it is lower than the reference za = −21 . The vertex is retained. The exploration of the tree at iteration 1 is shown in figure 1-10.

Figure 1-10: Exploration at iteration 1. The best vertex is X1 (lowest valuation). This vertex is separated by setting the variable x2 to 0 (vertex X10) or to 1 (vertex X11).

Mixed linear programming

39

Iteration 2: vertex X10 The relaxed problem associated with the vertex X10 (x1 = 1, x2 = 0) is

 6x + 5x4 + 4x5 + x6  3 min z = −11x3 − 9x4 − 7x5 − x6 − 20 s.t.  3 x3 ,x4 ,x5 ,x6  x j  0 , j = 3 to 6 1  51 x = → z = −  −25.5 The solution of this problem is:  3 2 2   x4 = x5 = x6 = 0 This solution is not feasible, as the variable x3 is not binary. The valuation of X10 is −25.5 and it is lower than the reference za = −21 . The vertex is retained. Iteration 2: vertex X11 The relaxed problem associated with the vertex X11 (x1 = 1, x2 = 1) is

 6x + 5x4 + 4x5 + x6  −5 min z = −11x3 − 9x4 − 7x5 − x6 − 36 s.t.  3  x j  0 , j = 3 to 6 The constraint cannot be satisfied because the variables are positive. This problem has no solution. The valuation + is assigned to X11 . The exploration stops at this vertex which contains no feasible solution. x3 ,x4 ,x5 ,x6

The exploration of the tree at iteration 2 is shown in figure 1-11.

Figure 1-11: Exploration at iteration 2. The best vertex is X10 (lowest valuation). This vertex is separated by setting the variable x3 to 0 (vertex X100 ) or 1 (vertex X101 ).

40

Optimization techniques

Iteration 3: vertex X100 The relaxed problem associated with the vertex X100 (x1 = 1, x2 = 0, x3 = 0) is

 5x + 4x5 + x6  3 min z = −9x4 − 7x5 − x6 − 20 s.t.  4 x4 ,x5 ,x6  x j  0 , j = 4 to 6 3 127 The solution of this problem is: x4 = , x5 = x6 = 0 → z = −  −25.4 5 5 This solution is not feasible, as the variable x4 is not binary. The valuation of X100 is −25.4 and it is lower than the reference za = −21 . The vertex is retained. Iteration 3: vertex X101 The relaxed problem associated with the vertex X101 (x1 = 1, x2 = 0, x1 = 0) is

 5x + 4x5 + x6  −3 min z = −9x4 − 7x5 − x6 − 31 s.t.  4 x4 ,x5 ,x6  x j  0 , j = 4 to 6 The constraint cannot be satisfied because the variables are positive. This problem has no solution. The valuation + is assigned to X101 . The exploration stops at this vertex which contains no feasible solution. The following iterations are summarized in table 1-2. Figure 1-12 shows the result of the complete exploration of the tree structure. The optimal solution was obtained by evaluating the vertex X0100 .

 x2 = x5 = 1  x = x = x = x = 0 → z = −23 3 4 6  1 This solution is confirmed at the end of the exploration, which requires the evaluation of only 19 vertices out of the 127 in the tree structure.

Mixed linear programming

Table 1-2: Summary of the iterations.

Figure 1-12: Exploration of the tree structure.

41

42

Optimization techniques

Separation on an integer variable Now consider the separation on an integer variable xe . The solution of the parent problem P gave the canonical expression for the variable xe .

xe +  aejx j = be

(1.75)

jN

Assume that the basis solution takes a non-integer value: be  . The vertex P is then separated by adding on the one hand the inequality constraint: xe  E() and on the other hand the inequality constraint: xe  E() + 1 . − The inequality xe  E() is changed to equality with a slack variable y  0 .

 xe +  aej x j = be  jN   xe + y− = E(be )

 y− −  aejx j = −F(be )

(1.76)

jN

+ The inequality xe  E() + 1 is changed to equality with a slack variable y  0 .

 xe +  aejx j = be  jN  y+ +  aej x j = F(be ) − 1  + jN  xe − y = E(be ) + 1

(1.77)

T In both cases, the new constraint is of the form: y + N xN =  ,   0 .

The simplex array T of the parent vertex P (1.67) is completed with the new variable and the new constraint to give the array T' of vertex S.

xB I T = 0

xN B−1N b cNT − z

⎯⎯ →

T' =

xB

y

xN

I 0

0 1

B−1N TN

b 

0

0

cNT

−z

(1.78)

The new problem is in canonical form in the basis (xB , y) . This basis is not primal-feasible, because the variable y takes the negative value  . On the other hand, it is dual-feasible, because the reduced costs resulting from the solution of the vertex P are all positive. The new problem associated to the vertex S (with the constraint inequality on the variable xe ) is thus ready to be solved by the dual simplex algorithm. Example 1-5 illustrates the separation-evaluation procedure on a problem in integer variables, detailing the dual simplex solution procedure.

Mixed linear programming

43

Example 1-5: Separation-evaluation in integer variables

7x1 − 2x2  14  s.t.  x2  3 1 2  2x1 − 2x2  3 The problem is put into standard form with 3 positive slack variables x3 , x4 , x5 . Note that these variables and the cost will be integers. The problem in standard form is 7x1 − 2x2 + x3 = 14  min z = −4x1 + x2 s.t.  x2 + x4 = 3 x1 ,x2  2x1 − 2x2 + x5 = 3 x3 ,x4 ,x5 0 Consider the problem: min z = −4x1 + x2 x ,x 

A tree-search method is applied with a depth exploration strategy: - the vertices are treated in increasing valuation (best vertex first); - the variables are treated in numbered order.

Iteration 0: vertex X (root of the tree) The relaxed problem associated with the vertex X is 7x1 − 2x2 + x3 = 14  min z = −4x1 + x2 s.t.  x2 + x4 = 3 x1 ,x2 ,x3 ,x4 ,x5 0 2x1 − 2x2 + x5 = 3 We form the simplex array of this relaxed problem. Initial array Basis: (x3 , x4 , x5 )

 x3 = 14  Basis solution:  x4 = 3   x5 = 3 The problem is directly in canonical form in the basis (x3 , x4 , x5 ) which is primalfeasible. We solve the relaxed problem of X by the primal simplex algorithm.

44

Optimization techniques

Pivoting 1: x5  x1

New basis: (x3 , x4 , x1 ) Basis solution:  x3 = 7 / 2   x4 = 3  x1 = 3/ 2 Pivoting 2: x3  x2

New basis: (x2 , x4 , x1 ) Basis solution:  x2 = 7 /10   x4 = 23/10  x1 = 11/ 5 Pivoting 3: x4  x5 New basis: (x2 , x5 , x1 ) Basis solution:  x2 = 3   x5 = 23/ 7  x1 = 20 / 7

20 59 , x2 = 3 → z = − . 7 7 This solution is not feasible, as the variable x1 is not integer. The solution is: x1 =

 59  The valuation of X (−59/7) gives a minorant of the cost: z*  E  −  + 1 = − 8.  7  The vertex X is separated by imposing a constraint on the variable x1 :  20  - x1  E   = 2 → vertex X0 ;  7   20  - x1  E   + 1 = 3 → vertex X1 .  7  These constraints are expressed from the canonical form of the solution of X 1 2 20 x1 + x3 + x4 = and introducing a positive slack variable x6 . 7 7 7

Mixed linear programming

45

Iteration 1: vertex X0

1 2 6  x6 − x3 − x4 = − 7 7 7 The new variable and the associated constraint are added to the simplex array. The constraint x1  2 yields: x1 + x6 = 2

Solution array of X Optimal basis: (x2 , x5 , x1 )

Initial array of X0 Initial basis:

(x2 , x5 , x1, x6 )

The problem is directly in canonical form in the basis (x2 , x5 , x1, x6 ) . This basis is not primal-feasible (x6  0) , but it is dual- feasible (positive reduced costs). The relaxed problem of X0 is solved by the dual simplex algorithm. Initial array Basis: (x2 , x5 , x1, x6 ) Basis solution:  x2 = 3  x5 = 23/ 7   x = 20 / 7  1   x6 = −6 / 7

46

Optimization techniques

Pivoting 1: x6  x4 New basis:

(x2 , x5 , x1, x4 )

 x2 = 0  x = −1 Basis solution:  5 x =2  1  x4 = 3 Pivoting 2: x5  x3 New basis:

(x2 , x3 , x1, x4 )

Basis solution:  x2 = 1/ 2  x3 = 1 x = 2  1  x4 = 5 / 2

1 15 → z=− . 2 2 This solution is not feasible, as the variable x2 is not integer. The solution is: x1 = 2 , x2 =

 15  The solutions contained in X0 have a cost bounded by: z*  E  −  + 1 = − 7.  2 Iteration 1: vertex X1

1 2 1 x3 + x4 = − . 7 7 7 The new variable and the associated constraint are added to the simplex array. The constraint x1  3 yields: x1 − x6 = 3

Solution array of X Optimal basis: (x2 , x5 , x1 )

 x6 +

Mixed linear programming

47

Initial array of X1 Initial basis:

(x2 , x5 , x1, x6 )

The problem is directly in canonical form in the basis (x2 , x5 , x1, x6 ) , which is dual-feasible. The leaving variable is x6 (only negative basic variable). No dual

pivoting is possible, because there is no negative coefficient on the row of x6 . This means that the problem X1 has no solution (incompatible constraints). 1 2 1 Indeed, the constraint: x6 + x3 + x4 = − cannot be satisfied ( x  0 ). 7 7 7 The tree under X1 is no longer explored, as it does not contain any solutions. The exploration of the tree at iteration 1 is shown in figure 1-13.

Figure 1-13: Exploration at iteration 1.

The only vertex to separate is X0 . It is therefore known that the solutions have a cost lower bounded by −7. Moreover, no feasible solution is yet known. 1 The vertex X0 is separated by a constraint on the non-integer variable x2 = : 2 1 - x2  E   = 0 → vertex X00 ; 2

1 - x2  E   + 1 = 1 2

→ vertex X01 .

48

Optimization techniques

These constraints are expressed from the canonical form of the solution of X0 1 1 and introducing a positive slack variable x7 . x2 − x5 + x6 = 2 2 Iteration 2: vertex X00

1 1 x5 − x6 = − . 2 2 The new variable and the associated constraint are added to the simplex solution array. It would be possible to remove the fixed variable x2 = 0 from the array, but for this illustrating example, the complete array with all variables is kept. The constraint x2  0 yields: x2 + x7 = 0

 x7 +

Solution array of X0 Optimal basis:

(x2 , x3 , x1, x4 )

Initial array of X00 Initial basis:

(x2 , x3 , x1, x4 , x7 )

The problem is directly in canonical form in the basis (x2 , x3 , x1, x4 , x7 ) .

This basis is not primal-feasible (x7  0) , but it is dual-feasible (positive reduced costs). The relaxed problem of X00 is solved by the dual simplex algorithm.

Mixed linear programming

Initial array Basis:

(x2 , x3 , x1, x4 , x7 )

Basis solution:  x2 = 1/ 2  x3 = 1   x1 = 2  x4 = 5 / 2  x = −1/ 2  7

Pivoting 1: x7  x6 New basis:

(x2 , x3 , x1, x4 , x6 )

Basis solution:  x2 = 0  x3 = 7 / 2   x1 = 3/ 2  x4 = 3  x = 1/ 2  6

3 , x2 = 0 → z = −6 . 2 This solution is not feasible, as the variable x1 is not integer. The solutions contained in X00 have a cost lower bounded by −6. The solution is: x1 =

Iteration 2: vertex X01

1 1  − x5 + x6 + x7 = − 2 2 The new variable and the associated constraint are added to the simplex array. The constraint x2  1 yields: x2 − x7 = 1

Solution array of X0 Optimal basis:

(x2 , x3 , x1, x4 )

49

50

Optimization techniques

Initial array of X01 Initial basis:

(x2 , x3 , x1, x4 , x7 )

The problem is directly in canonical form in the basis (x2 , x3 , x1, x4 , x7 ) .

This basis is not primal-feasible (x7  0) , but it is dual- feasible (positive costs). The relaxed problem of X01 is solved by the dual simplex algorithm. Initial array Basis:

(x2 , x3 , x1, x4 , x7 )

Basis solution:  x2 = 1/ 2  x3 = 1   x1 = 2  x4 = 5 / 2  x = −1/ 2  7

Pivoting 1: x7  x5 New basis:

(x2 , x3 , x1, x4 , x5 )

Basis solution:  x2 = 1  x3 = 2   x1 = 2  x4 = 2 x = 1  5

The solution is: x1 = 2 , x2 = 1 → z = −7 . This solution is feasible (integer variables) so that there is no need to explore the tree beyond X01 . The feasible solution gives a majorant of the cost: z*  za =− 7.

Mixed linear programming

51

Table 1-3 recaps the vertices explored at iteration 2. The tree structure is shown in figure 1-14.

Vertex

Solution

Cost

X

non-integer

−8  z*

X0

non-integer

−7  z*

X1

non-feasible

X00

non-integer

−6  z*

X01

integer za = −7

z*  −7

Table 1-3: Vertices explored at iteration 2.

Figure 1-14: Exploration at iteration 2.

The feasible solution found at X01 gives the reference cost za =− 7 . All vertices with a valuation greater than za are eliminated, as their valuation is a minorant of the cost of the solutions they may contain. The exploration of the vertex X00 can thus be stopped. There are no more vertices left to separate and the exploration of the tree is finished. The solution was obtained by evaluating the vertex X01 : x1 = 2 , x2 = 1 → z = −7 . The exploration involved the assessment of only 4 vertices.

1.3.4 Exploration strategy The exploration of the tree structure requires to store the list L = Xi  of vertices to explore, called active vertices. Each active vertex is stored with its relaxed solution (canonical form, variables and cost). The cost of the relaxed solution is the evaluation of the vertex. In addition, the reference cost za of the best known feasible solution is also stored. The exploration is initialized with the root vertex L = X and the reference value

za = + (if no feasible solution is known). An iteration consists in processing a

vertex and updating the list L.

52

Optimization techniques

Each iteration involves the following stages. •

choice of the vertex Xi  L to be separated;



choice of the non-integer (or non-binary) variable x j to constrain (or to fix);



separation of the vertex Xi on the variable x j . The 2 child vertices Xi0 and Xi1 are added to the list L. The parent vertex Xi is removed from the list L;



evaluation of the vertex Xi0 giving a relaxed solution x0 cost z0 . The assessment leads to the following three possibilities: • if the relaxed solution x0 is feasible (integer or binary), the reference

• • •

cost is updated: za → min(za ,z0 ) . The vertex Xi0 does not need further separation and it is removed from the list L; if z0  za , the vertex Xi0 contains no solution better than za . Its exploration is abandoned and it is removed from the list L; if z0  za , the vertex Xi0 must be explored further. It is kept in the list L;

evaluation of the vertex Xi1 in a similar way to Xi0 .

Figure 1-15 depicts the stages of an iteration.

Figure 1-15: Separation and evaluation process.

Mixed linear programming

53

The efficiency of a separation-evaluation method depends on the choice of the vertex to be separated, the choice of the separation variable, the necessary memory storage and the solution method of the relaxed problems. Let us examine these aspects. Choice of the vertex to be separated The two strategies are depth exploration and breadth exploration. The depth search systematically selects the lowest level vertex. The objective is to quickly arrive at a feasible terminal vertex in order to determine a first reference cost za . This value is indeed essential to eliminate branches during the search. Figure 1-16 illustrates the depth exploration strategy on a 5-level tree. The tree structure is shown in figure 1-16a, with arrows indicating the order in which the vertices are processed. The evolution of the list of active vertices is shown in figure 1-16b. The descent in the tree structure is carried out by starting with the leftmost branch (successive variables fixed to 0 for example) until meeting, either an infeasibility, or a feasible solution. Then the exploration resumes at the previous vertex to go down again as far as possible in the tree. (a)

(b)

Figure 1-16: Depth search. Depth search is economical in terms of memory space, as the list contains only one branch of the tree, i.e. at most n vertices for a problem with n binary variables. However, it may require the evaluation of many vertices, as it is necessary to wait until a feasible solution is found before branches can be eliminated from the tree. Furthermore, the first feasible solutions may be of poor quality (high cost za ), which does not allow for efficient branch elimination.

54

Optimization techniques

The breadth search systematically selects the vertex with the best (lowest) valuation. The objective is to determine a first reference cost za that is as low as possible, allowing the elimination of branches at a high level. Figure 1-17 illustrates the updating of the list for a breadth exploration strategy. The list at the beginning of the iteration has k vertices sorted in decreasing cost value. These vertices all have a valuation lower than the reference cost za (best known feasible cost). The last vertex Xk (best valuation vertex) is separated into two vertices Xa and Xb , which are evaluated.

Suppose that Xa yields a feasible (integer or binary) solution of cost z'a with

zi  z'a  zi+1 . The vertices X1,X2 , ,Xi can be removed from the list. The vertex Xa is also removed, as its exploration is complete.

Suppose besides that Xb yields a relaxed solution of cost zb with zj  zb  zj+1 . This vertex is inserted in the list between the vertices X j and X j+1 . At the end of this iteration, the vertex Xk that has been separated is removed from the list. The new list contains the previous k − i −1 vertices from Xi+1 to Xk −i plus the new vertex Xb .

Figure 1-17: Breadth search. Breadth search is generally more efficient than depth search (fewer vertices to evaluate), as it allows for early elimination of branches from the tree. However, it requires many more vertices to be stored in the list, which can lead to memory space problems.

Mixed linear programming

55

Choice of the separation variable The choice of the non-integer variable to separate the vertex is arbitrary. It is usually based on one of the following empirical criteria: • choice based on the cost function: The variable with the most negative coefficient c j in the cost function is chosen. It is hoped to find a new feasible solution with a large decrease in the reference cost; •

choice based on the constraints: The variable present in the largest number of constraints is chosen. It is hoped that an infeasibility will appear in order to eliminate the vertex;



choice based on the dual function: The variable giving the largest initial value to the dual function (before solving the dual problem) is chosen. It is hoped to obtain a high relaxed cost to eliminate the vertex.

These empirical criteria can have very different efficiency. They should be tried and adapted on a case-by-case basis. Memory storage The implementation of the algorithm requires precautions to save memory space. Indeed, the amount of information to be stored (list of active vertices and their relaxed solutions) can become very large depending on the size of the problem to be solved. The active vertices are stored in a chained list. This list is updated at each iteration by dynamic allocation/deallocation of the vertices. The links between successive vertices are defined by pointers. For a depth exploration with n binary variables, the list contains at most n vertices. The best known feasible solution is stored separately. Each vertex is a data structure comprising at least: - a Boolean per variable indicating whether that variable is fixed; - a Boolean per variable indicating that the variable is in the optimal basis; - the value of each variable (for fixed variables); - the value of the evaluation function; - a pointer to the next vertex in the list. For a problem with n binary variables, the values of the variables are Boolean. Storing a vertex requires a total of 3n Booleans, one real and one pointer. In practice, it is possible to solve linear problems with a few dozen integer variables or a few hundred binary variables. The number of real variables can be as high as 100 000, as these variables do not lead to the generation of additional branches.

56

Optimization techniques

Relaxed problem solving A tree-based method requires the evaluation of a large number of vertices. The relaxed problem must be solved as quickly as possible. The following elements contribute to the speed of resolution: •

preliminary reductions of the relaxed problem (section 1.1.3) allow for infeasibility detection and/or variable fixing;



the initialization from the solution of the parent vertex (section 1.3.3) allows to directly construct a dual-feasible basis. This warm start procedure saves a lot of computation time;



the preliminary knowledge of an initial feasible solution speeds up the elimination of branches from the tree. This solution can in some cases be provided directly by the user or determined by a greedy method adapted to the linear problem to be solved;



the evaluation of the relaxed solution can be stopped early when the dual function becomes greater than the feasible reference cost za . This is because the dual function gives a minorant of the optimal cost and it grows with each iteration of the dual simplex. It is therefore not necessary to complete the solution to eliminate the vertex when it exceeds za .

Most separation-evaluation methods are based on the dual simplex algorithm with a warm start and the early termination of an evaluation. The primal simplex algorithm or interior point methods do not have these advantages and are much less efficient in this context. However, they can be implemented as "fallback" methods in cases where the dual simplex method fails, for example due to numerical accuracy problems. The relaxed cost is a minorant of the integer solutions contained in a vertex. Ideally, it should be as large as possible to favor the elimination of vertices. In some cases, it can be strengthened by adding variables and/or constraints not present in the initial problem formulation, as discussed below. Adding variables Adding an integer variable to a problem can make the separation of vertices much more selective. This is particularly the case for knapsack problems as shown in example 1-6.

Mixed linear programming

57

Example 1-6: Adding an integer variable 2n

Consider the problem: max z =  3xi xiU

s.t.

i =1

2n

 2x

i

i =1

 2n + 1

The constraint imposes that at most n variables out of the 2n are equal to 1. The maximum cost is obtained by setting n variables to 1 and the other n to 0. The n choice of variables is indifferent. There are C2n equivalent binary solutions. The solution of the relaxed problem (real variables in [0 ; 1]) has n variables worth 1, n−1 variables worth 0 and one variable worth 0.5. The cost of the relaxed solution remains z = 3n + 0.5 as long as fewer than n variables are set to 0. It will thus be necessary to go down to level n of the tree to obtain a feasible n solution, then it will be necessary to find the C2n equivalent solutions to guarantee optimality. The separation-evaluation method is inefficient for this problem. Let us introduce an additional integer variable y defined by: y = 2n

The new problem is: max z =  3xi s.t. xiU,y

i =1

2n

 2x i =1

i

 2n + 1 and

2n

x . i

i =1

2n

x i =1

i

=y

This problem with 2n binary variables and one integer variable admits the same solutions as the original problem, because the constraint y  is satisfied by all original solutions. The solution of the new relaxed problem has, as before, n variables worth 1, n−1 variables worth 0 and one variable worth 0.5. The cost is: z = 3n + 0.5 and the variable y takes the value: y = n + 0.5. Let us separate the root vertex X on the variable y, which must be integer: • the vertex X0 receives the constraint: y  n . Its relaxed solution has n variables worth 1 and n variables worth 0. This solution is feasible of cost: z = 3n and the exploration stops at vertex X0 ; • the vertex X1 receives the constraint: y  n + 1 . This constraint imposes at least n +1 variables to 1. It is incompatible with the other constraint. The vertex X1 has no solution and the exploration stops at the vertex X1 . The separation on the additional integer variable y thus makes it possible to obtain n the binary solution with certainty by evaluating only 3 vertices instead of the C2n possible combinations.

58

Optimization techniques

Adding constraints The addition of constraints can enhance the evaluation of the vertices. The purpose of the additional constraints is to reduce the feasible domain of the relaxed problem. The relaxed solution is thus closer to the integer solution, which favors the elimination of branches. Additional constraints can be generated by integral or mixed cuts (branch and cut methods), linear combinations of constraints from the original problem, or congruence relations of the form

x + y = z  [x]p + [y]p  [z]p .

Example 1-7: Adding a constraint Consider the constraint on 5 integer variables: 5x1 + 2x2 + 6x3 + x4 + 4x5 = 7 By taking each member modulo p, valid inequality constraints are generated. • p = 2  x1 + x4  1

This constraint implies that x1 and x4 cannot be simultaneously zero. Otherwise, the 1st member would be even, while the 2nd member is odd.

• p = 4  x1 + 2x2 + 2x3 + x4  3 These inequality constraints help to fix variables or to make infeasibilities appear.

1.4 Applications Mixed linear programming is applicable to many problems. This section presents the formulation of classical applications. Many examples are detailed in references [R1] and [R8].

1.4.1 Travelling salesman problem Problem statement The Travelling Salesman Problem (TSP) consists in visiting n cities, passing through each city once and returning to the starting point. The objective is to find the shortest path. The n cities are denoted S1, ... , Sn. The distance from Si to Sj is denoted dij. The matrix of city-to-city distances is called the distancer: D = (dij )i,j=1 to n .

Mixed linear programming

59

In the wording of combinatorial optimization, the cities and distances form a graph G = (S, D) , where the cities are the nodes and the distances are the valuations of the edges. If the matrix D is symmetric, the direction of travel is indifferent and the graph is undirected. The problem is then a symmetric TSP. Otherwise, the problem is an asymmetric TSP. Before formulating the TSP as a mixed linear problem, let us show some possible paths. Example 1-8: Travelling salesman problem Let us consider a case with 5 cities as shown in figure 1-18. The matrix D is of size 5  5 .

 0   d21 D =  d31   d41 d  51

d12

d13

d14

0

d23

d24

d32

0

d34

d42

d43

0

d52

d53

d54

d15   d25  d35   d45  0 

Figure 1-18: TSP problem with 5 cities. Figure 1-19a shows a path passing through the 5 cities, but not feasible. This is because this circuit has 2 sub-circuits. Figure 1-19b shows a feasible, but nonoptimal path. The optimal circuit is shown in figure 1-19c. (a)

(b)

Figure 1-19: Non-feasible or non-optimal TSP path.

(c)

60

Optimization techniques

Formulation The TSP is formulated as a mixed linear problem. • Variables The binary variable sij is 1 if the path from Si to Sj is selected, and 0 otherwise. With the variables sii set to 0, there are a total of n  (n − 1) binary variables. •

Cost

n

n

The cost of the path is the total distance: z =  sijdij . i =1 j=1



Constraints

n

There is one departure from each city S i:

s

There is one arrival at each city Sj:

s

ij

= 1 , i = 1 to n (n constraints).

ij

= 1 , j = 1 to n (n constraints).

j=1

n

i =1

These constraints are not sufficient, as they do not prohibit sub-circuits, as in figure 1-19a. A first idea is to prohibit sub-circuits by explicit constraints. To prohibit the sub-circuit passing through the p cities S k1, Sk2, ... , Skp, we can introduce the inequality constraint: sk1k2 + sk2k3 + + skp−1kp + skpk1  p − 1 . The drawback of this approach is that it will require an exponential number of constraints (of the order of 2n ) to prohibit all possible sub-circuits. One way to get around this difficulty is to iteratively introduce the prohibition constraints. The initial problem is solved without any sub-circuit constraints. If the solution contains a sub-circuit, the corresponding constraint is added and the new problem is solved. By continuing in this way, one eventually arrives at a solution without sub-circuit. In the worst case, this method may lead to adding an exponential number of constraints and solving the new problem. There is therefore no guarantee of a result in a reasonable time. A more efficient method is to introduce constraints on the order of visit. Each city Sk is associated with a real variable tk between 1 and n. This variable represents the "time of passage" at the city Sk . The initial city S1 is chosen arbitrarily and its time is fixed: t1 = 1 . Consider then the following n  (n − 1) constraints.

ti − t j + nsij  n −1 , i = 1 to n , j = 2 to n

(1.79)

Mixed linear programming

61

If the path from Si to Sj is selected (sij = 1) , the constraint gives: ti  t j − 1 . The time at Si is earlier than the time at Sj. If the path from Si to Sj is not selected (sij = 0) , the constraint gives: ti − t j  n −1. This constraint is always satisfied, as the times are between 1 and n. The constraints (1.79) therefore impose increasing times along the path, except for the return in S1 (no constraint for j = 1). The real variables tk increase by at least 1 at each city visited and they are comprised between 1 and n. Their solution value is necessarily equal to the number of the city on the path. These constraints prohibit sub-circuits. Indeed, a path through the n cities with sub-circuits has at least two sub-circuits, as in figure 1-19a. One of the sub-circuits does not pass through S1, and it will not be able to satisfy the increasing time constraints (1.79). Constraints can also be added to allow more efficient separations in a tree method. The additional constraint:

n

n

 s i =1 j=1

ij

= n imposes, for example, that the number of

selected edges is exactly equal to n. Mixed linear programming can be used to solve TSP for up to 10 000 cities. Figure 1-20 illustrates the problem called Att532, which consists in visiting the 532 largest cities in the US.

Figure 1-20: Att532 problem.

62

Optimization techniques

Extensions The TSP formulation lends itself to various extensions, especially for optimizing vehicle routes. The cost function can represent the consumption or the travel time: m

p

z =  sijcij where cij is the cost (fuel, time) of the travel from Si to Sj i =1 j=1

Constraints can be added to the route, such as: - impose an order of visit between the city S i and the city Sj : ti  t j ; - limit the total time:

n

n

 s T  T i =1 j=1

ij ij

where Tij is the travel time from Si to Sj.

max

1.4.2 Assignment problem Problem statement The problem consists in assigning m resources to p tasks, while minimizing the total cost. The cost of assigning resource i to task j is cij . The number of tasks to be performed is less than or equal to the number of available resources: p  m . This assumption is not restrictive: if p > m, the inverse problem of assigning tasks to resources can be handled. Formulation The assignment problem is formulated as a mixed linear problem. • Variables The binary variable sij is 1 if resource i is assigned to task j, and 0 otherwise. There is a total of m  p binary variables. •

Cost

The total cost of the assignments is: z = •

Constraints

Task j is performed only once: Resource i is assigned once at most:

p

m

 s c i =1 j=1

m

s

ij

i =1

p

s j=1

ij

ij ij

.

= 1 , j = 1 to p (p constraints).

 1 , i = 1 to m (m constraints).

Mixed linear programming

63

By introducing slack variables (yi )i=1 to m , the problem is formulated as m

p

min z =  sijcij

sij ,yi U

i =1 j=1

m j = 1 to p  sij = 1 , i =1 s.t.  p  sij + yi = 1 , i = 1 to m  j=1

(1.80)

As the variables sij are binary, so are the variables yi . The constraints (1.80) are of the form: Ax = b , where the matrix A has only elements being 0 or 1 and the vector b has all its components equal to 1. This particular form of matrix facilitates the solution of problem (1.80). Resolution A rectangular matrix A is unimodular if the determinant of any sub-square matrix extracted from A is −1, 0 or 1. The following properties can be demonstrated: • a matrix whose elements are −1, 0 or 1, and whose each column contains at most two non-zero elements is unimodular; • if A is unimodular, then any submatrix B of A is also unimodular; • if B is a unimodular square matrix and b is a vector of integers, then the solution of the system Bx = b is integer. It can be shown that the matrix A of the assignment problem (1.80) is unimodular. Consider then the relaxed problem where the variables sij , yi are real positive, noting the m  p + m variables: x = (sij , yi ) and the m + p constraints: Ax = b . The solution of this continuous linear problem has m + p basic variables xB associated with a sub-matrix B and (m − 1)  p zero non-basic variables associated with a sub-matrix N. The basic variables are given by

Ax = BxB + NxN = b  BxB = b because xN = 0

(1.81)

The matrix B is unimodular (sub-matrix of A) and the vector b is integer (components equal to 1). The solution xB of the relaxed problem is therefore integer. It is obtained directly by a standard linear programming method.

64

Optimization techniques

Extensions The assignment problem (1.80) assumes independent tasks and associates one resource per task. The formulation can be adapted to more complex problems, including the maximum cost task, set covering or scheduling problems presented below. Extension 1: Maximum cost task Suppose that we want to minimize the cost of the most expensive task, instead of the total cost. The cost of task j is: zj =

m

s c i =1

ij ij

. We seek to minimize

m

z = max zj = max  sijcij j=1 to p

j=1 to p

(1.82)

i =1

This cost function is not linear. To formulate a linear problem, we introduce a real variable z and p constraints inequality zj  z .

m  sij = 1 , j = 1 to p  i=p1  min z s.t.  sij  1 , i = 1 to m z,sij  j=1 m  sijcij  z , j = 1 to p  i=1

(1.83)

The first p equalities control the completion of each task. The next m inequalities control the allocation of each resource. The last p inequalities ensure that the cost function z represents at least the most expensive task. The problem has m  p binary variables sij and one real variable z. Extension 2: Set covering Assume that tasks can be shared between resources according to the capabilities of each. This is a problem of set covering of p tasks with m resources. The applications concern, for example, the implementation of distribution sites that have to supply several customers. The variable sij is the capacity of resource i assigned to task j. This variable is real or integer, depending on the nature of the problem. The total cost of the assignments is: z =

m

p

 s c i =1 j=1

ij ij

.

Mixed linear programming

65

The task j requires a capacity t j : The resource i has a capacity ri :

m

s

ij

= t j , j = 1 to p .

ij

 ri , i = 1 to m .

i =1

p

s j=1

The set covering problem is formulated as m

p

min z =  sijcij sij

i =1 j=1

m  sij = t j , j = 1 to p s.t.  i=p1  sij  ri , i = 1 to m  j=1

(1.84)

The linear problem (1.84) may be continuous or mixed depending on whether the capacities sij are real or integer. Extension 3: Scheduling problem Let us assume that tasks require a certain duration and that some tasks should not overlap (disjointed tasks). This is a task scheduling problem. Applications concern time schedule, aircraft landing, connections, telecommunications... The real variable t j represents the start time of the task j of fixed duration dj . The binary variable u jk is 1 if task j is performed before task k, 0 otherwise. The problem has p real variables t j and p  p binary variables u jk . If tasks j and k are to be disjoint, an order constraint is imposed on the variables t j , tk and u jk . This constraint is formulated as

u jk + ukj = 1 u (t + d )  t , j = 1 to p , k = 1 to p k  jk j j

(1.85)

The cost function is usually the total time to be minimized: z = max(t j + d j ) . j

The constraints give rise to products of variables that are linearized using the techniques of section 1.1.2. The cost function is linearized by a real variable z subject to the constraints: t j + dj  z , j = 1 to p. We can apply temporal constraints similar to (1.85) on resources or constraints on a minimum temporal spacing between tasks.

66

Optimization techniques

1.4.3 Coloring problem Problem statement A graph is defined by a set of nodes and edges connecting the nodes. The m-coloring problem consists in coloring the graph with m colors, knowing that adjacent nodes (connected by an edge) must be of different colors. Formulation The coloring problem is formulated as a mixed linear problem. We note e jk the binary variable worth 1 if node j is adjacent to node k, and 0 otherwise. • Variables The binary variable sij is 1 if color i is assigned to node j, and 0 otherwise. There is a total of m  n binary variables. •

Constraints

The node j is assigned a single color:

m

s i =1

ij

= 1 (n constraints).

Adjacent nodes j and k have different colors: ejk (sij + sik )  1 . The m-coloring problem consists in finding a feasible solution with m colors. We consider a constant cost, as there is no criterion to minimize.

m j = 1 to n  sij = 1 , min z = 1 s.t.  i =1 sij ejk (sij + sik )  1 , i = 1 to m , j = 1 to n , k = 1 to n 

(1.86)

We are generally interested in the minimum number of colors needed to color the graph. This minimum number mc is the chromatic number of the graph. A minorant of mc can be found by solving the maximum cardinal clique problem shown below. Clique problem A clique of the graph G is a complete subgraph, i.e. a subgraph whose nodes are all connected by edges. If G has a clique with p nodes, then at least p colors are needed to color G, because each node is connected to all the others.

Mixed linear programming

67

To find a minorant of mc, we look for the largest clique of G, called the clique of maximum cardinal. This problem is formulated as follows. • Variables The binary variable si is 1 if node i belongs to the clique C, and 0 otherwise. There is a total of n binary variables. • Constraints Non-adjacent nodes j and k cannot simultaneously belong to the clique. These constraints take the form: (1 − ejk )(sj + sk )  1 . The maximum cardinal clique problem is formulated as n

max z =  si si

i =1

s.t. (1 − ejk )(sj + sk )  1 , j = 1 to n , k = 1 to n

(1.87)

Stable set Another problem of practical interest is the problem of the stable set of maximum cardinal. A stable set S of the graph G is a subgraph with no connected nodes. This is the "inverse" clique problem. The maximum cardinal stable set problem is formulated like the maximum cardinal clique problem, simply replacing e jk by 1 − ejk . n

max z =  si si

i =1

s.t. ejk (sj + sk )  1 , j = 1 to n , k = 1 to n

(1.88)

Figure 1-21 illustrates the problems of coloring and maximum cardinal clique.

Figure 1-21: Coloring and maximum clique problems.

68

Optimization techniques

1.4.4 Flow problem Problem statement A network is a graph defined by a set of nodes and (directed) arcs connecting the nodes. The capacity and cost of the arc from node i to node j are denoted by fij and cij respectively. The nodes s and t are the entry (source) and exit (sink) points of the network, respectively. The objective is to get a given flow  from the source to the sink with the lowest total cost. The set of arcs is represented by the nodes-arcs incidence matrix. This matrix A has n rows (n = number of nodes) and m columns (m = number of arcs). If arc k goes from node i to node j, the values in column k are zero except aik = +1 (departure node) and a jk = −1 (arrival node).

The incidence matrix is unimodular (section 1.4.2), as its elements are equal to −1, 0 or 1, and each column has at most two non-zero elements. The cost vector c has m elements representing the costs of the arcs.

Example 1-9: Node-arcs incidence matrix of a network Consider the 6-node, 9-arc network in figure 1-22 where the costs of the arcs are indicated on the arrows. The incidence matrix A is of size 6  9 and the cost vector c has 9 elements. arcs

1− 2

    A=    

1−3

2− 4

2 −5

2 −6

3− 4

3− 5

4 −6

5−6

− 1 −1 0 0 0 0 0 0 0   1 0 −1 −1 −1 0 0 0 0  0 1 0 0 0 −1 −1 0 0   0 0 1 0 0 1 0 −1 0  0 0 0 1 0 0 1 0 −1  0 0 0 0 1 0 0 1 1 

1− 2 1− 3

c=(3 1

2−4

2 −5

2−6

3

5

9

3− 4

3 −5

4 −6

2

3

5

Figure 1-22: Network with 6 nodes and 9 arcs.

5−6

2)

nodes v1 v2 v3 v4 v5 v6

Mixed linear programming

69

Formulation The flow problem can be formulated as a mixed linear problem. We denote eij the binary variable worth 1 if there is an arc from node i to node j, and 0 otherwise. •

Variables

The variable xij is the flow on the arc from node i to node j. This variable is real or integer depending on the nature of the problem. There is a total of m "useful" variables xij associated with the arcs of the network. •

Cost

n

The total cost of the flow through the network is: z =  eijcij xij . i, j=1



Constraints

The flow on the arc i-j is limited by its capacity: xij  fij . The flow is conserved at each node (Kirchhoff's law). The flow arriving at node j is equal to the flow leaving: The flow from the source s is  :

n

e k =1

n

n

i =1

k =1

 eijxij =  ejk xjk .

x = .

sk sk

n2 ) , memory space is saved by keeping only the

If the graph is sparse (m

variables xij associated with the existing arcs. The linear problem is formulated in a compact way using the node-arc incidence matrix of the network.

min z = cT x s.t. x

x = (xij )  f = (fij ) 

m m



Ax = b xf

(1.89)

is the vector of variables associated with the arcs. and c = (cij ) 

m

are the vectors of the arc capacities and costs.

The constraints Ax = b express the conservation of the flow at each node as well as the flow − leaving the source and the flow + arriving at the sink. The vector b 

 source bT =  − 

m

is defined by

node1

0

node m

0

sink  +  

(1.90)

70

Optimization techniques

The linear problem (1.89) is in integer variables if the flows xij on each arc are integer quantities. Since the constraint matrix is unimodular, the solution of the relaxed problem will be directly integer. Extensions The formulation of the flow problem can be adapted to various problems. Extension 1: Minimum cost path By fixing the flow  = 1 and removing the constraints on capacities, problem (1.89) gives the minimum cost path between the source and the sink. The costs of the arcs can represent distances or travel times between nodes. Since the constraint matrix A is unimodular, the solution is directly integer and the variables xij take the value 0 or 1. Extension 2: Maximum flow To search for the maximum flow that can go from the source to the sink, we add the variable  , which becomes the cost function. The costs cij of the arcs are not used and the linear problem is formulated as

max z =  s.t. x,



Ax = b xf

(1.91)

Extension 3: Multiple sources and sinks Assume that the network has several sources and several sinks. The source si

emits a flow i and the sink t j receives a flow j . The sum of the flows from the sources is equal to the sum of the flows to the sinks:  =  i =  j . si

tj

We define a super-source  linked to each source si by an arc of capacity i . The flow from the super-source is:  =  i . si

We define a super-sink  linked to each sink t j by an arc of capacity j . The flow to the super-sink is:

 =  j . tj

This brings us back to a simple flow problem of value  between the supersource and the super-sink.

Mixed linear programming

71

1.4.5 Knapsack problem Problem statement We have a set of objects with their volumes and prices. The objects to be carried in a knapsack of a given volume must be chosen in order to maximize the price. The object i has the volume ai and the price ci . The knapsack has a volume b. Formulation The knapsack problem can be formulated as a mixed linear problem. • Variables The binary variable xi is 1 if object i is selected, and 0 otherwise. Cost



The total price of the selected objects is: Constraints



The chosen objects must fit in the knapsack:

n

z =  ci xi . i =1

n

a x  b . i =1

i i

The problem of the so-called one-dimensional knapsack is formulated as

a T x  b max z = cT x s.t.  n x x  U

(1.92)

A good solution can be constructed by a greedy method based on the utility ui of

ci . ai This solution allows branches to be eliminated in a tree-based method. each object, defined as the price/volume ratio: ui =

Example 1-10: Greedy solution to the knapsack problem Consider the following knapsack problem with 8 objects. max z = 14x1 + 13x2 + 15x3 + 10x4 + 4x5 + 13x6 + 10x7 + 10x8 x

s.t. 7x1 + 7x2 + 10x3 + 7x4 + 3x5 + 10x6 + 8x7 + 9x8  30

These 8 objects are already numbered in order of decreasing utility.

72

Optimization techniques

The greedy solution x = (1 1 1 0 1 0 0 0) is priced at z = 46 with a volume of 27. The optimal solution x = (1 1 0 1 0 0 1 0) is priced at z = 47 with a volume of 29.

Extensions The formulation adapts to the case where several objects of the same type can be chosen (the variable xi is then an integer) and to the problem of several knapsacks to fill. This so-called "multidimensional" knapsacks problem is formulated as follows. • Variables The binary variable xij is 1 if object i is placed in knapsack j, and 0 otherwise. There is a total of n  m binary variables (n = number of objects, m = number of knapsacks). •

Cost

n  m  The total price of the selected objects is: z =  ci   xij  . i =1  j=1 



Constraints

n

The volume of the knapsack j is bj :

a x

The object i is in one knapsack at most:

x

i =1 m

j=1

i ij

ij

 bj .

1.

To improve the separation efficiency (tree method), we introduce the n variables: m

si =  xij . j=1

The binary variable si is 1 if object i is selected, and 0 otherwise. The multidimensional knapsack problem is formulated as n

max z =  cisi x ,s

i =1

n  ai xij  bj , j = 1 to m s.t.  im=1 with x Unm , sUn  xij = si , i = 1 to n  j=1

(1.93)

This formulation applies to placement problems (saving files on disks), loading problems (filling delivery vehicles) or cutting problems (minimizing waste).

Mixed linear programming

73

1.5 Quadratic problem Mixed linear programming techniques extend to problems where the cost function is quadratic convex.

1.5.1 Tree method The standard form of a quadratic problem in binary variables is as follows.

Ax = b 1 (1.94) min z = xT Qx + cT x s.t.  n x 2  x  U , U = 0 ; 1 We can always return to the case where the matrix Q is symmetric. 1 1 1 By posing Q' = (Q + QT ) , we have indeed: xT Q'x = xTQx + xTQT x = xTQ x. 2 2 2 A first approach is to apply linearization techniques (section 1.1.2) to come back to a linear problem. This approach has the disadvantage of increasing the number of variables. It is not efficient on high dimensional problems. A second approach is to directly apply a tree method similar to those used for linear problems (section 1.3): - we explore the tree structure by progressively setting the variables to 0 or 1; - the relaxed solution at each node gives a minorant of the branch cost; - branches with a higher valuation than the best known solution are eliminated. This approach is developed in this section. It requires the ability to efficiently solve the relaxed problem obtained by replacing integrity constraints with positivity constraints.



1 Ax = b min z = xTQx + cT x s.t. x x0 2

(1.95)

Since the relaxed problem is less constrained than the original problem, its solution is better and gives a minorant of the optimal cost of problem (1.94). Before tackling the solution of the relaxed problem, let us illustrate on an example the comparison between the integer solution and the relaxed solution of a quadratic problem.

74

Optimization techniques

Example 1-11: Solution of the relaxed quadratic problem Consider the problem with 2 integer variables

min z = 2x12 + 4x22 x1 ,x2

 x1 + x2  5  x1  2  s.t.  x2  1 2x1 + x2  10,5 x , x   1 2 The relaxed solution is

x1 =

10 5 100 , x2 = → zr = 3 3 3

The integer solution is

x1 = 3 , x2 = 2 → z* = 34 Figure 1-23: Relaxed solution and integer solution.

Figure 1-23 shows the cost level lines (dotted), the feasible domain (shaded), the integer solutions (circles) and the relaxed solution (square). Let us now turn our attention to solving the relaxed problem (1.95). This relaxed problem is put into standard form



1 b − Ax = 0 min z = xT Qx + cT x s.t. x −x  0 2

(1.96)

The Lagrangian is defined with multipliers  for the equality constraints and multipliers  for the inequality constraints.

1 L(x, , ) = xTQx + cT x + T (b − Ax) − T x 2

(1.97)

The solution of the relaxed problem satisfies the KKT conditions of order 1.

x L = 0   L = 0  L  0

Qx + c − AT  −  = 0   Ax = b  x  0

(1.98)

Mixed linear programming

75

The Lagrangian Hessian is constant and the KKT condition of order 2 yields (1.99)

xx L = Q  0

A sufficient condition for optimality is that the matrix Q is positive semidefinite. In this case, the cost function is convex and the relaxed problem admits a unique global minimum given by the KKT conditions (1.98). This minimum can be obtained in polynomial time by an interior point algorithm. Otherwise, the KKT conditions are not sufficient to guarantee the global optimality of a solution and there is no algorithm that ensures that this minimum is found in a reasonable time. In view of a tree method based on relaxed problem solving, it is necessary to make the problem convex in order to be able to solve it safely and quickly.

1.5.2 Convexification Convexification consists in transforming the quadratic problem (1.96) into a convex problem having the same binary solutions. The transformations are based on the property

x 0 ; 1  x2 − x = 0

(1.100)

2

Terms of the form (x − x) can be added to the quadratic cost function, without changing the values it takes for binary variables. The two main convexification techniques are product transformation and the addition of a diagonal matrix. Product transformation

n

T The quadratic part of the cost function is of the form: q = x Qx =  qijxi x j . The i, j=1

terms of the form: t(x, y) =  xy = eigenvalues of the matrix are  .

1  x  0   x      are not convex, because the 2  y   0  y 

Each term t(x, y) is replaced by tc (x, y) defined according to the sign of  . 1 1  2  tc (x, y) = + 2 (x + y) − 2 (x + y) i f   0  1 1  tc (x, y) = − (x − y)2 + (x + y) i f   0 2 2 

(1.101)

76

Optimization techniques

The term tc (x, y) is indeed convex (quadratic part with a positive coefficient). It takes the same values as t(x, y) when x and y are binary. Indeed, we have

 x  U  x2 = x (x  y)2 = x2 + y2  2xy = x + y  2xy because  . 2 y  U  y = y and the resulting terms of degree 1 are eliminated in the expression of tc (x, y) . The transformation (1.101) is applied to each term of the cost function according to the sign of the coefficient. Developing these terms, we get n

q x x

i, j=1

ij i

j

=

q x x

qij 0

ij i

q x x

+

j

qij 0

ij i

j

2 2 1 1 qij  + ( xi + x j ) − ( xi + x j )  +  qij  − ( xi − x j ) + ( xi + x j )        2 qij 0  2 qij 0  1 1 = qij  + xi2 + x2j − ( xi + x j )  +  qij  − xi2 + x2j + ( xi + x j )      2 qij 0 2 qij 0  1 1 +  qij  2xi x j  +  qij  2xi x j  2 qij 0 2 qij 0

=

(

)

(

)

hence the expression of the cost

q =

1 qij  + xi2 + x2j − ( xi + x j )    2 qij 0  1 +  qij  − xi2 + x2j + ( xi + x j )  +  2 qij 0 

(

(

)

)

n

 qijxi x j

(1.102)

i, j=1

The quadratic problem with the cost function (1.102) is convex and has the same binary solutions as the original problem.

Example 1-12: Convexification by product transformation The quadratic function: z = 3x1 − 2x2 + x3 + 2x4 − 4x1x3 + 2x1x4 − 4x2 x3 + 6x3x4 is not convex. Applying the transformation (1.101), we obtain

z' =− 4x2 − 6x3 − 2x4 + 3x12 + 2x22 + 7x32 + 4x42 − 4x1x3 + 2x1x4 − 4x2x3 + 6x3x4

The function z' is convex and takes the same values as z for binary variables.

Mixed linear programming

77

Adding a diagonal matrix The symmetric matrix Q has real eigenvalues and it admits an orthogonal basis of eigenvectors. Let D be the diagonal matrix of the eigenvalues of Q and P the −1 T orthogonal matrix (P = P ) of transformation in this basis. (1.103)

Q = PDPT

Assume that Q is not positive definite and consider the matrix Q' = Q + I where

  m and m is the most negative eigenvalue of Q. Then we have Q' = Q + I = PDPT + PPT = P(D + I)PT = PD'PT

(1.104)

The matrix D' is diagonal and has all its terms positive, because   m . The matrix Q' is thus positive definite and has the same basis of eigenvectors as Q. 2 The cost function is made convex by adding terms of the form (x − x) . n

n

n

i =1

i, j=1

i =1

q' = q +  (xi2 − xi ) =  qijxi x j +  (xi2 − xi )

(1.105)

The new quadratic cost function q' is convex and takes the same values as q when the variables are binary.

Example 1-13: Convexification by adding a diagonal matrix

1 0  1 2 2 The function: z = (x1 − x2 ) of matrix Q =   is not convex. 2  0 −1 

1 2

2 2 2 2 By choosing   m = −1 , the function: z' = (x1 − x2 ) + (x1 − x1 ) + (x2 − x2 )

is convex and takes the same values as z for binary variables.

The previous convexification techniques allow the relaxed problem to be solved safely and quickly, for example by an interior point method. The efficiency of a separation-evaluation method depends on the quality of the relaxed solution. A large relaxed cost (and thus close to the cost of the binary solution) favors the elimination of branches by comparison to the best known feasible solution. We must therefore try to formulate the quadratic problem in a way that maximizes the cost of the relaxed solution. This process of reconvexification of the cost function is useful, even if it is already convex.

78

Optimization techniques

For this purpose, we can use the linear constraints of problem (1.94)

n  aijx j = bi , i = 1 to m  j=1  x  0 ; 1  i

(1.106)

to add convex terms to the cost function: n m  n  n z ' = z +  ki xi   akjx j − bk  +  ui xi2 − xi i =1 k =1  j=1  i=1

(

)

(1.107)

with coefficients ki and ui chosen to maximize the relaxed cost. No convexification method is systematically better than the others. The choice must therefore be adapted to the quadratic problem to be solved. Example 1-14 compares the quality of the relaxed cost obtained with the two previous convexification techniques.

Example 1-14: Comparison of the two convexification methods

 x1 + x2  b 2 2 with b  1 . Consider the problem: min z = x1 − x2 s.t.  x1 ,x3  x1 , x2  0;1 1 0  2 2 The quadratic function: z = x1 − x2 of matrix Q =   is not convex.  0 −1  x = 0 The binary solution is:  1 → zb = −1 (by examining the 4 combinations).  x2 = 1 x = 0 → zr = −b2 The relaxed solution is obtained from the KKT conditions:  1 x = b  2 Let us compare the relaxed solutions of the two convexification methods.

Method 1: Product transformation Each term is replaced by an equivalent convex expression in binary variables. 1  x12 → (2x1 )2 − 2x1   2 2  → zc1 = 2x1 − x1 − x2 1 2  − x2 → − (2x2 )  2

(

)

Mixed linear programming

79

x + x  b The relaxed convexified problem is: min zc1 = 2x12 − x1 − x2 s.t.  1 2 x1 ,x2  x1 , x2  0 2 The Lagrangian of the problem is: L(x1 , x2 , ) = 2x1 − x1 − x2 + (x1 + x2 − b) (treating the constraints x1,x2  0 apart).

 4x1 − 1 +  = 0  x1 = 0   − 1 +  = 0    = 1 → zc1 = − b The KKT conditions yield:  (x + x − b) = 0 x = b  1 2  2

Method 2: Adding a diagonal matrix The most negative eigenvalue of the quadratic form is −1. 2 2 The terms a(x1 − x1 ) + a(x2 − x2 ) with a  1 are added to the cost function. The relaxed convexified problem is x + x  b min zc2 = (a + 1)x12 + (a − 1)x22 − ax1 − ax2 s.t.  1 2 x  x1 , x2  0 The Lagrangian of the problem is (treating the constraints x1,x2  0 apart)

L(x1 , x2 , ) = (a + 1)x12 + (a − 1)x22 − ax1 − ax2 + (x1 + x2 − b)  a −  x1 = 2(a + 1)   2(a + 1)x1 − a +  = 0  a −  The KKT conditions yield: 2(a − 1)x2 − a +  = 0   x2 = 2(a − 1)  (x + x − b) = 0  1 2    a(a − )  − b = 0   2 a − 1    The complementarity condition (3rd equation) gives two possible cases: a a a3 , x2 = → zc2 = − 2(a + 1) 2(a − 1) 2(a2 − 1) The variables x1 and x2 are positive, because a > 1. The solution exists in all cases;



first case:  = 0 → x1 =

• second case: x1 + x2 − b = 0 The solution is a2 (1 − b) + b b(a − 1) b(a + 1) 1  1 = , x1 = , x2 = → zc2 = b2  a −  − ab a 2a 2a 2  a The variables x1 and x2 are positive, because a > 1.

80

Optimization techniques

a2 (1 − b) + b b  0  a2  The multiplier  must be positive:  = . a b −1 The solution exists only for values of the real a giving a positive multiplier. The relaxed cost is the better of the two solutions above.   a3 1  1 zc2 = min  − 2 , b2  a −  − ab  2  a  2(a − 1)  We can now compare the relaxed costs given by the 2 methods as a function of the value of a. For example, let us assume that b = 1.5 and a = 2 or 4. Recall that we want the cost of the relaxed solution to be as high as possible. The relaxed cost with method 1 is: zc1 = −b = −1.5 . b a3 The relaxed cost with method 2 is: zc2 = − because a2  . 2 2(a − 1) b −1 For a = 2 , we get zc2 = −1.33  zc1 and method 2 is more efficient. For a = 4 , we get zc2 = −2.13  zc1 and method 1 is more efficient.

1.5.3 Quadratic assignment problem Problem statement The quadratic assignment problem illustrated in figure 1-24 consists in assigning n objects to n sites knowing that: - the objects i and j exchange a fixed flow fij ; - the sites u and v are at a fixed distance duv ;

- the cost is the product of the flow by the distance fijduv .

Figure 1-24: Quadratic assignment problem.

Mixed linear programming

81

Formulation This problem is formulated as a mixed linear problem. • Variables The binary variable siu is 1 if object i is assigned to site u, and 0 otherwise. There is a total of n  n binary variables. •

Cost

The total cost of the assignments is: •

Constraints

The object i is assigned to a single site: The site u receives a single object:

n



z=

i, j,u,v =1 n

s u =1 n

iu

s i =1

iu

siu s jv fijduv .

= 1 , i = 1 to n . = 1 , u = 1 to n .

The cost is a quadratic function of the binary variables. To solve this problem by a tree-based method, one can either apply a linearization technique to reduce to a linear problem, or directly treat the quadratic problem after convexification.

1.6 Conclusion 1.6.1 The key points •

Various linearization techniques can be used to transform a continuous nonlinear problem into a mixed-variable linear problem;



it is possible to reduce the dimension of the mixed problem significantly (fixing variables, removing constraints) before solving it;



cutting methods consist in iteratively adding constraints to the relaxed problem in order to arrive at an integer solution. These methods are used in conjunction with tree methods;



tree-based methods explore the tree of possible combinations by eliminating as soon as possible branches that cannot contain the optimal solution. The exploration strategies differ in the choice of the node to be separated and the choice of the variable to be fixed;



mixed linear programming is applicable to many practical problems (travelling salesman, assignment, flow...).

82

Optimization techniques

1.6.2 To go further •

Programmation mathématique (M. Minoux, Lavoisier 2008, 2 e édition) Chapter 2 presents the theoretical results of linear programming, the simplex method and the dual simplex method. Chapter 7 is devoted to integer linear programming. The tree and cutting methods are detailed in a very clear way with their theoretical justifications.



Optimization discrète (A. Billionnet, Dunod 2007) The book is devoted to mixed-variable optimization problems. Chapters 1 and 2 introduce the principles of integer linear and quadratic programming. Chapters 3, 4 and 6 detail the formulation and linearization techniques to reduce the problem to a mixed-variable linear problem, as well as the preprocessing to reduce the problem dimension. Chapter 5 presents several practical applications with their formulation and solution by commercial software. Numerous examples are given to illustrate the formulation of the problems and their numerical solution. This book is highly educational and well-supplied and is recommended for users of linear programming.



Programmation linéaire (C. Guéret, C. Prins, M. Sevaux, Eyrolles 2003) The book aims to show how to use linear programming in practical applications. Each chapter is devoted to a particular type of application (scheduling, planning, loading, transport, telecommunication, timetabling, etc.). The emphasis is on the formulation and use of commercial software.

Discrete optimization

83

2. Discrete optimization Discrete optimization concerns problems with integer variables. The difficulty lies in the exponential number of combinations and the absence of optimality conditions as in continuous optimization. Although combinatorial problems can be solved by linear programming, it is more efficient to apply specific algorithms, which are the subject of this chapter. Section 1 introduces the notions associated with graphs and complexity. Many combinatorial problems can be formulated as the search for a path in a graph. The graph formalism unifies the approaches and allows the development of problemspecific algorithms. Section 2 presents path problems. The objective is to find the minimum cost path in a graph between a starting point and an ending point. The main path algorithms are Ford's algorithm, Bellman's algorithm, and Dijkstra's and A* algorithms, which are the most efficient. Section 3 presents the scheduling problems. These problems can be considered as particular path problems. The standard methods are the PERT method and the MPM method. Section 4 presents the flow problems. The two standard problems are the search for the maximum flow that can traverse the network and the search for the maximum flow of minimum cost (when several maximum flow solutions exist). These problems can be solved by Ford-Fulkerson and Roy-Busacker-Gowen algorithms, respectively. Section 5 presents assignment problems. These problems can be considered as flow problems in a bipartite resource-task graph or they can be solved by the Hungarian method. Section 6 presents heuristics adapted to the different problems. These so-called greedy empirical methods produce an approximate solution of non-guaranteed quality. They offer the advantage of speed when the problem is too complex to be solved exactly and they can be used in some cases to initialize the tree methods presented in chapter 1.

84

Optimization techniques

2.1 Combinatorial problem Discrete or combinatorial optimization problems can be mostly modeled as graph routing problems. This section based on reference [R12] introduces the main notions associated with graphs and problem complexity.

2.1.1 Graph A graph is a set of nodes or vertices, some of which are connected by edges or arcs. We use the term edge if the graph is undirected and the term arc if the graph is directed. An edge is a pair of unordered nodes, denoted with square brackets: e = [v, w] . An arc is an ordered pair of nodes, denoted with parentheses: e = (v, w) . Two nodes connected to each other are neighbors or adjacent. A loop connects a node to itself. For an arc e = (v, w) , the following wording is used: - v is the initial end or origin of the arc e, and v is the predecessor of w; - w is the terminal end or end of the arc e, and w is the successor of v; - the arc e starting from v is outgoing at v; - the arc e arriving at w is incoming at w. There can be several links between two nodes. Figure 2-1 shows from left to right an arc, an edge, a loop and a triple link between two nodes.

Figure 2-1: Arc, edge, loop. The set of n nodes or vertices is noted: V = (vi )i=1 to n . The set of m edges or arcs is noted:

E = (ek )k=1 to m .

The graph G is defined by the two sets V and E: G = (V, E) . Note on the wording The term "arc" is often used, even for an undirected graph.

Discrete optimization

85

Number of arcs between nodes In a multigraph or p-graph, there can be up to p arcs between two nodes. In a simple graph or 1-graph, there is at most one arc between two nodes. m The density of a simple graph is the ratio 2 , between the actual number of arcs n and the theoretical maximum number (if all nodes were connected two by two). The outer half degree of node v is the number of arcs starting from v. The inner half degree of node v is the number of arcs arriving at v. The degree of the node v is the number of arcs starting and arriving at v. The average degree of a graph is the average of the degrees of the nodes (often around 3 in practice). An isolated node is a node of zero degree. Network A network is an oriented valued graph: each arc is assigned a cost (price of passing through the arc) and a capacity (quantity that can pass through the arc). The matrix F = (fij )i,j=1 to n represents the capacities of the arcs. The matrix C = (cij )i,j=1 to n represents the costs of the arcs. The node s is the source (entry point of the network). No arcs arrive at s. The node t is the sink (exit point of the network). No arc starts from t. The network R is defined by the sets V and E, the matrices F and C, the source s and the sink t: R = (V, E, F,C,s, t) . Representation A graph can be represented either by the successors of each node, or by the adjacency matrix, or by the incidence matrix. The adjacency matrix A is a Boolean matrix with n rows and n columns: - the rows correspond to the starting nodes; - the columns correspond to the arrival nodes. If there is an arc from node vi to node vj, the element a ij is 1, otherwise a ij is 0. The incidence matrix I is a Boolean matrix with n rows and m columns: - the rows correspond to the nodes; - the columns correspond to the arcs. If there is an arc ek from node vi to node vj, the element a ik is +1 and the element

a jk is −1 (otherwise a ik = a jk = 0 ). For a loop on node vi, the element a ii is +1.

86

Optimization techniques

Figure 2-2 shows the filling of adjacency and incidence matrices for an arc ek from node vi to node vj. Example 2-1 illustrates the three possible representations of a graph.

vj   vi    

1

     

  vi  vj   

ek +1 −1

     

Figure 2-2: Adjacency matrix and incidence matrix.

Example 2-1: Representation of a graph Consider the graph with 5 nodes and 10 arcs shown in figure 2-3. A first representation of this graph is the list giving the successors of each node. v 1→ v2 , v3 , v5 v 2→ v2 , v3 v 3→ v4 v 4→ v1 , v5 v 5→ v1 , v3 Figure 2-3: 5-node, 10-arc graph. A second representation of this graph is its adjacency matrix (left). A third representation of this graph is its incidence matrix (right). v1 v2 v3 v1  0 1 1  v2  0 1 1 v3  0 0 0  v4  1 0 0 v5  1 0 1

v4 0 0 1 0 0

v5 1  0 0  1 0 

e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 v1  +1 0 0 +1 +1 0 −1 0 0 −1    v2  −1 +1 +1 0 0 0 0 0 0 0  v3  0 0 −1 −1 0 +1 0 0 −1 0    v4  0 0 0 0 0 −1 +1 +1 0 0  v5  0 0 0 0 −1 0 0 −1 +1 +1

Discrete optimization

87

2.1.2 Route in a graph Many problems involve finding an optimal route in a graph. A route in a graph is called: - a path if the route is oriented; - a circuit if the route is oriented and closed; - a string if the path is undirected; - a cycle if the path is non-oriented and closed. A route is represented by the sequence of its arcs or by the sequence of its nodes (if the graph is simple). The length of the route is the number of consecutive arcs. Specific routes An elementary route passes through its nodes only once. An Eulerian route passes exactly once through each arc of the graph. A Hamiltonian route passes exactly once through each node of the graph. An Eulerian route can pass through a node several times, whereas a Hamiltonian route passes through each arc at most once. Eulerian or Hamiltonian routes are used in vehicle touring problems. The house game shown here consists in drawing a house without lifting the pencil and without passing over the same line twice. The result is an Eulerian, but not Hamiltonian, route. Special graphs A graph is complete if there is an arc between any pair of nodes. A graph is connected if there is a chain between any pair of nodes. A connected graph has at least n−1 edges. A tree is an undirected graph with no cycles. The number of edges in a tree is equal to the number of nodes − 1: m = n−1. A rooted tree is a directed tree (connected directed graph without cycle). All nodes in a tree are descendants of a single node called the root of the tree. A graph is planar if it can be represented in the plane without crossing arcs. The number of edges in a planar graph is: m  3n− 6. Planar graphs are used in electronic component placement and map coloring problems.

88

Optimization techniques

Connectivity The study of connectivity is a prerequisite for any graph problem. It relies on the adjacency matrix. This Boolean matrix A defined in section 2.1.1 indicates whether two nodes are connected (value 1) or not (value 0). A first question of connectivity is the existence of a path between any two nodes of the graph. This question is solved by computing the Boolean powers of the matrix I + A as explained below: - Boolean multiplication represents the logical product "and"; - Boolean addition represents the logical sum "or". These operations are shown in figure 2-4.

 0 1 0 0 0 1 0 1

+ 0 1

0 1 0 1 1 1

Figure 2-4: Boolean multiplication ("and") and addition ("or"). The Boolean matrix A indicates whether 2 nodes are connected by a 1-arc path. The product A.A = A 2 indicates whether 2 nodes are connected by a 2-arc path. noted

Continuing the reasoning, the Boolean matrix A k indicates whether 2 nodes are connected by a path with k arcs. The sum A0 + A1 + A2 + ... + Ak indicates whether there is a path with at most k arcs between 2 nodes (the matrix A0 = I indicates that each node is connected to itself). Using the Boolean identity A + A = A , we factor the sum into the form

I + A + A2 + ... + Ak = (I + A)k

(2.1)

k

The Boolean matrix (I + A) indicates for each node (row) which nodes can be reached (columns) by a path of length k at most. In a graph with n nodes, an elementary path has length n−1 at most. n −1 We therefore stop the calculation at the matrix (I + A) or at the first power k k k −1 such that (I + A) = (I + A) . n −1

The matrix (I + A) indicates for each node (row) which nodes are accessible (columns). A node w accessible from node v is a descendant of v and v is an ascendant of w. The set of descendants of v is noted (v) . The graph is connected n −1 if and only if all elements of (I + A) are 1.

Discrete optimization

89

Example 2-2: Existence of paths Consider the graph with 6 nodes shown opposite. Let us raise (I + A) to successive powers. 0  0 0 A= 0 0   0 1  0 0 (I + A)3 =  0 0   0

1 0 0 1 0  0 1 0 0 0 0 0 1 0 0  , 0 0 0 0 1  1 1 0 0 1  0 0 0 0 0 

1  0 0 I+A = 0 0   0

1 0 0 1 0  1 1 0 0 0 0 1 1 0 0  , 0 0 1 0 1  1 1 0 1 1  0 0 0 0 1 

1 1 1 1 1 1 1   1 1 1 0 1 0 1 0 0 0 1 1 0 1  , (I + A)4 =  0 0 1 0 1 0 0 0 1 1 1 1 1 1    0 0 0 0 1 0 0 4

1  0 0 (I + A)2 =  0 0   0

1 1 0 1 1  1 1 1 0 0 0 1 1 0 1  0 0 1 0 1  1 1 1 1 1  0 0 0 0 1 

1 1 1 1 1 1   1 1 0 1 0 1  1 1 0 1 ˆ = (I + A)5 =  0 0  , A 0 1 0 1 0 0 0 1 1 1 1 1    0 0 0 1 0 0

1 1 1 1  1 1 0 1 1 1 0 1  0 1 0 1 1 1 1 1  0 0 0 1

3

We observe that: (I + A) = (I + A) . We therefore stop the calculation at the power k = 4. ˆ = (I + A)5 , the rows indicate the successors of each node (when In the matrix A the value is 1) and the columns indicate the predecessors of each node (when the value is 1). The node v1 admits all other nodes as successors (first row formed by 1). The node v1 admits no predecessors (first column formed by 0 except on v 1). Such a node with no predecessors is a source and the graph is a tree of root v1 . The node v6 admits all other nodes as predecessors (sixth column formed by 1). The node v6 admits no successors (sixth row formed by 0 except on v6). Such a node with no successors is called a sink.

A second question of connectivity is the number of paths between any two nodes in the graph. This question is solved by calculating the algebraic powers of the adjacency matrix A. The matrix Ak (A power k) indicates the number of paths of length k between each pair of nodes, as shown by the following recurrence reasoning.

90

Optimization techniques

• Initialization For k = 1 , the element aij of the matrix A1 gives the number of paths of length 1 between node vi and node vj. This number is either 0 or 1. • Recurrence Note B = Ak and assume that the element bij of the matrix B gives the number of paths of length k between node v i and node vj. n

The matrix product C = BA is calculated by: cij =  bilalj , i, j = 1 to n . l=1

For two given nodes vi and vj, the term cij sums up all possible paths of length k starting from vi (term bil ) and which can be extended to v j by an arc between vl and vj (term alj ). This term gives the number of paths of length k+1 between the node vi and the node vj. In a graph with n nodes, an elementary path is of length n − 1 at most. We therefore stop the calculation at the matrix An−1 .

Example 2-3: Number of paths

Let us retrieve the graph with 5 nodes and 10 arcs from example 2-2 shown opposite.

Let us raise its adjacency matrix A to successive powers. 0  0 A = 0  1 1 

1 1 0 1 1 1   1 1 0 0 0 1 2 0 0 1 0 , A = 1 0   0 0 0 1 1 1  0 1 0 1 0 0 

2 1 0 1 2   1 1 0 1 1 3 0 0 1 , A = 1 1   2 0 1 1 2  2 1 1 1 1 

2 2 2 4 3   1 1 1 2 2 4 2 0 1 , A = 1 2   3 2 1 3 3  2 3 2 1 1 

5 2 3  3 1 2 3 2 1  4 3 3 4 2 3 

The element in row 3 column 1 of the matrix A4 indicates that there is only one path of length 4 between node v3 and node v1. Indeed, we observe that the only path of length 4 between these two nodes is: v3 → v4 → v1 → v5 → v1 .

Discrete optimization

91

Computations based on the adjacency matrix characterize the connectivity of a graph in a simple way. However, this approach is not the most efficient for low density graphs, because the adjacency matrix is then very sparse.

2.1.3 Complexity Combinatorial problems fall into different categories: •

path problems: - What is the minimum cost path between two nodes? - What is the minimum cost Hamiltonian circuit? (travelling salesman)



flow problems: - What is the maximum flow that can pass from the source to the sink? - What is the minimum cost of the maximum flow?



problems of assignment, coloring, stacking...

The difficulty comes from the number of combinations, which is an exponential function of the problem size. The size of a problem is the memory space required to store the data. It is measured by characteristic parameters: - for a graph with n nodes and m arcs, the size is measured by the pair (n,m); - for a square matrix nn, the size is measured by n. An algorithm is a sequence of elementary operations applied to data. The complexity of an algorithm is measured by the number of operations as a function of the size of the data. For example, consider the multiplication of two matrices of size nn. n

C = AB  cij =  aik bkj , i = 1 to n , j = 1 to n

(2.2)

k =1

The calculation of each element of the matrix C requires n multiplications and n additions. For the nn matrix elements, the total number of operations is 2n 3. The complexity of an algorithm is the order of magnitude of the number of operations as a function of the characteristic size n of the data: - a polynomial algorithm has a complexity in powers of n: 2 For example: O(n) , O(n log n) , O(n ) - a non-polynomial algorithm has a complexity in exponential of n: n

n n n For example: O(2 ) , O(n ) , O(n!) with n!   e

2n (Stirling formula)

92

Optimization techniques

A polynomial algorithm is considered efficient because it can handle large data sizes. A composition of polynomial algorithms remains polynomial. Table 2-1 shows the computation times as a function of the complexity of the algorithm and the size of the problem (from 10 to 10 000). The times are estimated for a computer performing one billion operations per second.

Table 2-1: Computation time as a function of algorithm complexity. Combinatorial problems are classified into optimization problems (OP) and existence problems (EP): •

an optimization problem consists in minimizing a function on a finite set: (PO): Find x* X such that f (x*) = min f (x) . xX

The answer to an optimization problem is the solution x*; •

an existence problem consists in answering a question of the type: (PE): There exists x  X such that f (x)  c . The answer to a problem of existence is 'yes' or 'no'.

The existence problem (EP) and the optimization problem (OP) are of comparable difficulty. Indeed, an algorithm solving (PO) can answer (PE). Conversely, an algorithm solving (PE) can solve (PO) by dichotomy on the value of c (the dichotomy being a polynomial algorithm). A combinatorial problem is said to be "easy" or "hard" depending on whether a polynomial algorithm for solving the existence problem is known. The problems are classified as NP, P and NPC. The class NP (Polynomial Non-Deterministic) contains problems for which a polynomial algorithm is used to verify a solution. The solution x0 is given (we do not care how it is obtained) and we have only to check that it solves problem (PE): f (x0 )  c . The class NP contains almost all combinatorial problems encountered in practice.

Discrete optimization

93

The class P (Polynomial Deterministic) contains problems for which a polynomial algorithm can find a solution. These problems are the easy NP problems. The NPC (NP-Complete or NP-Hard) class contains NP problems that do not belong to P and of "equivalent" difficulty. Two problems are said of equivalent difficulty if we can pass from one to the other by a polynomial transformation. NPC problems have no known polynomial solution algorithm. But, if a polynomial algorithm can be developed for one of them, then all NPC problems will fall into class P. NP problems that do not belong to either P or NPC are said to be indeterminate. Example 2-4 illustrates the different classes.

Example 2-4: NP, P and NPC problems (from [R12]) NP problems NP problems are those for which a polynomial algorithm for verifying a solution is known. NP problems are easy (P), hard (NPC) or indeterminate: • example of NP problem: Stacking problem: Are there p integers among n whose sum is b? Verification of a solution: We check that the p integers are among the n and that their sum is b. The verification algorithm is polynomial; • example of non-NP problem: Chess game: Is there a winning strategy in a given position? Verification of a solution: All possible games should be examined from the position. The verification algorithm is not polynomial; • example of NP indeterminate problem: Graph isomorphism: Can we pass from a graph G1 to a graph G2 by renumbering the nodes? The verification algorithm is polynomial, but it is not known if there is a polynomial solution algorithm. The problem is indeterminate. Problems of P P problems are those for which a polynomial solution algorithm is known. These problems are the easy NP problems:

94

• • • • • •

Optimization techniques

connectivity of a graph: Is there a path between any two nodes in a graph?; minimum cost path in a valued graph: What is the minimum cost path between two nodes in a graph?; maximum flow in a network: What is the maximum flow between the source and the sink?; Eulerian path in a graph: Is there a path that passes through each edge once and only once?; assignment (coupling): What is the minimum cost assignment between n resources and n tasks?; sorting n numbers.

NPC problems NPC problems are those for which no polynomial solution algorithm is known. These NP-complete problems are the NP-hard problems: •

• • •

coloring: Find the minimum number of colors to color a graph. The 4-color theorem for a planar graph conjectured in 1880 was proved in 1977 (computer-assisted demonstration); travelling salesman: Find the minimum cost Hamiltonian circuit in a valued graph. This problem serves as a test for combinatorial optimization algorithms; stacking (knapsack): Select items to fill a knapsack maximizing the total value; bin packing: Arrange objects using as few boxes as possible.

A combinatorial problem can be solved by mixed linear programming (chapter 1) or by a problem-specific algorithm (path, flow, assignment). These specific algorithms are presented from section 2.2 onwards. For large problems (easy or difficult), it is not possible to obtain the exact solution in a reasonable time. Approximate methods are either general metaheuristics (Volume I, chapter 2) or heuristics specific to a type of problem (stacking, bin packing, set covering, coloring). These heuristics, which generally use greedy approaches, are presented in section 2.6.

Discrete optimization

95

2.2 Path problem We place ourselves in a valued graph G = (V, E,C) defined by its nodes V, its arcs E and the costs of the arcs C. The classical problems consist in: - finding the minimum cost path between two given nodes; - finding the minimum cost path between a node and all other nodes; - finding the minimum cost path between all pairs of nodes. These problems can be solved by mixed linear programming (section 1.4.4) or by the following specific algorithms: - the Ford algorithm can be applied in any graph; - the Bellman algorithm applies in graphs without circuits; - the Dijkstra and A* algorithms apply if the valuations are positive. Table 2-2 summarizes the characteristics of these algorithms, which are detailed in the following sections. Their complexity is expressed as a function of the number of nodes n and the number of arcs m.

Table 2-2: Path algorithms.

2.2.1 Ford's algorithm Ford's algorithm determines the minimum cost path from the source to each node of the graph. The valuations of the arcs are of any sign. The minimum costs from the source to each node are improved iteratively. At each iteration, the node vi is marked with the value zi of the best cost found. The stages of the algorithm are as follows.

96

Optimization techniques

Initialization A value zs = 0 is assigned to the source and values zi =  to the other nodes. Iteration An iteration consists in traversing all the arcs of the graph in any order. Each node vi has a value zi. The arc from vi (value zi) to vj (value zj) has a cost cij. If zi + cij  z j , passing through vi improves the solution arriving at vj. The value of vj is updated: z' j = zi + cij . Each node is updated once per iteration. End of the algorithm We stop when no costs can be improved. Each node is then marked with the value of the best path from the source. In practice, it is not useful to go through all the arcs at each iteration. It is sufficient to examine the arcs starting from the nodes updated in the previous iteration. Example 2-5 illustrates how Ford's algorithm works.

Example 2-5: Ford's algorithm (from [R6]) Consider the 6-node valued graph shown opposite. The source is at v1. Some valuations are positive, others negative. Let us apply Ford's algorithm to find the minimum cost path from the source v1 to each of the nodes v2 ,v3 ,v4 ,v5 ,v6. Initialization The source v1 is given the value zi = 0 .

The other nodes receive the value zi =  .

Discrete optimization

Iteration 1 We examine all arcs in an arbitrary order, starting from the source v1. Each node is updated once at most. The arcs used for this iteration are in thick lines. Iteration 2 Unused arcs from iteration 1 are examined in an arbitrary order. Each node is updated once at most. The arcs used for this iteration are in thick lines. This iteration improves 2 nodes (v3,v4). Iteration 3 We examine the successors of the nodes updated at iteration 2 (v3,v4). Each successor is updated once at most. The arcs used for this iteration are in thick lines. This iteration improves 2 nodes (v5,v6). Iteration 4 We examine the successors of the nodes updated at iteration 3 (v5,v6). Each successor is updated once at most. The arcs used for this iteration are in thick lines. This iteration improves 1 node (v5). End of the algorithm There is no further improvement possible from the last updated node (v 5).

97

98

Optimization techniques

The value (or mark) of each node is the cost of the best path from the source to that node. The optimal arcs in thick lines are those whose cost equals the difference in marks between the start and end nodes. The minimum costs obtained in iteration 4 are summarized in the table opposite.

v1−v2

v1−v3

v1−v4

v1−v5

v1−v6

4

2

1

0

−1

Ford's algorithm is applicable in a graph with valuations of any sign. The graph may include circuits provided that these are not absorbing. The cost of an absorbing circuit is negative. The one shown here has a cost of −1. An absorbing circuit allows an unbounded decrease in the cost of a path. In the absence of an absorbing circuit, Ford's algorithm terminates in a finite number of iterations. The number of iterations depends on the order in which the arcs are processed. n

In a graph with n nodes, the complexity is in O(2 ) and Ford's algorithm is nonpolynomial. However, it is possible to derive polynomial algorithms by optimizing the order of processing of the arcs. This is the case of the Bellman and Dijkstra algorithms presented in the following sections.

2.2.2 Bellman's algorithm Bellman's algorithm applies in a graph without circuit (tree) with valuations of any sign. It proceeds in the same way as Ford's algorithm, but imposes an order of treatment of the nodes according to their position. In a graph without circuits, the nodes can be numbered in such an order that any arc connects nodes of increasing number. This order is called topological.

Discrete optimization

99

The Bellman algorithm processes the nodes in topological order. Each node is processed only once. The mark zi of node vi is the value of the best cost found. The stages of the algorithm are as follows. Initialization A value zs = 0 is assigned to the source and values zi =  to the other nodes. The n nodes (v1, v2 ,

, vn ) are arranged in topological order.

Treatment of nodes in topological order For each node vi, the values of the successors vj are updated. If zi + cij  z j , passing through vi improves the solution arriving at vj. The value of vj is updated: z' j = zi + cij . The node vj is processed. End of the algorithm We stop when the n nodes have been processed. Each node is then marked with the value of the best path from the source. Example 2-6 illustrates how Bellman’s algorithm works.

Example 2-6: Bellman’s algorithm (from [R6]) Consider the 5-node valued graph shown opposite. The source is at v1. The graph is circuit-free (tree). The valuations are of any sign. The nodes are numbered in topological order. Let us apply Bellman's algorithm to find the minimum cost paths from the source. The arcs used in each iteration are in thick lines.

100

Initialization The source v1 is given the value zi = 0 . The other nodes receive the value zi =  . The nodes are unprocessed.

Treatment of the first node The first node in topological order is v 1. The successors of v1 are updated. The node v1 is processed.

Treatment of the second node The second node in topological order is v 2. The successors of v2 are updated. The node v2 is processed.

Treatment of the third node The third node in topological order is v 3. The successors of v3 are updated. The node v3 is processed.

Treatment of the fourth node The fourth node in topological order is v 4. The successors of v4 are updated. The node v4 is processed.

Optimization techniques

Discrete optimization

101

Treatment of the fifth node The fifth node in topological order is v 5. This node has no successor. The node v5 is processed. End of the algorithm All nodes have been processed. The value (or mark) of each node is the cost of the best path from the source to that node. The optimal arcs in thick lines are those whose cost equals the difference in marks between the start and end nodes. The minimum costs are summarized in the table opposite.

v1−v2

v1−v3

v1−v4

v1−v5

6

−2

0

3

The topological order of a tree is not unique. A systematic way of constructing a topological order is to group the nodes by level: - level 0 is the set V0 of nodes without predecessors (sources); - level 1 is the set V1 of successors of V0; - level k is the set Vk of successors of Vk-1. A node can belong to several levels, as in figure 2-5b. Bellman's algorithm then consists in processing the nodes in successive levels. This level-based updating procedure is called dynamic programming. It relies on Bellman's principle of optimality. (a)

(b)

Figure 2-5: Bellman's optimality principle.

102

Optimization techniques

Bellman's optimality principle Any sub-path of an optimal path is itself optimal. Suppose that the optimal path from v 1 to vn passes through vi and vj, then the subpath from vi to vj is optimal. Indeed, if there were a better path from v i to vj (solid line in figure 2-5), the global path from v1 to vn would be improved by passing through this path. To apply the dynamic programming algorithm, the nodes in level 0 are initialized to z = 0 and the others to z =  . At each stage, the value z(vi ) is the cost of the best known path from the source to node v i. The nodes of level k are updated from their predecessors by

z(v j ) = min ( z(vi ) + cij ) viVk −1

(2.3)

The value z(v j ) will thus be the cost of the best path from the source to node v j. The relationship (2.3) called the functional equation of dynamic programming is illustrated in figure 2-6. Passing through vi1 : z1 = z(vi1 ) + ci1− j Passing through vi2 : z2 = z(vi2 ) + ci2− j Passing through vi3 : z3 = z(vi3 ) + ci3− j Best path:

z(vj ) = min(z1,z2 ,z3 ) Figure 2-6: Functional equation for dynamic programming.

Since each of the m arcs of the graph is processed only once, the complexity of the dynamic programming algorithm is O(m) . Dynamic programming can be applied forwards or backwards: • the objective of the forward procedure is to determine the optimal paths from the source to each node. We start from the first level and try to minimize the cost by adding up the costs of the examined arcs; • the objective of the backward procedure is to determine the optimal paths from each node to the sink. It starts from the last level and seeks to maximize the cost by subtracting the costs of the examined arcs. These two procedures are illustrated in example 2-7.

Discrete optimization

103

Example 2-7: Dynamic programming algorithm (from [R6]) Consider the 5-level valued graph in figure 2-7.

Figure 2-7: 5-level graph.

Let us apply the forward dynamic programming algorithm to find the minimum cost paths from the source to each node. The levels are processed in ascending order. The optimal arcs selected at each level are in thick lines. Treatment of level 1

104

Treatment of level 2

Treatment of level 3

Treatment of level 4

Optimization techniques

Discrete optimization

105

Figure 2-8 shows the optimal arcs in thick lines. The optimal paths from the source to each node are listed below.

Figure 2-8: Optimal forward paths.

Let us apply the backward dynamic programming algorithm to the same graph to find the minimum cost paths from each node to the sink. The levels are processed in descending order. The optimal arcs selected at each level are in thick lines. Treatment of level 3

106

Treatment of level 2

Treatment of level 1

Treatment of level 0

Optimization techniques

Discrete optimization

107

Figure 2-9 shows the optimal arcs in thick lines. The optimal paths from each node to the sink are listed below.

Figure 2-9: Optimal backward paths.

2.2.3 Dijkstra's algorithm Dijkstra's algorithm applies in a graph with positive valuations. It is identical to Ford's algorithm in that it treats the nodes by increasing value. Therefore, each node has to be processed only once. Initialization A value zs = 0 is assigned to the source and values zi =  to the other nodes. The nodes are initially unprocessed. Treatment of a node From the unprocessed nodes, we choose the node vi with the minimum value zi. The values of the nodes vj successors of node vi are updated. If zi + cij  z j , passing through vi improves the solution arriving at vj. The value of vj is updated: z' j = zi + cij . The node vj is processed.

108

Optimization techniques

End of the algorithm We stop when the n nodes have been processed. Each node is then marked with the value of the best path from the source. Example 2-8 illustrates how Dijkstra’s algorithm works.

Example 2-8: Dijkstra’s algorithm Consider the 5-node valued graph shown opposite. The source is at v1. The valuations are positive. Let us apply Dijkstra's algorithm to find the minimum cost paths from the source. The arcs used in each iteration are in thick lines. Initialization The source v1 has the value: zi = 0 .

The other nodes have the value: zi = . The nodes are unprocessed. Treatment of the first node The unprocessed nodes are: v1,v2,v3,v4,v5. The minimum value node is v1. The successors of v1 are updated. The node v1 is processed. Treatment of the second node The unprocessed nodes are: v2,v3,v4,v5. The minimum value node is v3. The successors of v3 are updated. The node v3 is processed.

Discrete optimization

109

Treatment of the third node The unprocessed nodes are: v2,v4,v5. The minimum value node is v5. The successors of v5 are updated. The node v5 is processed. Treatment of the fourth node The unprocessed nodes are: v2,v4. The minimum value node is v2. The successors of v2 are updated. The node v2 is processed. Treatment of the fifth node The unprocessed nodes are: v4. The minimum value node is v4. This node has no successor. The node v4 is processed.

End of the algorithm All nodes have been processed. The value (or mark) of each node is the cost of the best path from the source to that node. The optimal arcs in thick lines are those whose cost equals the difference in marks between the start and end nodes. The minimum costs are summarized in the table opposite.

v1−v2

v1−v3

v1−v4

v1−v5

5

2

6

3

110

Optimization techniques

Dijkstra's algorithm is faster than Ford's algorithm, because each node is processed only once. Its complexity is in O ( m.log(n) ) where n and m are the number of nodes and arcs, respectively. This polynomial algorithm is very 2 efficient on sparse graphs (m n ) , such as planar graphs for which m  3n − 6. It is especially used to find the shortest path in a road network.

2.2.4 A* algorithm Dijkstra’s algorithm processes the minimum value node at each stage without accounting for the remaining path (which is unknown). The A* algorithm modifies Dijkstra's algorithm by using an estimate of the remaining cost in order to choose which node to process. This estimate is given by a function h called heuristic. The heuristic h associates to each node vi an arbitrary estimate hi of the remaining cost between the node v i and the sink t. The valuation of node vi is the sum of the cost zsi (known) between s and vi and the cost hi (estimated) between vi and t. This valuation is noted: ei = zsi + hi .

Figure 2-10: Valuation of a node with heuristic. At each stage the A* algorithm processes the minimum valuation node, which is the most promising. Unlike Dijkstra’s algorithm, each node can be processed several times. The mark zsi of the node vi is the value of the best cost found between the source s and the node. The stages of the algorithm are as follows.

Discrete optimization

111

Initialization A value zs = 0 is assigned to the source and values zsi =  to the other nodes. All nodes are initially closed, except for the source s. Treatment of a node A node is open when its cost is changed from a predecessor. A node is closed when the costs of all its successors have been updated. Among the open nodes we choose the node vi of minimum valuation ei. The values of the nodes vj successor of node vi are updated. If zsi + cij  zsj , passing through vi improves the solution arriving at vj The value of vj is updated: z'sj = zsi + cij and the node vj is open. The node vi is closed when all its successors have been processed. End of the algorithm We stop when the best open node is the sink t. Each node is then marked with the value of the best path from the source. The number of nodes processed and the path obtained depend on the heuristic chosen. The two extreme cases are the null heuristic and the perfect heuristic: • the null heuristic (h i = 0) does not use an estimate of the remaining path. The chosen node is then the minimum cost node. This amounts to Dijkstra’s algorithm and all nodes are processed once; • the perfect heuristic (hi = zit ) assumes that the cost of the remaining optimal path is known. The chosen node is then on the optimal path. The optimal path is obtained directly, because the evaluation gives the exact solution. A poorly chosen heuristic may lead to more nodes being processed than Dijkstra’s algorithm, or it may even result in a non-optimal path. Before examining the properties of the heuristic, let us consider a first example of application of the A* algorithm where the heuristic is defined by the number of remaining arcs from the node to the sink.

112

Optimization techniques

Example 2-9: A* algorithm Consider the 16-node graph in figure 2-11.

Figure 2-11: Heuristic with estimation by the number of remaining arcs. The nodes are indicated by their abscissa and ordinate. The node vij has coordinates (i ; j). The start node (source) is v11. The end node (sink) is v44. The valuations of the arcs are positive and indicated on the arrows. The heuristic giving the remaining cost is the number of remaining arcs to v44: - for the starting node v11, there are 6 arcs to go; - for the node v43, there is 1 arc left to go. This estimate is indicated in brackets at the top right of each node. Let us apply the A* algorithm to find the minimum cost paths from the source to each node. At each iteration, we indicate: - the list of open nodes with their estimation; - the node to be treated (having the lowest estimate); - the best path found at this iteration; - the total number of nodes evaluated since the beginning. Nodes that have already been assessed are shown in dark grey, open nodes in light grey and the node to be treated is framed in thick lines.

Discrete optimization

Iteration 1 Open nodes: v12 (6.1), v21 (6) Node to be treated: v21 (6) Best path: z=1 v11 − v21 Updated nodes: 3 Iteration 2 Open nodes: v12 (6.1), v22 (7), v31 (6) Node to be treated: v31 (6) Best path: z=2 v11 − v21− v31 Updated nodes: 5 Iteration 3 Open nodes: v12 (6.1), v22 (7), v32 (7), v41 (6) Node to be treated: v41 (6) Best path: z=3 v11 − v21 − v31 − v41 Updated nodes: 7

113

114

Iteration 4 Open nodes: v12 (6.1), v22 (7), v32 (7), v42 (6) Node to be treated: v42 (6) Best path: z=4 v11 − v21 − v31 − v41 − v42 Updated nodes: 8 Iteration 5 Open nodes: v12 (6.1), v22 (7), v32 (7), v43 (6) Node to be treated: v43 (6) Best path: z=5 v11 − v21 − v31 − v41 − v42 − v43 Updated nodes: 9 Iteration 6 Open nodes: v12 (6.1), v22 (7), v32 (7), v44 (6) Node to be treated: v44 (6) Best path: z=6 v11 − v21 − v31 − v41 − v42 − v43 − v44 Updated nodes: 10

Optimization techniques

Discrete optimization

115

The algorithm is finished, as the node to be processed is the sink v44. The path obtained by A* algorithm is: v11 − v21 − v31 − v41 − v42 − v43 − v44 of cost: z = 6. The result is obtained in 6 iterations (= 6 processed nodes) and by updating a total of 10 nodes (nodes in grey that received an evaluation during the algorithm). Let us compare this result to the one obtained by Dijkstra's algorithm, which processes each node only once by choosing the node of minimum evaluation. This is equivalent to applying the A* algorithm with the null heuristic as shown in figure 2-12 by the zero in brackets on each node. The nodes are then processed in the following order (with their evaluation in brackets).

v11 (0) → v21 (1) → v12 (1.1) → v31 (2) → v13 (2.2) → v22 (2.6) → v41 (3) → v14 (3.3) → v32 (3.6) → v42 (4) → v23 (4.2) → v24 (4.3) → v33 (4.6) → v43 (5) → v44 (6)

Figure 2-12: Optimal path with null heuristic (Dijkstra).

Dijkstra’s algorithm gives the optimal path by processing 15 nodes and updating a total of 23 nodes. A* algorithm gives the optimal path by processing only 6 nodes and updating a total of 10 nodes. The performance of A* algorithm is much better in this example, but this is not always the case. Let us take the graph from figure 2-11 and change the cost of arc v43-v44, which passes from 1 to 4. The iterations of the A* algorithm remain the same until iteration 5, which gives the figure 2-13.

116

Optimization techniques

Figure 2-13: Change in the cost of arc v43-v44.

With the new cost of the arc v43-v44, the sink takes the value 9 and is no longer the minimum valuation node. In that case, A* algorithm is not finished and the iterations continue as follows. Iteration 6 Open nodes: v12 (6.1), v22 (7), v32 (7), v44 (9) Node to be treated: v21 (6.1) Best path: z = 1.1 v11 − v12 Updated nodes: 10

Discrete optimization

Iteration 7 Open nodes: v13 (6.2), v22 (6.6), v32 (7), v44 (9) Node to be treated: v13 (6.2) Best path: z = 2.2 v11 − v12 − v13 Updated nodes: 12

Iteration 8 Open nodes: v14 (6.3), v22 (6.6), v23 (7.2), v32 (7), v44 (9) Node to be treated: v14 (6.3) Best path: z = 3.3 v11 − v12 − v13 − v14 Updated nodes: 14 Iteration 9 Open nodes: v22 (6.6), v23 (7.2), v24 (6.3), v32 (7), v44 (9) Node to be treated: v24 (6.3) Best path: z = 4.3 v11 − v12 − v13 − v14 − v24 Updated nodes: 15

117

118

Iteration 10 Open nodes: v22 (6.6), v23 (7.2), v32 (7), v34 (9.3), v44 (9) Node to be treated: v22 (6.6) Best path: z = 2.6 v11 − v12 − v22 Updated nodes: 16

Iteration 11 Open nodes: v23 (7.2), v32 (6.6), v34 (9.3), v44 (9) Node to be treated: v32 (6.6) Best path: z = 3.6 v11 − v12 − v22 − v32 Updated nodes: 18

Iteration 12 Open nodes: v23 (7.2), v33 (6.6), v34 (9.3), v44 (9) Node to be treated: v33 (6.6) Best path: z = 4.6 v11 − v12 − v22 − v32 − v33 Updated nodes: 20

Optimization techniques

Discrete optimization

119

Iteration 13 Open nodes: v23 (7.2), v34 (6.6), v44 (9) Node to be treated: v34 (6.6) Best path: z = 5.6 v11 − v12 − v22 − v32 − v33 − v34 Updated nodes: 22 Iteration 14 Open nodes: v23 (7.2), v44 (6.6) Node to be treated: v44 (6.6) Best path: z = 6.6 v11 − v12 − v22 − v32 − v33 − v34 − v44 Updated nodes: 23 The algorithm is finished, as the node to be processed is the sink v44. The resulting path is: v11 − v12 − v22 − v32 − v33 − v34 − v44 of cost: z = 6.6. In this modified example (figure 2-13), the performance (14 nodes processed and 23 nodes updated) is strictly identical to that of Dijkstra’s algorithm.

The behavior of the A* algorithm depends on the properties of the heuristic. Let us go back to the notations of Figure 2-10 reproduced opposite.

120

Optimization techniques

To analyze the properties of the heuristic, we construct the revalued graph in which the valuations of the arcs are replaced by

c'ij = cij − (hi − h j )

(2.4)

Assume that these valuations are positive (assumption of consistency discussed below) and consider a node vj at the current iteration. The best known path from the source s to node vj is: (s − vi1 − vi2 − − vik − vj ) and it has a cost zsj. The valuation of the node vj with the heuristic h is given by

ej = zsj + h j

(2.5)

Expressing the sum of the arc costs from s to v j, and using (2.4), we obtain

ej = zs + cs−i1 = zs + c's−i1 + (hs − hi1 ) = zs + c's−i1 = z 'sj + hs

+ ci1−i2 + + c'i1−i2 + + (hi1 − hi2 ) + + c'i1−i2 +

+ cik − j + h j + c'ik − j + (hik − h j ) + h j + c'ik − j + hs

(2.6)

denoting z'sj the cost of the path from s to vj in the revalued graph. Formula (2.6) shows that the node of best valuation ej is also the node of best cost z'sj in the revalued graph (within the constant hs). A* algorithm with heuristic h is thus equivalent to Dijkstra’s algorithm in the revalued graph. Since A* algorithm stops when the best node is the sink, it examines at most the n nodes of the graph and gives the solution faster than Dijkstra’s algorithm. This assumes that the heuristic h satisfies certain conditions discussed below. Let us first illustrate in example 2-9 the equivalence with Dijkstra's algorithm.

Example 2-10: Equivalence between A* and Dijkstra’s algorithm Let us retrieve the example 2-9 with the heuristic defined by the number of remaining arcs. The solution obtained in iteration 6 is shown below.

Discrete optimization

121

Solution A* Open nodes: v12 (6.1), v22 (7), v32 (7), v44 (6) Node to be treated: v44 (6) Best path: z=6 v11 − v21 − v31 − v41 − v42 − v43 − v44 Updated nodes: 10

Figure 2-14 shows the revalued graph where the arc costs are changed to: c'ij = cij + (hi − h j ) . The heuristic being the number of remaining arcs, this amounts to decreasing the costs of the arcs by 1. The new costs are written to the right or above the arcs. Let us apply Dijkstra's algorithm to this revalued graph. This gives the solution in figure 2-14. Dijkstra solution Sequence of nodes processed: v11 (0) → v21 (0) → v31 (0) → v41 (0) → v42 (0) → v43 (0) → v44 (0) Figure 2-14: Dijkstra’s algorithm in the revalued graph. Dijkstra's algorithm in the revalued graph follows the same order of node processing as A* algorithm and it reaches the solution after 6 processed nodes. However, Dijkstra’s algorithm continues to process the remaining 9 nodes, while A* algorithm stops.

122

Optimization techniques

The following properties guarantee that the heuristic h finds the optimal path, while performing fewer iterations than Dijkstra’s algorithm. Feasible heuristic A heuristic is feasible if it underestimates the cost of the remaining path between each node and the sink: hi  zit . A feasible heuristic ensures that the optimal path is found. Let us assume that the optimal path has a cost z* and that a node v i is located on the optimal path. Its valuation ei = zsi + hi is lower than z*. When all other paths have been traversed and show a cost greater than z*, the node vi will be processed. Conversely, a non-feasible heuristic may result in a non-optimal path as shown in the following example.

Example 2-11: Non-feasible heuristic Consider the graph in figure 2-15a with the heuristic in parentheses on each node. This heuristic is not feasible, because it overestimates the path cost from v 2 to t:  h2 = 3 z = 1 → h2  z2t  2t (a)

(b)

Figure 2-15: Non-feasible heuristic. The optimal path is s − v2 − t of cost z* = 2 . A* algorithm results in the path: s − v1 − t of cost z = 3 shown in figure 2-15b. The node v2 remains open, as its valuation e2 = 4 is higher than that of the sink et = 3 . A* algorithm stops at a non-optimal solution.

Discrete optimization

123

Consistent heuristic A heuristic is consistent if it underestimates the cost of arcs: hi  hj + cij . In this case, the valuations (2.4) are positive and A* algorithm is equivalent to Dijkstra’s algorithm in the revalued graph. The optimal solution is then obtained by processing fewer (or as many) nodes as Dijkstra’s algorithm. A consistent heuristic is therefore feasible. It is also monotonous, which means that the evaluation decreases between a node and its successors: ei  ej . An inconsistent heuristic is detected by negative valuations (2.4). Such a heuristic can be feasible, but it may reopen nodes already processed as in example 2-12. In such cases, the A* algorithm performance may be strongly degraded.

Example 2-12: Inconsistent heuristic Consider the graph in figure 2-16a with the heuristic in parentheses on each node. The heuristic is not consistent, as it overestimates the cost of the arc v 2 − v3 :  h2 = 2   h3 = 0,5 → h2  h3 + c23 c23 = 0 (a)

(b)

Figure 2-16: Inconsistent heuristic. The heuristic is nevertheless feasible. Figure 2-16b shows for each node the optimal cost from that node to the sink. We can check that the heuristic underestimates each remaining cost.  z4t = 2  z3t = 2   z2t = 2  z1t = 3 z = 3  st

    

h4 = 1,5 h3 = 0,5 h2 = 2 h1 = 1 hs = 3

→ feasible heuristic

124

Optimization techniques

Let us apply A* algorithm with this feasible, but inconsistent, heuristic. The progress of the algorithm is shown in figure 2-17. The table in figure 2-17 gives the iterations of the algorithm with the processed node in the first column. The node v 3 is opened a first time at iteration 3 corresponding to the top schema. This node v3 is opened a second time at iteration 5 corresponding to the bottom schema.

Figure 2-17: A* algorithm with inconsistent feasible heuristic.

The algorithm terminates at iteration 5, because the node to be processed is the sink of valuation 3. The optimal solution is well found, as the heuristic is feasible. The node v3 has been processed twice, because the heuristic is not consistent (on the arc v2 − v3).

2.2.5 Demoucron and Floyd’s algorithm Ford's algorithm gives the minimum cost between the source and each node. The algorithm of Demoucron and Floyd is an extension to obtain the minimum cost between any two nodes. The matrix of minimum costs between all pairs of nodes is called the distancer. This matrix D of size nn is obtained in n iterations in a similar way to Ford's algorithm.

Discrete optimization

125

Initialization The elements of the matrix D are filled with the value: - dij = cij if the nodes vi and vj are connected by an arc of cost cij; - dij =  if the nodes vi and vj are not connected. Iteration k (1  k  n) The matrix D gives the cost of the best path between each pair of nodes. Iteration k consists of examining for each pair of nodes (v i , vj) the passage through the intermediate node vk. The best path from vi to vj has a cost dij. Passing through vk would have a cost dik + dkj. If dik + dkj  dij , passing through vk improves the solution between vi and vj. The value of dij is updated: d'ij = dik + dkj . Each element of the matrix D is updated in this way during the iteration. End of the algorithm We stop when the n nodes have been considered as intermediate nodes. The matrix D then contains the costs of the best paths between pairs of nodes. Like Ford's algorithm, Demoucron and Floyd's algorithm is applicable in a graph with any valuations and assumes that the graph does not contain an absorbing circuit. The presence of an absorbing circuit is detected by the appearance of a negative element on the diagonal of D: dii  0 . The algorithm consists of three nested loops: From k=1 to n (iteration k = number of the intermediate node) From i=1 to n (i = number of the starting node) From j=1 to n (j = number of the arrival node) Replace dij with min(dij ,dik + dkj ) Example 2-13 illustrates how Demoucron and Floyd’s algorithm works.

126

Optimization techniques

Example 2-13: Demoucron and Floyd's algorithm (from [R6]) Consider the 6-node valued graph shown opposite.

Let us apply the Demoucron and Floyd’s algorithm to calculate the distancer. Initialization The matrix D is filled with: dij = cij if nodes vi and vj are connected.

dij =  otherwise (shaded boxes).

Iteration 1 We examine the passage through the node v1. The column v1 is empty in the matrix. The node v1 does not receive any arcs. v1 cannot be an intermediate node. The matrix D is not changed. Iteration 2 We examine the passage through the node v2. The column v2 has a value from v1. We compare the costs d1j and d12 + d2 j .

d12 + d21 =  d12 + d22 =  d12 + d23 =  d12 + d24 = 5  6 → improvement d12 + d25 = 9   → improvement d12 + d26 = 

The matrix D is updated with the improved costs.

Discrete optimization

127

Iteration 3 We examine the passage through the node v3. The column v3 has values from v1 and v4. We compare the costs d1j and d13 + d3j .

d13 + d31 =  , d13 + d32 =  d13 + d33 =  , d13 + d34 =  d13 + d35 = 9 = d15 → identical d13 + d36 =  We compare the costs d 4 j and d43 + d3j .

d43 + d31 =  , d43 + d34 =  d43 + d32 =  , d43 + d35 = 3   → improvement d43 + d33 =  , d43 + d36 =  The matrix D is updated with the improved costs. For the following iterations, only the paths improved by the intermediate node are shown.

Iteration 4 We examine the passage through the node v4. The column v4 has values from v1 and v2. We compare the costs d1j and d14 + d4 j .

d14 + d43 = 7  8 → improvement d14 + d45 = 8  9 → improvement d14 + d46 = 12   → improvement We compare the costs d 2 j and d24 + d4 j .

d24 + d43 = 4   → improvement d24 + d45 = 5  6 → improvement d24 + d46 = 9   → improvement

128

Optimization techniques

Iteration 5 We examine the passage through the node v5. The column v5 has values from v1, v2, v3, v4. We compare the costs d1j and d15 + d5 j .

d15 + d56 = 10  12 → improvement We compare the costs d 2 j and d25 + d5 j . d25 + d56 = 7  9

→ improvement

We compare the costs d3 j and d35 + d5 j .

d35 + d56 = 3   → improvement We compare the costs d 4 j and d 45 + d5 j .

d45 + d56 = 5  7 → improvement Iteration 6 We examine the passage through the node v6. The row of v6 is empty (no arc starts from v6) and this node v6 cannot be an intermediate node. End of the algorithm All 6 nodes were examined. We obtain the distancer shown opposite.

2.3 Scheduling problem Scheduling consists in planning a process made up of different tasks, while respecting certain time constraints between the tasks. The objective is to complete the process as quickly as possible. The process consists of n tasks T1,

,Tn with respective durations d1, ,dn . The start and end dates of the task Ti are noted t i,d and t i,f = t i,d + d i .

The start dates of the tasks are the unknowns of the scheduling problem. Fictitious tasks T0 and T are also introduced, representing the beginning and end of the process, respectively. There may be several types of constraints on task completion.

Discrete optimization

129

Potential constraints - The task Ti cannot start before a given date:

t i,d  t i min ;

- the task Ti must be completed by a given date:

t i,f  t i max ;

- the task Ti cannot start before the task Tj is finished: t i,d  t j,f . Disjunctive constraints - The tasks Ti and Tj cannot occur simultaneous:  t i,d , t i,f 

 t j,d , t j,f  =  .

Cumulative constraints These constraints reflect limitations related to the resources available (machines, personnel, cost, etc.) to perform the tasks. They take into account aspects other than the temporal order and are specific to each problem. Standard scheduling algorithms only take into account potential constraints. The approximate GANTT method (bar chart) developed by K. Adamiecki (1896), then H. Gantt (1910) was for a long time the only one available. It is still useful for visualizing a schedule optimized by other methods, such as the PERT and MPM methods developed from 1958. These two methods based on a task graph are presented in the following sections.

2.3.1 PERT method The PERT method (Program Evaluation Research Task or Program Evaluation and Review Technique) also known as the CPM (Critical Task Method) is one of the first operational research methods. It was developed in the USA in 1958 to plan the nuclear submarine program. Each task Ti has a start event Ti,d and an end event Ti,f . These events form the nodes of a graph. The events T0 and T are added to represent the beginning and the end of the process. The arcs connect events and have the value of the time between events: • an arc between the start and end of a task has the value of the task duration; • a potential constraint (between the end of a task Ti and the beginning of another task Tj ) is taken into account by an arc of zero duration (or equal to the delay to be respected) between Ti,f and Tj,d .

130

Optimization techniques

The PERT method consists in applying Bellman's algorithm (section 2.2.2) in this graph by looking for the path of maximum length between T0 and T called the critical path of the process. The length of this path is the minimum time required to execute all tasks, while satisfying the potential constraints. There may be several critical paths (of equal duration). A task on a critical path is a critical task. It cannot be delayed without increasing the total duration of the process. A non-critical task has a margin and can be delayed without affecting the total duration.

Example 2-14: PERT method (from [R6]) Let us consider a process with 9 tasks labelled A, B, C, D, E, F, G, H, I. The tasks T0 and T represent the beginning and end of the process. Table 2-3 shows the duration and prerequisite events for each task.

Table 2-3: Task durations and prerequisites. Task I can start when task C is half completed. This intermediate event noted C m is added to the set of tasks and gives table 2-4.

Table 2-4: Task durations and prerequisites with intermediate events. The PERT graph is shown in figure 2-18. The nodes are the start and end events of the tasks given in table 2-4. The arcs connect successive events and have the value of the duration between the events. Dashed arcs mean zero duration. The point task Cm is represented by a single node for simplicity (it can be represented by its start and end linked by an arc of zero duration, but this arc does not interact with the rest of the graph).

Discrete optimization

131

Figure 2-18: PERT graph. Let us apply Bellman's algorithm to find the path of maximum duration from T0 to T . Figure 2-19 shows the costs of the nodes at the end of the algorithm.

Figure 2-19: Bellman's algorithm on PERT graph. The critical path (thick line) is: Cd − Cm − Cf − Fd − Ff − Gd − Gf of duration 63. The critical tasks are therefore C, F and G. The valuations of the nodes represent the earliest start dates of each task. These dates are summarized in table 2-5.

Table 2-5: Earliest start and end dates for each task.

132

Optimization techniques

2.3.2 MPM method The MPM method (Méthode des Potentiels Métra) was developed by B. Roy of the Métra company to plan the construction of the liner "France" in 1958. Like the PERT method, it comes down to a path problem in a graph. Each node represents the start of a task. The arcs represent duration constraints. All arcs starting from a task Ti,d have the same valuation di equal to the duration of the task Ti . This graph is similar to the PERT graph, except that it does not show "end of task" events. The MPM method implicitly applies Bellman's algorithm in the form of a table indicating for each task the prior tasks and their durations. This table is filled in progressively from the beginning T0 to find the earliest start and end dates of each task. The use of the MPM table is simple and avoids the explicit construction of the graph. The MPM method is illustrated on the previous scheduling problem.

Example 2-15: MPM method (from [R6]) Let us retrieve the scheduling problem from example 2-14. Table 2-4 is reproduced below with the intermediate task Cm representing half the completion of task C.

The MPM graph is shown in figure 2-20. The nodes are the beginnings of the tasks. The arcs originating from a node have the duration of the task as their value.

Figure 2-20: MPM graph.

Discrete optimization

133

Figure 2-21 shows the result obtained by Bellman's algorithm and the critical path C − F − G of duration 63.

Figure 2-21: Bellman's algorithm on the MPM graph. The MPM method consists of implicitly applying Bellman's algorithm in the form of an array. The initial MPM table is shown below. For the following presentation, this table has been split into two parts: A-B-C-D then E-F-G-H-I-T . The table is divided into columns associated with each task. For each task, the first row shows the name of the task and the rows below show all the previous tasks with their duration. For example, task G has as a prerequisite tasks D (duration 8), E (duration 18) and F (duration 25). An initially empty column is added to the left of each task column. These left-hand sub-columns will be filled in with the earliest dates.

Table 2-6: Initial MPM table.

134

Optimization techniques

First level We start with the first task T0 whose earliest date is known (= 0).

This date is entered to the left of T0 in the sub-columns where T0 appears, namely A, B, Cm. The columns A, B, Cm are then complete, because all their prior tasks have their date known. We can then calculate the earliest date of tasks A, B, C m. For example, the earliest date of A is: 0 (earliest date of T0 ) + 5 (duration from T0 to A). This earliest date is entered in the top left-hand cell of column A (same procedure for B and C).

Second level Columns A, B, Cm are complete. The earliest dates of tasks A, B, C m are known. These dates are entered in the sub-columns where A, B, Cm appear, namely C, D, E, F. Columns C, D, E are complete, as all their prior tasks have their date known. We can then calculate the earliest date of tasks C, D, E. For example, the earliest date of D is the maximum between: - 5 (earliest date of A) + 16 (duration from A to D); - 0 (earliest date of B) + 14 (duration from B to D). These earliest dates are entered in the top left-hand cell of columns C, D, E.

Discrete optimization

135

Third level Columns C, D, E are complete. The earliest dates of tasks C, D, E are known. These dates are entered in the sub-columns where C, D, E appear, namely F, G, H, I. The columns F, I are complete, because all their prior tasks have their date known. We can then calculate the earliest date of tasks F, I. For example, the earliest date of F is the maximum between: - 0 (earliest date of B) + 14 (duration from B to F); - 13 (earliest date of C) + 10 (duration from C to F). The earliest dates are entered in the top left-hand cell of columns F, I.

Fourth level Columns F, I are complete. The earliest dates of tasks F, I are known. These dates are entered in the sub-columns where F, I appear, namely G, H, T. Columns G, H are complete. The earliest date of tasks G, H can be calculated. The table can then be completed by calculating the earliest final date (column T). The final MPM table is presented in table 2-7.

Table 2-7: Final MPM table.

136

Optimization techniques

This final table shows the earliest dates of each task at the top left of the columns. The critical path is reconstructed from the end. The critical operation in each column is the one that gave the earliest date. T → G G → F F → C C → Cm Cm → T0 63 = 48+15 48 = 23+25 23 = 13+10 13 = 3+10 3 = 0+3

2.3.3 Margins Bellman’s algorithm in the form of PERT or MPM gives the critical path. Events on the critical path have an imperative date. For non-critical events, there may be a margin on the date of the event. A distinction is made between: - the free margin which does not shift the dates of other events; - the total margin that does not shift the final date of the process. An event Ei has an earliest starting date ti min given by Bellman’s algorithm and a latest starting date ti max (not known) which would not shift the end of the process. The durations dij separating consecutive events Ei and Ej are known. The earliest and latest dates as well as the margins are related by the following relations: •

the Ei event must wait for its predecessors:

ti min = max (t jmin + d ji ) ;



the Ei event must not delay its successors:

ti max = min (t jmax − dij ) ;



if the event Ei is on the critical path:

ti max = ti min ;



if the arc (or task) Ei − Ej is on the critical path: t jmin = ti min + dij .

jPr ed(i)

jSucc(i)

The free margin on the task Ei − Ej is:

mij = t jmin − ti min − dij .

The total margin on the task Ei − Ej is:

Mij = t jmax − ti min − dij .

The duration of the task Ei − Ej can be increased: - of mij without changing the dates of subsequent events; - of Mij without changing the final date, but this will postpone the later events to their latest date (and their free margins become then zero). When Bellman’s algorithm is complete, the latest dates are calculated backwards from the final date and the free and total margins are derived.

Example 2-16: Margins (from [R6]) Consider the 4-event problem A, B, C, D in figure 2-22.

Discrete optimization

137

The critical path: T0 − B − D − T is of duration 6.

Figure 2-22: Critical path and margins. Bellman’s algorithm yields the event earliest dates (1st number in brackets in figure 2-22). The latest dates (2nd number in brackets) are calculated backwards from T by subtracting the durations of the arcs travelled. The latest date of an event depends on the latest dates of its successors: ti max = min (t jmax − dij ) . jSucc(i)

These earliest and latest dates are summarized in table 2-8.

Table 2-8: Earliest and latest dates. The earliest and latest dates are used to determine for each task: - its free margin: mij = t jmin − ti min − dij ; - its total margin: Mij = t jmax − ti min − dij . These margins are given in table 2-9 where the critical tasks are colored.

Table 2-9: Free and total margins. It can be seen that the tasks (T0 − A) and (A − C) have a free margin of 0, although they are not critical. Therefore, these tasks cannot be delayed without shifting the subsequent tasks and the final date.

138

Optimization techniques

2.4 Flow problem We consider a network (section 2.1.1) defined by its nodes and (oriented) arcs. The capacity and cost of the arc from node i to node j are noted fij and cij . The nodes s and t are the entry (source) and exit (sink) points of the network. The standard flow problems are: - the search for the maximum flow that can pass through the network; - the search for the maximum flow with minimum cost (if several solutions exist). These problems can be solved by linear programming (section 1.4.4) or by the specific Ford-Fulkerson and Roy-Busacker-Gowen algorithms presented in the sections 2.4.1 and 2.4.2.

2.4.1 Ford-Fulkerson algorithm Ford-Fulkerson algorithm determines the maximum flow that can traverse a network. It is an iterative method based on the notion of augmenting path. Augmenting path Suppose that an initial flow is known. Each arc v i - vj is traversed by a flow xij  fij and the conservation law is respected at each node. An elementary chain is a sequence of distinct nodes connected by (non-oriented) edges. Figure 2-23 shows an elementary chain (v1, v2 , v3 , v4 ) with two direct arcs

(v1 − v2 , v3 − v4 ) and one indirect dashed arc (v2 − v3 ) .

Figure 2-23: Elementary chain. An elementary chain is said to be augmenting if: xij  fij ; - its direct arcs are not saturated: - its indirect arcs are of non-zero flow:

xij  0 .

The flow along the augmenting path can be increased of the quantity  : - by increasing the flow of direct arcs:

xij  fij →   fij − xij ;

- by decreasing the flow of indirect arcs: xij  0 →   xij .

Discrete optimization

139

This variation throughout the chain increases the total flow of  , while satisfying the conservation law (already satisfied by the initial flow). Figure 2-24 illustrates the effect of the variation  along the augmenting path.

Figure 2-24: Augmenting path. Node marking The search for an augmenting path is carried out by marking the nodes, according to the following procedure: •

initialization: - the source is marked +; - the other nodes are unmarked.



node marking: the set of arcs is traversed starting from the source and examining at each node the set of incoming and outgoing arcs. For an arc [u − v] : - if u marked and [u − v] unsaturated, then v is marked + (direct arc); - if v marked and [u − v] of non-zero flow, then u is marked − (indirect arc). For each node we store its predecessor in the order of marking.



augmenting path: if the sink is marked, the flow is not maximum. The augmenting path is obtained by going back to the predecessors from the sink. The flow is increased by  along the augmenting path: - the flow of direct arcs [vi − vj ] is increased by  (with   fij − xij ); - the flow of indirect arcs [vi − vj ] is decreased by  (with   xij ).

The procedure stops when the sink is unmarked. The flow is then maximum. Example 2-17 illustrates the iterations of Ford-Fulkerson algorithm with the marking procedure.

140

Optimization techniques

Example 2-17: Ford-Fulkerson algorithm (from [R6]) Consider the network in figure 2-25 with the capacities in brackets.

Figure 2-25: Transport network. We construct an initial flow compliant with the arc capacities and satisfying the conservation law at each node. The flows are noted on each arc and the saturated arcs are in thick lines (figure 2-26). This flow has a value of 80.

Figure 2-26: Initial flow.

First iteration The nodes are marked from the source. Table 2-10 shows the order of processing of the arcs, the resulting marking and the predecessor of each node.

Discrete optimization

141

Table 2-10: Marking at first iteration. Since the sink v3 is marked, there is an augmenting path found by tracking back the predecessors from table 2-10: v3 → v21 → v12 → v22 → v11 → v0 . Table 2-11 shows the achievable variations on each arc of the augmenting path. The maximum compatible variation of the arc capacities is: = 5 .

Table 2-11: Variation achievable along the augmenting path. The variation is applied to the augmenting path (thick lines in figure 2-27). The flow increases ( = +5) on the direct arcs [v0 − v11 ] , [v11 − v22 ] , [v12 − v21 ],

[v21 − v3 ] and decreases ( = −5) on the indirect arc [v12 − v22 ] .

Figure 2-27: Augmenting path.

142

Optimization techniques

The new flow of value 85 is shown in figure 2-28. The saturated arcs are in thick lines.

Figure 2-28: Flow after the first iteration. Second iteration The marking of the nodes starting from the source is given in table 2-12.

Table 2-12: Marking at second iteration. The marking stops at the node v22, whose arcs are all zero or saturated. As the sink v3 is not marked, the flow of figure 2-28 is maximum and has the value 85.

Cut The optimality of the flow obtained by Ford-Fulkerson algorithm is based on the notion of cut. The cut associated with a flow is the set W of marked nodes as shown in figure 2-29. Each node belongs either to W or to its complementary W : •

an arc [vi − vj ] going out of W is saturated.



Otherwise vj would be marked (+) and would be in W; an arc [vk − vl ] entering W has a zero flow. Otherwise vk would be marked (− ) and would be in W.

Discrete optimization

143

Figure 2-29: Cut associated with the flow. The flow inside the cut W can eventually increase, but the total flow out of W cannot be increased, nor can the total flow into W be decreased. The source is always in the cut. If the sink is not in the cup (unmarked), the flow arriving at it cannot be increased. This flow is then maximum.

Example 2-18: Cut Let us retrieve the maximum flow example 2-17 shown in figure 2-28. The nodes marked v0 , v11 , v22 (table 2-12) form the set W circled in figure 2-30. The arcs leaving W in solid lines are all saturated. The arcs entering W in dotted lines are all of zero flow. The sink v3 is outside W and we cannot increase the flow out of W. This flow is maximum.

Figure 2-30: Cut of the maximum flow.

144

Optimization techniques

2.4.2 Roy-Busacker-Gowen algorithm There are usually several solutions for the maximum flow. These solutions do not have the same cost depending on the arcs selected for the flow. Roy-BusackerGowen algorithm determines the maximum flow of minimum cost that can traverse a network. This method uses the deviation graph associated with the flow. Deviation graph The graph G is assumed to be antisymmetric. There is at most one arc between two nodes: if the arc [vi − vj ] exists, then the arc [vj − vi ] does not exist. For a given flow , the deviation graph Ge( ) associated with the flow  is a graph with the same nodes as G and whose arcs are defined as follows: •

if the arc [vi − vj ] of G is saturated (xij = fij ) , Ge does not include the arc [vi − vj ] and includes the arc [vj − vi ] of capacity fij ;



if the arc [vi − vj ] of G has a zero flow (xij = 0) , Ge includes the arc [vi − vj ] of capacity fij and does not include the arc [vj − vi ] ;



if the arc [vi − vj ] of G is of intermediate flow (0  xij  fij ) , Ge includes the arc [vi − vj ] of capacity fij − xij and includes the arc [vj − vi ] of capacity xij .

A path from the source to the sink in the deviation graph Ge corresponds to an augmenting path in the graph G. Indeed, this path will either take direct unsaturated arcs or indirect arcs of non-zero flow. Example 2-19 illustrates the use of the deviation graph to find an augmenting path.

Example 2-19: Deviation graph Consider an initial flow 0 in the graph G in figure 2-31a. The flow is indicated on each arc with the capacity in brackets. Saturated and zero flow arcs are in thick lines. The associated deviation graph Ge(0) is plotted in figure 2-31b.

Discrete optimization

145

(a)

(b)

Figure 2-31: Deviation graph associated with the initial flow. The table 2-13 details each arc of Ge(0) according to the flow through the arc.

Table 2-13: Arcs of the initial deviation graph. There is a path from source v1 to the sink v4 in the deviation graph Ge(0). This path shown in thick lines in figure 2-31b corresponds to the augmenting path v1 → v2 → v3 → v4 in the graph G. The flow can be increased by  = 1 along this augmenting path. Figure 2-32a shows the new flow 1 with the corresponding deviation graph Ge(1) in figure 2-32b. (a)

(b)

Figure 2-32: Deviation graph associated with the new flow.

146

Optimization techniques

Table 2-14 details each arc of Ge(1) according to the flow through the arc.

Table 2-14: Arcs of the new deviation graph. There is no path from v1 to v4 in the deviation graph Ge(1). The flow 1 is therefore maximum.

Let us now turn to the problem of the maximum flow with minimum cost. The cost of a flow  is: C =  cijxij , where xij is the flow through the arc [vi − vj ] and cij is the unit cost of the arc. The costs cij are marked on the deviation graph Ge () as follows: - the direct arcs of the deviation graph Ge () are assigned the costs +cij ; - the indirect arcs of the deviation graph Ge () are assigned the costs −cij . In the deviation graph valuated with these costs, we make the following diagnoses: • •

the flow  is of maximum value if there is no path from the source to the sink in the deviation graph; the flow  is of minimum cost if there are no absorbing cost circuits (negative cost circuits) in the deviation graph (Roy's theorem).

Example 2-20: Optimality diagnosis in the deviation graph Let us retrieve the example 2-19 and the deviation graph associated with the maximum flow 1 (figure 2-32). This graph is shown in figure 2-33, indicating on each arc its capacity and its cost in the form: (fij ,cij ) . The saturated arcs are in thick lines. The flow 1 has a value of  = 5 and a cost of c = 20 . The associated deviation graph Ge(1) is shown in figure 2-33b. The flow is maximum, because there is no path from the source v 1 to the sink v4. On the other hand, this flow is not of minimum cost, since there exists in Ge(1) an absorbing circuit v1 → v3 → v2 → v1 of cost −5 (thick lines). It is therefore possible to find a flow with the same value  = 5 and a lower cost (calculated in example 2-21).

Discrete optimization

(a)

147

(b)

Figure 2-33: Deviation graph with arc costs.

The search for an augmenting path is equivalent to the search for a path between the source and the sink in the deviation graph. Roy-Busacker-Gowen algorithm consists in choosing at each iteration the augmenting path of minimum cost. The minimum cost chain is obtained by applying Ford's algorithm (section 2.2.1) in the deviation graph. The flow along the augmenting path is then increased and the gap graph associated with the new flow is updated. The algorithm ends when there is no more path from the source to the sink in the gap graph. The resulting flow is then of maximum value and minimum cost. Ford's algorithm (section 2.2.1) applies for valuations of any sign and detects an absorbing circuit. Such a circuit leads to an infinite loop of Ford’s algorithm and a blocking of Roy-Busacker-Gowen algorithm. By selecting the minimum cost augmenting path at each iteration, the updated deviation graph does not contain an absorbing circuit and the algorithm terminates in a finite number of iterations. Example 2-21 illustrates Roy-Busacker-Gowen algorithm.

Example 2-21: Roy-Busacker-Gowen algorithm Let us retrieve the graph from figure 2-33 and apply Roy-Busacker-Gowen algorithm starting from a zero flow. This flow 0 and the associated deviation graph are shown in figure 2-34. For the zero flow, the deviation graph Ge is identical to the graph G.

148

Optimization techniques

Figure 2-34: Deviation graph for the initial zero flow. There are three paths from source v 1 to sink v4 in the deviation graph Ge(0): - the path v1 → v2 → v4 has a cost of 3; - the path v1 → v2 → v3 → v4 has a cost of 8; - the path v1 → v3 → v4 has a cost of 3. Let us choose the minimum cost path v1 → v2 → v4 as the augmenting path. The flow can be increased by  = 3 along this path. The new flow 1 with value  = 3 and cost c = 8 is shown in figure 2-35.

Figure 2-35: Deviation graph for the first iteration flow. There are two paths from source v 1 to sink v4 in the deviation graph Ge(1): - the path v1 → v2 → v3 → v4 has a cost of 8;

- the path v1 → v3 → v4 has a cost of 3. Let us choose the minimum cost path v1 → v3 → v4 as the augmenting path.

Discrete optimization

149

The flow can be increased by  = 2 along this path. The new flow 2 with value  = 5 and cost c = 15 is shown in figure 2-36.

Figure 2-36: Deviation graph for the second iteration flow. Let us check the optimality of the flow 2 of value  = 5 and cost c = 15 . This flow is of maximum value, because there is no path from v1 to v4 in Ge(2). This flow is of minimum cost, because there is no absorbing circuit in Ge(2). This flow 2 is of lower cost than the one in figure 2-33.

2.5 Assignment problem The objective is to assign n resources to n tasks, while minimizing the total cost. The cost of assigning resource i to task j is noted cij. This problem can be solved by mixed linear programming (section 1.4.2), by RoyBusacker-Gowen algorithm or by the Hungarian method.

2.5.1 Equivalent flow problem The assignment problem can be formulated as a flow problem. The nodes of the graph are the resources (ri )i=1 to n and the tasks (ti )i=1 to n . This graph is bipartite, because resources on the one hand and tasks on the other form two subsets of disjoint nodes (unlinked nodes within the subsets): - each resource ri is linked to a task tj by an arc of capacity 1 and cost cij; - all resources are linked to a source r0 by arcs of capacity 1 and cost 0; - all tasks are linked to a sink t0 by arcs of capacity 1 and cost 0. We are looking for the maximum flow of minimum cost between r0 and t0.

150

Optimization techniques

The value of the flow will be equal to n. The graph of the equivalent flow problem is plotted in figure 2-37.

Figure 2-37: Flow problem equivalent to the assignment problem.

Example 2-22: Equivalent flow problem

24

10

21

11

Consider an assignment problem with 4 resources and 4 tasks. The cost matrix is shown opposite. (rows = resources, columns = tasks)

14

22

10

15

15

17

20

19

11

19

14

13

The graph of the equivalent flow problem is shown in figure 2-38.

Figure 2-38: Equivalent flow graph. An initial flow is constructed by a greedy method. The resources are processed one by one. For each resource (line), the task with the lowest cost is chosen among

Discrete optimization

151

those still available. Figure 2-39 shows this initial assignment. The rows and columns chosen are progressively shaded as the assignments are made. (r1 – t2)

(r2 – t3)

(r4 – t1)

(r3 – t4)

Figure 2-39: Initial greedy assignment. This assignment corresponds to a flow 1 with a value of 4 and a cost of 50. Figure 2-40a shows the flow graph (only saturated arcs are shown with their cost) and figure 2-40b shows the associated deviation graph. The flow 1 is maximum, as there is no path from r0 to t0. This flow is not of minimum cost, because there is an absorbing circuit r3 → t1 → r4 → t4 → r3 drawn in thick lines. (a)

(b)

Figure 2-40: Flow associated with the initial assignment. The absorbing circuit indicates that the assignments of r3 to t4 and of r4 to t1 should be swapped. The resource r3 is assigned to t1 and the resource r4 is assigned to t4. Figure 2-41 shows the graph of the new flow 2. This flow has a maximum value of 4 and a minimum cost, as there is no absorbing circuit in the deviation graph.

The optimal assignment is shown opposite. The cost is 48.

24

10

21

11

14

22

10

15

15

17

20

19

11

19

14

13

152

Optimization techniques

Figure 2-41: Optimal flow deviation graph.

2.5.2 Hungarian method The Hungarian method (Kühn, Evergary, König, 1955) directly uses the cost matrix (cij )i,j=1 to n to determine the optimal assignment. This iterative method consists of the following stages: •

stage 1: row reduction Each row is subtracted from its smallest element. This yields a zero per line;



stage 2: column reduction Each column is subtracted from its smallest element. This yields at least one zero per column;



stage 3: covering the zeros The minimum number p of rows and columns covering all zeros is sought. This search using Ford-Fulkerson algorithm is detailed below (zero covering): - if p < n, the solution is not optimal. We proceed to stage 4; - if p = n, the solution is optimal. We proceed to stage 5;



stage 4: increase in cost We look for the smallest cost among the uncovered rows or columns. It is subtracted from the elements not covered. It is added to the elements covered twice. We come back to stage 3;



stage 5: optimal solution One zero is selected per row and per column, corresponding to the assignment.

Discrete optimization

153

Example 2-23: Hungarian method

24

10

21

11

Let us retrieve the problem of example 2-22 whose matrix is given opposite.

14

22

10

15

15

17

20

19

Let us apply the stages of the Hungarian method.

11

19

14

13

Stage 1: row reduction The smallest element in each row is subtracted. → C = 10 + 10 + 15 + 11 = 46 Stage 2: column reduction The smallest element in each column is subtracted. → C = 46 + 0 + 0 + 0 + 1 = 47

Stage 3: covering the zeros The method is detailed below. It is found that 1 row and 2 columns are needed to cover all zeros. p = 1 + 2 < n = 4 → not optimal Stage 4 Smallest element not covered: cmin = 1 It is subtracted from the elements not covered. It is added to the elements covered twice.

→ C = 47 + 1 = 48

→ −1 → +1

154

Optimization techniques

Stage 3: covering the zeros The method is detailed below. It is found that 2 rows and 2 columns are needed to cover all zeros. p = 2 + 2 = n → optimal

Stage 5: selecting a zero per row and column We return to the original cost matrix. The chosen zeros define the assignments. The corresponding elements are highlighted. The optimal assignment (r1 – t2) ; (r2 – t3) ; (r3 – t1) ; (r4 – t4) has a cost of 48.

Zero covering The third stage of the Hungarian method requires finding the minimum number of rows and columns covering all zeros of the matrix. This search is performed in a graph defined as follows: - a zero in row i and column j gives an arc between ri and tj of capacity 1; - the arcs from the source r0 and the arcs to the sink t0 are of capacity 1. We apply Ford-Fulkerson algorithm starting from the zero flow to determine the maximum flow from r0 to t0 . If the maximum flow is of value n, all resources and tasks are assigned. The optimal assignments correspond to the arcs (r i - tj) of flow 1 (= selected zeros).

Example 2-24: Zero covering

14

0

11

0

Let us go back to stage 3 of example 2-23 with the matrix given opposite.

4

12

0

4

The graph associated with the zeros of the matrix is shown below. The initial flow 0 is zero.

0

2

5

3

0

8

3

1

Discrete optimization

155

Marking the nodes (section 2.4.1) from r0 yields the augmenting path: r0 (+) → r1 (+) → t2 (+) → t0 (+) (plotted in thick green lines). With the sink t0 marked, the flow can increase by δφ=1 along the augmenting path: (r0 - r1 - t2 - t0). The new flow 1 of value 1 is shown below.

Marking the nodes from r0 yields the augmenting path: r0 (+) → r2 (+) → t3 (+) → t0 (+) (plotted in thick green lines). With the sink t0 marked, the flow can increase by δφ=1 along the augmenting path: (r0 - r2 - t3 - t0). The new flow 2 of value 2 is shown on the next page.

156

Optimization techniques

Marking the nodes from r0 yields the augmenting path: r0 (+) → r3 (+) → t1 (+) → t0 (+) (plotted in thick green lines). With the sink t0 marked, the flow can increase by δφ=1 along the augmenting path: (r0 - r3 - t1 - t0). The new flow 3 of value 3 is shown below.

Marking the nodes from r0 yields the chain: r0 (+) → r3 (+) → t1 (+). As the sink t0 is not marked, the flow is maximum. The minimum number of rows and columns covering the zeros is 3, less than the assignments to be made (4). This brings us to stage 4 of the Hungarian method. After stage 4, the cost matrix (opposite) has an additional zero in row 4 column 4. This zero adds an arc (r4 ̶ t4) in the previous graph and allows the sink to be marked by the chain (r0 - r4 - t4 - t0).

15

0

12

0

4

11

0

3

0

1

5

2

0

7

3

0

Discrete optimization

157

The flow 4 of value 4 is shown below with the saturated arcs in thick lines.

This flow is maximum. The optimal assignment corresponds to the saturated arcs: (r1 - t2) ; (r2 - t3) ; (r3 - t1) ; (r4 - t4)

Extensions The Hungarian method applies also to maximization problems (e.g. to maximize satisfaction on a preference matrix). To do this, we simply take the largest element cmax on each row of the matrix C, and replace each element cij in the row with

cmax − cij . The Hungarian method applies then as above to the matrix Cmax − C . The Hungarian method applies also if the number m of resources m is different from the number p of tasks. In this case, stage 3 of zero covering is carried out by Roy-Busacker-Gowen algorithm giving the maximum flow of minimum cost. If the maximum flow is min(m, p), the solution is optimal. Otherwise, the flow is increased along the minimum cost augmenting path. Example 2-25 illustrates the case of a number of resources different from the number of tasks.

Example 2-25: Different numbers of resources and tasks Consider the problem with 2 resources and 3 tasks with the cost matrix opposite. After the row and column reduction, we obtain the matrices shown opposite.

1

2

3

1

3

3

0

1

2

0

0

0

0

2

2

0

1

0

158

Optimization techniques

We are looking for the minimum cost covering of the zeros. In this simple case, we can list the 4 possible covering and compare their cost. (r1 – t1) and (r2 – t3) → C=1+3=4 (r1 – t2) and (r2 – t1) → C=2+1=3 → minimum cost (r1 – t2) and (r2 – t3) → C=2+3=5 (r1 – t3) and (r2 – t1) → C=3+1=4 In practice, the Roy-Busacker-Gowen algorithm is used in the graph of the zeros shown below. The initial flow 0 is zero.

There are two augmenting paths of cost +1: (r0 - r1 - t1 - t0) and (r0 - r2 - t1 - t0). The other augmenting paths are of higher cost. The flow is increased by 1 on the chain (r0 - r1 - t1 - t0). The new flow 1 of value 1 is shown below.

There are 3 augmenting paths: - (r0 - r2 - t3 - t0) of cost +3; - (r0 - r2 - t1 - r1 - t2 - t0) of cost + 1 − 1 + 2 = +2; - (r0 - r2 - t1 - r1 - t3 - t0) of cost + 1 − 1 + 3 = +3. The flow is increased by 1 on the minimum cost chain (r0 - r2 - t1 - r1 - t2 - t0) (thick lines). The new flow 2 of value 2 is shown below.

Discrete optimization

This flow is maximum, as all resources are assigned. The total cost is 1 + 2 = 3. The optimal assignment is: (r1 - t2) → cost = 2; (r2 - t1) → cost = 1.

159

1

2

3

1

3

3

2.5.3 Theoretical justification The assignment problem can be formulated as a linear problem in binary variables (section 1.4.2). The Hungarian method is then interpreted as an iterative solution of the dual problem.

Justification of the Hungarian method The assignment problem is formulated as a linear problem denoted (P).

n → multipliers u  xij = 1 , j = 1 to n n n min z =  cijxij s.t.  i=n1 xij i =1 j=1  xij = 1 , i = 1 to n → multipliers v  j=1 The binary variable xij is 1 if resource i is assigned to task j, 0 otherwise. The constraints express that each resource (i = 1 to n) and each task (j = 1 to n) is assigned once and only once. The Lagrange multipliers associated with the constraints are noted as: - u = (u1, ,un ) for n constraints on the resources; - v = (v1, , vn ) for the n constraints on the tasks.

160

Optimization techniques

T Let us rewrite this problem (P) as: min z = c x s.t. Ax = b x0;1

with the matrix A and the vectors b, c, x defined by

The solution of the primal problem (P) is naturally binary, because the matrix A is unimodular. The dual problem (D) is formulated as u → n max z ' = bT  s.t. AT   c with  =     v → n or by making the variables and constraints explicit n

n

i =1

j=1

max z ' =  ui +  v j s.t. ui + v j  cij , i = 1 to n , j = 1 to n ui ,v j

The dual problem has 2n variables and n² constraints. The dual cost z' is the sum of the dual variables u and v. To maximize the dual cost, we will try to saturate the constraints inequalities. The second members of the inequalities correspond to the cost matrix shown below.

v1 vj vn c1j c1n  u1  c11     cij cin  ui  ci1       c c c un  n1 nj nn  Each variable ui is bounded by the minimum cost on the row: ui  min cij = ui max , i = 1 to n . j

noted

Each variable vj is bounded by the minimum cost on the column: vj  min cij = vjmax , j = 1 to n . i

noted

Discrete optimization

161

Let us show that the Hungarian method is an iterative solution of the dual problem. Stage 1: row reduction Subtract from each row of the matrix (cij ) the smallest element noted ui max .

u 'i = ui − ui max

This operation is equivalent to changing the variables by:  . c'ij = cij − ui max It makes at least one zero appear in each row of the matrix (c'ij ) . Stage 2: column reduction Subtract from each column of the matrix (c'ij ) the smallest element noted vjmax .

v'j = vj − vjmax

This operation is equivalent to changing the variables by:  . c''ij = c'ij − vjmax It makes at least one zero appear in each column of the matrix (c''ij ) . With these changes of variables, the dual problem becomes n

n

i =1

j=1

max z ' =  u 'i +  v 'j + zmax s.t. u 'i + v 'j  c''ij , i, j = 1 to n u 'i ,v 'j

n

n

i =1

j=1

The value zmax =  ui max +  v jmax gives a lower bound on the cost. The matrix (c''ij = cij − ui max − vjmax ) has at least one zero per row and per column. Stage 3→ 5: covering zeros with n rows and columns Suppose we can choose n zero elements c ''ij so as to cover each row and each column. For each zero c ''ij , we group the corresponding dual variables u 'i and v 'j . We obtain n pairs (u 'i , v'j ) satisfying the constraints: u 'i + v'j  0 . We make these couples appear in the cost z ' by noting (ik , jk )k =1 to n their indices. n

n

n

i =1

j=1

k =1

z ' =  u 'i +  v 'j + zmax =  (u 'ik + v 'jk ) + zmax  zmax

because u 'ik + v'jk  0

We deduce that the dual cost z is at most zmax . This value is reached for the zero solution (u 'i = 0, v'j = 0) which is therefore optimal of cost zmax .

The optimal assignments (ik , jk )k =1 to n correspond to the n zero elements c ''ij chosen to cover all rows and columns.

162

Optimization techniques

Stage 3→ 4: covering zeros with less than n rows and columns Suppose that we can cover each row and each column of the matrix with less than n zero elements c ''ij . The smallest non-zero cij on the rows with a single zero is chosen. This element noted cm is located in row im and in column jm .

→ cm = cim jm

The row im has a single zero in the column j0 .

→ cim j0 = 0

Consider then the zero solution (ui = 0 , vj = 0) except for: - the variable vj0 : vj0 = −cm ; - the variables ui0 : ui0 = +cm

→ rows i0 with a single zero in the column j0 .

This solution is feasible: ui0 + vj = cm + 0 = cm  ci0 j if j  j0  = ci0 j0 if j = j0 ui0 + vj0 = cm − cm = 0 u + v = 0 − c = −c  0  c if i  i j0 m m ij0 0  i

→ by choice of cm

The cost is greater than zmax :

z=

u

i0 im

i

 +cm

+ uim + vj0 + zmax =  +cm

c

i0 im

m

+ zmax  zmax

 −cm

The reduction in stage 4 corresponds to the following change of variables to come back to the zero solution.

u 'i0 = ui0 + cm c' = c − c  i0 j i0 j m  v'j0 = vj0 − cm c' = c + c ij0 m  ij0

→ on all rows i0 with a single zero in the column j0 → on the column j0

Discrete optimization

163

The effect of this change of variable on the cost matrix is shown below.

u i0 u im

       

v j0

v jm

0 0 0 0

cm

 + cm

   → − cm    → − cm  

u 'i 0 u 'im

       

v ' j0

v' jm

0 cm 0

0 0

       

The cost matrix after reduction becomes (c'ij ) : → it makes a zero appear in row im and column jm instead of cm (smallest non-zero element of single-zero rows); → it keeps the zeros in the column j0 on the single-zero rows. It keeps at least one zero per row and per column. The zero solution (u 'i = 0, v'j = 0) is feasible for the new reduced problem. This solution is optimal if all rows and all columns can be covered by choosing n elements c 'ij .

2.6 Heuristics It is usually not possible to solve large combinatorial problems exactly. One can then resort to heuristics, which are empirical methods adapted to a particular problem. They are mostly based on so-called greedy approaches that make the most optimal immediate choice at each stage. These methods are simple and fast, as the solution is developed without iterations, but there is no guarantee on the quality of the result. The result of a heuristic can be used to initialize a metaheuristic (Volume I, chapter 2) or a tree-based method (section 1.3). This section presents some specific heuristics adapted to classical combinatorial problems.

164

Optimization techniques

2.6.1 Stacking problem Statement We have a set of n objects and a box of size b. Object number i has size ai and value ci. We have to choose the objects to stack in the box to maximize the total value. This stacking problem, also known as knapsack, is NP-complete. Heuristics The principle is to choose as a priority the objects with the best value/size ratio, called utility. The objects are sorted in decreasing utility

c1 c2 c    n a1 a2 an and then stacked in that order as long as the size b of the box allows. a1 + a2 + + ap b → a1 + a2 + + ap + ap+1  b

The same principle applies in the case where several copies of each object can be selected. Example 2-26 shows that this intuitive approach can lead to poor results, even in very simple cases.

Example 2-26: Stacking by greedy method Problem 1: choice of two objects The size of the box is: b  2 . The values of the objects are: c = (1 , b − 1) . The sizes of the objects are: a = (1 , b) . The objects are sorted in decreasing order of utility:

c1 c b −1 =1  2 = a1 a2 b

The greedy solution is to first choose object 1 of size a1 = 1 . Object 2 of size a2 = b no longer fits. The result is a stack of value c = 1 . The optimal solution is to take object 2, which gives a stack of value c = b − 1 . The greedy solution is poor if b is large, because the box is little filled.

Discrete optimization

165

The greedy solution is better when the objects are small compared to the box (ai b) , as it is possible to approach a maximum filling. Problem 2: cutting a cable A seller has a cable of length: b = 6 790. Ten customers place orders for the following lengths: a = (2597 , 2463 , 2292 , 1625 , 1283 , 1089 , 759 , 599 , 315 , 211): •

the greedy solution is to satisfy the largest orders first. The length sold is: 2597 + 2463 + 1625 = 6685 and there remains 105 unsold;



the optimal solution is to satisfy orders 1, 4, 5, 7, 9, 10. The length sold is: 2597 + 1625 + 1283 + 759 + 315 + 211 = 6790, which is the entire length available.

2.6.2 Bin packing problem Statement We have a set of n objects and several boxes of identical sizes b. Object number i is of size ai. All objects must be packaged using as few boxes as possible. This bin packing problem is NP-complete. Heuristics The principle is to place the largest objects first, trying as much as possible to fill the boxes already used. The objects are sorted in descending order of size: a1  a2   an , and then placed in that order, if possible in a box already in use. If the object fits in more than one box, the one that the object fills the most is chosen. This heuristic works well when the objects are small compared to the boxes (a b) . Worst cases occur for problems with few objects like the one in example 2-27.

166

Optimization techniques

Example 2-27: Bin packing by greedy method We are trying to place the 6 objects opposite of sizes a = (4, 3, 3, 2, 2, 2) in boxes of size b = 8. The greedy solution consists of choosing to place the objects by decreasing size, adding a new box when necessary. It requires 3 boxes. Object a1=4 a2=3 a3=3 a4=2 a5=2 a6=2 Total Box 1 Box 2

4

7

7 3

5

7

7 2

Box 3

2

The optimal solution shown here uses only 2 boxes. The relative performance of the heuristic on this case is 50% compared to the optimum. This is a worst case for this type of problem.

2.6.3 Set covering problem Statement There is a set of n resources to perform m tasks. Resource number j has a cost c j and can perform Nj tasks. Resources must be chosen to perform all tasks, while minimizing the total cost. Unlike the assignment problem (section 2.5), each resource can perform multiple tasks. This set covering problem is NP-complete. Heuristics The principle is to select resources according to their cost wrt their feasible tasks. The average cost of resource j is

cj

Nj

. At each stage, the resource with the lowest

average cost is chosen and assigned all the tasks it can perform. These tasks are removed from the list and the average resource costs on the remaining tasks are recalculated.

Discrete optimization

167

To facilitate the process, the resource/task compatibility matrix A is defined with elements aij = 1 if resource j can perform task i and 0 otherwise. After each assignment the corresponding rows and columns are deleted until all tasks are covered.

Example 2-28: Set covering by greedy method The aim is to achieve 4 tasks with 5 resources of costs c = ( 7 3 7 12 6) . The resource/task compatibility matrix is r1

r2

r3

r4

r5

1 0 1 1 0   t 0 1 0 1 0 A = 2 t3  1 0 0 0 1   t4  0 0 1 0 1 Figure 2-42 shows the sequence of successive assignments. At each stage, the average cost of the remaining resources (columns) on the remaining tasks they can perform is calculated. This average cost shown in the last row is used to select the least expensive resource. After the 3 stages, we obtain the assignments: (r1 → t1), (r2 → t2), (r5 → t3, t4). This choice of cost 7 + 3 + 6 = 16 is the optimal solution. t1

Figure 2-42: Set covering by greedy method.

168

Optimization techniques

2.6.4 Coloring problem Statement The nodes of a graph should be colored with as few colors as possible. Adjacent (or neighboring) nodes must be of different colors. This coloring problem is NP-complete. Heuristics The DSATUR algorithm of Brelaz (1979) consists in coloring the nodes one by one, choosing at each stage the most "difficult" node to color. We define: - the degree i of the node vi which is its number of neighbors; - the saturation i of the node vi which is the number of colors of the neighbors. At each iteration the node with the maximum saturation (and maximum degree if several nodes have the same saturation) is selected. The selected node is colored if possible with an existing color, otherwise with a new color.

Example 2-29: Coloring by greedy method We want to color a graph with 8 nodes. The following figures show the successive iterations with the state of the graph on the left and the table giving the degrees, the saturations and the colors of the nodes.

Discrete optimization

169

The result is a solution using 4 colors. Color 1: v2 , v6 Color 2: v3 , v7 Color 3: v5 , v8 Color 4: v1 , v4

170

Optimization techniques

The coloring algorithm can be used for the numerical calculation of derivatives. Consider a simulator with n inputs and m outputs. To calculate the Jacobian matrix (partial derivatives) by finite differences, the simulator must be called n times by successively varying x1, x2 , , xn . This operation is costly in terms of computing time in an optimization algorithm. If the outputs y j do not depend on all the inputs xi (sparse Jacobian matrix), several inputs can be grouped together to vary them simultaneously. The structure of the Jacobian matrix must be known (theoretically or experimentally). The grouping of variables is obtained by forming the input incompatibility graph (inputs that cannot be varied simultaneously) and applying a coloring algorithm to group compatible inputs. The inputs with the same color are those that can be varied simultaneously.

Example 2-30: Coloring for numerical derivation

 y1 = x 1x 4  Consider a simulator with 5 inputs and 3 outputs of equations:  y2 = x 1x 2 x 5 .  y3 = x 3 x 5  0 0  0 y   =   0 0  . The structure of the Jacobian matrix is: x    0 0  0  The input incompatibility graph is constructed. The nodes of this graph correspond to the input variables (x1 ,x 2 ,x3 ,x 4 ,x 5) . If an output depends on several inputs, these inputs are connected by an edge: - output y 1

→ (x1 ,x 4) ;

- output y 3

→ (x 3 , x 5) .

- output y 2

→ (x1 , x 2) , (x1 ,x 5) , (x 2 , x 5) ;

We apply the greedy coloring algorithm in this graph.

Discrete optimization

171

The result is a solution using 3 colors. Color 1: x1 , x 3

Color 2: x 4 , x 5 Color 3: x 2

The Jacobian matrix can be calculated in 3 calls (instead of 5) by successively varying (x1 and x 3) , then (x 4 and x 5) , then x 2 .

172

Optimization techniques

2.6.5 Travelling salesman problem Statement The travelling salesman must visit n cities travelling the shortest distance possible. Each city must be visited once and only once, whilst returning to the starting city at the end. The travelling salesman problem (denoted TSP) is NP-complete. Heuristics There are many heuristics suitable for the travelling salesman problem and its variants, including the following three: • minimum cost arc heuristic: at each stage the path is extended by the minimum cost arc; • maximum regret arc heuristic: at each stage the maximum regret arc (= non-selection cost) is chosen; • minimum cost insertion heuristic: at each stage a new node is inserted at the position that minimizes the cost. These three heuristics are illustrated in example 2-31. Example 2-31: Heuristics for TSP Consider a 4-city problem A, B, C, D opposite. The optimal solution is the path (ADBCA) of length 6. The performances of the 3 heuristics are compared. Minimum cost arc heuristic We start from A and extend at each stage through the arc of minimum cost. The stages are illustrated in figure 2-43. This gives the path (ABDCA) of length 13.

Figure 2-43: Minimum cost arc heuristics.

Discrete optimization

173

Maximum regret arc heuristic The travelling salesman must pass through all the nodes. The consequences of not selecting an arc from node v to node w are examined. If the arc (v,w) is not selected, we will have to select: - another arc starting from v and generating a cost at least equal to rv;

- another arc arriving at w and generating a cost at least equal to rw.

The regret associated with arc (v,w) is the minimum cost of not selecting arc (v,w). Its value is rvw = max(rv ,rw ) . The regret matrix is deduced from the distance matrix by taking the value of rv (on the row) and rw (on the column). For the arc CA, we have for example rv = 2 (arc CB) and rw = 1 (arc BA). Therefore, the value 2 is entered for the CA arc in the regret matrix.

Figure 2-44: Regret matrix. Let us choose among the arcs of maximum regret (= 2) the arc CA. We delete its row and column in the distance matrix, and look for the next arc among the arcs still available. The stages 1, 2 and 3 are illustrated, with the matrix of available arcs on the left and the matrix of regrets in the center. The successively selected arcs are in thick lines. This gives the path (CADBC) of length 6.

174

Optimization techniques

Costs of available arcs

Regret matrix

Maximum regret arc

Stage 1

Stage 2

Stage 3

Minimum cost insertion heuristic At each iteration a new node is inserted at the position that minimizes the cost: •

initialization We choose an arc with minimum cost → (AB) = 1;



inserting a new node on (AB) Node C: best insertion → (CAB) = 2 Node D: best insertion → (ABD) = 2 The path (CAB) of length = 2 is chosen;



inserting a new node on (CAB) Node D: best insertion → (CADBC) = 6 (taking into account the return to the initial node) This gives the path (CADBC) of length = 6.

Discrete optimization

175

2.7 Conclusion 2.7.1 The key points •

Many combinatorial problems can be reduced to route problems in graphs;



path problems are solved by Ford's, Bellman's, Dijkstra's or the A* algorithm;



flow problems are solved by Ford-Fulkerson and Roy-Busacker-Gowen algorithms;



assignment problems are solved by the Hungarian method;



greedy heuristics quickly give approximate solutions.

2.7.2 To go further •

Algorithmes de graphes (P. Lacomme, C. Prins, M. Sevaux, Eyrolles 2007) The book is devoted to optimization problems in graphs. Chapters 1, 2 and 3 introduce theoretical notions on graphs, complexity and hard problems. Chapter 4 introduces structures for the implementation of algorithms in the Delphi language. Classical combinatorial optimization problems are addressed in chapter 5 with the description and implementation of dedicated algorithms. The book is accompanied by a CD-Rom with all the software presented.



Précis de recherche opérationnelle (R. Faure, B. Lemaire, C. Picouleau, Dunod 2009) The book deals with operations research problems including combinatorial optimization and stochastic problems. Chapters 1 to 3 introduce the notions of graphs and complexity. Chapter 4 presents algorithms adapted to path problems. Numerous examples and exercises allow the reader to become familiar with the different methods.



Stochastic optimization (J.J. Schneider, S. Kirkpatrick, Springer 2006) This book presents many heuristics (a term preferred to "metaheuristics") and analyzes more particularly the simulated annealing method, of which the authors are specialists. The different methods are applied and compared on the travelling salesman problem.

Functional optimization

177

3. Functional optimization Functional optimization, also called calculus of variations, concerns problems where the unknown is a function. Functional optimization is said to be in infinite dimension, as opposed to continuous or discrete optimization which deals with a finite number of variables. The unknown function can indeed be conceived as an infinite number of unknown variables which would be the values of the function. Section 1 introduces the notions of functional (function of functions), neighborhood of functions and variation of a functional. These notions allow to define a strong or weak minimum of a functional depending on whether we consider neighborhood in value or in value and derivative. The standard problem of the calculus of variations consists in minimizing an integral type functional. Section 2 establishes various optimality conditions. The necessary conditions of weak minimum lead to the Euler-Lagrange equation, whose solutions form the extremals of the functional. The sufficient conditions are based on the study of the conjugate points associated with the Jacobi equation. The extension to piecewise derivable functions leads to the Weierstrass-Erdmann corner conditions. The necessary strong minimum conditions based on the Weierstrass function are the equivalent of the maximum principle in optimal control. Section 3 introduces the consideration of constraints. Constraints can be on the endpoint conditions (final constraints), on the fixed value of an integral (integral constraint) or on each point of the unknown function (current constraint). These constraints add optimality conditions in the form of transversality conditions for final constraints or in the form of unknown multipliers for integral or current constraints. Section 4 presents the canonical form of a calculus of variations problem. The canonical variables form a Hamiltonian system with special properties, useful especially for applications in mechanics. The canonical form allows to derive the Hamilton-Jacobi-Bellman equation satisfied by the value function over the whole extremal field of the functional. Section 5 introduces the essential notions of dynamic systems. This modelling allows us to move from a problem of calculating variations to a much more general problem of optimal control which is the subject of chapter 4.

178

Optimization techniques

3.1 Formulation 3.1.1 Functional We consider real functions y defined on an interval [a;b] . y : x [a;b]

(3.1)

y(x) 

These functions belong to a space noted Y which can be, according to the case: - the space of continuous or differentiable functions on [a;b] ; - the space of continuous or piecewise derivable functions on [a;b] . A functional J is a function of Y in . J : yY

(3.2)

J(y) 

A functional is therefore a "function of functions". The objective is to find the functions y  Y minimizing J. This leads to defining the notions of neighborhood and variation of the functional J.

3.1.2 Neighborhood The space of functions Y is provided with a norm measuring the distance between two functions. A norm on Y is a function of Y in + denoted and satisfying

 y =  . y ,   y + z  y + z The second property is the triangular inequality.

(3.3)

y, z  Y ,  

The usual norms on function spaces are: • the 0-norm (for continuous functions): •

the 1-norm (for differentiable functions):

y 0 = max y(x) ; xa;b

y 1 = max y(x) + max y(x) ; xa;b

xa;b

1/p



the Lp norm (for integrable functions): The L norm is identical to the 0-norm:

b  p y p =   y(x) dx  . a  y = y 0.

Functional optimization

179

The neighborhood of a function y* is the set of functions of Y such that (3.4)

y − y*  

for a given positive real  . The neighborhood depends on the norm considered. The neighborhood in 0-norm is the set of continuous functions close to y* in value. These functions are not necessarily derivable.

y(x) − y*(x)   on [a;b]

(3.5)

The neighborhood in -norm is the set of functions that are derivable and close to y* in value and derivative. This neighborhood is smaller (because it contains fewer functions) than the 0-norm neighborhood.

y(x) − y*(x) + y(x) − y* (x)   on [a;b]

(3.6)

Figure 3-1 shows functions y0 and y1 close to y for norms 0 and 1.

Figure 3-1: Neighborhood in norm 0 and 1.

3.1.3 Variation To study the variation of a functional J in the neighborhood of y, we consider functions of the form y +  where  is a function and  is a "small" real. The function  (called perturbation) is feasible if y +  belongs to Y. The first and second variations of J in the neighborhood of y are defined as follows. First variation The first variation of J in y is the linear functional J y such that

 , 

, J(y + ) = J(y) + J y () + o()

(3.7)

By defining the real-variable function g  associated with the function 

g : 

g () = J(y + )

(3.8)

180

Optimization techniques

the first variation of J in y is expressed as

g () − g  (0) J(y + ) − J(y) = lim  = g (0) →0 →0   The first variation is a linear functional, which means that it satisfies J y () = lim

J y (11 + 22 ) = 1J y (1 ) + 2J y (2 )

(3.9)

(3.10)

Second variation The second variation of J in y is the quadratic functional 2 J y such that

 ,  , J(y + ) = J(y) + J y () + 2J y () 2 + o( 2 )

(3.11)

With the function g  defined in (3.8), the second variation is expressed as

2 J y () = lim →0

J(y + ) − J(y) − J y () 2 g  () − g  (0) − g (0)

(3.12) 1 = lim = g (0) →0 2 2 The second variation is a quadratic functional, which means that it is of the form 2 J y () = K(, ) where K(1, 2 ) is a bilinear functional (linear functional with respect to each of the two functions 1 and 2 ).

3.1.4 Minimum A function y* is a local minimum of the functional J if the neighboring functions of y* give higher values for J. For any small real   0 , we have

y  Y , y − y*    J(y*)  J(y)

(3.13)

The minimum is said to be weak or strong depending on the norm considered for the neighborhood: •

a weak minimum corresponds to a neighborhood in 1-norm. The condition (3.13) concerns only differentiable functions;



a strong minimum corresponds to a neighborhood in 0-norm. The condition (3.13) concerns all continuous functions. The minimum is said to be strong, because this neighborhood contains more functions than the neighborhood in norm 1.

Functional optimization

181

Using the second-order expansion (3.11), the minimum condition gives:

J(y) = J(y* +) = J(y*) + J y* () + 2J y* () 2 + o( 2 )  J(y*)  J y* () + 2 J y* () 2  0

(3.14)

This inequality must be satisfied for any feasible perturbation  and any small real  . It leads to conditions of order 1 (on J y ) and order 2 (on 2 J y ) as follows. The necessary conditions of minimum are obtained for a broad inequality.

 J y* () = 0 (3.15) y* minimum of J   2 ,  feasible   J y* ()  0 The sufficient conditions of minimum are obtained for a strict inequality.  J y* () = 0 (3.16) ,  feasible  y* minimum of J  2   J y* ()  0 The strictly positive second order term allows to neglect the third order terms. The section 3.1.5 applies these conditions to integral functions.

3.1.5 Standard problem The standard problem of the calculus of variations is of the form b

min J(y) =  L  x, y(x), y(x)  dx yY

(3.17)

a

The function L :

3



in the integral is called the Lagrangian of the problem.

This function depends on three real variables (x,y,z) and it is assumed to be "sufficiently derivable". To simplify the equations, the following notations are used: L  x, y(x), y(x)  = L(x, y, y) noted

L L d  L  = Ly , = L z or L y ,   = Lz noted noted y z dx  z  noted

(3.18)

The second partial derivatives are similarly noted Lyy ,Lyz ,Lzz . The notations y and Lz refer to the total derivatives of the functions y and L z with respect to the variable x.

182

Optimization techniques

Y is the space of functions of class C1 on [a;b] and with fixed values in a and b.

 y(a) =  (3.19) y  Y  y  C1 ([a;b]) and   y(b) =  Figure 3-2 shows three functions y1, y2 and y* belonging to Y (functions of class C1 with fixed values at the ends of the interval).

Figure 3-2: Functions with fixed endpoint values. The neighborhood of the function y* is the set of functions of the form y = y* +  belonging to Y. The perturbation  must therefore satisfy

 y(a) =   (a) = 0 (3.20)  C1 ([a;b]) and   y(b) =   (b) = 0 The first and second variations of the functional J defined by (3.17) have then the following form: b

J y* () =   ( L y − Lz ) dx a

b

1  J y* () =  ( 2 (L yy − Lyz ) +  '2 L zz ) dx 2a 2

(3.21)

These formulas demonstrated below will be used in the section 3.2 to establish the necessary and sufficient conditions for local minimum.

Functional optimization

183

Demonstration The variations of J are obtained from definition (3.11) recalled here:

J(y* +) = J(y*) + J y* () + 2J y* () 2 + o( 2 ) . b

Let us calculate J(y* +) from (3.17): J(y * +) =  L  x, y * +,(y * +) dx. a

The Lagrangian is expanded to order 2 with respect to  .

L  x, y* + ,(y* + ) =

L  x, y*, y* + L y + L z

1 1 +  22 L yy +  2L yz +  22 Lzz + o( 2 ) 2 2 All partial derivatives of L are evaluated in (x, y*, y*) . By replacing in the expression of J(y* + ) , and then identifying the terms in  and  2 , we obtain b   J (  ) =  y* a (L y + Lz )dx   b 2 J () = 1 (2 L + 2L + 2 L )dx yy yz zz  y* 2 a 

The first equation is integrated by parts, noting Lz = b

b

d  L   (x, y*, y*)  . dx  z 

b

J y* () =  (L y + L z )dx =  L ydx + L z a −  Lz dx a

b

a

a

b

 J y* () =  (L y − Lz )dx because (a) = (b) = 0 (feasible perturbation  ) a

The second equation is also integrated by parts. b 1 2 J y* () =  (2 L yy + 2L yz + 2 L zz )dx 2a b

b

b

b

b

a

a

2 2 2 2 with  2 'L yz dx =  ( )L yz dx =  L yz  a −   Lyzdx = −   Lyzdx a

a

b

1 2 (L yy − Lyz ) + 2 L zz ) dx (  2a This gives the expressions (3.21).  2 J y* () =

184

Optimization techniques

3.2 Optimality conditions In this section we establish optimality conditions for the standard problem of calculus of variations (3.17) recalled below. b  y(a) =  (3.22) min J(y) =  L(x, y, y)dx with  y  y(b) =  a For this type of problem, we consider derivable functions on [a;b] . A distinction is made between a weak and a strong minimum: • a weak minimum concerns class C1 functions with the 1-norm neighborhood. Weak minimum conditions are discussed in sections 3.2.1 and 3.2.2; • a strong minimum concerns piecewise class C1 functions with the 0-norm neighborhood. Strong minimum conditions are discussed in sections 3.2.3 and 3.2.4.

3.2.1 Weak minimum necessary conditions The functions considered in this section are of class C1 on [a;b] . The theorem 3.1 gives necessary conditions that a function y* must satisfy to be a weak local minimum of the functional J. Theorem 3-1: Necessary conditions for a weak minimum If y* is a weak local minimum of problem (3.22), then y* satisfies: •

the Euler-Lagrange equation (first order condition):

Ly − Lz = 0 . •

(3.23)

the Legendre condition (condition of order 2):

Lzz  0 .

(3.24)

Demonstration (see [R14]) The Euler-Lagrange equation (1755) and the Legendre condition (1786) are established from the first and second variations of J in y*.

Functional optimization

185

Condition of order 1 Assume that y* is a weak local minimum of J. According to (3.15), the first variation of J must be zero for any feasible perturbation  . Using the expression (3.21), we must have b

J y* () =  (L y − Lz )dx = 0 ,  a

For a weak minimum, we consider class C1 functions  such that: (a) =(b) = 0. Let us define the function: P(x) = L y − Lz

b

 J y* () =  Pdx . a

Assume by contradiction that the function P is not identically zero on [a;b] . Then there exists c [a;b] such that P(c) = 2  0 (the reasoning is similar if P(c) = 2  0 ). Since the function P is continuous, there is a non-zero interval

[c1;c2 ] around c on which P(x)   . Let us define the perturbation  as

(x − c1 ) 2 (c 2 − x) 2 if x [c1;c 2 ] (x) =  if x  [c1;c 2 ] 0 This perturbation is feasible (of class C1 and taking zero value in a and b). Let us calculate the first variation of J for this perturbation  . c2

b

J y* () =  Pdx =  P(x − c1 )2 (c2 − x) 2 dx  a

c1

c2

 (x − c ) (c 1

2

2

− x) 2 dx

c1

2 2 This integral is strictly positive:   0 and (x − c1 ) (c 2 − x)  0 on ]c1;c 2[ .

This would yield J y* ()  0 , which would contradict the necessary condition of order 1 (3.15). The initial assumption is therefore false: the function P(x) = Ly − Lz is identically zero on [a;b] . This establishes the Euler-Lagrange equation. Condition of order 2 Assume that y* is a weak local minimum of J. According to (3.15), the second variation of J must be positive for any feasible perturbation  . Using the expression (3.21), we must have

2 J y* () =

b

1 ( 2 (L yy − Lyz ) + 2Lzz ) dx  0 ,  2 a

186

Optimization techniques

P(x) = L zz Let us note:  Q(x) = L yy − Lyz

 2 J y* () =

b

1 ( 2P + 2Q ) dx . 2 a

Assume by contradiction that the function P is not positive or zero on [a;b] . Then there exists c [a;b] such that P(c) = −2  0 . Since the function P is continuous, there is an interval [c −  ;c + ] around c on which P(x)  − . Let us define the perturbation  as  2 (x − c) if x  [c −  ;c + ] sin (x) =   0 else This perturbation is feasible (of class C1 and taking zero value in a and b). The figure opposite shows the shape of the functions P(x) and (x) in the vicinity of c.

Let us calculate the second variation of J for this perturbation  .

J y* () =

b

c+

c+

1 1 2 2(x − c) 1 (x − c) 2 2   P +  Q dx = Psin 2 dx +  Qsin 4 dx ( ) 2   2a 2 c−   2 c− 

2 max P  2 c−x c+ by taking a majorant under each integral. 



+

 max Q c− x c+

By assumption we have: P(x)  −  0 on [c −  ;c + ]

2  +  max Q . c− x c+  For  sufficiently small, the second member becomes negative. This would yield 2 J y* ()  0 , which would contradict the necessary condition of so that the inequality yields: J y* ()  −

order 2 (3.15). The initial assumption is therefore false: the function P(x) = Lzz is positive or zero on [a;b] . This establishes the Legendre condition.

Functional optimization

187

The Euler-Lagrange equation (denoted EL) is a differential equation of order 2. The integration constants are determined by the boundary conditions y(a) =  and y(b) =  . In detailed form, equation (EL) is written as

L d  L  (x, y, y) −   (x, y, y) = 0 y dx  z 

(3.25)

or by developing the composed derivative of the second term

 L L L L   x, y(x), y(x) =  z + y z + y z   x, y(x), y(x)  y y z   x

(3.26)

Extremal and first integral A function y satisfying equation (EL) is called an extremal of the functional (3.22). The extremal field of the functional is the set of solutions of equation (EL). These solutions are parameterized by two integration constants. An extremal is not necessarily a minimum of the functional, because equation (EL) is only a necessary condition. A first integral of J is a function (x, y) that keeps a constant value along any extremal y*.

 x, y*(x) = Cte

(3.27)

Special cases: •

if the function L does not depend explicitly on y, then Ly = 0 .

The Euler-Lagrange equation in its form (3.25) reduces to

d  L  te    = 0  L y = C dx  y 

(3.28)

The function L y is in this case a first integral (corresponding to the impulse or the momentum in mechanics); • if the function L does not depend explicitly on x, then Lzx = 0 . The Euler-Lagrange equation in its form (3.26) reduces to

Ly = y Lzy + y Lzz

(3.29)

It can be deduced that (the verification is presented afterwards):

Lz y − L = Cte

(3.30)

188

Optimization techniques

The function H = Ly y − L is in this case a first integral (corresponding to the Hamiltonian or energy in mechanics).

Verification Let us calculate the total derivative of Lz y − L with respect to x. d ( Lz y − L ) = ( Lzx + Lzy y + Lzz y) y + Lz y − ( L x + L y y + Lz y) dx = ( Lzy y + Lzz y − L y ) y + L zx y − L x The first term is zero according to the Euler-Lagrange equation (3.29). The other terms are zero because L and therefore L z are not explicit in x by assumption. The derivative of Lz y − L is therefore zero and this quantity is a first integral.

Example 3-1 shows the application of the weak minimum conditions to the calculation of the shortest distance between two points in the plane.

Example 3-1: Minimum length curve in the plane We seek the curve y(x) minimizing the distance between A and B in the plane.

B

(

)

2 2 2 2 2 The curvilinear distance is: D AB =  ds with ds = dx + dy = dx 1 + y '(x) . A

We are looking for the curve y*(x) solution of b

min  1 + y(x) 2 dx y

a

b

 min  L(x, y, y)dx y

a

with L(x, y, z) = 1 + z 2

Functional optimization

189

The Lagrangian is not explicit in y. The Euler-Lagrange equation yields L d  L  L y =   = = C te  y = C te (first integral)  2 y dx  y  y  1+ y The extremals of this problem are curves of constant slope, hence straight lines. The particular solution associated with two points A and B is the segment joining these two points. 3

Legendre's necessary condition is also satisfied: Lzz = (1 + y2 ) 2  0 . All straight lines do satisfy the necessary weak minimum conditions. We will see in example 3-4 that the sufficient conditions are satisfied.

Example 3-2 is the historical brachistochrone problem formulated by Bernoulli in 1696. This problem led to the development of the calculus of variations.

Example 3-2: Brachistochrone We are looking for the shape of the curve AB that minimizes the travel time of a particle sliding under the effect of gravity (without friction), in other words the shape of the optimal toboggan from A to B.

Figure 3-3: Brachistochrone problem. The term "brachistochrone" is of Greek origin: "" = shortest, "" = time.

190

Optimization techniques

Formulation of the problem The first stage is to write the problem in the form (3.22). The particle starts from the point A (a ;  = 0) with a zero velocity and arrives at the point B (b; ) . The energy of the particle is constant because the gravity field is conservative. The energy at A is zero (taking the y-intercept at A), which determines its velocity

1 2

2 as a function of the height: E = mv − mgy = 0  v = 2gy .

The curve from A to B has the equation y(x) . The travel time from A to B is B

ds with ds 2 = dx 2 + dy 2 = dx 2 (1 + y(x) 2 ) v A

TAB = 

b

The problem is formulated as: min  y

a

1 + y(x) 2 dx y(x)

 y(a) = 0 with  .  y(b) = 

Resolution of the problem

1 + z2 is not explicit in x. y According to (3.30), the Euler-Lagrange equation gives the first integral The Lagrangian: L(x, y, z) =

L y y − L = H = Cte  L y y − L =

y2 y(1 + y2 )



1 + y2 1 = H  y(1 + y2 ) = 2 y H

The differential equation to solve is: y(1 + y2 ) = 2c with c = Let us perform the function change: y = − tan

1 . 2H2

 (equation E1) 2

and replace in the differential equation to express y. 2c  y= = 2ccos2  y = c(1 + cos ) 2 1 + y 2

 2

Deriving this expression yields: y = −c sin  = −2c sin cos

 (equation E2). 2

By identifying the expressions (E1) and (E2) of y , we obtain an equation in .

    y = − tan = −2c sin cos  2c cos 2 = 1  c(1 + cos )d = dx 2 2 2 2 This differential equation is integrated into: x = c( − 0 + sin ) . We obtain expressions for x and y parametrized in terms of .

Functional optimization

191

x() = c( − 0 + sin ) = x c + csin  The solutions are the curves of equation:  . = yc + ccos   y() = c(1 + cos ) These extremals are cycloids with center (x c ; yc ) and radius c (figure 3-4). The conditions in A and B give the 2 integration constants c and 0. A cycloid results from a uniform circular motion around a uniformly translating center (e.g. the motion relative to the ground of a point on a bicycle wheel).

Figure 3-4: Cycloid solution of the brachistochrone.

The conditions of theorem 3-1 can be generalized to different problems. Problem with several variables Consider the following functional optimization problem.

min J(z) = z



(x,y)D

2

L ( x, y,z,z x ,z y ) dxdy

The Lagrangian here is a function of

5

in

(3.31) .

The functional J deals with a function z of two variables x and y, defined over a region D of 2 . A necessary condition for a weak minimum is then

L   L    L  =   +  z x  z x  y  z y 

(3.32)

192

Optimization techniques

This second-order partial differential equation is the generalization to two variables of the second-order Euler-Lagrange differential equation (3.23). It can be proved in a similar way from the first variation of the functional J (3.31). Equation (3.32) generalizes to a function z of n variables. Problem with several functions Consider the functional optimization problem: b

min J(y1 , , y n ) =  L ( x, y1 , , y n , y1 , , yn ) dx

y1 , ,y n Y

(3.33)

a

The Lagrangian here is a function of

2n +1

in

.

The functional J depends on n functions y1, ...,yn of the variable x. These functions   y j (a) =  j of class C1 have their values fixed in a and b:  , j = 1 to n . y (b) =   j j  A necessary condition for a weak minimum is then

L d  L  =   , j = 1 to n y j dx  yj 

(3.34)

Each function (y j ) j=1 to n satisfies the Euler-Lagrange equation: L y j = Lz j . The demonstration is similar to the case of a single function (by applying n independent perturbations j ). Legendre's condition generalizes in the same way. Parameterized curve Let us retrieve the functional optimization problem in its standard form. b

min J(y) =  L(x, y, y)dx y

a

 y  C1[a;b] with   y(a) =  , y(b) = 

This formulation restricts the solutions to functions y : x  It does not allow to find general curves in the plane (x, y) .

(3.35) y(x)  .

To enlarge the set of solutions, we consider curves parametrized by a real variable t [t a ;t b ] .

x = x(t)   y = y(t)

x(t a ) = a  y(t a ) =  with  and  x(t b ) = b  y(t b ) = 

(3.36)

Functional optimization

193

By introducing the notations

dx dy dy y = x , = y , = y  y = noted noted noted dt dt dx x the term under the integral (3.35) is expressed as

 y(t)  L ( x, y, y ) dx = L  x(t), y(t),  x(t)dt x(t)   Problem (3.35) can then be written as

(3.37)

(3.38)

tb

min K(x, y) =  M ( t, x, y, x, y ) dt x,y

ta

(3.39)  y(t)  with M ( t, x, y, x, y ) = L  x(t), y(t),  x(t) x(t)   This is a problem of calculus of variations of the form (3.33) with two unknown functions x(t) and y(t) , with end conditions in t a and t b . Each unknown function satisfies the Euler-Lagrange equation (3.34).

 M d  M  M x = M x  x = dt  x     (3.40)     M d  M M = M  =   y  y y dt  y  This differential system on x(t) and y(t) is of dimension 2 and of order 2. The two differential equations are in fact not independent. Each of them is equivalent to the Euler-Lagrange equation of the original problem (3.35).

Verification Let us first consider the first equation (3.40) associated with x(t) : M x = M x .

y  We express the derivatives M x and M x of: M ( t, x, y, x, y ) = L  x, y,  x . x  −y y → M x = Lx x , M x = Lz 2 x + L = L − Lz = L − Lz y with the notations (3.37) x x then replace in M x = M x .

Lx x =

d d ( L − Lz y) = ( L − Lz y) x dt dx

(equation E)

194

Optimization techniques

d  dx ( L ) = L x + L y y + Lz y   d ( L y ) = d ( L ) y + L y z z  dx z dx By replacing in equation (E), the terms in Lx and y are eliminated.

d Let us develop the derivatives : dx

d ( Lz ) which is Euler-Lagrange equation of problem (3.35). dx Then consider the second equation (3.40) associated with y(t) : M y = M y . This yields: L y =

y  Let us express the derivatives M y and M y of: M ( t, x, y, x, y ) = L  x, y,  x x 

1 → M y = L y x , M y = Lz x = Lz with the notations (3.37) x d d d then replace in M y = M y : L y x = ( Lz ) = ( Lz ) x  L y = ( Lz ) dt dx dx

The Euler-Lagrange equation of the original problem (3.35) is again found.

The formulation (3.39) allows any curves in the plane (x, y) as a solution. This formulation applies especially to the search for geodesics. Geodesics A geodesic is a curve minimizing the distance between two points on a given surface. Consider a surface defined in a general way by a position vector r depending on two real variables (u, v) . A geodesic on the surface is a parametric curve of the form: r(t) = r ( u(t),v(t) ) . The length element on the surface is expressed as 2

ds2 = dr = rudu + rvdv

2

= ru2du 2 + 2ru  rvdudv + rv2dv2

(3.41)

2 2 or by posing: E = ru , F = ru  rv , G = rv

ds = Eu2 + 2Fuv + Gv2 dt

(3.42)

A geodesic between two points A and B on the surface is solution to the problem B

tb

A

ta

min J(u, v) =  ds =  Eu2 + 2Fuv + Gv2 dt u,v

(3.43)

Functional optimization

195

This is a problem with two unknown functions u(t), v(t) with end conditions in ta and tb. The Euler-Lagrange equations (3.40) for u and v yield

 E u u2 + 2Fu uv + G u v2 d  2(Eu + Fv) =   2 2 dt  Eu2 + 2Fuv + Gv2  Eu + 2Fuv + Gv  2 2 d 2(Fu + Gv)  E v u + 2Fv uv + G v v =   2 2 dt  Eu2 + 2Fuv + Gv2  Eu + 2Fuv + Gv 2

  → for u    → for v 

(3.44)

2

The functions E = ru , F = ru  rv , G = rv are called coefficients of the fundamental quadratic form of the surface. The geodesics in the plane (straight lines) were determined in example 3-1. Example 3-3 illustrates the search for geodesics on a cylinder using equations (3.44).

Example 3-3: Geodesics on a cylinder Let us consider a right cylinder with a circular base and a radius a. The position on the cylinder is defined by an angle  and a height z.  a cos    −a sin    0       r =  a sin    r =  a cos   , rz =  0   z   0  1       The geodesic is sought in parametric form: r(t) = r ( (t),z(t) ) . 2 2 2 We calculate the coefficients E, F, G: E = r = a , F = r  rz = 0 , G = rz = 1 . Equations (3.44) give then: d   a 2  a 2 = 0 = c1   2 2   2 dz  dt  a  + z   a 22 + z2    c1z = c2a 2  =c  d z  z d   = c2  dt  2 2 2  = 0  a 22 + z2  a  + z   

The solution is of the form: z = z0 + c( − 0 ) which is the equation of a helix.

196

Optimization techniques

3.2.2 Weak minimum sufficient conditions The functions considered in this section are of class C1 on [a;b] . The sufficient minimum conditions are based on the study of neighboring extremals and conjugate points. These two notions are introduced below. Neighboring extremals Recall that an extremal of the functional J (3.22) is a solution function of the EulerLagrange equation (3.23). An extremal does not necessarily satisfy the endpoint conditions and it is not necessarily a minimum of J. Two extremals y1 and y2 are called neighboring extremals if their distance in norm is small: y2 − y1   . The neighboring extremals satisfy the property 3-2. Property 3-2: Jacobi equation If y* and y are two neighboring extremals of the J-functional (3.22), then their difference v = y − y* satisfy the Jacobi equation associated with the J functional.

P = L zz Qv = (Pv) with  Q = L yy − Lyz

(3.45)

Demonstration Each extremal satisfies the Euler-Lagrange equation, which gives the system L y (x, y*, y*) − Lz (x, y*, y*) = 0 → for y* (system S)  L y (x, y, y) − Lz (x, y, y) = 0 → for y = y* + v Let us expand the terms of the second equation to order 1 with respect to v. L y ( x, y, y ) = L y ( x, y* + v,(y* + v) )

= L y ( x, y*, y* ) + L yy ( x, y*, y* ) v + L yz ( x, y*, y* ) v = L y + L yy v + L yz v

noted

Lz ( x, y, y ) = Lz + Lzy v + Lzz v noted

Lz ( x, y, y ) = (Lz + Lzy v + Lzz v) = Lz + Lzy v + Lzy v + (Lzz v)

Functional optimization

197

Let us replace in the system S the second equation by its development.

− Lz = 0 → for y*  L y  ( L y + L yy v + L yz v ) − ( Lz + Lzy v + L zy v + (L zz v) ) = 0 → for y = y* + v

Using the first equation, the second equation reduces to Lyy v − Lzy v − (Lzz v) = 0 which is the Jacobi equation (3.45).

The Jacobi equation is obtained by expanding the Euler-Lagrange equation to order 1 in the vicinity of a solution y*. The Jacobi equation is said to be the variational equation associated with the Euler-Lagrange equation. The neighboring extremals can also be determined from the accessory minimum problem stated in property 3-3. Property 3-3: Accessory minimum problem If y* and y are two neighboring extremals of the functional J (3.22), then their difference v = y − y* is a solution of the problem

P = L zz (3.46) min K(v) =  ( Pv2 + Qv 2 ) dx with  v Q = L yy − Lyz a This problem is equivalent to minimizing the second-order expansion of the functional J in the neighborhood of the extremal y*. b

Demonstration Let us first show the connection between problems (3.45) and (3.46). The functional K is of the form b

K(v) =  M(x, v, v)dx with M(x, v, v) = Pv2 + Qv 2 a

Its Euler-Lagrange equation is: Mv = Mv  Qv = (Pv) which is the Jacobi equation (3.45). The Jacobi equation represents the Euler-Lagrange equation of the accessory minimum problem. Let us then establish the problem (3.46) from the expansion of J to order 2 in the neighborhood of y*. This expansion is given by (3.11). J(y* +v) = J(y*) + J y* (v) + 2J y* (v) 2 + o( 2 )

198

Optimization techniques

The first and second variations are given by (3.21). b

J y* (v) =  v ( L y − Lz ) dx = 0 since y* (extremal) satisfies equation (EL): Ly = Lz a

b

b

1 1 v 2 (L yy − Lyz ) + v2 L zz ) dx =  ( Pv2 + Qv 2 ) dx (  2a 2a Let us replace J by its second-order expansion in the formulation (3.22). b 1 min J(y) → min J(y* + v) = J(y*) +  2  ( Pv2 + Qv 2 ) dx y v 2 a This gives the formulation of the accessory problem. 2 J y* (v) =

Conjugate points The Jacobi equation allows us to determine the extremals close to y* without accounting for the endpoint conditions: y(a) =  , y(b) =  . The points x = a and x = c ]a;b] are called conjugate points of the functional J if there is a neighboring extremal y = y* + v distinct from y* with v(a) = v(c) = 0. The existence of a conjugate point means that there exist two distinct extremals starting from the same point A(a; ) and crossing at a point C(c;  ) with c ]a;b]. Figure 3-5a shows points A and C conjugate w.r.t an extremal AB and figure 35b shows points A and B conjugate for the minimum distance on a sphere. There are indeed an infinite number of geodesics between two diametrically opposed points. The study of the geodesics on a sphere is detailed in example 3-5. (a)

(b)

Figure 3-5: Conjugate points.

Functional optimization

199

Example 3-4: Conjugate points for the geodesics in the plane The geodesics in the plane were determined in example 3-1. Recall the expression of the Lagrangian for this problem: L(x, y,z) = 1 + z2 . The extremals (solutions of Euler-Lagrange equation) are linear functions: y = C

te

3

They satisfy the Legendre condition: Lzz = (1 + y2 ) 2  0 . Neighboring extremals The neighboring extremals of y* are found by solving the Jacobi equation. 3 −  P(x) = L zz = 1 + y*2 2 = C te because y* = C te Qv = (Pv) with  Q(x) = L yy − Lyz = 0 because L y = 0 The equation reduces to v = 0 whose solution is: v(x) = v(a) + v(a)(x − a) . We find that the distance between two neighboring extremals is a linear function (consistent with the fact that the extremals are all linear functions).

(

)

Conjugate points Consider a neighboring extremal to y* starting from the same point A: v(a) = 0 . If this extremal is distinct from y*, then v is not identically zero and v(a)  0 . The linear function v(x) , which is zero at a and has a non-zero slope, cannot cancel on the interval ]a;b] . There is therefore no conjugate point for the plane geodesics problem. It is established below that the absence of conjugate points is a sufficient condition for a minimum.

Example 3-4 fulfils special conditions that allow to establish the absence of a conjugate point. Let us examine these special conditions. Suppose on the one hand that the Lagrangian L is not explicit in y: Ly = 0 . Jacobi's equation (3.45) simplifies, because Q = Lyy − Lyz = 0 .

(Pv) = Qv = 0  Pv = Cte

(3.47)

Assume moreover that y* satisfies the strong Legendre condition: P = Lzz  0. Equation (3.47) then shows that the derivative of v has a constant sign.

200

Optimization techniques

If v(a) = 0 , then the function v (not identically zero) no longer cancels on ]a;b] and there is no conjugate point for the extremal y*. Jacobi's condition (1837) concerns the absence of a conjugate point. It establishes sufficient conditions that a function y* must satisfy to be a weak local minimum of the functional J.

Theorem 3-4: Sufficient conditions for a weak minimum Assume that y* satisfies: •

the Euler-Lagrange equation (first order condition):

Ly − Lz = 0 . •

the strong condition of Legendre (second order condition):

Lzz  0 . •

(3.48)

(3.49)

the condition of Jacobi:

x = a does not have any conjugate point in ]a;b] .

(3.50)

Then y* is a weak local minimum of the problem (3.22).

Demonstration (see [R14]) The use of the three assumptions is highlighted in the demonstration. We start from the expansion (3.11) of the functional J to order 2 in the neighborhood of y*, with the first and second variations given by (3.21). J(y* + ) = J(y*) + J y* () +  2 J y* () 2 + o( 2 ) b   J (  ) =  y* a  ( L y − Lz ) dx  with  b 2 J () = 1 2 (L − L ) + 2 L dx ( yy yz zz )  y* 2 a 

The first variation is zero, because y* satisfies (by assumption) the EulerLagrange equation: Ly = Lz .

Functional optimization

201

The second variation takes the form

 P = Lzz with   Q = L yy − Lyz We aim to show that, under the assumptions of the theorem, we have 2 J y* ()  0 ,  feasible ,   0 2 J y* () =

b

1 ( P2 + Q2 ) dx 2 a

The feasible perturbations  are of class C1 and such as: (a) = (b) = 0 . 2 The demonstration consists in transforming  J y* () to make a square appear

under the integral. b

2 Consider a term of the form: I =  d(w ) where w is a function of class C1. a

b

b

This term is always zero: I =  d(w2 ) =  w2  = 0 because (a) = (b) = 0 , a

a

2

so that it can be added to  J y* () without changing its value.

2 J y* () = 2 J y* () + I =

b

1 (  '2 P + 2w + 2 (Q + w) ) dx 2 a

By Legendre's strong condition: P  0 . The function P does not cancel on [a;b]. Suppose there is a function w such that: P(Q + w) = w (the existence of such a function is demonstrated below). 2

Factoring by P under the integral, and with the equation satisfied by w, we get 2 b b 1  w w2  1  w  2 J y* () =  P  2 + 2 + 2 2  dx =  P   +   dx  0 2a  P P  2a  P 

w  = 0   = 0 because (a) = 0 . P 2 For a non-zero feasible perturbation, we have:  J y* ()  0 . This integral can cancel only if:  +

2 It remains to show the existence of w of class C 1 such that: P(Q + w) = w .

Consider a solution v of the Jacobi equation: Qv −

d (Pv) = 0 . dx

This solution depends continuously on the initial value v(a) .

202

Optimization techniques

By Jacobi’s condition, there is no point on the interval ]a;b] that is conjugate to the point x = a . If v(a) = 0 , then v does not cancel on the interval ]a;b] . By continuity, for v(a) =  with  small, the solution v does not cancel on the interval ]a;b] . Therefore, there is a solution v that does not cancel on ]a;b] . Let us then define the function w as: w = −

v P. v

This function of class C1 satisfies: vw = −Pv 

d d (vw) = − (Pv) = −Qv dx dx

(because v is a solution of Jacobi’s equation). Deriving (vw) , we obtain

v w v w2 = − by definition of w). w= (since v P v P 2 Thus, we have shown the existence of a function w such that: P(Q + w) = w . vw + vw  = − Qv  Q + w  = −

Notes on Legendre's strong condition: P = Lzz  0 •



It can be shown that a weak minimum satisfying the strong Legendre condition does not admit a conjugate point. The absence of a conjugate point is therefore a necessary condition of minimum when P = Lzz  0 . In the case where L is not explicit in y: Ly = 0 , we have established above (3.47) that the strong Legendre condition leads to the absence of a conjugate point. This condition alone is then sufficient to guarantee a weak minimum.

Example 3-5 illustrates the application of sufficient conditions to determine geodesics on a sphere.

Example 3-5: Geodesics on a sphere We seek minimum distance curves between two points A and B on the unit sphere. The position on the sphere is defined by the latitude  and the longitude . To facilitate the calculations, the axes are chosen so that points A and B are on the meridian of zero longitude (as in figure 3-6a). With this choice of axes, points A and B have the coordinates:    B  A A  , B   A = 0   B = 0 

Functional optimization

203

(a)

(b)

Figure 3-6: Geodesics and conjugate points on a sphere.

Formulation of the problem The distance element ds on the sphere is expressed in spherical coordinates.  x = cos  cos   2 2 2 2 2 2 2  y = cos  sin  → ds = dx + dy + dz = d + d cos  . z = sin   We are looking for the function () which minimizes the distance from A to B. The problem is formulated as:

B

B

A

A

min DAB =  ds = 



1 + ()2 cos 2  d

with the Lagrangian defined by: L(, , ) = 1 + 2 cos 2  . Searching for extremals The extremals are the solutions of the Euler-Lagrange equation: with L not explicit in  :

d  L  L   =0   =c  d    

This gives the differential equation:

L d  L  =  .  d   

 cos2  1 + 2 cos2 

=c .

d c = . d cos  cos 2  − c 2

A (non-obvious) solution is: tan ( −  0 ) =

csin  cos 2  − c2

(checked by derivation).

204

Optimization techniques

The integration constants 0 ,c are determined by the conditions in A and B. csin A  In A (A ;  A = 0) : − tan  0 = 2 2  cos A − c    c = 0 ,  0 = 0 or  . csin B  In B(B ;  B = 0) : − tan  0 = cos 2 B − c2  The extremal from A to B therefore has the equation: tan  = 0 . This extremal is a great circle arc following the meridian through A and B. Let us see if this extremal satisfies the sufficient conditions of theorem 3-4. Legendre's strong condition The function P is defined by: P() =

  L    with    

L  cos 2    L  cos 2  L cos 2  =  −  =  L     L L2 The extremal has the equation: tan  = 0 , which leads to L(, , ) = 1 + 2 cos 2  

 = 0 , L(, , ) = 1 and P() = cos 2  . Legendre's strong condition: P()  0 is satisfied if the extremal does not pass through a pole. Jacobi’s condition The Jacobi equation is: (Pv) = Qv with Q = 0 , because L is not explicit in  .

k  v = v0 + k tan  cos2  If v(A ) = 0 , then v cancels again for C = A +  . The solutions are:

Pv = k  v =

The point A has as for conjugate point the diametrically opposite point C. Let us summarize the sufficient conditions for the distance AB to be a minimum: •

the extremal (AB) is a great circle meridian arc of equation



Legendre's strong condition holds if the extremal does not pass through a pole



 = 0  L = 1 , DAB = B − A ;

   =   ; 2  Jacobi’s condition (no conjugate point) is satisfied if the length of (AB) is less than the length of a half great circle.

Functional optimization

205

Note 1 If A and B are not diametrically opposed, one can choose the reference frame so that −

   A  B  and the sufficient minimum conditions are then satisfied. 2 2

Note 2 The formulation in () assumes the variable  is increasing. If the latitudes are oriented in the "wrong direction" (i.e. B  A +  ), the length of the arc (AB) is greater than the length of a half great circle and Jacobi’s condition is not satisfied. In this case, there is a shorter path by traversing the arc in a retrograde direction (with  decreasing) as shown in figure 3-6b. Note 3 If A and B are diametrically opposed, all semicircles (AB) are solutions.

3.2.3 Corner necessary conditions Theorem 3-1 gives necessary conditions for a weak minimum on the space of functions of class C1 on [a;b] . This section extends the space to functions of class C 1 by pieces on [a;b] . The function y(x) may have a derivative discontinuity at a point c as in figure 3-7. Such a point is called a "corner" or an "edge".

Figure 3-7: Functions C1 by pieces.

206

Optimization techniques

The problem of calculus of variations is formulated as b  y(a) =  (3.51) min J(y,c) =  L(x, y, y)dx with  and y(c − )  y(c + ) y,c y(b) =   a The unknowns in this problem are the function y and the position c of the corner. Theorem 3-5 completes theorem 3-1 by adding a condition associated with a corner.

Theorem 3-5: Corner necessary conditions Assume that y* is a minimum of problem (3.51) with a corner in x = c * . Then y* satisfies the conditions of theorem 3-1. Furthermore, the functions L z and Lz y − L are continuous in x = c * .

Demonstration (see [R14]) The demonstration consists in expressing the first variation of the functional J by applying perturbations on the function y and on the corner position c, and then in writing the conditions so that this first variation is zero. Consider a function y of class C1 by pieces on [a;b] . This function is assumed to have a single corner in x = c (figure 3-8).

Figure 3-8: Functions y1 and y2 of class C1 on each interval.

Functional optimization

207

The functions y1 and y2 are the restrictions of y to the intervals [a;c] and [c;b] .

 y1 (x) if x [a;c] y(x) =   y2 (x) if x [c;b]

The function y is continuous in x = c :

y1 (c) = y2 (c) = y(c) .

 y1 (c) = y(c− ) x = c Its derivative is discontinuous in :  . +  y2 (c) = y(c ) Definition of perturbations Assume that the function y* with a corner in c* is a weak minimum of J. Let us apply perturbations 1 and 2 of class C1 to the functions y1 * and y2 * , as well as a perturbation c on the position of the corner c * .  y1 = y1 * + 1 on [a;c] with 1 (a) = 0 and c = c* + c   y2 = y2 * + 2 on [c;b] with 2 (b) = 0 In the case c  c* , we extend the function y1 * by a segment on [c*;c] .

y1p *(x) = y*(c*) + y* (c*− )(x − c*) for c*  x  c In the case c  c* , we extend the function y2 * by a segment on [c;c*] .

y2p *(x) = y*(c*) + y* (c*− )(x − c*) for c  x  c* These perturbations are shown in figure 3-9.

Figure 3-9: Perturbed function with linear extension.

208

Optimization techniques

The function y is of class C1 on each interval and satisfies the endpoint conditions: y(a) =  , y(b) =  . We must impose its continuity in x = c .

y1 *(c*) = y2 *(c*) .  y1 (c) = y1 *(c*) + y1 + y1c Let us express the values of y1 (c) and y2 (c) :   y2 (c) = y2 *(c*) + y 2 + y 2c The function y* is continuous at c*:

with the following notations shown in figure 3-10.

y1 = variation in c* of y1 * due to 1

→ y1 = 1 (c*)

y 2  = variation in c* of y2 * due to 2

→ y2 = 2 (c*)

y1c = variation in c* of y1 * due to c

→ y1c = y* (c*− )c

y2c = variation in c* of y2 * due to c

→ y2c = y* (c*+ )c

The variations y1c and y2c result from the linear extensions of y1 * and y2 * .

Figure 3-10: Continuity condition. Putting these contributions together, the continuity of y in c gives the relation

y1 (c) = y2 (c)  y1 + y1c = y2 + y2c

 1 (c*) + y* (c*− )c = 2 (c*) + y* (c*+ )c

This continuity condition (C) will be used below.

(equation C)

Functional optimization

209

Calculation of the first variation Let us now calculate the first variation of J with these perturbations. Decomposing on the intervals [a;c*] and [c*;b] , J is expressed as b

c*

b

a

a

c*

J(y*,c*) =  L ( x, y*, y* ) dx =  L ( x, y1*, y1 * ) dx +  L ( x, y 2 *, y 2 * ) dx = J1 (y1*,c*) + J 2 (y 2 *,c*)

Let us expand to order 1 the functional J1 on the interval [a;c] .

J1 (y1 * + 1 ,c* + c) =

c*+c

 L ( x, y * +  ,(y * +  )) dx 1

1

1

1

a

=

c*

 ( L +  L 1

y

+ 1L z ) ( x, y1*, y1 * ) dx +

c*+c

a

 L ( x, y *, y *) dx 1

1

c*

The second integral yields c*+c

 L ( x, y *, y *) dx = L ( c*, y *(c*), y * (c*) ) c 1

1

1

c*

1

= L ( c*, y*(c*), y* (c*− ) ) c = L(c*− )c noted

Integrating by parts the term in 1 Lz in the first integral, with the condition:

1 (a) = 0 , we obtain for the first variation of J1 c*

J1y* (1 , c) =  1 ( L y − Lz ) dx + 1 (c*)L z (c*− ) + L(c*− )c a

Similarly, the first variation of J2 is given by b

J 2y* (2 , c) =  2 ( L y − Lz ) dx − 2 (c*)L z (c*+ ) − L(c*+ )c c*

The first variation of J is the sum of these two contributions. J y* (1 , 2 , c) = J1y* (1 , c) + J 2y* (2 , c) c*

b

=  1 ( L y − Lz ) dx +  2 ( L y − Lz ) dx a

c*

+ 1 (c*)L z (c * ) − 2 (c*)L z (c *+ ) + ( L(c *− ) − L(c *+ ) ) c −

The values of 1 (c*), 2 (c*), c are linked by the continuity condition (C). By noting  the value of the two members of equation (C), we express the values of 1 (c*), 2 (c*) as a function of the two independent perturbations c,  .

1 (c*) =  − y* (c*− )c  + 2 (c*) =  − y* (c* )c

210

Optimization techniques

This yields J y* as a function of independent perturbations 1 , 2 , c,  . c*

b

a

c*

J y* (1 , 2 , c,  ) =  1 ( L y − Lz ) dx +  2 ( L y − Lz ) dx −  L z c*−  +  L z y − L c*− c c*+

c*+

The necessary condition of minimum in y* is that the first variation is zero.

J y* (1, 2 , c, ) = 0 , 1, 2 feasible , c, 

The coefficient for each perturbation must be zero: - the terms in 1 , 2 give the Euler-Lagrange equation on [a;b] : Ly = Lz ; - the term in  imposes the continuity of L z in x = c * ;

- the term in c imposes the continuity of Lz y − L in x = c * .

The continuity conditions of L z and Lz y − L at a corner are called necessary conditions of Weierstrass-Erdmann (established in 1865 and 1877 respectively). They apply at each discontinuity point of the derivative. Example 3-6 shows the use of these corner conditions to obtain piecewise C1 solutions.

Example 3-6: Surface of revolution of minimum area/Catenary We are looking for the surface of revolution with the minimum area generated by rotating a curve (AB) around the axis (Ox), as shown in figure 3-11a. The equation of the curve (AB) is: y(x) , a  x  b . The endpoint conditions are: y(a) =  , y(b) =  . (a)

(b)

Figure 3-11: Minimum area of revolution/catenary.

Functional optimization

211

Formulation of the problem The curve element at abscissa x has a length: ds = 1 + y(x)2 dx . By rotation around Ox, this element generates the surface: dS = 2yds . B

b

A

a

2 The problem is formulated as: min S = 2 yds = 2  y(x) 1 + y(x) dx . y

This problem of surface of revolution is equivalent to the problem of the catenary. Catenary problem We are looking for the shape taken by a homogeneous weighted wire attached at A and B as shown in figure 3-11b. The density of the wire is noted  . The length element ds at y has a potential energy: dEP = gyds . b

The wire shape minimizes the total potential energy: E P =  gy(x) 1 + y(x) 2 dx . a

b

2 The problem is formulated as: min E P = g  y(x) 1 + y(x) dx . y

a

This formulation is analogous to the previous surface of revolution problem. Note: The length of the curve (AB) is free. In the case of a given length curve, the resolution must account for an integral constraint as in section 3.3.2. Solutions of class C1 Let us start by looking for solutions of class C1 on [a;b] . The Lagrangian L(x, y,z) = y 1 + z 2 is not explicit in x. As shown in (3.30), the Euler-Lagrange equation admits as a first integral: L y' y − L = H = Cte , which leads to a differential equation satisfied by y.

yy2

− y 1 + y2 = H  y = 

y2 − H2 H

1 + y2 This equation is integrated by separating the variables x and y. dx =

 Hdy

 x = x 0  H.ln

y2 − H2 (Ach = inverse hyperbolic cosine)

y + y2 − H2 y = x 0  H.Ach   H H

212

Optimization techniques

The curve (AB) is a chain  x − x0  equation: y = H.ch  .  H  The surface of revolution generated is a catenoid, shown opposite ("catena" = chain). This solution considers only curves of class C1. Solutions of class C1 by pieces Let us now look for solutions of class C1 piecewise. The coordinates of the endpoints are A (−a ; ) and B (a ; ) .

 x = x(t) The solutions are sought in the form of parametric curves:  .  y = y(t) b

2 2 The problem is formulated as: min  y(t) x(t) + y(t) dt . x,y

a

The Lagrangian depends on two functions x and y: L(t, x, y, x, y) = y x 2 + y 2 .

L x = L x Each function x(t) and y(t) satisfies the Euler-Lagrange equation:  . L y = L y This two-function problem x(t) and y(t) of one variable t is equivalent to the one-function problem y(x) in variable x, as shown in (3.40). The two Euler-Lagrange equations are therefore not independent. We choose to solve the equation in Lx which is simpler.

Lx = 0  Lx = K = Cte  yx = K x 2 + y 2 Two forms of extremals are obtained depending on the value of the constant K. • 1st case: K  0 We retrieve class C1 solutions of the chain type by posing: x = t  x = 1 . The constants are determined by the conditions in A (−a ; ) and B (a ; ) .

x a The chain solution is: y = H.ch   with H determined by:  = H.ch   . H H The constant H exists only if   1.509a (numerically obtained minimum). Physically, the ordinate  must be high enough to keep the low point above the axis (Ox), which is the axis of rotation for the surface problem or the ground level for the catenary problem.

Functional optimization



213

2nd case: K = 0 te

The Euler-Lagrange equation has two solutions: yx = 0  y = 0 or x = C . A composite solution is formed connecting these two solutions at C (xC ; yC = 0) . This composite solution must satisfy the corner conditions in C. Corner conditions The first condition is the continuity of p = Lx in C. This condition is well satisfied, as p = L x = K = 0  p− = p + = 0 .

The second condition is the continuity of H = Lx x − L in C. This condition is well satisfied at point C.  L x = K = 0  H− = H+ = 0  2 2  L = y x + y = 0 because yC = 0 The corner conditions are satisfied by connecting the extremals: x = C te and y = 0. te

The conditions in A and B impose x = a for solutions of the form x = C . The solution curve consists of three segments [AA'] (x = −a) , [A'B'] (y = 0) and [B'B] (x = +a) . These segments form three sides of a rectangle as shown in figure 3-12.

Figure 3-12: Chain and rectangle solutions.

Let us now compare the "chain" and "rectangle" solutions in terms of the value of the functional and the feasibility.

214

Optimization techniques

The area of the rectangle solution is obtained by integrating over each segment. t =+ a t =  A ' B' B'   t =0  S = 2   +  +  y x 2 + y 2 dt  = 2   y y dt +  0dt +  y y dt  A' B t =− a t =0 A   t = 

(

0



)

=   − y 2  +  y 2  = 2 2  0 This surface corresponds to two discs generated by the segments [AA'] and [BB']. If the ordinate  is sufficient (   1.509a ), the chain solution is better (lower surface). If the ordinate  is too small, the chain solution is not feasible, as the curve would pass below the axis (Ox). The "rectangle" solution is the only feasible one in this case.

We will see in section 3.4 that the Weierstrass-Erdmann corner conditions reflect the continuity of the canonical variables of problem (3.51). The conditions established here consider neighboring functions in norm 1. The next section extends the conditions to neighboring functions in norm 0 to define a strong minimum.

3.2.4 Strong minimum necessary conditions In this section, we consider functions of class C 1 by pieces on [a;b] with the neighborhood in norm 0. The Weierstrass function E :

4



is defined by

E(x, y,z,w) = L(x, y,w) − L(x, y,z) − (w − z)Lz (x, y,z)

(3.52)

Theorem 3-6 gives a necessary condition that an extremal y* must satisfy to be a strong local minimum of J. Theorem 3-6: Necessary condition for a strong minimum Assume that y* is a strong local minimum of problem (3.22). Then y* is an extremal satisfying the Weierstrass condition

E(x, y*, y*,w)  0 , w  in any point x  [a;b] that is not a corner. Recall that an extremal satisfies the Euler-Lagrange equation: Ly = Lz .

(3.53)

Functional optimization

215

Demonstration (from [R14]) Assume that the function y* is a strong local minimum of J and consider two points x0 and x1 in [a;b] , such that the interval [x0 ;x1 ] does not contain a corner. We define functions y parametrized by a real   0 and another real w.  y *(x)   y *(x 0 ) + w(x − x 0 ) y(x, ) =  x1 − x  y *(x) + x − (x + ) ( y *(x 0 ) + w − y *(x 0 + ) ) 1 0   y *(x) The shape of such a function y(x, ) is shown in figure 3-13.

if a  x  x 0 if x 0  x  x 0 +  if x 0 +   x  x1 if x1  x  b

Figure 3-13: Perturbed function on [x0 ; x1]. The functions y(x, ) are of class C1 with discontinuous derivatives in the three points x0 , x0+ and x1. For   0 small, the functions y(., ) are close to y* in norm 0. For  = 0 , the function y(.,0) coincides with y*. y* being a strong minimum of J, we have: J(y*) = J ( y(.,0) )  J ( y(., ) ) ,   0 . The function F : 

F() = J ( y(., ) ) defined for   0 therefore admits a

+ minimum in  = 0 . Its right derivative at 0 must be positive: F(0 )  0 . + This derivative F(0 ) is calculated below to show that

F(0+ ) = E(x 0 , y*(x 0 ), y* (x 0 ), w)

(Weierstrass function evaluated for the function y* at point x 0). The point x0 and the real w being arbitrary, we will thus show the condition (3.53).

216

Optimization techniques

Calculation of the derivative of the function F b

x0

a

a

F() = J(y(., )) =  L ( x, y(x, ), y x (x, ) ) dx = 

+

x 0 +



x0

+

x1



x 0 +

b

+

x1

The function y(x, ) depends on  only on the intervals [x 0 ;x 0 + ] and

[x 0 +  ;x1 ] . The derivatives of the integrals on these two intervals are calculated:



derivative with respect to  of the integral: I0 =

x 0 +

 L ( x, y(x, ), y (x, ) ) dx x

x0

On [x 0 ;x 0 + ] : y(x, ) = y*(x 0 ) + w(x − x 0 )  yx (x, ) = w

→ L ( x, y(x, ), yx (x, ) ) = L ( x, y*(x 0 ) + w(x − x 0 ),w )

For  small, we get x +  d d 0 ( I0 ) =   L ( x, y*(x 0 ) + w(x − x 0 ), w ) dx  = L ( x 0 + , y*(x 0 ) + w , w ) ; d d  x0 



derivative with respect to  of the integral: I1 =

x1

 L ( x, y(x, ), y (x, ) ) dx x

x 0 + x  d d 1 ( I1 ) =   L ( x, y(x, ), y x (x, ) ) dx  d d  x0 + 

= −L ( x 0 + , y(x 0 + , ), y x (x 0 + , ) ) +

x1

d ( L ( x, y(x, ), y x (x, ) ) ) dx d x 0 +



by separating the derivative with respect to the lower bound (1st term) and the derivative under the integral. The derivative under the integral is d L ( x, y(x, ), y x (x, ) ) = L y ( x, y(x, ), y x (x, ) ) y  (x, ) d + L z ( x, y(x, ), y x (x, ) ) y x (x, ) By replacing in the expression of

d ( I1 ) , we have d

d ( I1 ) = − L ( x 0 + , y(x 0 + , ), y x (x 0 + , ) ) d +

x1



L y ( x, y(x, ), y x (x, ) ) y  (x, )dx

x 0 +

+

x1



x 0 +

L z ( x, y(x, ), y x (x, ) ) y x (x, )dx

Functional optimization

217

Let us note I2 the second integral above.

I2 =

x1



Lz ( x, y(x, ), y x (x, ) ) y x (x, )dx

x 0 +

By integrating by parts, we have x1

I2 =  Lz ( x, y(x, ), y x (x, ) ) y (x, )  x + − 0

x1

d L z ( x, y(x, ), y x (x, ) ) y  (x, )dx dx x 0 +



Let us calculate the term in square brackets using the expression of y(x, ) . On [x 0 +  ;x1 ] : y(x, ) = y*(x) +

x1 − x ( y*(x 0 ) + w − y*(x 0 + ) ) x1 − (x 0 + )

In x1 : y(x1, ) = y*(x1 )  y (x1, ) = 0 In x 0 +  : y(x0 + , ) = y*(x 0 ) + w  yx (x 0 + , ) + y (x 0 + , ) = w The term in square brackets is

 y (x 0 + , ) = w − yx (x 0 + , )

x1

 L z ( x, y(x, ), y x (x, ) ) y  (x, )  x + = 0

− L z ( x 0 + , y(x 0 + , ), y x (x 0 + , ) )( w − y x (x 0 + , ) )

Let us now group together all the terms of F() coming from I0 and I1 .

F() = L ( x 0 + , y*(x 0 ) + w, w ) − L ( x 0 + , y(x 0 + , ), y x (x 0 + , ) ) − Lz ( x 0 + , y(x 0 + , ), y x (x 0 + , ) )( w − y x (x 0 + , ) ) x1

d    L y ( x, y(x, ), y x (x, ) ) − L z ( x, y(x, ), y x (x, ) )  y  (x, )dx dx  x 0 +  We are interested in the value in  = 0 , for which: y* = y(.,0) . By assumption: d - y* is an extremal: L y ( x, y*, y* ) − L z ( x, y*, y* ) = 0 ; dx - x0 is not a corner, so y* is derivable at x 0 : yx (x 0 ,0) = y* (x 0 ) . +



With these assumptions, we obtain

F(0+ ) = L ( x 0 , y*(x 0 ), w ) − L ( x 0 , y*(x 0 ), y* (x 0 ) ) − Lz ( x 0 , y*(x 0 ), y* (x 0 ) )( w − y* (x 0 ) )

= E ( x 0 , y*(x 0 ), y*'(x 0 ),w )

which is the expected relation.

218

Optimization techniques

The Weierstrass condition (1879) reflects the local convexity of the Lagrangian with respect to the variable z = y .

L(x, y*,w)  L(x, y*, y*) + (w − y*)Lz (x, y, y*) , w 

(3.54)

The Weierstrass excess function E is the difference between the function L(x,y,z) and its tangent at the point (x; y). Using the canonical variables p and H (which will be studied in section 3.4)

p = Lz  H = Lz y − L

(3.55)

the Weierstrass function can be written as

E(x, y*, y*, w) = L(x, y*, w) − L(x, y*, y*) − (w − y*)L z (x, y*, y*) = L(x, y*, w) − L(x, y*, y*) − (w − y*)p = ( py* −L(x, y*, y* ) − ( pw − L(x, y*, w) ) = H(x, y*, y*, p)

(3.56)

− H(x, y*, w, p)

which shows that the Hamiltonian H is maximum when w = y* . We will see in the context of an optimal control problem (chapter 4) that the Weierstrass condition is directly linked to the maximum principle.

3.2.5 Summary The different minimum requirements are summarized below: - weak minimum: with functions C1 and neighborhood in norm 1; - strong minimum: with functions C1 by pieces and neighborhood in norm 0. Necessary conditions for a weak local minimum

Ly = Lz

Euler-Lagrange (1740, 1755)

Lzz  0

Legendre (1786)

Sufficient conditions for a weak local minimum

Ly = Lz

Euler-Lagrange (extremal)

Lzz  0

Legendre (strong condition) Jacobi (1837)

No conjugate point

Functional optimization

219

Necessary conditions for a strong local minimum

Ly = Lz

Euler-Lagrange (extremal)

Legendre Lzz  0 L z and Lz y − L continuous Weierstrass-Erdmann (1865, 1877)

E(x, y*, y*,w)  0 , w

in every corner Weierstrass (1879) everywhere but corners

3.3 Constraints The previous section established optimality conditions for the standard problem  y(a) =  (3.57) with  y  y(b) =  a The only constraints on the solution y *(x) were on the endpoint values. This section extends the optimality conditions to different types of constraints. b

min J(y) =  L(x, y, y)dx

3.3.1 Final constraint It is assumed in this section that the endpoint coordinates can vary. y(a) =  x(a) = a The changes in abscissa and ordinate are noted: and . y(b) =  x(b) = b The first variation of the functional J is then given by





b

J =   ( L y − Ly ) dx +  L yy  + (L − L y y)x  a a b

b

(3.58)

a

Demonstration The functional J depends on the function y and on the abscissas a and b. b

J(y,a,b) =  L(x, y, y)dx a

Let us apply a perturbation  on the y-function and perturbations a and b on the abscissas a and b as shown in figure 3-14.

220

Optimization techniques

Figure 3-14: Function with free endpoints. Let us calculate J(y + ,a + a, b + b) by expanding the Lagrangian to order 1.

J(y + ,a + a,b + b) =

b +b



L ( x, y + ,(y + ) ) dx =

a +a

=

b +b



Ldx +

The first integral gives at order 1:



a +a

Ldx =

a



a +a

 ( L + L

y

+ L y ) dx

a +a

a +a

b +b

b +b

b

b +b

a

b

Ldx +  Ldx +



b +b

 ( L

y

+ L y ) dx

a +a

b

b

a

a

Ldx =  Ldx + L(b)b − L(a)a =  Ldx +  Lx a

b

The second integral is integrated by parts, neglecting the terms in a, b , which are of order 2. b +b



a +a

b

b

a

a

( Ly + L y ) dx =  ( L y + L y ) dx =   ( L y − Ly ) dx + L y a

b

The first variation J is obtained by grouping these terms. b

J = J(y + ,a + a,b + b) − J(y,a,b) =   ( L y − Ly ) dx + L y  + Lx a a b

b

a

We now seek to make the ordinate variations y(a), y(b) appear. The variation y at the endpoints results on the one hand from the function  , on the other hand from the abscissa variation a or b as shown in figure 3-14.

Functional optimization

221

We have the relations y(a) = (a) + y(a)a (a) = y(a) − y(a)a a = x(a)   with   y(b) = (b) + y(b)b (b) = y(b) − y(b)b b = x(b) By replacing in the expression of J , we obtain the formula (3.58). b

J =   ( L y − Ly ) dx +  L yy  + (L − L y y)x  a a b

b

a

The formula (3.58) is used below for a problem with a free final ordinate and then for a problem with a constrained final position on a curve. Problem with free final ordinate Assume that the coordinates a, ,b are fixed and the ordinate  is free. The problem is formulated as b

min J(y) =  L(x, y, y)dx y

with y(a) = 

a

Figure 3-15 shows three functions y1, y2 , y* of values 1, 2 ,  * in x = b .

Figure 3-15: Function with free final ordinate.

(3.59)

222

Optimization techniques

Theorem 3-7 gives necessary conditions that a function y* must satisfy in order to be a weak local minimum of J with free ordinate in x = b . Theorem 3-7: Necessary conditions of minimum with free final ordinate If y* is a weak local minimum of problem (3.59), then y* satisfies •

the Euler-Lagrange equation

Ly − Lz = 0 •

(3.60)

the condition of transversality (3.61)

Lz (b) = 0

Demonstration In the case where a, ,b are fixed, we have: x(a) = y(a) = x(b) = 0 . b

(

)

The first variation (3.58) reduces to: J =   L y − Ly dx + L y (b)y(b) . a

L y − Ly = 0 . L y (b) = 0

The condition of minimum: J = 0 ,  , y(b) requires: 

The Euler-Lagrange equation (3.60) is a second order differential equation with two integration constants. These constants are determined by the initial condition y(a) =  and the transversality condition (3.61), which replaces the final condition y(b) =  . Example 3-7 shows the use of this transversality condition.

Example 3-7: Minimum distance in the plane with free end Let us retrieve example 3-1 assuming now the ordinate is free at x = b . We are looking for the curve y(x) minimizing the distance between the fixed point A and a free point B of abscissa b. te The extremals (example 3-1) are still straight lines: y' = C .

Functional optimization

223

The initial condition requires that we pass through point A (a ; ) . The problem is formulated as b

min  1 + y(x) 2 dx y

a

with the Lagrangian:

L(x, y,z) = 1 + z2 The transversality condition gives

L y (b) = 0  (b) = 0  y(b) = 0 . y 1 + y2

The solution is the horizontal segment [AB*] passing through A, which gives indeed the minimum distance to the imposed abscissa x = b .

Problem with constrained final position on a curve Assume that (a ; ) are fixed and that the endpoint must lie on the curve with equation y = (x) . The abscissa b is free. The problem is formulated as b

min J(y) =  L(x, y, y)dx y,b

a

 y(a) =  with   y(b) = (b)

(3.62)

Figure 3-16 shows three functions y1, y2 , y* arriving on the curve y = (x) .

Figure 3-16: Function with end position on a curve.

224

Optimization techniques

Theorem 3-8 gives necessary conditions satisfied by a function y* to be a weak minimum of J with the final position such that y(b) = (b). Theorem 3-8: Necessary conditions of minimum with final constraint If y* is a weak local minimum of problem (3.62), then y* satisfies •

the Euler-Lagrange equation

Ly − Lz = 0 •

(3.63)

the condition of transversality

L + Lz ( − y*)(b) = 0

(3.64)

Demonstration (a ; ) being fixed: x(a) = y(a) = 0 , the first variation (3.58) reduces to b

J =   ( L y − Ly ) dx +  L yy  (b) + (L − L y y)x  (b) a

The variation y(b) depends on function  and variation b . These variations are linked, as the endpoint must remain on the curve y = (x) as in figure 3-17.

Figure 3-17: Constrained variation at the endpoint.

Functional optimization

225

The final constraint imposes: y(b) =(b)b . Replacing in J , we obtain b

J =   ( L y − Ly ) dx +  L + L y ( − y)x  (b) a

The condition of minimum: J = 0 ,  , x(b) requires

L y − Ly = 0       L + L y ( − y )  (b) = 0

The Euler-Lagrange equation (3.63) yields two integration constants and the free final abscissa b is also to be determined. These three unknowns must satisfy the three equations concerning respectively the initial condition y(a) =  , the final constraint y(b) = (b) and the transversality condition (3.64). Example 3-8 shows the use of this transversality condition.

Example 3-8: Minimum distance to a curve We are looking for the curve minimizing the distance between the fixed point A and the curve of equation y = (x) as shown in figure 3-18. (a)

(b)

Figure 3-18: Minimum distance to a curve. The endpoint on the curve is free and the distance is weighted by a function w(x, y) . In particular, the function w(x, y) can represent the inverse of the velocity with respect to the position. The solution in this case is the fastest path to reach the target curve y = (x) .

226

Optimization techniques b

The problem is of the form: min  w(x, y) 1 + y(x) 2 dx s.t. y(b) = (b) . y,b

a

Let us write the transversality condition (3.64) in b with the Lagrangian given by

L(x, y,z) = w(x, y) 1 + z2 wy

(  − y ) = 0  1 + y = 0 1 + y2 The transversality condition imposes in b: y(b)(b) = −1 . L + Lz ( − y*) = 0  w 1 + y2 +

It reflects the orthogonality of the solution curve and the constraint curve at the end point, as shown in figure 3-18b.

3.3.2 Integral constraint It is assumed in this section that the endpoints are fixed, but that the solution is subject to an integral form constraint. The problem is formulated as b  y(a) =   min J(y) =  L(x, y, y )dx s.t. C(y) =  M(x, y, y)dx = 0 ,  y  y(b) =  a a To solve this type of problem, we define the augmented cost as b

(3.65)

b

K(y) =  0 J(y) + C(y) =  (  0 L + M ) (x, y, y)dx

(3.66)

a

The real numbers  0 and  are the Lagrange multipliers of the cost and the constraint. The function N = 0L + M is called the augmented Lagrangian.

Theorem 3-9 gives necessary conditions that a function y* must satisfy to be a weak minimum of J with the integral constraint C(y) = 0 . Theorem 3-9: Necessary conditions of minimum with integral constraint Assume that y* is a weak local minimum of problem (3.65). Then there exist (0 ; )  (0 ; 0) such that y* satisfies

Ny − Nz = 0

(3.67)

We recognize the Euler-Lagrange equation applied to the augmented Lagrangian.

Functional optimization

227

Demonstration (from [R14]) Assume that y* is a minimum of J under the constraint C(y) = 0 . Apply perturbations of the form y = y* +11 +22 with any functions 1 , 2 of class C1. The function F : (1, 2 )  2 ( J(y),C(y) )  2 is of class C1 of 2 in 2 . Let us study this function in the vicinity of (1 ; 2 ) = (0 ; 0) .

Its value in (1 ; 2 ) = (0 ; 0) is

F ( 0,0) = ( J(y*),C(y*) = 0 )

 J   1 Its gradient matrix in (0, 0) is of the form: F(0,0) =   J    2

C  1  . C   2 

The implicit function theorem states that if the gradient matrix F(0,0) is invertible, then the function F is a bijection from a neighborhood of (0,0) into a neighborhood of ( J(y*),C(y*) ) .

A pair (1 ; 2 )  (0 ; 0) can then be found such that C(y) = 0 (feasible) and J(y)  J(y*) . This situation is illustrated in the figure above with a solution y on the x-axis: C(y) = 0 and a value J(y) lower than J(y*) . This contradicts the assumption that y* is a minimum. Therefore, the matrix F(0,0) is necessarily singular, which means that its columns are linearly dependent. There exist (0 ; )  (0 ; 0) such that:  0

J C + = 0 , noting  = (1 , 2 )   

(equation E)

2

.

228

Optimization techniques

Let us calculate the derivatives of J and C by applying (3.11) and (3.21) for any perturbation  . b

b

J(y + ) =  L ( x, y + ,(y + ) ) dx =    ( L y − Lz ) dx a



a

b

J =  ( L y − Lz ) dx  a b

b

C(y + ) =  M ( x, y + ,(y + ) ) dx =    ( M y − Mz ) dx a



a

b

C =  ( M y − Mz ) dx  a

Replacing these derivatives in (E) with N defined by: N =0L +M , we obtain b

 ( N

y

− Nz ) dx = 0 , 

a

Since the perturbation  is arbitrary, its coefficient in the integral must be zero. We conclude that there exist (0 ; )  (0 ; 0) such as N y − Nz = 0 .

The values of (0 ; ) are determined to within one multiplicative factor. The multiplier  0 is called the abnormal multiplier.

If 0 = 0 (abnormal case), there is only one function y* satisfying the constraint. If 0  0 (normal case), the constraint C(y*) = 0 determines the ratio  / 0 . The general choice in the normal case is to set 0 = 1 .

An integral constraint is also called an isoperimetric constraint in reference to the problem of Dido (Queen of Carthage in 814 BC) presented below.

Example 3-9: Problem of Dido The maximum area enclosed by a curve of given length is sought. We will solve this problem in Cartesian coordinates, then in polar coordinates, which will allow an extension to the maximum volume problem in dimension 3.

Functional optimization

229

Formulation in Cartesian coordinates The points A and B are given and define the x axis. The curve with equation y(x) joins points A and B. The area between the curve (AB) b

and the x axis is: S =  ydx . a

The length of the curve (AB) is b

2 fixed: L =  1 + y(x) dx = L 0 . a

The problem is formulated as b

b

a

a

min J(y) = −  ydx s.t. C(y) =  1 + y(x) 2 dx − L 0 = 0 y

Let us introduce the multiplier  of the integral constraint by setting 0 = 1. 2 The augmented Lagrangian is: N(x, y, y) = − y +  1 + y .

Equation (3.67) yields:

N d  N  d  y  =    y dx  y  dx  1 + y2

  = −1 .  

This second-order differential equation can be solved analytically.

y

1 + y

2

= −(x − x 0 )  y =

x − x0

2

 − (x − x 0 ) 2

 y = y0 −  2 − (x − x 0 ) 2

 (x − x 0 ) 2 + (y − y 0 ) 2 =  2

The curve around the maximum area is a circular arc. The coordinates of the center (x 0 ; y0 ) and the radius  are determined by a,b and the length L0 . Remark on the formulation • Let us consider on the one hand the problem: "Maximize the area enclosed by a curve of given length" 2 maxS(y) s.t. L(y) − L0 = 0 → Lagrangian N1 (x, y, y) = − y +  L 1 + y y



Let us consider on the other hand the problem: "Minimize the length of the curve enclosing a given area" 2 min L(y) s.t. S(y) − S0 = 0 → Lagrangian N2 (x, y, y) = 1 + y + S y y

1 . L These two problems have the same extremals which are arcs of circle. The Lagrangians are identical by posing: S = −

230

Optimization techniques

Formulation in polar coordinates Let us take the problem in polar coordinates (r, ) . The equation of the curve (AB) is r() . An element of length dL and normal n at the position r generates (seen from the origin O): - an apparent length dLr = dLcos  with  = (r,n) ; - an angle at the center d =

dLr ; r

- a triangle of area 1 dS = hdL with h = r  n = r cos  2 (triangle with base dL , vertex O and height h).

r 1 d , dS = r 2d. cos  2 The problem is formulated with the two unknown functions r() , () . 1 r max S(r, ) =  r 2d s.t. L(r, ) =  d = L 0 r,  2 cos   dL and dS are expressed in terms of the angle d : dL =

This is a parametric curve problem as in (3.36). Each function satisfies the EulerLagrange equation (3.40), here concerning the augmented Lagrangian. By introducing the multiplier  of the integral constraint, with 0 = 1 , we have

sin    N  = (N  ) → r cos 2  = 0 →  = 0 ( n parallel to r ) 1 2 r N = r + → 2 cos   N = (N  ) → r +  1 = 0 → r = −  = − = Cte r r cos  cos  

The curve enclosing the maximum area is thus a circle of radius r0 = − .

The value of the radius is determined by the constrained length, equal to L 0 .

L=

2

r 0 cos  d = L0

r = r0 L with   r0 = 0 2  = 0

As with a continuous optimization problem, the sensitivity of the cost (area) to the constraint (length) is given by the opposite of the multiplier.

L  S = r02 =   0   2 

2



S  L0  =   = r0 = − L0  2 

Functional optimization

231

Maximum volume problem The formulation in polars allows a generalization to dimension 3. The "spatial" Dido problem consists in finding the maximum volume enclosed by a surface of given area. Let us repeat the previous approach, now in spherical coordinates (r, , ) . The surface has the equation r(, ) . An element of surface dS and normal n at the position r generates (seen from the origin O): - an apparent surface dSr = dScos  with  = (r,n) ; - a solid angle d =

dSr ; r

- a cone of volume 1 dV = hdS with h = r  n = r cos  3 (cone with base dS , vertex O and height h). dS and dV are expressed in terms of the solid angle d .

r2 1 d , dV = r 3d cos  3 The total volume and surface are obtained by integrating on the solid angle d . The entire space corresponds to a solid angle  = 4 . The problem is formulated with the two unknown functions r(, ) , (, ) . 1 r2 max V(r, ) =  r 3d s.t. S(r, ) =  d = S0 r, 3 cos    As in dimension 2, we obtain a parametric curve problem. Let us solve the Euler-Lagrange equation with the augmented Lagrangian. sin   N = (N  ) → r 2 =0 →  = 0 ( n parallel to r )  1 3 r2   cos 2  N = r + → 3 cos   N = (N  ) → r 2 + 2 r = 0 → r = − 2 = −2 = C te r  r cos  cos   The surface enclosing the maximum volume is thus a sphere of radius r0 = −2 . The value of the radius is determined by the constrained surface, equal to S0 . 4 r = r0 r2 S0 S=  d = S0 with   r0 = cos  4  = 0 0 dS =

232

Optimization techniques

As with a continuous optimization problem, the sensitivity of the cost (volume) to the constraint (area) is given by the opposite of the multiplier. 3

1

4 4  S 2 V 1  S0  2 1 V = r03 =   0   =   = r0 = − 3 3  4  S0 2  4  2

3.3.3 Path constraint It is assumed in this section that the endpoints are fixed, but that the solution is constrained at each point. The problem is formulated as b  y(a) =  min J(y) =  L(x, y, y)dx s.t. M(x, y, y) = 0 , x [a;b] ,  y  y(b) =  a To solve this type of problem, we define the augmented cost.

b

b

a

a

K(y) = J(y) +  (x)M(x, y, y)dx =  ( L + (x)M ) (x, y, y)dx

(3.68)

(3.69)

The function (x) acts as a multiplier of the constraint at each point x. The function N = L + (x)M is called the augmented Lagrangian. Theorem 3-10 gives necessary conditions that a function y* must satisfy to be a weak minimum of J with the path constraint M(x, y, y ') = 0 . Theorem 3-10: Necessary conditions of minimum with path constraint Assume that y* is a weak minimum of the problem (3.68). Then there is a function (x) such that y* satisfies

Ny − Nz = 0

(3.70)

The demonstration will be given in the context of optimal control (chapter 4). The value of (x) at each point is determined by the constraint M(x, y, y) = 0 . A path constraint of the form M(x, y) = 0 is called a holonomic constraint. This type of constraint allows in some cases to reduce the dimension of the problem by expressing y as a function of x.

Functional optimization

233

Example 3-10: Pendulum problem Consider a pendulum of length d in a uniform gravity field g. The potential energy per unit mass is: U = −gy . The kinetic energy per unit mass is

1 T = (x 2 + y 2 ) . 2

The motion must satisfy the holonomic constraint

M = x 2 + y2 − d 2 = 0 .

We will see in section 3.4 that the motion minimizes the action integral defined as tf

S(x, y) =  L ( t, x, x, y, y ) dt

with L = T − U .

t0

The problem is formulated as tf

1  min   (x 2 + y2 ) + gy  dx s.t. M(x, y) = x 2 + y 2 − d 2 = 0 . x,y 2  t0  Let us introduce the multiplier  (t) associated with the current constraint. The Euler-Lagrange equations deal with the augmented Lagrangian which depends on the two functions x(t) and y(t) .

 N x = N x → 2x = x 1 N = (x 2 + y2 ) + gy + (x 2 + y 2 − d 2 ) →  2  N y = N y → 2y + g = y  x = 2 x  The equations of motion are thus:  y = 2y + g  2 2 2 x + y = d with 3 unknown functions x(t), y(t), (t) .

 x = d sin  , we eliminate  (t) and find the equation of the pendulum  y = d cos 

By posing: 

g  = − sin  . d

234

Optimization techniques

3.4 Canonical form This section presents the canonical (or Hamiltonian) formulation of a calculus of variations problem and its applications in mechanics.

3.4.1 Change of variables A calculus of variations problem can be formulated in various ways depending on the choice of the unknowns and the functional. Here we establish some properties concerning the changes of variables. Equivalent functionals Consider two problems with respective functionals J and K and their EulerLagrange equations. b

min J(y) =  L(x, y, y)dx y

→ L y = Ly

a

(3.71)

b

min K(y) =  M ( x, y, y ) dx → M y = My y

a

The functionals J and K are said to be equivalent if they have the same extremals (which are the solutions of the Euler-Lagrange equations). Property 3-11: Sufficient condition for equivalence of two functionals If the Lagrangians L and M differ by one total derivative, then the functionals J and K are equivalent and differ by one constant.

Demonstration Suppose that M(x, y, y) = L(x, y, y) +

d(x, y) where (x, y) is any function. dx

Let F(x, y, y) be the function equal to the total derivative of (x, y) .

F(x, y, y) =

d(x, y) =  x (x, y) +  y (x, y)y(x) dx Fy =  xy +  yy y    Fy = y =  yx +  yy y Fy =  y

Functional optimization

235

The derivatives M y and My are given by

M y = L y + Fy = L y +  xy +  yy y  My = Ly + Fy = Ly +  yx +  yy y

 My − My = Ly − Ly

The Euler-Lagrange equations in L and M therefore have the same solutions. Let us calculate the value of K(y) . b

b

b

d   te K(y) =  Mdx =  (L + F)dx =   L +  dx = J(y) + (b) − (a) = J(y) + C dx  a a a

The two functionalities do differ by one constant.

Change of variable Consider the change of variable defined by: y(x) = f ( x,Y(x) ) . b

Assume that y(x) is an extremal of: J(y) =  L(x, y, y)dx . a

b

Then Y(x) is an extremal of: K(Y) =  M ( x, Y, Y ) dx with M defined by a

M(x,Y,Y) = L ( x,f (x,Y),f x + f YY ) def

(3.72)

Demonstration Let us calculate the derivatives MY and MY with M defined by (3.72).

MY = L yf Y + L y (f xY + f YY Y)  MY = L yf Y

Deriving the 2nd equation with respect to x and using the 1st equation, we have

d  d   d  M Y =  L y  f Y + L y  f Y  = Lyf Y + L y (f Yx + f YY Y) dx  dx   dx  = Lyf Y + (M Y − L yf Y )

MY =

from which we deduce: MY − MY = (Ly − Ly )f Y . If y(x) is an extremal of the functional J, then Ly − Ly = 0 and Y(x) is an extremal of the functional K because MY − MY = 0 .

236

Optimization techniques

Change of variable with parameter Consider the functional J in standard form: b

J(y) =  L(x, y, y)dx

(3.73)

a

and apply a change of variable depending on a parameter  :  x* = X(x, y, y, ) x = X(x, y, y,0) (3.74) (x*, y*) with  and   y* = Y(x, y, y, )  y = Y(x, y, y,0) (x*, y*) corresponds to the identity. For  = 0 , the transformation (x, y) (x, y)

The functional J is invariant by the transformation if it keeps its value.

J(y*) = J(y) 

x*= b*



L ( x*, y*, y* ) dx * =

x*=a*

x =b

 L ( x, y, y) dx

(3.75)

x =a

Noether's theorem gives a first integral in the case of an invariant functional. This theorem is used to establish conservation laws in mechanics (section 3.4.4). Property 3-12: Noether's theorem If the functional J (3.73) is invariant by the transformation (3.74) whatever the integral bounds a and b, then the function L y

Y X + ( L − L y y ) is a first integral.  =0  =0

Demonstration Formula (3.58) gives the variation of J as a function of perturbations  , x(a), x(b), y(a), y(b) . b

J =   ( L y − Ly ) dx + [L yy]ab + [(L − L y y)x]ab a

Let us calculate the variations x , y by expanding (3.74) to order 1 in  .

 x* = X(x, y, y, ) = X(x, y, y,0) +  X  =0 = x +  X  =0  x =  X  =0   y* = Y(x, y, y, ) = Y(x, y, y,0) +  Y =0 = y +  Y =0  y =  Y =0

Functional optimization

237

The first variation is in the form b

J =   ( L y − Ly ) dx +   L y Y =0 + ( L − L y y ) X  =0  a

b

a

Along an extremal, we have

b L y − Ly = 0   L y Y =0 + ( L − L y y ) X  =0  = 0  a J = 0

By assumption, the functional J must be invariant whatever the bounds a and b. The term in square brackets must therefore be constant.

L y Y =0 + ( L − L y y) X =0 = Cte

This constant quantity along an extremal is indeed a first integral.

Noether's theorem remains valid for a functional depending on several unknown functions (y j ) j=1 to n as in (3.33). Indeed, the above proof applies to each function which satisfies its own Euler-Lagrange equation (3.34).

3.4.2 Canonical variables Consider a problem that depends on n functions y = (y1,

, yn ) .

b

min J(y) =  L(x, y, y)dx y

(3.76)

a

We define n functions noted p = (p1,

,pn ) and the function H(x, y,p) by

p = L y  H = py − L

(3.77)

The n functions (y j ) j=1 to n of

in

are called coordinate.

The n functions (p j ) j=1 to n of

in

are called momentum.

The function H of

2n +1

in

is called the Hamiltonian and is expressed as

n

H(x, y,p) =  pi yi − L(x, y1,..., y n , y1 ,..., yn ) i =1

(y, p, H) are called canonical variables associated with the J functional.

(3.78)

238

Optimization techniques

Note on Legendre’s transformation The canonical variables can be defined by the transformation of Legendre . n → is the function h : n → The Legendre transform of the function f : defined by: h(p) = maxn ( pz − f (z) ) . def z

By denoting zp the value of z that maximizes pz − f (z) for fixed p, we have the following properties: −1 d ( pz − f (z) ) = 0 in z p  p = f (z p )  h(p) = z p and h(p) = (f (z p ) ) ; dz - the function h is convex; - if f is convex, the Legendre transform of h gives back f (involution). In order to define the canonical variables associated with the functional J, we apply the Legendre transformation to the Lagrangian L(x, y, z) considered as a

H(x, y,p) = max ( pz p − L(x, y,z p ) ) = pz p − L(x, y,z p )  def z . = Lz (x, y,z p ) p def

function of z: 

The canonical variables are used below to transform the second-order EulerLagrange equation into a system of first-order differential equations. Canonical equations

H y = −L y

The derivatives of H = py − L are given by:   H p = y

.

The Euler-Lagrange equation of problem (3.76) gives

Ly = Ly  − Hy = p

(3.79)

We call canonical (or Hamiltonian) equations the following differential system.

 y = H p (3.80)  p = −H y This differential system in variables (y, p) is of order 1 and of dimension 2n. It is equivalent to the Euler-Lagrange equation in y variables (differential system of order 2 and dimension n).

Functional optimization

239

First integral A first integral of the functional J is a function that keeps a constant value along any extremal y*. Let us calculate the total derivative of the Hamiltonian H(x, y,p) along an extremal. Using the canonical equations (3.80) of the extremal, we obtain

dH H H H H = + y + p = dx x y p x

(3.81)

If H does not depend explicitly on x, then H is a first integral.

Note on Poisson’s brackets Let us calculate the total derivative of a function (x, y, p) along an extremal. Using the canonical equations (3.80) of the extremal, we obtain

d      H  H = + y + p = + − dx x y p x y p p y

 H  H − . def y p p y A function (y, p) not explicit in x is a first integral if ,H = 0 . We define the Poisson bracket of  and H by:  ,H =

Poisson’s brackets are used widely in celestial mechanics.

Canonical transformation Consider two functionals J(y) and K(Y) . The functional J of Lagrangian L(x, y, y) has the canonical variables (y, p) and the Hamiltonian H(x, y,p) . b

b

a

a

J =  L(x, y, y)dx =  ( py − H(x, y, p) ) dx

p = L y with  H = py − L

(3.82)

The functional K of Lagrangian M(x,Y,Y) has the canonical variables (Y,P) and the Hamiltonian H*(x, Y, P) . b

b

a

a

K =  M(x, Y, Y)dx =  ( PY − H*(x, Y, P) ) dx

P = M y (3.83) with  H* = pY − M

240

Optimization techniques

Suppose that the two functionals J and J* are equivalent, which means that they have the same extremals. A sufficient condition for this is that their Lagrangians differ by one total derivative (property 3-11).

py − H(x, y,p) = PY − H*(x,Y,P) +

d dx

(3.84)

(x, y, Y) is any function of the y and Y coordinates. Expressing from (3.84) the differential d as a function of dx,dy,dY :

d = pdy − PdY + ( H*(x,Y,P) − H(x, y,p) ) dx

(3.85)

we obtain the variables p, P, H * as a function of the partial derivatives of  .

p=

   , P=− , H* = H + y Y x

(3.86)

The function (x, y, Y) is called the generating function of the canonical (Y, P) . The problems in variables (y, p, H) or (Y, P, H*) transformation (y, p) are equivalent. Their respective canonical systems are

 Y = H*P  y = Hp with H(x,y,p) and  with H*(x,Y,P)   P = − H*Y p = − H y

(3.87)

Note on generating functions The generating function can be expressed in variables (y, Y) , (y, P) , (p, Y) or (p, P) . We note 1 (x, y,Y) the function in variables (y, Y) defined above (3.84). The transformation from one form to the other is done as follows.

1 (x, y,Y)

 d1 = pdy − PdY + (H* −H)dx

 2 (x, y,P) = 1 (x, y,Y) + PY

1  ,P=− 1 y Y  d 2 = pdy + YdP + (H* −H)dx → p=

 2  2 ,Y= y P  d3 = − ydp − PdY + (H* −H)dx

→ p= 3 (x,p,Y) = 1 (x, y,Y) − py

→ y=−

3  ,P=− 3 p Y

Functional optimization

241

 4 (x,p,P) = 1 (x, y,Y) − py + PY  d 4 = − ydp + YdP + (H* −H)dx → y=−

 4  4 ,Y= p P

3.4.3 Hamilton-Jacobi-Bellman equation Consider a problem with fixed endpoint A (a; ) and variable endpoint B (b; ) .  y(a) =  (3.88) with   y(b) =  a The value function V(b, ) is the value of J for the extremal y* from A to B. b

min J(y) =  L(x, y, y)dx y

b

V(b, ) =  L ( t, y*, y* ) dt

(3.89)

a

Theorem 3-13: Hamilton-Jacobi-Bellman equation The value function satisfies the equation of Hamilton-Jacobi-Bellman (HJB).

V V + H(x, y, ) = 0 x y

(3.90)

Demonstration We calculate the partial derivatives of the value function with respect to b and . To do this, we start from the first variation of the functional J given by (3.58). b

J =   ( L y − Ly ) dx + [L yy]ab + [(L − L y y)x]ab a

If y* is an extremal (Ly = Ly ) and A is fixed (x(a) = y(a) = 0) , then

J = Lyy(b) + (L − Ly y)x(b) = py(b) − Hx(b) with the canonical variables p and H defined in (3.77). This variation J represents the differential dV of the value function.

242

Optimization techniques

By noting (x; y) instead of (b; ) the coordinates of point B, we have

dV = pdy − Hdx 

V V = −H , =p x y

The Hamiltonian H is a function of (x, y, p) with p =

V , which leads to y

 V V  = −H(x, y, p) = −H  x, y,  x y  

Solving the equation HJB yields the value function V(x, y) at any point M (x; y) starting for a fixed point A (a; ) . Once the value function has been determined, the extremals can be found using property 3-14.

Property 3-14: First integral deduced from the value function Suppose that the value function V(x, y, ) depends on constants noted  . Then the functions

V are first integrals of problem (3.88). 

Demonstration It must be shown that

d  V   2 V  2 V dy + is zero along an extremal.  = dx    x y dx

V(x, y, ) satisfies the equation HJB:

Deriving w.r.t  , we have:

 V V  + H  x, y,  = 0 . x y  

  V V   2 V H  2 V + H(x, y, )  = + =0.    x y  x p y

Along an extremal y(x) , we have: y' =

H  2 V dy  2 V  + =0. x dx y p

Analytical solution of the HJB equation is generally not possible. In simple cases such as example 3-11, special form solutions can be obtained by separation of variables.

Functional optimization

243

Example 3-11: Hamilton-Jacobi-Bellman equation b

2 Consider a functional of the form: J(y) =  f (y) 1 + y dx . a

2 Let us express the canonical variables from: L(x, y, y) = f (y) 1 + y .

H = py − L = py − f (y) 1 + y2  y  p = L y = f (y) 1 + y2  The 2nd equation is used to express y as a function of (x, y, p) , then replace it in the 1st equation to express H as a function of (x, y, p) . f (y)y p p=  y = → H(x, y,p) = − f (y) 2 − p 2 2 2 2 1 + y f (y) − p 2 2 2 The equation HBJ is then: Vx + H(x, y,Vy ) = 0  Vx + Vy = f (y) .

Solution by separation of variables Let us look for a solution of the form: V(x, y) = v(x) + w(y) .

v(x)2 + w(y)2 = f (y)2  v(x) 2 = f (y) 2 − w(y) 2 =  2 = Cte because the equality must be true for all (x, y) . Integrating each member with the initial condition: V(a, ) = 0 , we obtain

 v(x) =  (x − a) y  y  V(x, y) =  (x − a) + f (u) 2 −  2 du  2 2    w(y) =  f (u) −  du   To determine the extremals starting from A (a; ) , we use property 3-14 indicating V that is a first integral.  y

V du = x −a − = C te = 0 (for x = a , y = ) 2 2  f (u) −   y

The extremals therefore have the equation: x −  

du f (u)2 −  2

=a.

244

Optimization techniques

Distance functional In the case f (y) = 1 , the functional J is the distance in the plane. The value function and the equations of the extremals are simplified. 2 Value function: V(x, y) = (x − a) + 1 −  (y − )

Extremal:

x−

 1− 2

(y − ) = a

We find the equation of a line through A. For a given point M (x; y) , the constant  is:  =

(x − a) (x − a) 2 + (y − ) 2

.

Let us replace  in the value function.

V(x, y) = (x − a) + 1 −  2 (y − ) = (x − a) 2 + (y − ) 2 We find indeed that the value function represents the minimal AM distance.

3.4.4 Application to mechanics The laws of mechanics can be established from the calculus of variations. Consider a system of n material points (particles) in a given potential field:

m = (m1, ,mn ) ;

- particle masses:

r(t) = ( r1 ,

- particle positions: - particle velocities: - particle accelerations: - total kinetic energy: - total potential energy: - force applied to particle i:

, rn ) = q ; noted

dr v(t) = = ( v1, , v n ) = q ; noted dt dv a(t) = = ( a1 , ,a n ) = q ; noted dt

n 1 1 T = mq 2 =  mi qi 2 ; 2 i =1 2 U(t,q) ; U Fi = − (derived from the potential). q i

The action of the system is defined by tf

S =  L(t,q,q)dt t0

1 with L = T − U = mq 2 − U(t,q) 2

(3.91)

Functional optimization

245

The Lagrangian L of the particle system is the difference between the kinetic energy and the potential energy. The laws of mechanics are based on the following postulate. Least action postulate: the trajectories of the particles minimize the S action. We can therefore find the trajectories of the particles by looking for the extremals of the functional S. The Euler-Lagrange equation of the functional (3.91) yields

Lq = Lq  −

U d = (mq)  F = mq q dt

(3.92)

We find Newton's second law (fundamental principle of dynamics). The postulate of least action "contains" Newton's second law. It also allows us to find the conservation laws. Let us express the canonical variables associated with the functional S (3.91).

p = Lq = mq  2 H = pq − L = mq − L = 2T − (T − U) = T + U

(3.93)

The variables p are the quantities of motion (or momentum) of the particles. The Hamiltonian H is the total energy of the system. Let us look at some specific systems.

Conservative system For a conservative system, the potential U is not explicitly time dependent. The Hamiltonian H (3.93) is then a first integral from (3.81).

dH H  = = (T + U) = 0  H = T + U = Cte dt t t

(3.94)

We find the law of conservation of energy.

Translation invariant system Consider the translation of parameter  defined by

 t* = X(t,q,q, ) = t  q* = Y(t,q,q, ) = q + 

(3.95)

As the system is invariant by this transformation, so is the functional (3.91).

246

Optimization techniques

Noether's theorem (property 3-12) then gives the first integral

L y

Y X + ( L − L y y ) = Cte  =0  =0

(3.96)

or by using the canonical variables p = Ly , H = L − Ly y

p

Y X + H = Cte  =0  =0

(3.97) te

For the transformation (3.95), we obtain: p = mq = C . We find the law of conservation of momentum for a translationally invariant system.

Rotation invariant system An infinitesimal rotation of an angle  about an axis n transforms the vector q into a vector q* = q + q defined by q = n  q → q* = q + n  q

Consider the rotation of parameter  defined by

 t* = X(t,q,q, ) = t (3.98)  q* = Y(t,q,q, ) = q + n  q Since the system is invariant by this transformation, the functional (3.91) is also invariant. Noether's theorem (property 3-12) then gives the first integral

p

Y X + H = Cte  =0  =0

(3.99)

te For the transformation (3.98), we obtain: p  (n  q) = n  (q  p) = C . te Since the relations holds for any axis of rotation n , we can deduce: q  p = C .

This quantity is the angular momentum (moment of momentum): h = q  mq . def

We find the law of conservation of angular momentum for a rotation invariant system.

Functional optimization

247

Kepler problem Kepler's problem is the motion of a particle in a 1/r potential. Let us use the previous results to find the main properties of the Kepler problem. The movement is planar because the acceleration is central. We place ourselves in polar coordinates (r, ) as shown opposite.

r  .  r 

The velocity components are: v = 

Let us express the Lagrangian of the system: - potential energy: - kinetic energy: - Lagrangian:

 U=− ; r 1 1 T = v 2 = (r 2 + r 22 ) ; 2 2 1  L(t,r, ,r, ) = T − U = (r 2 + r 22 ) + . 2 r

The Euler-Lagrange equations for the functions (r, ) yield

  2 Lr = Lr  r − r 2 = r  L = L  0 = d (r 2)  r 2 = Cte    dt The second equation involves the modulus of angular momentum h .

r  r  0        h = r  v =  0    r  =  0   0  0   2       r 

The Lagrangian L does not depend explicitly on the time t. The system is conservative and its energy (Hamiltonian) is then constant. H = T + U = Cte The Lagrangian L does not depend explicitly on the polar angle  . The system is rotationally invariant and its angular momentum is then constant.

h = r  v = Cte

248

Optimization techniques

3.5 Dynamic system This section introduces the state formulation of a system which allows us to move from the calculus of variations to more general problems of optimal control.

3.5.1 State formulation The calculus of variations considers problems of the form b

min J(y) =  L(x, y, y)dx y

(3.100)

a

where the unknown is a derivable function y(x) . A more general approach is to formulate a control problem by introducing an unknown function u(x) and expressing the derivative as a differential equation:

y = f (x,u, t) . Control problem The variables are changed as follows: - the variable x is replaced by the time t; - the function y(x) is replaced by the state x(t) ; - the unknown function is the command or control u(t) ; - the state follows a differential equation of the form: x = f (x, u, t) . This differential equation is called state equation or dynamic equation or evolution equation. The control problem is then formulated as b

min J(u) =  L(x, u, t)dt with x = f (x, u, t) u

(3.101)

a

This formulation is much more general than (3.100): - the unknown function u(t) is arbitrary and the curve x(t) results; - the dimensions of u(t) and x(t) are arbitrary; - it is easier to impose all kinds of constraints on u(t) and x(t) . Example 3-12 illustrates the reformulation of the brachistochrone problem into a control problem.

Functional optimization

249

Example 3-12: Brachistochrone as a control problem The problem of the brachistochrone was addressed by the calculus of variations in example 3-2. Recall that the aim is to find the curve (AB) that minimizes the travel time of a particle under the effect of gravity. The formulation in calculus of variations is b

min  y

a

 y(a) = 0 1 + y(x) 2 dx with  y(x)  y(b) = 

Let us formulate an equivalent control problem: - the variable is the time t; - the two-component state vector is the position of the particle x(t), y(t) ; - the control (t) is the angle of the curve with the axis (Ox). The conservation of energy gives:

1 2 v − gy = 0  v = 2gy . 2

 x = vcos  = 2gy cos 

The equation of state is: 

 y = vsin  = 2gy sin 

x(t 0 ) = x A , y(t 0 ) = y A x(t f ) = x B , y(t f ) = y B

with 

The unknowns here are the control (t) and the final time t f . The control problem is formulated as tf  x = vcos  = 2gy cos   x(t 0 ) = x A , y(t 0 ) = y A min J = t f − t 0 =  dt with  ,  ,t f y = vsin  = 2gy sin   x(t f ) = x B , y(t f ) = y B t0 

State equation For a given system, the choice of the state vector depends on the characteristics one wishes to study. The state vector must completely define the system at a given time, independently of its previous evolution. The evolution of the system from a time t 0 depends only on the initial state x(t 0 ) and is obtained by integrating the state equation x = f (x, u, t) from the initial condition. This differential equation has a solution as soon as the functions f and u are sufficiently regular (for example if f is of class C 1 in x, f and fx are continuous with respect to u and t, and u is continuous by pieces). The set of successive states x(t) forms the trajectory of the system. The system can be autonomous, controlled or linear.

250

Optimization techniques

The system is autonomous if f does not depend explicitly on time: x = f (x, u) . The solution then depends of the duration t − t 0 , independently of the initial time. The system is uncontrolled if f does not depend on the control: x = f (x, t) . The solution then depends only on the initial state x(t 0 ) . The system is linear if f is linear in x and u: x(t) = F(t)x(t) + G(t)u(t) . The solution is then a linear function of the initial state and the control. The properties of linear systems are presented in section 3.5.3. Variational equation For a nonlinear system, we are interested in the behavior in the vicinity of a nominal (or reference) trajectory. The nominal trajectory noted x*(t) is obtained with the control u*(t) between the initial time t 0 and the final time t f . Perturbations of the control u(t) produce state perturbations x(t) . The nominal and perturbed trajectories have the respective state equations

 x* = f (x*, u*, t) (3.102)   x* + x = f (x* + x , u* + u , t) Expanding the second equation to order 1 and eliminating the terms of order 0, we obtain the equation for the evolution of the deviation x(t) .

f  T F(t) = x (x*,u*, t) (3.103) x = F(t)x + G(t)u with  G(t) = f (x*,u*, t)T  u The matrices F(t),G(t) are calculated on the nominal path (x*, u*) . The deviation x(t) follows a linear state equation that can be solved with the methods presented in section 3.5.3. This equation allows the study of stability in the vicinity of the nominal trajectory as presented below.

3.5.2 Stability This section presents some elements on the stability of dynamical systems. For simplicity, we limit ourselves to an autonomous system of dimension 2 of the form

 x1 = f1 (x1 , x 2 )   x2 = f 2 (x1 , x 2 )

(3.104)

Functional optimization

251

Combining the equations in (3.104), we obtain an equation linking x1 and x 2 .

dx 2 f 2 (x1 , x 2 ) = dx1 f1 (x1, x 2 )

(3.105)

The trajectory of the system can be represented in the phase plane (x1, x 2 ) . The set of possible trajectories forms the phase portrait of the system. To draw the phase portrait, one can either: - integrate the differential system (3.104) in x1 (t) and x 2 (t) , then eliminate t; - or integrate the differential equation (3.105) linking x1 and x 2 ; - or use the tangent field (3.105) (method of isoclines).

Example 3-13: Phase portrait Example of uncontrolled system Consider the uncontrolled system defined by:  + a = 0 .

 x1 = x 2 .  x 2 = −ax1

Defining the state (x1, x 2 ) = (, ) , we obtain the system: 

Eliminating time and integrating gives the relation between x1 and x2.

dx 2 ax = − 1  ax1dx1 + x 2dx 2 = 0  ax12 + x 22 = c dx1 x2 The phase portrait is the set of these curves as the constant c varies. These are conics of center O (ellipses if a  0 , hyperbolas if a  0 ). Example of controlled system Consider the controlled system defined by

u = − 1 if   0  = u with  u = + 1 if   0

By defining the state (x1 , x 2 ) = ( , ) ,

 x1 = x 2 . x 2 = u

we obtain the system: 

252

Optimization techniques

Eliminating time and integrating gives the relation between x1 and x2.

dx 2 u =  x 2dx 2 = udx1  x 22 = 2ux1 + c dx1 x 2 The phase portrait is formed by 2 families of parabolic arcs. u = −1 if x1  0 The control u is given by:  . u = +1 if x1  0

Equilibrium points An equilibrium point or singular point of the system (3.104) is a point such that

 x1 = Cte  x1 = f1 (x1 , x 2 ) = 0 (3.106)    te  x2 = f 2 (x1 , x 2 ) = 0  x2 = C The stability depends on the behavior in the vicinity of the equilibrium points. The case of a linear system is analyzed first, followed by a nonlinear system. Linear system A linear system of order 1 and dimension 2 has a state equation of the form

 x1 = c11x1 + c12 x 2   x 2 = c 21x1 + c 22 x 2

(3.107)

The only equilibrium point is the origin: x1 = x 2 = 0 . To study the stability of the system in the vicinity of the origin, we form the equivalent second-order differential equation.

 x1 = x → x + ax + bx = 0   x 2 = x The general solution is of the form

(3.108)

 x(t) = k1es1t + k 2es2t if s1  s 2 (3.109)  st st  x(t) = k1e 1 + k 2 t e 1 if s1 = s 2 where s1 and s2 are the real or complex roots of the characteristic equation s 2 + as + b = 0

(3.110)

Functional optimization

253

Figure 3-19 shows the possible behaviors depending on the position of the roots s1 and s2 in the complex plane. Depending on the case, the equilibrium point is called stable/unstable node, inflection point, stable/unstable focus or center.

Figure 3-19: Equilibrium point of a linear system.

Nonlinear system A nonlinear system may have several singular points, limit cycles and/or chaotic behavior. A limit cycle is a solution forming a closed curve. The motion on this curve is periodic. Neighboring initial conditions can converge to this curve or diverge from it. The limit cycle is said: - stable if all neighboring trajectories converge on the limit cycle; - unstable if all neighboring trajectories diverge from the limit cycle; - semi-stable if some trajectories converge and others diverge.

Example 3-14: Limit cycle

 x1 = x 2 + ax1 (x12 + x 22 − 1) n . 2 2 n  x 2 = − x1 + ax 2 (x1 + x 2 − 1)

Consider the nonlinear system: 

Let us switch to polar coordinates.

r = ar(r 2 − 1)n r = x1 cos  + x2 sin   x1 = r cos  → →    r= − x1 sin  + x2 cos   = −1 x 2 = r sin 

The circle with center O and radius 1 is a limit cycle.

r(t 0 ) = 1  r = 0  r(t) = 1

254

Optimization techniques

The stability of the limit cycle depends on n and a. Figure 3-20 shows the three possible evolutions from conditions close to the limit cycle.

Figure 3-20: Limit cycle.

Chaotic behavior means high sensitivity to initial conditions. The state of the system becomes unpredictable after some time as shown below.

Example 3-15: Chaotic behavior Consider the nonlinear system of order 2: x + 0.1x + x 5 = 6sin t . Figure 3-21 shows the evolution of the system from two neighboring conditions. Dotted lines

x 0 = 2  x 0 = 3

Solid lines

x 0 = 2.01  x 0 = 3.01 Figure 3-21: Chaotic behavior.

The evolution of the system becomes completely different from t = 30. The perturbed path cannot be predicted from the dotted reference path.

Functional optimization

255

Local and asymptotic stability Note x e an equilibrium point and x = x − x e the deviation from it. Different forms of stability are defined in the vicinity of the equilibrium point x e : • the point x e is locally stable if an arbitrarily small deviation x(t) can be obtained at t  t 0 by choosing the initial condition x(t 0 ) ;



the point x e is asymptotically stable if lim x(t) = 0 ;



the point x e is exponentially stable if x(t)  x(t 0 ) e−t , ,  0 .

t →

A nonlinear system can remain bounded without being stable, for example if it admits a stable limit cycle. To analyze the stability of a system in the vicinity of an equilibrium point, one can proceed by linearization or by Lyapunov’s method. It is assumed here that the system is autonomous with a state equation of the form x = f (x) . Study by linearization The equation for the deviations in the vicinity of the equilibrium point x e is

f (3.111) (x e )T x If all eigenvalues of F have strictly negative real parts, the system is exponentially stable. If one eigenvalue of F has a strictly positive real part, the system is unstable (= not stable). Otherwise, it is not possible to say anything about the stability of the nonlinear system. x = Fx with F =

Study by Lyapunov’s method A Lyapunov function of the system x = f (x) is a function V(x) of class C1 defined positive: V(x)  0 if x  0 and decreasing:

dV x(t)  0 . dt

The following sufficient stability conditions are established: • if the system admits a Lyapunov function V, the point x e is locally stable; • if V is strictly decreasing, the point x e is asymptotically stable; • if lim V(x) =  , the point x e is globally asymptotically stable. x →

In most cases, one can define a Lyapunov function from the energy of the system and demonstrate stability by studying this function.

256

Optimization techniques

3.5.3 Linear system This section deals with linear systems of the form (3.112)

x(t) = F(t)x(t)

The results also apply to nonlinear systems x = f (x, t) when considering their deviation x(t) from a nominal trajectory x*(t) . The deviation x(t) follows the linear variational equation T

 f  (3.113) x(t) = F(t)x(t) with F(t) =  ( x*(t), t )   x   where the Jacobian matrix F(t) is evaluated along the nominal path. Some important notions about linear systems are introduced below: transition and covariance matrix, adjoint state, observability, controllability. Transition matrix The transition matrix (t, t 0 ) of the linear system x(t) = F(t)x(t) allows to go from the state at time t0 to the state at time t. (3.114)

x(t) = (t,t 0 )x(t 0 )

If the state is of dimension n, the transition matrix is of dimension n  n . The term ij (t, t 0 ) represents the value taken by the component x i (t) when all components of x(t 0 ) are 0 except the component x j (t 0 ) which is 1 (pulse). This correspondence is illustrated in figure 3-22. The transition matrix is also called the impulse response matrix.

Figure 3-22: Transition matrix.

Functional optimization

257

The transition matrix has the following properties: •

inverse and product

(t, t) = I  (t 0 , t1 )(t1 , t 0 ) = I (t , t )(t , t ) = (t , t ) 1 0 2 0  2 1 •

differential equation followed by (t, t 0 ) for a fixed initial time t0

x(t) = (t, t 0 )x(t 0 ) d  (t, t 0 ) = F(t)(t, t 0 )  dt x(t) = F(t)x(t) •

(3.115)

(3.116)

differential equation followed by (t f , t) for a fixed final time tf

 x(t f ) = (t f , t)x(t)   x(t) = F(t)x(t)



d (t f , t) = −(t f , t)F(t) dt

(3.117)

Equation (3.117) is called the adjoint equation of (3.116). Symplectic matrix For some linear systems, the transition matrix is symplectic, which means that it satisfies the relation

 0 I with J =    −I 0  The interest of a symplectic matrix is that its inverse is obtained by  T J = J

(3.118)

 −1 = −J T J

(3.119)

Let us calculate the derivative of  T J using equation (3.116):  = F .

d T ( J) =  T J +  T J =  T (FT J + JF) dt

(3.120)

The matrix  is symplectic if: FT J + JF = 0 . Indeed,  T J is then constant equal to its initial value J . For a partitioned matrix, we have

 F21 − F21T F11T + F22   F11 F12  T F=  F J + JF =    T T  F21 F22   −F11 − F22 F12 − F12  Such a matrix is symplectic if F12 and F21 are symmetric and F11T = −F22 .

(3.121)

258

Optimization techniques

Example 3-16: Motion in a gravity field Consider the motion of a material point in a central gravity field. The position, velocity and gravity are noted respectively r , v,g .

 r = v r with g(r) = − 3 . The equations of motion are:  r  v = g(r) The linearized equations in the vicinity of a reference trajectory are

r = v  v = G r

 3x 2 − r 2 3xy  3xz   g   with G = = 5 (3r r T − r 2 I) = 5  3yx 3y 2 − r 2 3yz  r r r  2 2 3zy 3z − r   3zx

The matrix G is the gravity gradient matrix. The variational system is linear of the form

0 I   r  x = Fx with x =   and F =    v  G 0

F12 = I and F21 = G symmetric The matrix F is partitioned (3.121) and so that:  T F11 = −F22 = 0 The transition matrix is therefore symplectic and it satisfies

(t 0 , t1 ) = (t1 , t 0 )−1 = −J(t1, t 0 )T J

 r   r   = (t1 , t 0 )   .  v  t  v  t

The deviations are propagated by the relation: 

1

0

The symplectic matrix property simplifies the propagation calculations.

Covariance matrix Consider a linear system x(t) = F(t)x(t) whose state is a random variable with mean x(t) and covariance P(t) .

 x(t) = E  x(t)    T P(t) = E ( x(t) − x(t) )( x(t) − x(t) )  To simplify the formulas, let us assume that the initial mean is zero. The state propagates with the transition matrix: x(t) = (t, t 0 )x(t 0 ) .

(3.122)

Functional optimization

259

The mean and covariance then propagate according to the equations

 x(t) = (t, t 0 )x(t 0 )  T P(t) = (t, t 0 )P(t 0 )(t, t 0 )  T P(t) = F(t)P(t) + P(t)F(t)

(3.123)

Demonstration For the mean

x(t) = E (t, t 0 )x(t 0 ) = (t, t 0 )E x(t 0 )  = (t, t 0 )x(t 0 ) For the covariance, assuming the initial mean is zero: x(t 0 ) = 0  x(t) = 0

P(t) = E  x(t)x(t)T  = (t, t 0 )E  x(t 0 )x(t 0 ) T  (t, t 0 ) T = (t, t 0 )P(t 0 )(t, t 0 )T The covariance differential equation is obtained by deriving directly and using: x(t) = F(t)x(t) .

d E  x(t)x(t) T  = E  x(t)x(t) T + x(t)x(t) T  dt = E  F(t)x(t)x(t)T + x(t)x(t) T F(t) T  = F(t)P(t) + P(t)F(t)T

P(t) =

Adjoint state Consider a linear system propagated from t to tf with its transition matrix

x(t f ) = (t f , t)x(t)

(3.124)

and a linear function of the final state

 x(t f ) = cT x(t f ) = cT(t f ,t)x(t)

(3.125)

The adjoint state associated with the function  is defined as the derivative of

 x(t f ) with respect to the state x(t) at time t.

p(t) =

def

 x(t f ) = (t f , t)T c x(t)

(3.126)

260

Optimization techniques

The adjoint state p(t) , also called costate or influence function, represents the sensitivity of the function  at the final time with respect to state variations along the trajectory. Its value at the final time is: p(t f ) = (t f , t f )c = c . The propagation equations of the adjoint state form the adjoint equations. They are obtained by deriving (3.126) from (3.117):

d (t f , t) = −(t f , t)F(t) . dt

p(t) = −F(t)T p(t) (3.127)  p(t ) = c  f The adjoint state, known at the final time, is calculated by backward integration. A linear change of state leads to a change of adjoint given by

y(t) = G(t)x(t) → q(t) = G(t) − T p(t)

(3.128)

Demonstration The state x(t) has the transition matrix  : x(t) =(t, t 0 )x(t 0 ) and the adjoint:

p(t) =(t f , t)T c .

We calculate the transition matrix (t, t 0 ) for a state y(t) defined by y(t) = G(t)x(t) −1 −1  x(t) = (t, t 0 )x(t 0 )  G(t) y(t) = (t, t 0 )G(t 0 ) y(t 0 )  −1  y(t) =  (t, t 0 )y(t 0 )   (t, t 0 ) = G(t)(t, t 0 )G(t 0 ) We then define the linear function   y(t f ) associated with the state y(t) .

  y(t f ) =  x(t f ) = cT x(t f ) = cTG(t f ) −1 y(t f ) = d T y(t f ) with d = G(t f ) − T c def

The adjoint q(t) associated with the function  is defined by (3.126).

  y(t f ) = (t f , t)T d y(t) Replacing (t, t 0 ) and d by their expressions in terms of (t,t 0 ) and G(t) , we q(t) =

def

obtain (3.128).

q(t) = (t f , t)T d = G(t) − T (t f , t)T G(t f )T  G(t f ) − T c = G(t)− T (t f , t)T c = G(t)− T p(t)

Functional optimization

261

Observability Consider a linear system of equation: x(t) = F(t)x(t) for which we have linear measurements of the form

y(t) = H(t)x(t) with x 

n

, y

m

mn

, H

(3.129)

The system is observable if it is possible to assess the initial state vector x(t 0 ) from a series of measurements y(t) between t 0 and t f . We define the of observability matrix M(t 0 , t f ) by tf

M(t 0 , t f ) =  (t, t 0 )T H(t)T H(t)(t, t 0 )dt

(3.130)

t0

A condition for observability is that the matrix M(t 0 , t f ) is invertible.

Justification Integrate the measurement equation with the state given by: x(t) =(t, t 0 )x(t 0 ) .

y(t) = H(t)x(t) = H(t)(t, t 0 )x(t 0 ) 

tf

 (t, t ) 0

T

H(t) T y(t)dt = M(t 0 , t f )x(t 0 )

t0

If M(t 0 , t f ) is invertible, we can express x(t 0 ) in terms of the integral. It is shown that this condition is also necessary. An equivalent observability condition is that the symmetric matrix M(t 0 , t f ) is positive definite.

Controllability A controlled linear system has an equation of the form

x(t) = F(t)x(t) + G(t)u(t)

(3.131)

where u(t) is the control vector. The general solution of this system is expressed with the transition matrix (t,t 0 ) associated with the uncontrolled system: x(t) = F(t)x(t) . tf

x(t f ) = (t f , t 0 )x(t 0 ) +  (t f , t)G(t)u(t)dt t0

(3.132)

262

Optimization techniques

Demonstration Let us start with the equation of state: x(t) = F(t)x(t) + G(t)u(t) . Pre-multiplying by (t f ,t) : (t f ,t)x(t) = (t f ,t)F(t)x(t) + (t f ,t)G(t)x(t)

d (t f , t) = −(t f , t)F(t) , we get dt d (t f , t)x(t) = − (t f , t)x(t) + (t f , t)G(t)x(t) dt d This equation can be written as: (t f , t)x(t) = (t f , t)G(t)x(t) . dt and with

tf

By integrating from t 0 to t f : (t f , t)x(t)t =  (t f , t)G(t)x(t)dt tf

0

t0

tf

and with (t f ,t f ) = I , we get: x(t f ) = (t f , t 0 )x(t 0 ) +  (t f , t)G(t)x(t)dt . t0

Equation (3.132) is interpreted as the superposition of the contributions of the initial state x(t 0 ) and the control u(t) . The initial state generates the term (t f , t 0 )x(t 0 ) as for an uncontrolled system. The control u(t) applied at t for a duration dt generates a state change dx(t) given by: x(t) = F(t)x(t) + G(t)u(t) → dx(t) = G(t)u(t)dt . This variation dx(t) itself generates a final change: dx(t f ) = (t f , t)dx(t) . The final state is obtained by summing all these contributions from t 0 to t f , which leads to the integral term in (3.132). The controllable system is if any final state x(t f ) is accessible from any initial state x(t 0 ) . We define the controllability matrix C(t 0 , t f ) by tf

C(t 0 , t f ) =  (t f , t)G(t)G(t) T (t f , t) T dt

(3.133)

t0

A necessary and sufficient condition for controllability is that the matrix C(t 0 , t f ) is invertible.

Functional optimization

263

Demonstration The general solution of the equation of state is given by (3.132). tf

x(t f ) = (t f , t 0 )x(t 0 ) +  (t f , t)G(t)u(t)dt t0

T T Consider the control defined by: u(t) = G(t) (t f , t) c with c 

n

.

This control yields the final state: x(t f ) = (t f , t 0 )x(t 0 ) + C(t 0 , t f )c : • if C(t 0 , t f ) is invertible, we can go from x(t 0 ) to x(t f ) by taking

c = C(t 0 ,t f )−1  x(t f ) − (t f ,t 0 )x(t 0 ) ;

if C(t 0 , t f ) is not invertible, there exists a non-zero c 



n

such that

T

c C(t 0 , t f )c = 0 . We then have tf

tf

2

c C(t 0 , t f )c =  c (t f , t)G(t)G(t) (t f , t) cdt =  cT (t f , t)G(t) dt = 0 T

T

T

t0

T

t0

The positive term under the integral must be constantly zero.

cT (t f , t)G(t) = 0 , t

Let us then consider any control u(t) . Using the general solution (3.132) tf

x(t f ) − (t f , t 0 )x(t 0 ) =  (t f , t)G(t)u(t)dt t0

T and pre-multiplying by c , we obtain tf

c  x(t f ) − (t f , t 0 )x(t 0 ) =  cT(t f , t)G(t)u(t)dt = 0 T

t0

T

because the term c (t f , t)G(t) is zero.

This relation, which is true for any control u(t) , shows that the final state cannot be arbitrary, because the vector x(t f ) − (t f , t 0 )x(t 0 ) belongs to the space orthogonal to the vector c. Not all possible final states can be reached.

264

Optimization techniques

3.5.4 Two-point boundary value problem We have seen that the adjoint state in (3.127) is calculated by backward integration from the final condition, while the state is calculated by forward integration from the initial condition. This two-point boundary value problem occurs in optimal control (chapter 4). We study here a solution method for a linear problem with two endpoint conditions of the form

Ax(t 0 ) = a (3.134) x(t) = F(t)x(t) + g(t) with  Bx(t f ) = b The state vector x(t) is of dimension n. The initial and final conditions are defined by linear systems. The vector a  m defines m initial conditions with the matrix A  mn . The vector b  n −m defines n−m final conditions with the matrix B  (n−m)n . The objective is to find the initial state vector x(t 0 ) that allows both the m initial conditions and the n−m final conditions to be met. The transport (or sweep) method solves the problem in the following three stages: •

four matrices C1 (t),C2 (t),C3 (t),C4 (t) are defined from A, B, F(t) : −1

 C (t) C2 (t)  A A = 1    F(t)   def  B  B  C3 (t) C4 (t)  •

the matrix S(t) 

m(n −m)

and the vector s(t) 

(3.135) m

are calculated by

integrating the following differential system from t 0 to t f :  S = −SC3S − SC4 + C1S + C 2   s = (C1 − SC3 )s + (A − SB)g



S(t 0 ) = 0 with  s(t 0 ) = a

(3.136)

the state x(t) is obtained by backward integration of the state equation: x(t) = F(t)x(t) + g(t) starting from the final state x(t f ) defined by −1

 A   S(t )b + s(t f )  x(t f ) =    f  B b 

(3.137)

Functional optimization

265

Justification The principle of this method is to "transport" the initial condition Ax(t 0 ) = a to the final time. To do this, the state vector x(t) vectors y(t)

m

and z(t) 

n −m

n

is partitioned into two sub-

.

 y(t) = Ax(t) These vectors are defined by:  with the matrices A and B of (3.134). z(t) = Bx(t)  y(t 0 ) = a The initial and final conditions are:  . z(t f ) = b −1

 y A  A  y Let us express x as a function of y and z:   =   x  x =     z  B B z  and replace in the state equation.

−1

 y A A  y  A x = Fx + g    =   F     +   g  z  B  B  z  B Using the matrices C1 ,C2 ,C3 ,C4 defined in (3.135), this differential system is

 y = C1y + C2 z + Ag .  z = C3 y + C4 z + Bg

written as: 

Let us introduce a matrix S(t)  such that: y(t) = S(t)z(t) + s(t) .

m(n −m)

and a vector s(t) 

m

functions of time

The existence of S(t) and s(t) is ensured for example with: S(t) = 0 , s(t) = y(t). Let us replace y = Sz + s in the differential system

 y = C1y + C2 z + Ag Sz + Sz + s = C1Sz + C1s + C2z + Ag y =Sz +s ⎯⎯⎯ →    z = C3 y + C4 z + Bg  z = C3Sz + C3s + C4z + Bg then substitute z in the first equation (S + SC3S + SC4 − C1S − C2 )z + s + (SC3 − C1 )s + (SB − A)g = 0 Now assume that S(t) is chosen to cancel the z-term. The remaining term is then also zero. This leads to the following conditions on S(t) and s(t) . S = −SC3S − SC4 + C1S + C2 which gives the differential system (3.136).  s = (C1 − SC3 )s + (A − SB)g

266

Optimization techniques

S(t 0 ) = 0 . s(t 0 ) = a

To satisfy the initial condition: y(t 0 ) = a , we also impose: 

Integrating the system from t 0 to t f , we obtain S(t f ) and s(t f ) , from which we deduce: y(t f ) = S(t f )z(t f ) + s(t f ) . Since the final value of z is known: z(t f ) = b , we obtain the full final state vector

x(t f ) , which allows us to return to the initial state x(t 0 ) by backward integration

of the state equation.

Example 3-17 illustrates the solution of a two-point boundary value problem using the transport method.

Example 3-17: Double integrator with conditions at both ends Consider the double integrator problem in dimension 1.  x1 (t 0 ) = a  x1 = x 2 with    x 2 (t f ) = b x 2 = u The initial condition is on the position x1 , the final condition on the velocity x 2 . The matrices associated with this problem are

 C C2   0 1  0 1  0  A = (1 0 ) F= →  1 =  , g=  ,   0 0  u  B = ( 0 1)  C3 C4   0 0 

S = 1 S(t 0 ) = 0 with  The differential system in S(t) and s(t) is written as:  s(t 0 ) = a s = −Su t

The solution is given by: S(t) = t − t 0 and s(t) = a −  ( − t 0 )u( )d . t0

We then have the final state vector tf    A   Sf b + sf   a + b(t f − t 0 ) −  ( − t 0 )u()d  x(t f ) =    =  t0 B b    b   −1

which is integrated backwards to obtain the complete solution from t 0 to t f .

Functional optimization

267

3.6 Conclusion 3.6.1 The key points •

The extremals of a calculus of variations problem are the solutions of the Euler-Lagrange equation. These extremals may or may not be minima;



the sufficient conditions for optimality are based on the absence of conjugate points, determined by solving the Jacobi equation;



the final constraints (free endpoint or endpoint constrained on a curve) lead to transversality conditions;



the extremals are solutions of the canonical system formed from the Hamiltonian of the functional to be minimized;



the value function (= value of the functional at any point) is a solution of the Hamilton-Jacobi-Bellman partial differential equation.

3.6.2 To go further •

Calculus of variations and optimal control theory (D. Liberzon, Princeton University Press 2012) This book presents the calculus of variations in chapters 1 to 3. The concepts are introduced progressively in a rigorous manner, while avoiding too heavy formalism. Chapter 3 makes the transition between the calculus of variations and optimal control. This book is highly educational and is to be recommended as an introduction to these subjects.



Calculus of variations (I.M. Gelfand, S.V. Fomin, Dover 1963) This book is entirely devoted to the calculus of variations. The different conditions of optimality (order 1 and 2, weak or strong minimum,) are demonstrated in chapters 1 to 6. Chapter 7 presents the generalization to more complex problems formulated by multiple integrals.



Calculus of variations with applications (G.M. Ewing, Dover 1985) Like the previous one, this book is entirely devoted to the calculus of variations, with a more formal presentation. The optimality conditions are proved with additions on parametric problems.



Geometric optimal control (H. Schättler, U. Ledzewicz, Springer 2012) This comprehensive book includes a first chapter on the calculus of variations.

268



Optimization techniques

The variational principles of mechanics (C. Lanczos-Urruty, Dover 1949)

This book presents the Hamiltonian approach to mechanics. The theory of calculus of variations is recalled in chapter 3, and then applied to derive the canonical equations and the Hamilton-Jacobi-Bellman equation.

Optimal control

269

4. Optimal control An optimal control problem consists in finding the control law of a dynamic system in order to achieve a trajectory at the best cost. This formulation generalizes the calculus of variations formulation presented in chapter 3 and allows a wide variety of problems in engineering or economics to be addressed. Section 1 presents the formulation of a control problem and the conditions for optimality. The Pontryaguin minimum principle (historically called the maximum principle by a choice of opposite sign) states that the optimal control is a global minimum of the Hamiltonian of the problem. Its determination requires the introduction of an adjoint state and the solution of a two-point boundary value problem. The variational approach establishes only the weak version (local minimum of the Hamiltonian), but it interest is to generalize easily to problems with constraints. Section 2 introduces the consideration of constraints. The terminal constraints induce so-called transversality conditions on the adjoint and the Hamiltonian. The interior constraints apply at an intermediate time and allow to account for discontinuities of dynamics or state of the system. They induce jump conditions on the adjoint and the Hamiltonian. The current and state constraints must be respected on the whole trajectory. The inequality constraints can induce junction conditions with control discontinuities. Section 3 studies the extremals which are the trajectories satisfying the first-order optimality conditions. For the same problem, there may exist normal or abnormal (cost-independent), regular or singular (not determined by the first-order conditions) extremals. Linearization in the vicinity of a nominal solution allows the construction of a state feedback control, useful for real-time applications. The value function that gives the optimal cost from any initial condition is a solution of the Hamilton-Jacobi-Bellman equation. Section 4 presents the second-order optimality conditions. These conditions are established from the second variation of the augmented cost and lead to a local linear quadratic problem that is solved by the transport method. The sufficient minimum conditions are based on the absence of a conjugate point. Singular arcs may exist in the frequent case of a linear control. Higher order conditions are needed to establish the optimality of these arcs and their possible junctions to regular arcs.

270

Optimization techniques

4.1 Optimality conditions 4.1.1 Control problem The standard formulation of a control problem is as follows. tf

min J(u) =  L  x(t), u(t), t  dt +   x(t f ), t f  u,t f

t0

(4.1)

 x(t) = f  x(t), u(t), t  with   x(t 0 ) = x 0

The state x(t) of dimension n follows the state equation: x(t) = f  x(t),u(t),t  . The initial conditions (x 0 ,t 0 ) are fixed, the final conditions (x f ,t f ) are free. The control u(t) of dimension m is any function of time.

The trajectory x(t) , t 0  t  t f  associated with the control u(t) , t 0  t  t f  is obtained by integrating the equation of state from the initial state x 0 . When there is no ambiguity, we write the problem (4.1) in a more compact form by omitting the time variable. tf  x = f (x, u, t) min J(u) =  L(x, u, t)dt + (x f , t f ) with  u,t f  x(t 0 ) = x 0 t0

To simplify the formulas, the partial derivatives will be noted f x =

(4.2)

f f , fu = . x u

We are looking for the control law minimizing the functional J which is composed of an integral cost term:

tf

 L(x, u, t)dt

t0

and a final cost term: (x f , t f ) .

The problem is stated in the form: - of Lagrange if the cost is purely integral ( = 0) ; - of Mayer if the cost is purely final (L = 0) ; - of Bolza in the general case. These three forms are equivalent. The transition from one to the other is made by the following transformations.

Optimal control

271

Transition from Mayer to Lagrange form Assume that the cost is purely final J(u) = (x f , t f )

(4.3)

with x = f (x,u, t) , x(t 0 ) = x 0

and define the function L(x,u, t) by

L(x,u, t) =

def

  (x, t)T f (x,u, t) + (x, t) x t

(4.4)

The final cost can then be expressed as

(x f , t f ) = (x 0 , t 0 ) +

tf

d

 dt (x, t)dt

t0 tf

    = (x 0 , t 0 ) +   (x, t) T x + (x, t)  dt  x  t  t0 

(4.5)

tf

= (x 0 , t 0 ) +  L(x, u, t)dt t0

tf

The integral cost

 L(x, u, t)dt

equates the final cost (4.3) to within one constant.

t0

Transition from Lagrange to Mayer form Assume that the cost is purely integral

J(u) =

tf

 L(x, u, t)dt

(4.6)

with x = f (x, u, t) , x(t 0 ) = x 0

t0

and define the additional state variable  by (4.7)

 = L(x,u, t) with (t 0 ) = 0

 x   f (x, u, t)       L(x, u, t) 

x 

The new state y =   of dimension n+1 has the equation: y =   =  def The integral cost can then be expressed as tf

tf

t0

t0

d

 L(x,u, t)dt =  dt dt = (t ) − (t ) = (t ) f

0

f

The final cost defined by (yf ,t f ) = (t f ) equates the integral cost (4.6).

(4.8)

272

Optimization techniques

Constraints Problem (4.2) has fixed initial conditions and free final conditions. The formulation can be extended to different types of constraints: • •

fixed or free initial time and state, fixed or free final time and state constraints on the initial state: 0  x(t 0 ), t 0  = 0 ;



constraints on the final state:



point constraints on the state:

1  x(t1 ),t1  = 0 at t1 [t 0 ;t f ] ;



discontinuities in dynamics:

x = f1 (x,u, t) if t  t1 ;  x = f 2 (x,u, t) if t  t1

• • •

discontinuities in state: path equality constraints: path inequality constraints:

f  x(t f ),t f  = 0 ;

x(t1+ ) = x(t1− ) + x1 at t1 [t 0 ;t f ] ;

c (x,u, t) = 0 , t ; c (x,u, t)  0 , t .

The optimality conditions in the presence of these different types of constraints will be presented in section 4.2.

4.1.2 Principle of the minimum Consider a standard control problem with a fixed final time. tf x = f (x,u, t) min J(u) =  L(x,u, t)dt + (x f ) with  u x(t 0 ) = x 0 t0

(4.9)

The state x(t) is of dimension n, the control u(t) is of dimension m. The final cost (xf ) depends only on the state x f , as the final time t f is fixed. We define the adjoint state p(t) , also called costate, and the Hamiltonian H(x, u, p, t) by the following equations. H(x, u, p, t) = p 0L(x, u, t) + p Tf (x, u, t)   H d with p(t f ) = p 0 (x f ) p = − x dx 

(4.10)

The adjoint p(t) has the same dimension as the state x(t) and it is calculated by backward integration from its final value p(t f ) . The real p0 is called the abnormal multiplier. The Hamiltonian is a function of

n +m+n +1

in

.

We then have the following necessary conditions of optimality.

Optimal control

273

Theorem 4-1: Pontryaguin minimum principle (PMP) Let u*(t) be a solution of problem (4.9) and x*(t) the associated trajectory. Then there exist p0  0 and p*(t) , non-simultaneously zero, satisfying the equations (4.10) and such that the control u*(t) minimizes the Hamiltonian at each time.

min H(x*,u,p*,t) → u*(t)

(4.11)

u

The proof of the existence of (p0 ; p*)  (0 ; 0) is difficult. We limit ourselves here to verifying the minimum property of the Hamiltonian when p0  0 .

Verification of the minimization condition (see [R14]) Consider a control law u*(t) from t0 to tf. The associated trajectory x*(t) is obtained by integration of the state equation: x* = f (x*, u*, t) . Let us apply a control perturbation defined as follows.

u*(t) if t 0  t  t1 −   u(t) =  v if t1 −   t  t1 u*(t) if t  t  t 1 f  The time t1 ]t 0 ;t f ] is arbitrary. The value   0 is assumed to be small and the constant v is arbitrary. Figure 4-1: Needle variation. This perturbation, called needle variation is shown in figure 4-1. It only changes the control u* on [t1 −  ; t1 ] . The interval is assumed to be small, but the perturbation v on this interval can be arbitrarily large. The needle variation on [t1 −  ; t1 ] changes the trajectory from t1 −  . The perturbed trajectory is of the form if t 0  t  t1 −  x*(t) x(t) =  x*(t) + x if t1 −   t  t f

274

Optimization techniques

The proof of (4.11) proceeds in four stages: calculation of the state change at t1, propagation to tf, resulting final cost and transition to an integral cost. First stage: variation of the state at time t1 We calculate the variation x(t1 ) resulting from the variation of u on [t1 −  ; t1 ]. The state at t1 −  is nominal: x(t1 − ) = x*(t1 − ) .

This nominal state at t1 is obtained with the nominal control u* on [t1 −  ; t1 ] .

x* = f (x*,u*, t) on [t1 −  ; t1 ]  x*(t1 ) = x*(t1 − ) +

t1

 f (x*,u*, t)dt

t1 −

The perturbed state at t1 is obtained with the perturbed control v on [t1 −  ; t1 ] .

x = f (x , v, t)

on [t1 −  ; t1 ]  x(t1 ) = x*(t1 − ) +

t1

 f (x* + x , v, t)dt

t1 −

By difference, and for  small, we have at the first order

x(t1 ) = x(t1 ) − x*(t1 ) =  f (x * +x , v, t) − f (x*,u*, t)  t1 + o()

As the interval [t1 −  ; t1 ] is small, so is the perturbation x(t1 ) . T We expand to order 1 in x : f (x* + x , v, t) = f (x*, v, t) + f x x + o(x)

and replace in x(t1 ) : x(t1 ) =  f (x*, v, t) − f (x*,u*, t)t ( x is of order 2). 1

Second stage: propagation of the state perturbation to the final time tf The control on [t1 ;t f ] is identical to the nominal control u*.

Let us write the propagation equation of the deviation x = x − x* on [t1 ;t f ] .

 x = f (x ,u*, t) = f (x* + x ,u*, t) = f (x*,u*, t) + f xT x + o(x) → x = f xT x   x * = f (x*,u*, t) T The solution of the equation x = f x x is expressed with its transition matrix  (section 3.5.3).

 (t , t ) = − (t f , t1 )f xT x(t f ) = (t f ,t)x(t1) with  f 1 as established in (3.117)  (t f , t f ) = I Replacing x(t1 ) (found at stage 1), we have

x(t f ) = (t f , t1 )x(t1 ) = (t f , t1 ) f (x*, v, t) − f (x*,u*, t) t

1

Optimal control

275

Third stage: variation of the final cost Assume the control problem in Mayer form: J(u) = (x f ) .

A variation x f produces at order 1 a cost variation J : J = x (x f *)x f . By replacing x(t f ) (found at stage 2), we have

J = x (xf *)(t f , t1 ) f (x*, v, t) − f (x*,u*, t)t

1

Let us define the adjoint p(t) and the Hamiltonian H(x,u,p, t) by

p(t) = p0(t f , t)T x (x f ) with p0  0  T H(x,u,p, t) = p f (x,u, t) p = −f x p because (t f , t) = −(t f , t)f xT The adjoint satisfies:  , p(t f ) = p 0x (x f ) because (t f , t f ) = I

or by using H:

p = −H x .  p(t f ) = p0x (x f )

This definition is the one in (4.10) in the case of a purely final cost (L = 0) . Let p* be the adjoint associated with (u*, x*) and let J be expressed in terms of p and H.

J =

  p*(t1 )T f (x*, v, t) − f (x*,u*, t) t = H(x*, v,p*, t) − H(x*,u*,p*, t)t 1 1 p0 p0

A necessary condition for optimality of u* is: J  0 , t1 ,   0 , v .

The control u* thus achieves a minimum of H(x*,u,p*, t) (since  0, p0  0 ). Fourth stage: extension to an integral cost Let us now consider the case of a problem in Bolza form. tf

J(u) =  L(x,u, t)dt + (x f ) . t0

We return to the Mayer form by adding a state variable  as in (4.7).

 = L(x,u, t) , the augmented state vector is (t 0 ) = 0

With this variable defined by: 

x f  y=  → y=    L The final cost is expressed as: J = f + (x f ) = (yf ) . def

276

Optimization techniques

The augmented adjoint q associated with the augmented state y and the final cost (yf ) is defined as in stage 3.    x = x   pf  p  p   −f x p q=  → q= =  with q(t f ) =   = p0         −L  = 0   f    = 1  We observe that the additional adjoint component noted  is constant.

 = 0  (t) = (t f ) = p0

T

p f  T The Hamiltonian of this problem is: H =     = p0 L + p f .    L

This definition corresponds to the one given in (4.10) in the case of a Bolza problem. The adjoint p still satisfies the equations (4.10) as in stage 3. The result obtained in stage 3 thus extends to the case of an integral and final cost T with the Hamiltonian defined by: H = p0 L + p f . The statement of theorem 4-1 calls for some remarks. Note 1: strong/weak minimum principle The above demonstration considers arbitrarily large control perturbations on a small duration. It shows that the optimal control u* achieves a global minimum of the Hamiltonian at each time. For this reason, the minimum principle is called strong. The variational approach (section 4.1.3) will consider small control perturbations over the whole trajectory. This approach will show that the optimal control u* only achieves a local minimum of the Hamiltonian at each time. This result will constitute the weak minimum principle. Note 2: abnormal multiplier The multiplier p0 allows solutions with p0 = 0 to be taken into account. These so-called abnormal extremals are presented in section 4.3.2. In the normal case (p0  0) , the value of p0 can be freely chosen (it is usually set to 1). Note 3: sign convention Theorem 4-1 is stated assuming a positive abnormal multiplier: p0  0 , which leads to a minimum of the Hamiltonian (in stage 3 of the proof). The opposite choice p0  0 would lead to a maximum of the Hamiltonian.

Optimal control

277

The original theorem (1962) adopts the convention p0  0 and is therefore called

"Pontryaguin maximum principle". This name remains in use even when p0  0 . The use of the acronym PMP hides this wording ambiguity. The less natural convention p0  0 comes from the Weierstrass condition established in calculus of variations (section 3.2.4), as explained below.

Link with the calculus of variations b

Consider a problem of calculus of variations: min J(y) =  L(x,y,z = y)dx . y

a

p = L z (equation E) H = Lz y − L

The canonical variables (3.55) are defined by: 

The Euler-Lagrange necessary condition is: L y = Lz  p = L y . The Weierstrass strong minimum condition is: max H(x,y,w,p) → y . w

Equivalent control problem (with the convention p0 = −1)

x → t  By renaming the variables:  y(x) → x(t) and with the state equation: x = u ,  y(x) → x(t)  an equivalent control problem is formulated with a control u 

.

b

min J(u) =  L(t,x,u)dx with x = u u

a

H = −L + pT u The PMP with p0 = −1 yields:  p = L x and max H  Hu = −Lu + p = 0  p = Lu u

Replacing p = Lu , we have:

H = − L + L u u (with u of dimension 1).  L u = L x

We retrieve the canonical variables (equation E) and the Euler-Lagrange equation with u → y . The Weierstrass condition is thus equivalent to the PMP with the convention p0 = −1, which leads to the maximization of the Hamiltonian.

278

Optimization techniques

Example 4-1 illustrates the stages involved in solving a control problem using the PMP.

Example 4-1: Ballistic range Consider the trajectory of a ballistic missile with a flat Earth and a constant gravity model. The trajectory in the (Oxz) plane is shown in figure 4-2. Modelling The assumptions on propulsion and control are as follows: • the missile takes off at t 0 = 0 and stops propelling at the fixed time t f ; • the thrust acceleration is constant with modulus a; • the thrust direction is defined by the pitch angle  (angle with the horizontal); • the evolution law (t) is free and represents the control of the missile. The components of position, velocity and acceleration are given below. Position: Velocity: Gravity: Acceleration:

x r =  z   vx  v=   vz   0 g=   −g 

 cos   a = a   sin   Figure 4-2: Ballistic missile trajectory.

x = vx z = v  z  . v = a cos   x  v z = a sin  − g The range R depends on the conditions at the time of injection t f . v R = x f + xf  vzf + vzf2 + 2gzf   g 

x    z  evolves according to: The position-velocity state:  vx     vz 

Optimal control

279

Control problem The control problem is in Mayer form (purely final cost). x 0 = 0 x = vx  z = v  z 0 = 0 z min (x f , z f , v xf , v zf ) = −R(x f , z f , v xf , v zf ) with  and    v x = a cos  vx 0 = 0  v z = a sin  − g  v z0 = 0 Application of the PMP The Hamiltonian is: H = px vx + pz vz + pvx a cos  + pvz (asin  − g) with the adjoint (px ,pz ,pvx ,pvz )

pvz (equation 1)  pvx To determine (t) , we solve the adjoint equations with their final conditions. → p x (t) = A p x = −H x = 0 p = −H = 0 → p z (t) = B z  z Adjoint equations:  → p vx (t) = C + A(t f − t) p vx = −H vx = − p x p vz = −H vz = − p z → p vz (t) = D + B(t f − t)  R  → A = −1 p x (t f ) = x = x f  R v xf  → B = − p z (t f ) = z = z 2 v zf + 2gz f f  Final conditions:  v + v zf2 + 2gz f p vx (t f ) = vx = R → C = − zf  v xf g    R v xf  v zf   p (t ) =  = → D = − 1 +  vz f vz 2    v g v + 2gz zf  zf f   Observing that: D = −BC and with A = −1 , equation 1 yields p (t) D + B(t f − t) C − (t f − t) v xf tan (t) = vz = = −B = −B = (equation 2) 2 p vx (t) C + A(t f − t) C − (t f − t) vzf + 2gzf The application of the PMP gives: min H →

tan  =

The maximum range is therefore obtained with a constant direction of thrust. It can be noted that this result obtained with a flat Earth and constant acceleration remains true if the acceleration varies according to a predetermined law a(t) .

280

Optimization techniques

Optimum thrust angle To find the value of  , we integrate the trajectory (with a and  constant).

 x f = (a cos ) t f2 / 2 x = vx  z = v 2  z f = (a sin  − g) t f / 2 z →    v x = a cos   v xf = (a cos ) t f  v z = a sin  − g   v zf = (a sin  − g) t f Replacing zf ,vxf ,vzf into equation 2, we obtain tan  (a sin  − g)2 + g(a sin  − g) = a cos  , a (equation 3) g The variable n is the acceleration of the missile expressed in g.

which can be written as: sin 3  − 2n sin 2  + n = 0 with n =

Search for solutions We search the solutions of equation 3 as a function of the acceleration level n. The angle  is between 0 deg (vertical) and 90 deg (horizontal). 3 2 Figure 4-3 shows the function f () = sin − 2n sin  + n plotted for four different values of n.

Figure 4-3: Solution as a function of acceleration level.

Optimal control

281

We observe that the equation does not have a solution if n  1 . Indeed, take-off is impossible with a thrust that is less than the weight (a  g) . When n  1 , the equation has a unique solution with a thrust angle comprised between 45 and 90 deg. If n = 1 , the optimum angle is 90 deg. It is indeed necessary to thrust vertically to take off (a = g) . If n →  , the optimum angle is 45 deg. This corresponds to an instantaneous velocity impulse. We retrieve a known result: the launch direction maximizing the range from the ground is indeed 45 deg.

4.1.3 Variational method The variational method consists in expressing the variation of the cost J as a function of small variations u applied along the trajectory. This approach based on an augmented cost leads to a weaker result than the PMP, but it has the advantage of being easily generalized when the control problem is subject to various constraints. Augmented cost Consider a control problem with free initial and final conditions. tf

min J =  L(x, u, t)dt + (x 0 , t 0 , x f , t f ) with x = f (x, u, t)

u,x 0 ,t 0 ,x f ,t f

(4.12)

t0

The state x(t) depends on the control u(t) by the state equation: x = f (x,u, t) . Control variations u(t) produce state variations x(t) which must be taken into account in the calculation of J . The Lagrange method is used: - the equation x = f (x,u, t) represents a constraint applied at each time t; - the constraint with multipliers p(t) called adjoints is added to the cost J. The augmented cost J a is thus defined by tf

J a = J +  pT f (x,u, t) − x  dt

(4.13)

t0

By introducing the Hamiltonian defined by

H(x,u,p, t) = L(x,u, t) + pTf (x,u, t)

(4.14)

282

Optimization techniques

the augmented cost is expressed as tf

J a =   H(x,u,p, t) − pT x  dt + (x 0 , t 0 , x f , t f )

(4.15)

t0

T The integration by parts of the term p x leads to tf

tf

J a =   H(x,u,p, t) + pT x  dt − p T x  + (x 0 , t 0 , x f , t f ) t0

(4.16)

t0

First variation Let us apply variations on the control u(t) , on the state x(t) , on the initial time

t 0 and on the final time t f . By expanding formula (4.16) to the first order (small

variations), we obtain the following first variation of the augmented cost.

J a =

tf

tf

 H udt +  (H T u

t0

x

+ p) T xdt

t0

T

+ x 0 + p(t 0 )  x 0 + t 0 − H(t 0 )  t 0

(4.17)

T

+ x f − p(t f )  x f +  t f + H(t f )  t f

Demonstration Let us apply variations u(t), x(t), t 0 , t f to the augmented cost (4.16). tf

J a =   H(x,u,p, t) + pT x  dt + p(t 0 )T x(t 0 ) − p(t f ) T x(t f ) + (x 0 , t 0 , x f , t f ) t0

By expanding each term to order 1, we have

J a =

tf

 (H x + H u + p x)dt T x

T u

T

→ variation in theintegral

t0

+  H + p T x  (t f )t f −  H + p T x  (t 0 )t 0 + p(t 0 )T x(t 0 ) + p(t 0 ) T x(t 0 )

→ variation of p(t 0 ) T x(t 0 )

− p(t f )T x(t f ) − p(t f )T x(t f )

→ variation of p(t f ) T x(t f )

+ Tx 0 x(t 0 ) + t 0 t 0 + Tx f x(t f ) + t f t f

→ variation of (x 0 ,t 0 ,x f ,t f )

→ variation of bounds

Optimal control

283

p(t 0 ) = p(t 0 )t 0 . p(t f ) = p(t f )t f

The variations of the adjoint at t 0 and t f are expressed as:  The terms in p(t 0 ) and p(t f ) are eliminated and we obtain

J a =

tf

tf

T

T  H udt +  (H x + p) xdt + x0 + p(t 0 )  x 0 + t0 − H(t 0 )  t 0 T u

t0

t0

T

+ xf − p(t f )  x f + t f + H(t f )  t f

In formula (4.17), the variations of the state x(t) and of the control u(t) are not independent. They are indeed linked by the linearized state equation

x = f (x,u,t)  x = f x x + f uu

(4.18)

The explicit expression of x(t) as a function of u(t) is not known. To get rid of this dependence, we choose the adjoint in order to cancel the integral in x in formula (4.17). We thus find the adjoint equations (4.10). (4.19)

p = −H x

With this choice, the first variation (4.17) no longer depends on x(t) . It depends only on u(t), x 0 , t 0 , x f , t f .

J a =

tf

 H udt + 

t0

T u

T

x0

+ p(t 0 )  x 0 + t 0 − H(t 0 )  t 0

(4.20)

T

+ xf − p(t f )  x f + t f + H(t f )  t f This formula makes it possible to express the necessary conditions for optimality and to calculate the sensitivities of the cost functional. Necessary conditions for optimality A necessary condition of first order for optimality is

Ja = 0 , u, x0 , t 0 , x f , t f Since the variations u(t), x 0 , t 0 , x f , t f are independent, their coefficients must be zero in (4.20).

284

Optimization techniques

The condition ( Ja = 0 , u ) requires (4.21)

Hu = 0 , t The optimal control is a stationary point of the Hamiltonian at each time.

If the initial conditions are free, the condition ( Ja  0 , x 0 , t 0 ) requires

p(t 0 ) = − x0  H(t 0 ) = t 0

→ for δx 0 → for δt 0

(4.22)

If the final conditions are free, the condition ( Ja  0 , x f , t f ) requires

 p(t f ) = x f → for δx f (4.23)   H(t f ) = − t f → for δt f These relations at the initial or final point are called transversality conditions. Each transversality condition provides a number of equations equal to the number of unknowns: n equations for x0/f , 1 equation for t 0/f . These conditions lead to a two-point boundary value problem discussed in section 4.1.4. Influence functions Assume that the problem is in Lagrangian form ( = 0) . We can always reduce to this formulation by the transformation (4.4). On the optimal trajectory: Hu = 0 , Ja = J * and the formula (4.20) reduces to

J * = p(t 0 )T x 0 − H(t 0 )t 0 − p(t f )T x f + H(t f )t f

(4.24)

This formula shows the partial derivatives of the optimal cost J* with respect to the initial and final conditions. These derivatives are called influence functions.

 J *  x = p(t 0 )  0   J * = − H(t ) 0  t 0

 J * = − p(t f )   x f and   J * = H(t ) f  t f

(4.25)

If the initial/final conditions are free (hence cost-optimal), the corresponding derivatives of J* are zero. This is consistent with the optimality conditions (4.22) and (4.23) in the case of a Lagrangian form ( = 0) . When the initial/final conditions are fixed, the formulas (4.25) allow us to know the effect of initial or final perturbations on the optimal cost.

Optimal control

285

Let us assume that the optimal trajectory from (x 0 ;t 0 ) to (x f ;t f ) is known and

place ourselves at any point (x;t) on this trajectory. According to Bellman principle of optimality (developed in section 4.3.6), the part of the trajectory from (x;t) to (x f ;t f ) is optimal and we can apply the formulas (4.25) to it. In particular, at each point of the optimal trajectory we have:

J * = p(t) x(t)

(4.26)

Change of state vector Assume that we make a change of state vector: y = g(x) . Let p and q be the adjoints associated with x and y respectively. According to (4.26), we have: g n   g1  J *  dy  J *  x1 x1  p = x =  dx  y   dy dg    (4.27)  with = = gx =   noted dx dx  J *   q = g n   g1  y  x x n   n where g x is the gradient matrix (transpose of the Jacobian) of y = g(x) . We deduce thus the adjoint change formula associated with the change of state. (4.28)

y = g(x)  q = g −x1p

Example 4-2: Switching from polar to Cartesian coordinates

x  y

 r   r cos   .     r sin  

The polar-Cartesian transformation is defined as:   = g   =   cos  The gradient matrix G of the transformation is: G =   −r sin  The adjoints are transformed as follows.

p  px  1  r cos  − sin    p r  −1  r   =G  =     p  r  r sin  cos    p   py 

sin   . r cos  

1  p x = p r cos  − r p sin  →  p = p sin  + 1 p cos  r   y r

286

Optimization techniques

Weak minimum principle Let us expand formula (4.20) to order 2 with respect to u in order to express the second variation of the augmented cost. T

2 J a =

t 1 f  x   H xx H ux   x     dt    2 t0  u   H xu H uu   u 

(4.29)

The state variations x(t) follow the linearized state equation: x = f x x + f u u. 2 A necessary condition of order 2 for optimality is:  J a  0 , u . We will see in section 4.4.2 that this requires

(4.30)

Huu  0 , t

This condition associated with (4.21) shows that the optimal control u* achieves a local minimum of the Hamiltonian at each time. This result is weaker than the PMP (global minimum) and constitutes the weak minimum principle. The variational approach is applied in mechanics to derive the Lagrange equations for a non-conservative system.

Application to mechanics: Lagrange equations (from [R3] and [R13]) The Lagrange equations in mechanics are established using the above variational techniques. For a conservative system, the principle of least action is used. For a non-conservative system, the principle of virtual work is used. Conservative system Consider a system defined by a state vector q (generalized coordinates). For a conservative system, the forces are derived from a potential. The potential energy noted V(q) is a function of the coordinates.

The kinetic energy noted T(q,q) is a function of the coordinates and their derivatives (or velocities). The following quantities are defined from V(q) and T(q,q) : - the Lagrangian of the system: L(q,q) = T(q,q) − V(q) ; - the Hamiltonian of the system: H(q,q) = T(q,q) + V(q) ; ("mechanical Hamiltonian" or energy) tf

- the action between t0 and tf : S =  L(q,q)dt . t0

Optimal control

287

The principle of least action postulates that the trajectory minimizes the action. tf

minS =  L(q,q)dt q

→ q(t)

t0

By posing u = q , we formulate an equivalent control problem. tf

minS =  L(q, u)dt s.t. q = u u

t0

The "control Hamiltonian" associated with this problem is denoted Hc .

Hc (q,u,p) = L(q,u) + pT u L  Hc  +p=0 min u d  L  L u  Applying the PMP results in:  .  = dt  u  q p = − Hc = − L q q  Returning to q = u , we obtain the equations:

d  L  L .  = dt  q  q

Let us now express the control Hamiltonian as a function of V and T with

p=−

L L =− u q

L T = (T − V) − u T because L(q,u) = T(q,u) − V(q) u u Since the kinetic energy is quadratic with respect to the velocity, we have Hc = L + pT u = L − u T

T T = 2T  u T = 2T q u The result is: Hc = (T − V) − 2T = − (T + V) = −H . qT

The control Hamiltonian is the opposite of the mechanical Hamiltonian which represents the energy. The sign change comes from the choice p0 = +1 (note 3 on theorem 4-1). Non-conservative system For a non-conservative system, the forces noted Q(q) do not derive from a potential and the principle of least action does not apply. qf

T The work of the forces is expressed as: W =  Q(q) dq and it depends on the path q0

followed between q0 and qf .

288

Optimization techniques

The principle of virtual works postulates that the trajectory q(t) is such that

 tf  tf    T(q,q)dt  +  Q(q)T qdt = 0 , q , q t  t 0  0

The first term is the change in kinetic energy due to changes in q and q . The second term is the work associated with the displacement q . The displacement q is arbitrary (virtual) regardless of the characteristics of the system. tf

By expanding to order 1:

 ( T q + T q + Q q ) dt = 0 and posing q = u , T q

T q

T

t0 tf

 ( T q + T u + Q q ) dt = 0

it comes down to:

T q

T u

T

s.t. q = u .

t0

Let us apply the variational method by introducing an adjoint p associated with the constraint q = u . We add the constraint with its adjoint in the integral. tf

 T q + T u + Q q + p T q

t0

T u

T

T

(u − q)  dt = 0

Then we integrate by parts. tf

 ( T

u

t0

T T + p ) u + ( Tq + Q + p ) q  dt + (pq) t 0 − (pq) t f = 0 

To cancel the term in q , the adjoint is required to satisfy: Tq + Q + p = 0 . The integral must cancel for any variation u : Tu + p = 0 . Combining these two equations with q = u , we obtain:

d  T  T =Q.  − dt  q  q

These Lagrange equations deduced from the principle of virtual work generalize those obtained for a conservative system from the principle of least action. In the case of a conservative system: Q = −Vq , we retrieve indeed

d  T  (T − V) L L T = = with L(q,q) = T(q,q) − V(q)   = dt  q  q q q q

Optimal control

289

Parameters Assume that the system depends on the control u(t) and real parameters . The hybrid control problem is formulated as tf

min J(u) =  L(x,u, t, )dt + (x f , ) with x = f (x,u, t, ) u,

(4.31)

t0

The aim here is to write optimality conditions associated with the parameters . For this reason, we do not specify whether the initial and final conditions are free or fixed. The treatment of these conditions remains the same as in (4.17). The Hamiltonian and the adjoint are defined as in (4.14) and (4.19).

H(x,u,p, t, ) = L(x,u, t, ) + p Tf (x,u, t, )  p = − H x

(4.32)

Let us apply variations of control u(t) and parameters  . The first variation of the augmented cost J a (4.16) is then given by T

 tf  J a =  H udt +   H  dt +    t  t0  0  tf

(4.33)

T u

Demonstration Let us apply variations u(t), x(t),  to the augmented cost defined by (4.16). tf

J a =   H(x,u,p, t, ) + pT x  dt + p(t 0 ) T x(t 0 ) − p(t f ) T x(t f ) + (x f , ) t0

Each term is expanded to the first order (ignoring variations in the initial and final conditions). tf

J a =  (HTx x + HTu u + HT + pTx)dt + T t0

tf

 tf



t0

t 0

 

T T T With the choice p = −Hx , there remains: J a =  Hu udt +   Hdt +    .

Formula (4.33) allows us to express necessary conditions of optimality for a control problem with parameters.

290

Optimization techniques

If the control u(t) is optimal, then Ja = 0 , u , which requires

Hu = 0 , t

(4.34)

If the parameters  are optimal, then Ja = 0 ,  , which requires tf

 H dt +  



=0

(4.35)

t0

Each parameter gives an equation (4.35), which completes equations (4.22) and (4.23) associated with the initial and final conditions (if they are free). Formula (4.33) is also of interest when the reals  represent fixed parameters of the dynamic system. The optimized trajectory for the nominal values  gives a control u* and an optimal cost J* . The optimal cost derivative with respect to these parameters is then given by t

J * f = H dt +   t0

(4.36)

where the integral is calculated on the optimal trajectory with the control u* . This formula allows to evaluate the first-order effect of model uncertainties, without re-solving the control problem with parameters  +  .

Model parameters An alternative method for proving condition (4.35) is considered here, as well as its use in dealing with a free final time problem. Additional state component An alternative method of proving (4.35) is to add a state component x n+1 associated with the parameter  . The equation of state for this component is x n+1 = 0 , x n+1 (t 0 ) =  . By replacing  by x n+1 , the problem (4.31) takes the form tf

 x1:n = f (x1:n , u, t) min J(u) =  L(x1:n +1 , u, t)dt + [x1:n (t f ), x n +1 (t 0 )] with   x n +1 = 0 t0

u,x n +1 (t 0 )

The adjoint pn +1 associated with x n+1 follows the equation: pn+1 = −Hxn+1 = −H .

Optimal control

291

The conditions of transversality on the adjoint pn +1 are: - pn+1 (t 0 ) = −xn+1 (t 0 ) = − , because x n +1 (t 0 ) is free; - pn+1 (t f ) = xn+1 (t f ) = 0 ,

because  does not depend on x n +1 (t f ) . tf

tf

t0

t0

Integrating on [t 0 ;t f ] , we get: pn +1 (t f ) = pn +1 (t 0 ) +  pn +1dt   +  Hdt = 0 . The optimality condition (4.35) on  is retrieved.

Free final time The free final time can be optimized by the following change of variable. t − t0 t − t0 = = → dt = d tf − t0  The normalized time  varies from 0 to 1. The parameter  is to be optimized. The control problem is then with fixed final time f = 1 and it is formulated as f

min J =  L(x,u, t 0 + ) d + (x f , t 0 + f ) with u,

0

dx =  f (x,u, t 0 + ) d

T The Hamiltonian is: H(x,u,p, t, ) = L(x,u, t 0 + ) + p  f (x,u, t 0 + ) .

The optimality condition (4.35) on the parameter  is:

f

H



  d +  = 0 .

0

Let us calculate the partial derivatives of the Hamiltonian and the final cost:

dH H = shown below (4.44): dt t H L f H dH d = L + pT f +  + pT = H +  = H + (t − t 0 ) = (t − t 0 )H  ,  t t t dt dt f tf H H dt 1 t −t t d =  = (t − t 0 )Htf = f 0 H(t f ) = H(t f ) ; which yields:  0      0 t0 •

derivative of the Hamiltonian using

• derivative of final cost:   = (t f ) because  = t f − t 0 .  t

 (t f ) = 0. t We retrieve the transversality condition (4.23) associated with the free final time. With these derivatives, the optimality condition on  gives: H(t f ) +

292

Optimization techniques

4.1.4 Two-point boundary value problem Consider a free final time control problem. tf  x = f (x, u, t) min J(u) =  L(x, u, t)dt + (x f , t f ) with  u,t f  x(t 0 ) = x 0 t0

(4.37)

The state and adjoint equations form a Hamiltonian system.  x = H p with H = L + pT f  p = − H x The optimal control is determined by minimizing the Hamiltonian.

(4.38)

H u = 0 (4.39)   → u *(x,p, t) u Huu  0 The initial conditions relate to the state and the final conditions to the adjoint. min H(x,u,p, t)

x(t 0 ) = x 0  p(t f ) = x (x f , t f )

(4.40)

If the final time is free, we have the additional final condition

H(t f ) = −t (x f , t f )

(4.41)

The initial and final conditions form the transversality conditions. The optimal trajectory is obtained by integrating (4.38) with the control determined at each time by (4.39). The difficulty comes from the endpoint conditions (4.40): the initial state x(t 0 ) is known, but not the adjoint p(t 0 ) . This initial adjoint must be found in order to satisfy the final condition on p(t f ) . The unknowns of the problem are: - the initial adjoint p(t 0 ) , with n components; - the final time t f (if free).

The conditions to be satisfied are: - the transversality condition on the final adjoint p(t f ) , with n conditions;

- the transversality condition on the final Hamiltonian H(t f ) (if t f is free). This two-point boundary value problem (TPBVP) with n + 1 unknowns and n + 1 equations is depicted in figure 4-4.

Optimal control

293

Figure 4-4: Two-point boundary value problem. The optimality conditions of a control problem systematically lead to a two-point boundary value problem, with one part of the conditions on (x, p) expressed at the initial time and the other part expressed at the final time. Methods for solving this type of problem are presented in chapter 5. In some cases, the existence of a first integral simplifies the solution. First integral Let us calculate the total derivative of the Hamiltonian on the optimal trajectory.

dH H dx H du H dp H (x,u,p, t) = + + + dt x dt u dt p dt t

(4.42)

Using equations (4.38) and (4.39)

H dp H dx H =− , = , =0 x dt p dt u

(4.43)

the total derivative reduces to

dH H = dt t

(4.44)

In the frequent case of an autonomous system the dynamics (function f) and the cost (function L) do not depend explicitly on time. We then have

H(x,u,p, t) = L(x,u) + pTf (x,u) 

H =0 t

(4.45)

In this case, the Hamiltonian is constant along the optimal trajectory and it provides a first integral (constant quantity along the trajectory). If the final time is free, its value is given by the transversality condition (4.41).

H(t) = H(t f ) = −t (xf ,t f )

(4.46)

294

Optimization techniques

Minimum time problem The problem of reaching a target in the minimum time is formulated as tf

min J =  1dt u,t f

t0

x = f (x,u, t) with  x(t 0 ) = x 0

(4.47)

The transversality condition (4.41) gives: H(t f ) = 0 . If the system is autonomous, the Hamiltonian is constant along the whole trajectory. (4.48)

H = 1 + pTf (x,u) = 0 , t

This relation between x and p can replace a final condition, which simplifies the solution of the two-point boundary value problem. The following two examples illustrate the solution of a minimum time problem in dimension 2. Example 4-3 concerns a problem of navigation in a fluid stream.

Example 4-3: Navigation in a fluid stream (from [R3]) We consider the plane trajectory of a vehicle in a moving fluid, for example an aircraft in the presence of wind or a boat in the presence of current. Modelling The assumptions about the motion are as follows: • the velocity e of the fluid is a function of the position (drive velocity); • the velocity w of the vehicle relative to the fluid has a constant modulus w; • the control is the orientation  of the relative velocity. Figure 4-5 shows the relative w , absolute va and drive e velocities.

 u(x, y)  e=   v(x, y)   cos   Vehicle relative velocity: w = w    sin   Fluid drive velocity:

State equations:

 x = w cos  + u(x, y)   y = w sin  + v(x, y) Figure 4-5: Relative and absolute velocity.

Optimal control

295

Control problem The objective is to return to the origin O in the shortest possible time from a given position (x 0 ; y0 ) . The final velocity is free. The problem is formulated as tf

min J =  1 dt ,t f

t0

x(t f ) = 0 x = w cos  + u with  and   y = w sin  + v  y(t f ) = 0

Application of the PMP The Hamiltonian is: H = 1 + p(w cos  + u) + q(w sin  + v) with the adjoint (p,q) The application of the PMP results in: min H → H = −psin  + qcos  = 0 

The system is autonomous: H(t) = H(t f ) = 0 (minimum time)

p = − H x = − pu x − qv x q = − H y = − pu y − qv y

The adjoint equations are: 

Control and trajectory determination We want to express the control as a function of the position. Let us use the two equations on H to express the adjoint (p,q) as a function of the control  . H = 0 p(w cos  + u) + q(w sin  + v) = −1    − q cos  = 0 psin  H  = 0 pW = − cos    with W = w + u cos + vsin  qW = − sin 

pW + pW =  sin  pW = − cos  →  qW + qW = − cos  qW = − sin  p = − H x = − pu x − qv x with (p,q) given by: (adjoint equations)  q = − H y = − pu y − qv y Wu x cos  + Wv x sin  − Wcos  = W sin  we obtain the system:  Wu y cos  + Wv y sin  − Wsin  = −W cos  2 2 Then we eliminate W :  = v x sin  + (u x − v y )sin  cos  − u y cos  Deriving these equations: 

The optimal trajectory is found by integrating the differential system in (x, y, ) .

 x = w cos  + u(x, y)   y = w sin  + v(x, y)  2 2  = v x sin  + (u x − v y )sin  cos  − u y cos 

296

Optimization techniques

The initial conditions (x 0 ; y0 ) are given. The initial control 0 is sought such that the trajectory passes through the origin O. Let us look at two simple special cases that allow for an analytical solution. Case of a constant stream If u and v are constant, the derivatives u x ,u y ,vx ,v y are zero and the equation for  reduces to  = 0 . The solution:  = 0 = Cte corresponds to a straight-line trajectory towards the origin.

Case of a stream parallel to (Ox) and linear as a function of y: u = cy , v = 0 The equation in  integrates.

 = −u y cos 2  = −ccos 2  

d = −cdt  tan  = tan f + c(t f − t) cos2 

The control (t) follows a linear tangent law as a function of time.

We rewrite the equations of motion by changing the variable to  instead of t. d d Change of variable: = −ccos2   dt = − dt ccos2  Equation in y

dy = w sin  dt Equation in x



dy w sin  w 1 1  =−  y=  −  2 d ccos  c  cos f cos  

dx dx w w  1 1  = w cos  + cy  =− − −  2  dt d ccos  ccos   cos f cos   These differential equations can be integrated analytically. After (long) calculations, we obtain

 w  tan  − tan f  1 1  1   1   + tan   − x =   + ln  tan  +   − ln  tan f + cos    cos f     2c  cos f  cos f cos    1   w 1  y = c  cos  − cos   f    The initial conditions (x 0 ; y0 ) allow us to determine the unknowns (0 ; f ) by solving a nonlinear system of dimension 2.

Optimal control

297

Numerical application Figure 4-6 shows the application for a stream defined by: u = − y , v = 0 . The initial conditions are: x0 = y0 = −4.5m .

The solution: 0 = 98.8 deg , f = 240.0 deg gives a final time: t f = 8.2s . The arrows indicate the direction of the relative velocity every second.

Figure 4-6: Optimal trajectory in a linear stream.

Example 4-4 is a double integrator problem in dimension 2.

Example 4-4: Double integrator in dimension 2 (from [R3]) We consider a plane trajectory controlled in acceleration. Modelling The assumptions about the motion are as follows: • the acceleration a is of constant modulus; • the control is the direction u of the acceleration oriented by an angle  .

298

Optimization techniques

Position: Velocity: Control: Acceleration:

x → r =v r =  y  vx  v =  → v=a  vy   cos   u =   sin  

a = au

Figure 4-7: Double integrator model.

Control problem The objective is to return and stop in O in the minimum time from given initial conditions (r0 ; v0 ) . The problem is formulated as tf

min J =  1 dt u,t f

t0

 r(t 0 ) = r0  r(t ) = 0  r = v with  ,  ,  f  v = au  v(t f ) = 0  v(t 0 ) = v0

Application of the PMP The Hamiltonian is: H = 1 + pr .v + apv .u with the adjoint components (pr ;pv ) . The application of the PMP gives: min H u

→ u=−

pv pv

(unit vector).

 p r = −H r = 0 → p r = B The adjoint equations are:   p v = −H v = −pr → p v = B(t f − t) + A with constant vectors A and B Control and trajectory determination We replace the adjoints in the expression of u and derive the angle  . u A + By (t f − t) p A + B(t f − t) → tan  = y = y u=− v =− pv u x A x + Bx (t f − t) A + B(t f − t) The control (t) follows a bilinear tangent law as a function of time. In order to integrate the trajectory, we reduce it to an equivalent linear tangent law.

tan  =

A y + By (t f − t)

A x + Bx (t f − t)



tan( − ) = tan(f − ) + e(t f − t)

Optimal control

299

The relations between the constants (Ax ,Ay ,Bx ,By ) and ( ,e, 0 , f ) are found by expanding tan( − ) and identifying the terms.

A x = 1 − tan(f − ) tan  A = tan( − ) + tan  tan(f − ) + tan  + e(t f − t) f  y tan  = →  1 − tan(f − ) tan  − e(t f − t) tan  Bx = − e tan  By = e  We write the equations of motion by changing the variable to  instead of t. The change of variable is defined by d tan( − ) = tan(f − ) + e(t f − t)  dt = − 2 ecos ( − ) For the following calculations, we denote: - (x , y) the Cartesian components of the position; - (u , v) the Cartesian components of the velocity; - (x , y, u , v) the derivatives with respect to t; - (x ', y',u ', v') the derivatives with respect to  . From the equations in t:

d  x = u , u = a cos  and with dt = −  2 ecos ( − )  y = v , v = a sin 

−u −a cos    x ' = ecos 2 ( − ) , u ' = ecos 2 ( − )  we get the equations in  :  −v −a sin  y ' = , v' = 2  ecos ( − ) ecos 2 ( − )  These equations are integrated analytically. After (long) calculations, we obtain a a  x − x f = 2 (f x cos  − f y sin ) − u f (t f − t) , u − u f = (f u cos  − f v sin )   e e   y − y = a (f sin  + f cos ) − v (t − t) , v − v = a (f sin  + f cos ) f x y f f f u v  e2 e  f x = − f u tan( − ) + f v  f y = − 1 f u − 1 f v tan( − ) + 1 tan(f − ) − tan( − )  2 2 2 cos(f − )  with  1 1 f u = ln tan(f − ) + cos( − ) − ln tan( − ) + cos( − ) f   1 1 − f v = cos(f − ) cos( − ) 

300

Optimization techniques

The current values (x, y,u, v, ) along the trajectory are thus expressed as a function of the final values (xf , yf ,u f , vf , f ) , of the final time t f and of the constants  and e. Final conditions The aim is to return to the origin (xf = yf = 0) and to stop there (u f = vf = 0) . With these final conditions, the equations of the trajectory simplify to a a  x = 2 (f x cos  − f y sin ) , u = (f u cos  − f v sin )   e e   y = a (f sin  + f cos ) , v = a (f sin  + f cos ) x y u v  e2 e  with (f x ,f y ,f u ,f v ) expressed as a function of ( −  , f − ) . Let us place ourselves at any point (x, y,u, v) . The above equations form a system of dimension 4 whose unknowns are ( ,e, f , ) . System reduction To solve this system, we switch to polar coordinates. The position r is defined by (r; ) : - r is the polar radius; -  is called the sight angle. The velocity v is defined by (w;  ) : - w is the velocity modulus; -  is the angle of the velocity with the line of sight. Figure 4-8: Polar coordinates. The transformation to polar coordinates is defined by  x = r cos  , u = w cos ( +  )   y = r sin  , v = w sin ( +  ) w2 Let us express from (x, y,u, v) the two quantities and  . ar

Optimal control

301

  w2 u 2 + v2 x =  ar =  a x 2 + y2  y =  xu + yv  with  cos  = rw  u = xv − yu   sin  = rw   v =  The functions (f x ,f y ,f u ,f v )

a  w2 f u2 + f v2 (f x cos  − f y sin ) e2  ar = 2 2 fx + fy  a (f x sin  + f y cos )  a2 f f + f f  e2 → cos  = 3 x u y v a e rw  (f u cos  − f v sin ) 2  e a f f −f f sin  = 3 x v y u  a e rw  (f u sin  + f v cos ) e depend only on the 2 unknowns ( −  , f − ) .

We are thus reduced to a nonlinear system of dimension 2.  w2 f u2 + f v2  ar = 2 f x + f y2 where Atan2 denotes Arctan(x,y)     = Atan2( f x f u + f yf v , f x f v − f y f u ) The values of (w, r,  ) depend on (x, y,u, v) which are known (current point). The numerical resolution of the system gives ( −  , f − ) .

a f u2 + f v2 tan( − ) − tan(f − ) and t f − t = . e w The value of  is obtained from the transversality condition: H(t f ) = 0 . We then deduce: e =

H(t f ) = (1 + p r .v + ap v .u ) t = 1 − a A f

using vf = 0 , u = −

pv , p v = B(t f − t) + A pv A x = 1 − tan(f − ) tan  . A y = tan(f − ) + tan 

The vector A has the components: 

The equation: H(t f ) = 1 − a A = 0 gives: cos  =

a cos(f − )

,

which gives  from (f − ) calculated above. Numerical application

−1   x = 10 m u = 0 m  s The initial conditions are:  and  . −1 v = 0.5 m  s y = 4 m   The acceleration is: a = 0.1 m  s −2 . The solution gives a final time: t f = 24.13 s.

302

Optimization techniques

Figure 4-9 shows the evolution of the angle  . The dashed curve is the angle v = 180 +  −  between the line of sight (towards O) and the direction of the acceleration. There is a phase of acceleration towards the origin (v  90) up to t  14 s , then a phase of deceleration (v  180) to reduce the velocity and stop at the origin. The value of  during the deceleration indicates the direction of approach to the target (here   50 ).

Figure 4-9: Double integrator control in dimension 2. Figure 4-10 shows the position (x; y) and the velocity (u; v) . The final approach is almost straight along the angle   50 seen in figure 4-9.

Figure 4-10: Double integrator trajectory in dimension 2.

Optimal control

303

w2 Figure 4-11 summarizes the set of solutions as a function of  and . 2ar These two variables depend on the position and velocity coordinates (x, y,u, v) . The angle  v = 180 −  (abscissa) between the direction of the target and the velocity varies from 0° to 180°. An angle  v  90 (resp.  v  90 ) indicates approaching (resp. moving away from) the target. The ratio inverse varies from 0 to 1.

w2 (ordinate) or its 2ar

Figure 4-11: Summary of double integrator solutions. The solid lines are trajectories following the arrows (clockwise). The dashed lines are the level lines of v = 180 +  −  and

a(t f − t) . An angle v  90 (resp. w

v  90 ) indicates accelerating towards (respectively away from) the target.

The trajectories end in the lower left quadrant and converge on the point of coordinates (0 ; 1) . On the arrival phase near the target:

w2  1 increases; 2ar - the velocity is directed towards the target: the angle  v  90 decreases to 0°, (corresponding to a straight path); - the acceleration is always opposite to the target: v  90 (to brake). - the velocity is low and the distance decreases: the ratio

304

Optimization techniques

Depending on the initial conditions, the trajectory may start with an acceleration phase towards the target: v  90 , before the arrival braking phase described above. This occurs especially when the initial point is in the upper left quadrant,

 w2   1 and directed towards the target ( v  90). with a high initial velocity   2ar 

4.2 Constraints This section presents the optimality conditions when the control problem is subject to various types of constraints or discontinuities.

4.2.1 Terminal constraints Consider a control problem with initial and final constraints. tf

min J =  L(x, u, t)dt + (x 0 , t 0 , x f , t f ) with x = f (x, u, t)

u,x 0 ,t 0 ,x f ,t f

t0

(4.49)

and  (x 0 , t 0 , x f , t f ) = 0

The initial (x 0 ;t 0 ) and final (x f ;t f ) conditions may vary, but the solution must satisfy q constraints of the form: (x 0 ,t 0 ,x f ,t f ) = 0 .

As in (4.10), we introduce the adjoint p(t) and the Hamiltonian H(x,u,p, t) .

H(x, u, p, t) = L(x, u, t) + p Tf (x, u, t)   H p = − x 

(4.50)

The control u(t) is obtained by minimizing the Hamiltonian at each time.

min H(x,u,p, t) → u(t) u

(4.51)

The Hamiltonian considered here is normal (with the convention: p0 = 1 ), which excludes abnormal extremals. We restrict ourselves here to normal extremals. We then have the following necessary conditions of optimality.

Optimal control

305

Property 4-2: Necessary conditions for optimality with terminal constraints Assume that the control u(t) defined by (4.51) is a solution of (4.49). Then there are q multipliers  associated with the q constraints  = 0 such that: •

the terminal constraints are satisfied

(x0 ,t 0 ,xf ,t f ) = 0 •

the initial adjoint (if x 0 free) and the final adjoint (if x f free) satisfy

p(t 0 ) = − x (t 0 ) −  x (t 0 )  p(t f ) = x (t f ) +  x (t f ) •

(4.52)

(4.53)

the initial Hamiltonian (if t 0 free) and the final Hamiltonian (if t f free) satisfy

H(t 0 ) = t (t 0 ) +  t (t 0 )  H(t f ) = − t (t f ) −  t (t f )

(4.54)

These conditions form a two-point boundary value problem: - the q equations (4.52) are linked to the unknowns  ; - the n conditions of transversality on p(t 0 ) are linked to the unknowns x(t 0 ) ; - the n transversality conditions on p(t f ) are linked to the unknowns x(t f ) ; - the transversality condition on H(t 0 ) is linked to the unknown t 0 ; - the transversality condition on H(t f ) is linked to the unknown t f .

Demonstration We use the variational method by adding the q constraints  with multipliers  to the augmented cost (4.13). Formula (4.16) becomes tf

J a =   H(x, u, p, t) + p T x  dt + p(t 0 ) T x(t 0 ) − p(t f ) T x(t f ) t0

+ (x 0 , t 0 , x f , t f ) +  T (x 0 , t 0 , x f , t f ) Applying the variations u(t), x(t), t 0 , t f to the augmented cost gives formula T (4.17) with additional terms from  (x 0 , t 0 , x f , t f ) .

306

Optimization techniques

J a =

tf

 H udt T u

t0

T

+ x 0 +  x 0  + p(t 0 )  x 0 + t 0 +  t 0  − H(t 0 )  t 0

tf

T

+  (H x + p)T xdt + x f +  x f  − p(t f )  x f + t f +  t f  + H(t f )  t f t0

The first-order optimality condition is: Ja = 0 , u, x 0 , t 0 , x f , t f .

As the variations u, x0 , t 0 , x f , t f are independent, their coefficients must be zero. This leads to the choice (4.50) to eliminate x and to the condition Hu = 0 for the term in u . The transversality conditions (4.53) and (4.54) eliminate the terms in (x0 ; xf ) and in (t 0 ; t f ) . Example 4-5 shows the application to a launch into orbit problem.

Example 4-5: Launch into orbit (from [R3]) We consider a trajectory controlled in acceleration in the vertical plane. Modelling The assumptions about the motion are as follows: • the Earth is flat and the gravity g is constant and vertical; • •

the target orbit is defined by an altitude z c and a horizontal velocity vc ; the acceleration a of constant modulus is along u defined by the angle  .

Figure 4-12 shows the trajectory in the vertical plane (Oxz).

x y

Position: r =   → r = v

 vx   → v = g + au  vy 

Velocity: v = 

 0   −g 

Gravity: g = 

 cos    , a = au  sin  

Control: u = 

Figure 4-12: Launch into orbit.

Optimal control

307

Control problem The aim is to reach the orbit in the minimum time by taking off at zero velocity. The injection abscissa x(t f ) is free. The problem is formulated as tf

min J =  1 dt u,t f

t0

z(t f ) = z c  r = v  r(t 0 ) = 0  with  and  , v x (t f ) = v c  v(t 0 ) = 0  v (t ) = 0  v = g + au  z f

Application of the PMP The Hamiltonian is: H = 1 + pr .v + pv .(g + au) with the adjoint (pr ,pv ) . The application of the PMP gives: min H → u = − u

pr = −H r = 0

The adjoint equations are: 

pv pv

(unit vector).

→ pr = B

p v = −H v = −pr → p v = B(t f − t) + A

.

with constant A and B vectors The injection abscissa x(t f ) being free, we have the transversality condition

px (t f ) = 0  Bx = 0

Control and trajectory determination We replace the adjoints in the expression of u and derive the angle  . p A + B(t f − t) u A + Bz (t f − t) → tan  = z = z u=− v =− pv ux Ax A + B(t f − t) The control (t) follows a linear tangent law of the form: tan  = tan 0 − ct . We rewrite the equations of motion by changing the variable to  instead of t.

dv  dv = −ccos 2  = g + au  d  dt d tan  = tan 0 − ct  dt = − →  2 dr dr ccos   = −ccos 2  = v  dt d First, the velocity components are integrated into the variable  .  a  1  a  1  a  dv x  v x = ln  tan 0 +  − ln  tan  +  = −  d c  cos 0  c  cos    ccos  →   a 1 1   dv z = − a sin  − g dt   v z = c  cos  − cos   − gt ccos 2  d  d 0   

308

Optimization techniques

The components of the position are then integrated into  (long calculations).

  a  1 1 1  1   − + tan  ln  tan  + x = 2    − tan  ln  tan 0 + c  cos 0 cos  cos   cos 0        a  tan 0 tan  2 tan  1  1   gt 2   z = + − + ln tan  + − ln tan  +   − 0    2c2  cos  cos  cos    cos cos   0 0 0   2   Final conditions The final conditions are on vx , vz ,z with the control tan f = tan 0 − ct .

This forms a system of dimension 4 whose unknowns are (0 , f , t f ,c) .

 tan f = tan 0 − ct f   v (t ) = a ln  tan  + 1  − a ln  tan  + 1  = v    c 0 f  x f c  cos 0  c  cos f    a 1 1   v (t ) = −   − gt f = 0 z f  c  cos 0 cos f     a  tan 0 tan f 2tan f 1   1   gt f2 z(t f ) = 2  + − + ln  tan f + − ln tan  + = zc  −   0 2c  cos 0 cos f cos 0 cos f   cos 0   2   System reduction We eliminate (c, t f ) with the first 2 equations. This leaves a system in (0 , f ) .

a  1 1  −    = tan 0 − tan f  g  cos 0 cos f   1  1     tan 0 + tan 0 +    cos 0 2az c 2 cos 0   tan 0 tan f    =0 − − ln − ln  cos  cos  1  vc2 1    f 0 tan f + tan f +    cos f  cos f   The first equation gives 0 as a function of f (equation of degree 2 in cos0 ). There remains an equation in f solved numerically. We deduce 0 , then t f by 1    tan 0 + cos   v 0  = c (tan 0 − tan f ) t f ln  1  tan  +  a f  cos f 

Optimal control

309

Numerical application

 z c = 200 km The final target conditions are:  (circular orbit at 200 km) −1  v c = 7 784 m  s −2 The constant gravity is g = 9 m  s .

The total impulse delivered during the trajectory is given by V = at f . The table opposite shows the solutions obtained for acceleration levels of 2g, 3g and 5g respectively. Higher acceleration reduces the final time and decreases the total impulse required.

Acceleration 0 (°) f (°) tf (s) V (m/s)

a = 2g 45.64 11.46 509.5 9 171

a = 3g 43.90 −9.20 319.1 8 616

a = 5g 49.24 −31.75 195.4 8 792

The corresponding trajectories are plotted in figure 4-13. The arrows indicate the thrust direction on the 3g trajectory.

Figure 4-13: Optimal launch trajectories. We then consider the determination of the acceleration level that minimizes the total impulse V = at f . The problem is solved for acceleration levels between 1.5g and 6g and for orbits of altitude 200, 300 and 400 km. The velocity in circular orbit at altitude z c is given by: vc = g(R T + z c ) , with the Earth radius R T = 6 378 km and the average gravity g = 9 m  s −2 . The results plotted in figure 4-14 show that the optimum acceleration depends on the target altitude and that the impulse is quite sensitive to the level of acceleration, especially if it is low.

310

Optimization techniques

Figure 4-14: Required impulse as a function of altitude and acceleration.

Property 4-2 also applies for an integral constraint of the form tf

 g(x,u, t)dt = c

(4.55)

t0

For this purpose, we define an additional state variable x n+1 such that

 x n +1 (t 0 ) = 0 x n +1 = g(x,u, t) with   x n +1 (t f ) = c

(4.56)

The Hamiltonian and the adjoint equations become T H(x1:n +1 ,u,p1:n +1, t) = L(x1:n ,u, t) + p1:n f (x1:n ,u, t) + p n +1g(x 1:n ,u, t)

p1:n = −H x1:n p1:n +1 = −H x1:n+1   te pn +1 = −H x n+1 = 0  p n +1 = C

(4.57)

The adjoint pn +1 constant is an unknown linked to the constraint x n+1 (t f ) = c . This unknown and the associated equation complete the two-point boundary value problem.

Optimal control

311

4.2.2 Interior constraints Consider a system with a discontinuity at a time t1 [t 0 ;t f ] . − + A state discontinuity results in different states at t1 and t1 .

 x(t1− ) = x1−  + +  x(t1 ) = x1

(4.58)

A discontinuity in dynamics results in a change in the state equation.

f − (x, u, t) if t 0  t  t1 f (x, u, t) =  + f (x, u, t) if t1  t  t f

(4.59)

The integral cost functional may also differ on [t 0 ;t1[ and [t1 ;t f ] .

L− (x, u, t) if t 0  t  t1 L(x, u, t) =  + L (x, u, t) if t1  t  t f

(4.60)

It is further assumed that q constraints are to be met at time t1 . (4.61)

(x1− , x1+ , t1 ) = 0

The so-called hybrid control problem with these interior constraints (also called point or intermediate constraints) is formulated as t1−

tf

t0

t1+

min J =  L− (x, u, t)dt +  L+ (x, u, t)dt + (x1− , x1+ , t 1 ) − +

u,x1 ,x1 ,t1

 x = f − (x, u, t) if t 0  t  t1 with  +  x = f (x, u, t) if t1  t  t f

(4.62)

and (x1− , x1+ , t1 ) = 0

− + The variables (x1 , x1 , t1 ) are to be optimized in the same way as the control u(t).  − + = x (t1 ). The derivatives of  (or  ) with respect to x 1 or x 1 are noted: x1 noted

− + The objective here is to write optimality conditions associated with (x1 , x1 , t1 ) .

For simplicity, it is assumed that there is only one interior point at time t1 and it is not specified whether the terminal conditions are constrained or not. These terminal conditions do not appear in either the cost or the constraints of (4.62). The generalization to several interior points and terminal conditions is discussed on page 314.

312

Optimization techniques

We define the Hamiltonians H − on [t 0 ;t1[ and H + on [t1 ;t f ] .

H − (x, u, p, t) = L− (x, u, t) + p Tf − (x, u, t) if t 0  t  t 1 (4.63) H(x, u, p, t) =  + + T + H (x, u, p, t) = L (x, u, t) + p f (x, u, t) if t 1  t  t f The adjoint equations and the optimal control are defined on each interval with the corresponding Hamiltonian.

 H − p = − x  + p = − H  x

, min H − (x, u, p, t) → u(t) if t 0  t  t 1 u

(4.64)

, min H (x, u, p, t) → u(t) if t 1  t  t f +

u

We then have the following necessary conditions of optimality. Property 4-3: Necessary conditions for optimality with interior constraints Suppose that the control u(t) defined by (4.64) is a solution of (4.62). Then there are q multipliers  associated with the q constraints  = 0 such that •

the interior constraints are satisfied

(x1− , x1+ , t1 ) = 0 •

− + the adjoints at t1 and t1 satisfy

p(t1− ) = x (t1− ) +  x (t1− )  + + + p(t1 ) = − x (t1 ) −  x (t1 ) •

(4.65)

(4.66)

− + the Hamiltonians at t1 and t1 satisfy

H+ (t1+ ) − H − (t1− ) = t (t1 ) +  t (t1 )

(4.67)

These conditions form a two-point boundary value problem: - the q equations (4.65) are linked to the unknowns  ; − - the n transversality conditions on p(t1− ) are linked to the unknowns x(t1 ) ; + - the n transversality conditions on p(t1+ ) are linked to the unknowns x(t1 ) ;

- the transversality condition on H(t1 ) is linked to the unknown t1 .

Optimal control

313

Case of a continuous state + − If the state is continuous: x(t1 ) = x(t1 ) = x(t1 ) , condition (4.66) is replaced by (4.68)

p(t1+ ) − p(t1− ) = − x (t1 ) −  x (t1 )

These n transversality conditions on p(t1 ) are linked to the n unknowns x(t1 ) . The adjoint is discontinuous due to the constraint, although the state is continuous.

Demonstration We use the variational method by adding to the augmented cost (4.13) the q − constraints  with multipliers  . Integrating by parts over each interval [t 0 ;t1 ] + and [t1 ;t f ] , the formula (4.16) becomes t1−

 H

Ja =

t0



(x, u, p, t) + p T x  dt + p(t 0 ) T x(t 0 ) − p(t 1− ) T x(t 1− ) +  T (x 1− , x 1+ , t 1)

tf

+   H + (x, u, p, t) + p T x  dt + p(t1+ ) T x(t1+ ) − p(t f ) T x(t f ) + (x 1− , x 1+ , t 1) + t1

− + Applying variations u(t), x(t), x1 , x1 , t1 to the augmented cost, we obtain

+ − the equivalent of formula (4.17) on each interval [t 0 ;t1 ] and [t1 ;t f ] . − − On [t 0 ;t1 ] , the changes in t1 act like final changes (x f , t f ) . + + On [t1 ;t f ] , the changes in t1 act like initial changes (x 0 , t 0 ) . T − − + + We add the variations coming from  (x1 , x1 , t1 ) and (x1 , x1 , t1 ) to get

J a =

t1−

t1−

tf

tf

t0

t1+

t1+

− T +T + T  H udt +  (H x + p) xdt +  H u udt +  (H x + p) xdt

t0

−T u

T

+ x (t1− ) +  x (t1− ) − p(t1− )  x1− +  t1  + H(t1− )  t1 T

+ x (t1+ ) +  x (t1+ ) + p(t1+ )  x1+ + t1 − H(t1+ )  t1 − + The first-order optimality condition is: J a = 0 , u(t), x(t), x1 , x1 , t1 . As the variations u(t), x(t), x1 , x1 , t1 are independent, their coefficients must be zero. This leads to (4.64) for eliminating x and to Hu = 0 for the term in u . −

+

− + Conditions (4.66) and (4.67) eliminate the terms in (x1 ; x1 ) and t1 .

314

Optimization techniques

Case of a continuous state − + If the state is continuous in t1 , the state variations are equal: x1 = x1 = x1 . T The term in x1 comes from integration by parts, from  (x1 , t1 ) and (x1 , t1 ). T

+ − Its expression:  p(t1 ) − p(t1 ) + x1 +  x1   x1 leads to the condition (4.68).

The conditions (4.66-67) are called jump conditions, because they generate discontinuities on the adjoint and Hamiltonian, and consequently on the control. The generalization to several interior points in t1 ,t 2 , ,t k is immediate: − + − + - the constraints are of the form: (x1 , x1 , t1 , x 2 , x 2 , t 2 ,

, x k− , x k+ , t k ) = 0 ;

− + − + - the final cost is of the form: (x1 , x1 , t1 , x 2 , x 2 , t 2 ,

, x −k , x +k , t k ) ; - the integral cost is decomposed into k intervals with functions Lk and f k . At time tk, the conditions (4.65-67) are associated with the unknowns (x k , x k , t k ). Conditions (4.66) and (4.67) also allow us to find the transversality conditions (4.53) and (4.54) associated with the terminal constraints. t + → t 0 p(t 0 ) = − x (t 0 ) −  x (t 0 ) At the initial time, by posing:  1+ , we have:  .  x1 → x 0 H(t 0 ) = t (t 0 ) +  t (t 0 ) −

 t1− → t f , we have: −  x1 → x f

At the final time, by posing: 

+

p(t f ) = x (t f ) +  x (t f ) .  H(t f ) = − t (t f ) −  t (t f )

Example 4-6 shows the effect of jump conditions in simple cases.

Example 4-6: Jump conditions Assume that the final cost  does not depend explicitly on the conditions at t1 . 1st case: assume that the state has a fixed discontinuity at a free time t1 . − + + − The interior constraint is of the form: (x1 , x1 , t1 ) = x1 − x1 − c = 0 .

H(t1+ ) − H(t1− ) =  t (t1 ) = 0 H(t1+ ) = H(t1− )  + + p(t ) = − (t )  = −   Conditions (4.66-67) yield:  1  + x 1 − p(t1 ) = p(t1 ) p(t1− ) =  x (t1− ) = −   The Hamiltonian and the adjoint are continuous at t1 . The constraint does not generate any jump.

Optimal control

315

2nd case: assume that the state has a fixed discontinuity at t1 =  .

1 (x1− , x1+ , t1 ) = x1+ − x1− − c = 0 . − +  2 (x1 , x1 , t1 ) = t1 −  = 0

The two interior constraints are of the form:  Conditions (4.66-67) yield

H(t1+ ) − H(t1− ) = 1,t (t1 )1 +  2,t (t1 ) 2 =  2 H(t + ) = H(t1− ) +  2  + + +   +1 p(t1 ) = −1,x (t1 )1 −  2,x (t1 ) 2 = −1 − p(t1 ) = p(t1 ) p(t − ) =  (t − ) +  (t − ) = − 1,x 1 1 2,x 1 2 1  1 The adjoint is continuous, but the Hamiltonian is discontinuous. 3rd case: assume that the state is continuous and that the constraint does not depend explicitly on t1 . The interior constraint is of the form: (x1 ) = 0 and the time t1 is free. Conditions (4.66-67) yield

H(t1+ ) − H(t1− ) =  t (t1 ) = 0 H(t1+ ) = H(t1− )   +  + − − p(t1 ) = p(t1 ) −  x (t1 ) p(t1 ) − p(t1 ) = −  x (t1 )

The Hamiltonian is continuous, but the adjoint is discontinuous.

4.2.3 Path constraints Consider a control problem with equality and inequality constraints. tf

min J =  L(x, u, t)dt + (x f ) with x = f (x, u, t) u

t0

  E (x, u, t) = 0 and  , t   I (x, u, t)  0

(4.69)

The qE equality constraints  E and the qI inequality constraints  I are called path constraints. They must be satisfied at all points along the path. The principle of the minimum (theorem 4-1) then applies in the form

 E (x, u, t) = 0 min H(x, u, p, t) s.t.  u  I (x, u, t)  0

→ u *(t)

The Hamiltonian is minimized under the constraints E = 0 and I  0 .

(4.70)

316

Optimization techniques

This constrained optimization problem has to be solved at each time. By introducing Lagrange multipliers  E multipliers and I associated with the constraints  E and  I respectively, we form the Lagrangian of problem (4.70). This Lagrangian is called here the augmented Hamiltonian and it is noted H a in order not to confuse it with the integral cost function L(x, u, t) .

Ha (x,u,p, t,  E ,  I ) = H(x,u,p, t) +  TE  E (x,u, t) +  TI  I (x,u, t)

(4.71)

The first-order KKT conditions of problem (4.70) are

 E (x, u, t) = 0  (x, u, t)  0 H a  I = 0 and  u  I  0 if  I = 0  = 0 if   0 I  I

(4.72)

An inactive inequality constraint at time t has a zero multiplier. The system (4.72) is to be solved at each time to find the control u*(t) :

Ha =0; u - the qE multipliers  E are linked to the qE equations E (x,u,t) = 0 ; - the qI multipliers I are zero or linked to the qI equations I (x,u, t) = 0 . - the m components of u* are linked to the m equations

Example 4-7 is a double integrator with bounded control.

Example 4-7: Double integrator in dimension 1 We consider a material point moving on a straight line. The state consists of the position r and the velocity v. The control is the acceleration u between −1 and +1.

r = v . v = u

The state equations are: 

Control problem The objective is to return and stop in O in the minimum time starting from given initial conditions (r0 , v0 ) . The minimum time control problem is formulated as tf

min J =  1 dt u,t f

t0

r(t f ) = 0 r = v r(t 0 ) = r0 with  ,  ,  , − 1  u  +1 v = u v(t 0 ) = v0 v(t f ) = 0

Optimal control

317

Application of the PMP The Hamiltonian is: H = 1 + pr v + pvu with the adjoint of components (pr ,pv ) .

−1 if p v  0 Applying the PMP gives: min H s.t. − 1  u  +1 → u =  u +1 if p v  0 This control is of bang type (u = 1) with a switching (or commutation) function defined by the adjoint pv .

p r = −H r = 0 → p r = b , a ,b constants p v = −H v = −pr → p v = b(t f − t) + a

The adjoint equations are: 

Control and trajectory determination The adjoint pv is a linear function of the time. Its sign changes at most once. The path consists of at most two arcs controlled with u = 1 . Let us integrate the equations for each arc with their respective controls: • the first arc starts from the initial state (t 0 ,r0 ,v0 ) with the control u 0 = 1 .



 v = v0 + u 0 (t − t 0 ) v = u 0   v 2 − 2u 0 r = v02 − 2u 0 r0  2 r = r0 + v0 (t − t 0 ) + u 0 (t − t 0 ) / 2 r = v the second arc arrives at the final state (t f ,rf ,vf ) with the control u f = 1 .  v = vf + u f (t − t f ) v = u f   v 2 − 2u f r = v f2 − 2u f rf = 0  2 r = rf + vf (t − t f ) + u f (t − t f ) / 2 r = v

These arcs are represented by parabola arcs in the phase plane (r , v) .

− 2 If u f = −1 , the final arc is on the parabola  : v = −2r (quadrant r  0, v  0 ). + 2 If u f = +1 , the final arc is on the parabola  : v = +2r (quadrant r  0, v  0 ).

The  curve formed by the half parabolas − and + is the switching curve. 2

This curve  of equation: v sgn(v) = −2r is drawn in solid lines in figure 4-15. It separates the plane into two regions. The control depends on the current position (r , v) in relation to the curve  : • if the point is above  , the control is u = −1 . This control decreases the velocity and the point joins the curve + ; • if the point is below  , the control is u = +1 . This control increases the velocity and the point joins the curve − . Two trajectories are drawn in dotted lines from each of the two regions.

318

Optimization techniques

Figure 4-15: Double integrator in the phase plane. Let us calculate the final time as a function of the initial conditions (r0 ,v0 ) .

The initial and final arc intersect at (t c ,rc , vc ) . These coordinates are solution of

 vc2 − 2u 0 rc = v02 − 2u 0 r0 (initial: u = u 0 ) 1  vc2 = v02 − u 0 r0  2 2 (final: u = u f = −u 0 and rf = v f = 0)  vc + 2u 0 rc = 0 The time spent on the initial arc is obtained by v −v vc = v0 + u 0 (t c − t 0 )  t c − t 0 = c 0 u0 The time spent on the final arc is obtained by v − vc vc vf = vc + u f (t f − t c )  t f − t c = f = uf u0 We deduce the total time: t = t f − t 0 =

2vc − v0 u0

 2vc = v0 + u 0t .

2 2 Replacing vc and (r0 ,v0 ) , we have: 2t − 4u 0r0 + (v0 − u 0 t) = 0 .

This equation gives the total time as a function of (r0 ,v0 ) . The initial control u 0 2

is determined by the sign of v0 sgn(v0 ) + 2r0 (position relative to  ). Figure 4-15 shows the level line of the final time (time to return to the origin) associated with the switching points of the two trajectories already drawn.

Optimal control

319

If a path constraint is not explicit in u, the approach (4.70) does not apply, as the minimization of the Hamiltonian would not take the constraints into account. These non-explicit constraints in u called state constraints are of the form

 E (x, t) = 0 (4.73)   I (x, t)  0 Let us consider successively the case of an equality constraint, then an inequality. Equality state constraint: (x, t) = 0 The constraint (x, t) = 0 has to be satisfied at each time of the trajectory. Since the function  (x, t) is constant, its derivative with respect to time is zero. Using the state equation: x = f (x, u, t) , this derivative is expressed as T

d    dx  (4.74) = + =  Tx (x, t)f (x, u, t) +  t (x, t)  dt  x  dt t The function  (x, t) is zero if and only if its derivative is zero and its initial or final value is zero. We can therefore replace the constraint (x, t) = 0 by T  x (x, t)f (x, u, t) +  t (x, t) = 0 , t  (x 0 , t 0 ) = 0 or (x f , t f ) = 0

(4.75)

If the derivative is explicit in u, the approach (4.70) can be applied by replacing the constraint (x, t) = 0 by its derivative (4.74) and adding a constraint on the initial or final value of  . This initial or final constraint is taken into account in the transversality condition on p(t 0 ) or p(t f ) with a multiplier  .

(x 0 , t 0 ) = 0 → p(t 0 ) = −x (t 0 ) −  x (t 0 ) or (x f , t f ) = 0 → p(t f ) = x (t f ) +  x (t f )

(4.76)

If the derivative of  is not explicit in u, we continue to derive until we obtain an explicit function in u. The constraint is said of order k if it is necessary to derive k times the function  to obtain an explicit expression in u. The constraint is then replaced by

(x, t) = 0 , t

(k)   (x, t) = 0 , t   ( j)   (x 0 , t 0 ) = 0 for 0  j  k − 1

dk . def dt k

(k) with the notation  =

(4.77)

320

Optimization techniques

The initial constraints are then on all derivatives from order 0 to k−1. These initial constraints are taken into account in the transversality conditions with their respective multipliers. Inequality state constraint: (x, t)  0 An inequality constraint can be active ( = 0) or inactive (  0) on successive arcs of the path. Suppose that the constraint becomes active at t1 .

On the part t  t1 , the constraint is not taken into account in (4.70).

On the part t  t1 , the constraint is treated as an equality. Deriving k times to make the control u appear, we replace the constraint with the conditions (4.77) applied from t1 .

(x, t) = 0 , t  t1

(k)   (x, t) = 0 , t  t1   ( j)   (x1 , t1 ) = 0 for 0  j  k

(4.78)

The k constraints at time t1 are interior constraints. They are taken into account in transversality conditions of the form (4.66) and (4.67) with their respective multipliers. The change of a constraint from active to inactive is handled in the same way. Connections between saturated ( = 0) and unsaturated (  0) arcs are called junctions. An important difficulty is that the optimal number of junctions is not known in advance (except in simple cases). An arbitrary assumption on this number is usually required to introduce the corresponding times t1,t 2 , in the formulation of the two-point boundary value problem. Example 4-8 shows a problem with an inequality state constraint leading to junctions between saturated and unsaturated arcs.

Example 4-8: Minimum distance with junction We are looking for the shortest path between two given points in the plane without entering the circle of center O and radius a as shown in figure 4-16. We pass to an equivalent minimum time problem by assuming a constant velocity of direction u . The state is the position r and the state equation is: r = u . The control is the unit vector u : u = 1 .

Optimal control

321

2 2 The state constraint (not to enter the circle) is formulated as: (r) = a − r  0 .

Figure 4-16: Minimum distance with junction.

Control problem The minimum time control problem is formulated as tf (r) = a 2 − r 2  0  r(t 0 ) = r0 min J =  1 dt with r = u ,  ,  u,t f  u = 1  r(t f ) = rf t0 Application of the PMP The Hamiltonian is: H = 1 + p  u with the adjoint p .

 u = 1 The application of the PMP gives: min H s.t.  . 2 2 u (r) = a − r  0 We determine the order on the unsaturated (  0) and saturated arcs ( = 0) , then we look for the junction conditions. Unsaturated arc The control is given by: min H = 1 + p  u s.t. u = 1 → u = − u

p p

The adjoint equation is: p = −H r = 0  p constant . The control u (direction of velocity) is constant and the trajectory is a straight line segment, which indeed minimizes the distance in the absence of constraints.

322

Optimization techniques

Saturated arc The state constraint is derived until the control appears.

(r) = a 2 − r 2  (r) = −2r  r = −2r  u The constraint  is of order 1. It is replaced by its derivative. (r) = 0 (r) = 0   (r1 ) = 0

We deduce the control on the saturated arc: (r) = −2r  u = 0  u ⊥ r The saturated arc follows the circle with the control u (velocity) constantly perpendicular to the circle radius. Junction conditions The junction conditions between unsaturated and saturated arc at a time t1 are

p(t1+ ) − p(t1− ) = − r (t1 )  + − H(t1 ) − H(t1 ) =  t (t1 )

 r = −2r with (r) = a 2 − r 2    t = 0

p+ = p− + 2 r . + − H = H

from which we can deduce: 

Let us express the Hamiltonian before and after the junction.  − p− − − − H = 1 + p  u with u = − − (segment) p   + + + + (arc of circle) H = 1 + p  u with u ⊥ r − + These expressions of H and H are replaced in the junction conditions. + − − − −   p = p + 2 r p = −p u − + − − − +  (p + 2  r)  u = p  u  u  u = 1 sin ce  + +  + − −   p  u = p  u u  r = 0 + − from which we deduce: u = u (unit vectors). The junction is tangential to the circle. This is the expected result for minimizing the distance around the circle.

Note The control is here continuous at the junction (which is not the case in general).

Optimal control

323

If we repeat the calculation assuming a different velocity v − outside the circle v− − + and v + on the circle, we obtain the relation: u  u = + . v This is Descartes' law of refraction which reflects a change in direction when the medium changes index (different speed of propagation).

Control discontinuities A discontinuity in the control is called a corner or edge. Discontinuities are generally associated with: - an interior point modifying the definition of the Hamiltonian as in (4.63); - an interior constraint generating an adjoint jump as in (4.66) or (4.68); - a state constraint passing from active to inactive or vice versa. The control obtained by global minimization of the Hamiltonian (from the PMP) can be discontinuous even in the absence of interior or state constraints. Figure 4-17 shows a Hamiltonian with two local minima as a function of u. The − + function H(u) is plotted at times t , t and t . The minima evolve with time. The global minimum changes from u − to u + generating a control discontinuity at t.

Figure 4-17: Jump of the global minimum.

4.2.4 Quadratic-linear problem The standard formulation of a quadratic-linear (QL) control problem is

min J = u

t

1 T 1 f (x Sx) tf +  (x TQx + u T Ru)dt 2 2 t0

x = Fx + Gu with  x(t 0 ) = x 0

The initial time t 0 , the final time t f and the initial state x(t 0 ) are fixed.

(4.79)

324

Optimization techniques

The objective is to come close a zero final state x(t f ) = 0 , while limiting the state values x(t) and control u(t) along the trajectory. This justifies the choice of a quadratic cost composed of an integral term with weighting matrices Q and R on the state and control, and of a final term with a weighting matrix Sf on the final state. The assumptions on these matrices are as follows: - the matrices F, G, Q and R are functions of time → F(t), G(t), Q(t), R(t); - the matrices Q and Sf are positive semidefinite (they can be set to zero); - the matrix R is positive definite. The Q, R and Sf matrices are set according to the desired shape of the solution. Suppose we want to limit the state and control components by

 x i (t f )  x i,max (t f ) , i = 1 to n  (4.80)  x i (t)  x i,max (t) , i = 1 to n   u j (t)  u j,max (t) , j = 1 to m Each state and control component must remain below a threshold which can be variable along the trajectory. We can choose for example diagonal matrices: Sf = diag(si ), Q = diag(qi ), R = diag(ri ) with coefficients

si =

1 1 1 , qi = , ri = 2 2 x i max (t f ) (t f − t 0 )x i max (t) (t f − t 0 )u i max (t) 2

(4.81)

These coefficients are to be set by trials and observing the effect on the solution. Let us apply the minimum principle to the QL problem (4.79). The Hamiltonian and the adjoint are given by

p = −Qx − FT p 1 1 H = x T Qx + u T Ru + p T (Fx + Gu) with  2 2 p(t f ) = Sf x(t f ) The optimal control minimizes the Hamiltonian.

min H  Ru + G T p = 0  u = −R −1G T p u

(4.82)

(4.83)

The matrix R is assumed to be positive definite and therefore invertible. By replacing u in the state equation, we form a two-point boundary value problem.

 x(t 0 ) = x 0  x   F −GR −1G T   x     with   = T −F  p   −Q p(t f ) = Sf x(t f )  p  Example 4-9 shows the application to an interception problem.

(4.84)

Optimal control

325

Example 4-9: Interception

 r = v

Consider a mobile with position r , velocity v , acceleration u : 

 v = u

.

The initial time t 0 , the final time t f and the initial state (r0 ,v0 ) are given. The control is the acceleration. The objective is to approach a zero final position and velocity (rf = 0 , vf = 0) , while minimizing the energy consumed. tf

This energy is measured by the integral:

 u dt (L 2

2

norm of the acceleration).

t0

QL control problem The QL control problem is formulated as t

1 1 1f min J = K r r(t f ) 2 + K v v(t f ) 2 +  u 2dt u 2 2 2 t0

The positive reals Kr and Kv are the weights on the final position and velocity. Application of the PMP

1 2

2 The Hamiltonian is: H = u + p r  v + p v  u with the adjoint (pr ,pv ) .

The adjoint equations are te p r = 0  pr (t f ) = K r r(t f )  pr = K r r(t f ) = C with →    p v = (t f − t)K r r(t f ) + K v v(t f ) p v (t f ) = K v v(t f )   p v = −p r Applying the PMP gives: min H  u = −pv = (t − t f )Kr r(t f ) − K v v(t f ) u

The state equations are integrated with this control.

1  2  v = u → v(t) = 2 (t − t f ) K r r(t f ) − (t − t f )K v v(t f ) + v(t f )   r = v → r(t) = 1 (t − t )3 K r(t ) − 1 (t − t ) 2 K v(t ) + (t − t )v(t ) + r(t ) f r f f v f f f f  6 2 By expressing r(t f ),v(t f ) in terms of r(t), v(t) and  = t f − t (time to go) 1  Dr(t f ) = ( + 2 K v )v + (1 + K v )r   2  Dv(t ) = (1 − 1 3K )v − 1 2 K r f r r  6 2 

1 1 with D = 1 + K v + 3K r + 4 K r K v 3 12

326

Optimization techniques

we obtain an expression for the control as a function of the state (feedback control) 1 1 K r (1 + K v )r + (K v + 2 K r + 3K r K v )v 2 3 u=− with  = t f − t 1 3 1 4 1 + K v +  K r +  K r K v 3 12 Application to interception Consider a mobile M aiming at a target C: - M has a position rM (t) , a velocity vM (t) and an acceleration u M (t) ;

- C has a position rC (t) , a velocity vC (t) and an acceleration u C (t) . The position and velocity differences between C and M, noted r and v , satisfy

 r = r M − r C  r = v     v = u M − u C = u  v = v M − vC

We retrieve the previous equations with u representing here the difference of acceleration between C and M. The coefficients K r and K v are chosen according to the targeted final conditions. • Velocity-to-gain The aim is to reach a given velocity (for an injection into orbit or for a range).

K r = 0 1 → u=− v   K v = 

This control is of the form velocity-to-gain. The required acceleration is the velocity difference divided by the time-to-go. • Perfect interception The aim is to reach a given position. The final velocity is free.

K r =  3 → u = − 2 (r + v)   K v = 0

This control is of the form proportional navigation (discussed below). • Perfect rendezvous The aim is to reach a given position and velocity perfectly.

K r =  1 → u = − 2 (6r + 4v)   K v = 

This control is also of the form proportional navigation.

Optimal control

327

Geometric interpretation of proportional navigation The reference (or nominal) trajectory is the straight line D travelled at constant velocity vs . The point I is the target intercept position at t f . The position and velocity are projected along D and the normal direction.

 r = rs + rn   v = vs + v n

The motion along D is not controlled.

vs = −

rs = Cte 

The control acts in the normal direction.

rn = vn  vn = u n

The sight angle  between IM and D is given to order 1 by

=

rn r = n rs vs

 =

rn + v n 2 vs

rn = vs  which we replace in the control. 2 rn + v n =  vs 

This gives us:  •

Perfect interception

u=− •

3 3 (r + v)  u n = − 2 (rn + vn )  u n = −3vs 2  

Perfect rendezvous

1 1  2  (6r + 4v)  u n = − 2 (6rn + 4v n )  u n = − vs  + 4  2      u The acceleration n normal to the line of sight is thus expressed as a function of the sight angle  . This control manages the transverse deviation (normal to D). A correction u s along D must be added to control the time of passage in I with respect to the target motion. u=−

328

Optimization techniques

Transport method To solve the linear system (4.84), we look for a solution similar to the final condition, that is of the form (4.85)

p(t) = S(t)x(t)

Justification The solution of the linear system (4.84) is expressed with its transition matrix.

 x(t)    xx (t, t f )  xp (t, t f )   x(t f )     =  p(t)    px (t, t f )  pp (t, t f )   p(t f )  The transversality condition: p(t f ) = S(t f )x(t f ) is used to replace the final adjoint.

x f = ( xx +  xpSf ) −1 x  x = ( xx +  xpSf )x f    −1 p = ( px +  ppSf )( xx +  xpSf ) x p = ( px +  ppSf )x f The adjoint is of the form: p(t) = S(t)x(t) . with S(t) =  px (t, t f ) +  pp (t, t f )S(t f )   xx (t, t f ) +  xp (t, t f )S(t f )  def

−1

By replacing p = Sx in equations (4.84)

x x = Fx − GR −1G T p = (F − GR −1G TS)x →   T T p = −Qx − F p Sx + Sx = − (Q + F S)x

(4.86)

then eliminating x , we obtain the differential equation satisfied by the matrix S.

S = −SF − FTS + SGR −1G TS − Q

(4.87)

This Riccati equation (quadratic term in S) is integrated backwards from the known final matrix S(t f ) = Sf , chosen for example by (4.81). We deduce the initial adjoint: p(t 0 ) = S(t 0 )x(t 0 ) and then the trajectory by forward integration of the system (4.84). The matrix S(t) allows to express the control (4.83) in state feedback: u = −R −1G TSx . The resolution process by the by the transport method is depicted in figure 4-18.

Optimal control

329

Figure 4-18: Solving the QL problem by transport method. Regulator For a stationary system (constant matrices F,G,Q,R), the Riccati equation (4.87) can admit a constant solution noted S . (4.88)

−S F − FTS + SGR −1G TS − Q = 0 This can happen especially when the final time t f tends to infinity.

To calculate the matrix S , one can solve the matrix equation (4.88) directly or integrate backwards the differential equation (4.87) starting from S(t f ) = 0 until a stabilization (S  0) is obtained. This matrix must be positive. The control is then expressed in state feedback with a constant gain matrix. (4.89)

u = −C x with C = R −1G TS

This control is called a regulator. It limits the variations of x(t) and u(t) over an infinite time, as in example 4-10.

Example 4-10: Regulator

1 

A regulator is sought for a first-order system: x = − x + u .

330

Optimization techniques

− x m  x  + x m . −u m  u  + u m

The objective is to keep x and u between the bounds:  The quadratic problem is formulated as t 1 f  x2 u2  1 min J =   2 + 2  dt with x = − x + u . u 2 t0  x m u m   Equation (4.88) gives:

2 1 S + u 2mS2 − 2 = 0  xm

with the matrices: F = −

1 1 1 , G =1 , Q = 2 , R = 2 .  xm um

2  1  2 um 1 +  − 1  .  u 2m  x m2  2  1 −1 T 2 u The regulator control is: u(t) = −R G S x(t) = −  1 +  m2 − 1 x(t) .   x m  If x is not bounded (x m → ) , the optimal control is zero. u If u is not bounded (u m → ) , the optimal control is: u(t) = − m x(t) . xm

The only positive definite solution is: S =

Final constraints Assume that the final state is subject to linear constraints of the form (4.90)

(x f ) = Mf x f = c

Mf is a given matrix, c is the target value.

The quadratic-linear problem is formulated as

min J = u

t

1 f T (x Qx + u T Ru)dt 2 t0

x = Fx + Gu , x(t 0 ) = x 0 with  (x f ) = Mf x f = c

(4.91)

Conditions (4.82 to 4.84) are unchanged. Only the transversality condition on p(t f ) is modified and becomes, with the multipliers  of the final constraints

p(t f ) = M(t f )T 

(4.92)

Optimal control

331

The transport method consists in expressing the adjoint and the constraints as

p(t) = S(t)x(t) + T(t)  (x f ) = M(t)x(t) + N(t) = c

(4.93)

Justification The solution of the linear system (4.84) is expressed with its transition matrix.

 x(t)    xx (t, t f )  xp (t, t f )   x(t f )     =  p(t)    px (t, t f )  pp (t, t f )   p(t f )  Let us use the transversality condition: p(t f ) = M(t f ) to replace the final adjoint. T −1 T  x =  xx x f +  xp M f   x f =  xx (x −  xp M f )    T −1 −1 T p =  px x f +  pp M f  p =  px  xx x + ( pp −  px  xx  xp )Mf 

The adjoint is of the form (4.93): p(t) = S(t)x(t) + T(t)

S(t) =  px (t, t f ) xx (t, t f ) −1  def by posing  =  pp (t, t f ) −  px (t, t f ) xx (t, t f ) −1  xp (t, t f )  M Tf T(t) def The final constraints are also of the form (4.93).  M(t) =  xx (t, t f ) −1  def (xf ) = M(t)x(t) + N(t) by posing  = −  xx (t, t f ) −1  xp (t, t f )M fT  N(t) def

By deriving the expressions (4.93), replacing in equations (4.84) and identifying the terms in x and  , we obtain a differential system satisfied by the matrices S, T, M, N, with the final values given by the constraints (4.90). S  T  M N 

= −SF − FTS − Q + SGR −1G TS T

−1

T

= −F T + SGR G T = −MF + MGR −1G TS = MGR −1G T T

S(t f ) = 0  T T(t ) = M(t f ) with  f M(t f ) = M f given   N(t f ) = 0

(4.94)

We observe that: T = MT , because these matrices satisfy the same equations. The system (4.94) is integrated backwards from the known final conditions.

332

Optimization techniques

Suppose we solve problem (4.91) without the final constraints, which is equivalent to ignoring the multipliers  in solution (4.93). The value taken by the final constraints would then be: (xf ) = M(t)x(t) . The function (x) = Mx thus yields the free (or natural) value of the constraints if we solve the problem (4.91) from the current state x without the constraints. The multipliers  are determined from (4.93) at the initial time.

c = M(t 0 )x(t 0 ) + N(t 0 )   = N(t 0 )−1 ( c −  0 )

(4.95)

The matrix N is negative.  N = MGR −1G T M T  0  N(t)  0 for t  t f .   N(t f ) = 0

In the general case, N(t 0 ) is invertible and the formula (4.95) gives  . The initial adjoint is given by (4.93) and the trajectory is obtained by forward integration of the system (4.84). The matrices S,M, N give the control (4.83) in state feedback.

u = −R −1G TSx − R −1G T MT N −1 (c − ) with  = Mx

(4.96)

The multipliers  (4.95) and the control u (4.96) are functions of the deviation between c (target value) and  (free value without constraints). The solution of the unconstrained problem corresponds to zero multipliers:  = 0 . The resolution process by the transport method is depicted in figure 4-19.

Figure 4-19: Constrained QL resolution by transport method.

Optimal control

333

4.2.5 Robust control Consider a linear system of state x subjected to perturbations w. The observable outputs form a vector z which is a linear function of the state.

 x = Ax + Dw (4.97)  z = Cx The matrices A, C and D are constant. The vectors x and z can represent the deviations from a nominal solution. The equations (4.97) are then the variational equations of a nonlinear system. We assume that the nominal output is z = 0 and look for worst perturbations in the sense of maximizing z. For this, we consider the cost 

1 min J =  ( w T w −  z T z)dt w  t0

with   0

(4.98)

T The objective is to maximize the norm of z (term −z z ), while applying the

smallest possible perturbations (term +

1 T w w ). In the absence of this second 

term, the solution would not be bounded.

Property 4-4 gives a method for calculating the solution. Property 4-4: Worst perturbations Suppose there exists a symmetric positive definite matrix P such that: - the matrix P satisfies the Riccati differential equation

PA + AT P +  CT C +  PDDT P = 0

(4.99)

T

- the matrix A +  DD P is a Hurwitz matrix, which means that all its eigenvalues have a negative real part. Then the solution of problem (4.98) is given by

w* =  DT Px*

(4.100)

and the minimum cost is

J* = −x T0 Px 0

(4.101)

334

Optimization techniques

Demonstration The stated solution is checked by deriving the function: V(x) = x T Px .

V = x T Px + x T Px = (Ax + Dw)T Px + x T P(Ax + Dw) = x T (PA + AT P)x + 2x T PDw

= − x T (CT C + PDDT P)x + 2x T PDw since PA + AT P = − CTC −  PDDT P = − zT z −  x T PDDT Px + 2x T PDw since Z = Cx 1 1 = w T w −  zT z − (w −  DT Px)T (w −  DT Px) by factoring   Let us integrate from t 0 to t1 . t1

V(x1 ) − V(x 0 ) =  ( t0

t

1 2 1 1 2 2 w −  z )dt −  w −  DT Px dt   t0

Then take the limit t1 →  to get the cost J. 

J = ( t0

t1   2 1 1 2 2 w −  z )dt = lim  x1T Px1 +  w −  DT Px dt  − x T0 Px 0 t1 →    t0 

T The minimum of J is obtained for the perturbation: w =  D Px .

With this solution, the state equation gives: x = Ax + Dw = (A + DDT P)x . By assumption, the matrix A + DDT P has all its eigenvalues with negative real part. The system is therefore exponentially stable: lim x(t1 ) = 0 . t1 →

T 0

The optimal cost finally reduces to: J* = −x Px 0 .

Interpretation The solution can be interpreted with the L2 norms of the perturbation w and of the output z. The cost (4.98) is expressed as

J=

1 2 w 2 − z 

2 2

with z 2 =

def



 z z dt T

(4.102)

t0

Since the optimal cost is given by (4.101), we have for any perturbation w

J*  J  − x T0 Px 0 

1 2 w 2 − z 

2 2

(4.103)

Optimal control

335

For an initial state of zero, we obtain the inequality

 z2 w

(4.104)

, w

2

The gain L2 of the system (4.97) is defined as the maximum amplification factor between the perturbation w and the output z. This gain is denoted by k.

k = sup def w 0

z w

(4.105)

2 2

If the matrix P defined in property 4-4 exists, then the gain k is bounded by

1 . 

By a demonstration similar to above, we establish the following equivalence. Property 4-5: Gain L2 The gain L2 is bounded by  if and only if there is a symmetric positive definite matrix P such that 1 1  PA + A T P + CT C + PDD T P = 0      A + 1 DD T P Hurwitz matrix   

(4.106)

A sufficient condition for the gain L 2 to be bounded by  is obtained by relaxing equality (4.106) into a Riccati inequality. 1 1  PA + A T P + CT C + PDD T P  0      A + 1 DD T P Hurwitz matrix   

(4.107)

To calculate the gain k defined by (4.105), we use the transfer matrix G of the system (4.97), which relates the Laplace transforms of w and z.  x = Ax + Dw (4.108)  z = C(sI − A) −1 Dw = Gw  def z = Cx  It is shown that the gain k is the largest singular value of the matrix G( j) for all possible frequencies 

: k= G



= sup  ( G( j) ) . 

This value is called the norm H of the transfer matrix.

336

Optimization techniques

Stabilization Let us retrieve the linear system (4.97) and introduce a control u.

 x = Ax + Bu + Dw  z = Cx

(4.109)

The aim is to stabilize the output z despite the perturbation w. For this purpose, let us look for a state feedback control: u = Kx . The system takes the form  x = A f x + Dw (4.110) with A f = A + BK  z = Cx with the matrix A f of the closed loop system. Stabilization consists in searching for a gain matrix K such that: - the gain L2 is less than a given bound ; - the closed-loop system is stable. A sufficient condition is that there exists a symmetric positive definite P such that

1 1 PAf + AfT P + CTC + PDDT P  0  

(4.111)

T This condition implies: PAf + Af P  0 which is the Lyapunov condition for the

matrix A f to be stable (Hurwitz matrix).

We are thus led to search for a gain matrix K and a symmetric positive definite matrix P satisfying (4.111). This search is done by introducing symmetric positive definite matrices Q and R and a parameter   0 . • inequality (4.111) is transformed into equality by adding Q :

1 1 PAf + AfT P + CTC + PDDT P + Q = 0   •

(4.112)

the gain K is sought in the form:

K=−

1 −1 T R BP 2

(4.113)

Replacing in (4.112) the matrix Af = A + BK with K given by (4.113), we arrive at a Riccati equation.

1 1 1 PA + AT P + CTC + PDDT P − PBR −1BT P + Q = 0   

(4.114)

It is then necessary to find setting parameters Q, R,  such that this equation admits a solution P. This search can be done by a systematic procedure as described in reference [R14].

Optimal control

337

4.3 Extremals This section presents the different types of solutions to a control problem.

4.3.1 Definitions Consider a control problem in Lagrangian form without specifying the terminal conditions. tf

min J =  L(x, u, t)dt u

with x = f (x, u, t)

(4.115)

t0

The Hamiltonian depends on the adjoint p(t) and the abnormal multiplier p0  0.

H(x,u,p, t) = p0L(x,u, t) + p Tf (x,u, t)

(4.116)

An extremal is a quadruplet (x,p0 ,p,u) satisfying the following Hamiltonian system where the control minimizes the Hamiltonian (by the convention p0  0 ).

 x = H p  p = − H x

with u → min H(x, u, p, t) u

(4.117)

The extremal field (also called the Hamiltonian system flow) is the set of trajectories obtained by integration of (4.117) by varying the state and the initial adjoint. The solution of a control problem with specified terminal conditions is a particular extremal. Extremals can be normal or abnormal, regular or singular: •



an extremal is said to be normal if p0  0 , abnormal if p0 = 0 . An abnormal extremal occurs, for example, when the solution is completely determined by the constraints. This solution is then indifferent to the cost function. For a normal extremal, we usually fix p0 = 1 ; an extremal is said to be regular if H u is explicit in u, singular otherwise. For a regular extremal, the optimal control is a solution of Hu = 0 . A singular extremal requires the examination of higher order conditions.

An optimal trajectory can have regular arcs and singular arcs.

338

Optimization techniques

4.3.2 Abnormal extremal Assume that there is locally only one control law u* satisfying the constraints of the control problem. The solution of the problem is then u*, independently of the cost function. According to the PMP, this control achieves the minimum of the Hamiltonian (4.116), for any function L(x, u, t) .

Hu = p0 Lu + pTf u = 0 , L

(4.118)

This is only possible if p0 = 0 , which yields an abnormal extremal. Abnormal extremals may occur in other cases. Example 4-11 shows a control problem that admits normal or abnormal extremals depending on the initial conditions.

Example 4-11: Oscillator The aim is to bring a harmonic oscillator to rest in the minimum time from given initial conditions. The control is the acceleration bounded between −1 and +1. The problem is formulated as tf  x1(t 0 ) = x10  x1 = x 2  x1(t f ) = 0 min J =  1dt with  ,  ,  , −1  u  1 u,t f x 2 = −x1 + u  x 2 (t 0 ) = x 20  x 2 (t f ) = 0 t0 Application of the PMP The Hamiltonian is: H = p0 + p1x 2 + p2 (−x1 + u) with the adjoint (p1 ,p2 ) and the abnormal multiplier p0 .

−1 if p2  0 Applying the PMP gives: min H s.t. − 1  u  +1 → u =  u +1 if p2  0 The control u = 1 is determined by the adjoint p2 (switching function).

 p1 = p2  p2 = −p2  p2 = a cos(t + )  p2 = −p1

The adjoint equations are: 

The switches (change of sign of p2 ) are spaced by a duration of  . Representation in the phase plane We can represent in the phase plane the arcs of the trajectory for u = 1 .

 x1 = x 2 dx 2 −x1 + u  =  (x1 − u)dx1 + x 2dx 2 = 0  (x1 − u)2 + x 22 = c2  dx1 x2 x 2 = −x1 + u

Optimal control

339

− The arcs of the trajectory are semicircles with center A (−1;0) for u = −1 and

A + (+1;0) for u = +1 . The extremals are constructed backwards from the origin. The last arc to arrive at the origin is located on - the semi-circle C− (center A − , radius 1) if u = −1 ; - the semi-circle C+ (center A + , radius 1) if u = +1 . The previous arc is a semi-circle - of center A + if we end up on C− ; - of center A − if we end up on C+ . Figure 4-20 shows in the phase plane the set of initial conditions - leading to an arrival on the semicircle C+ (top); - leading to an arrival on the semicircle C− (bottom).

Figure 4-20: Penultimate arc. Continuing the study backwards, we deduce that the previous arcs are semicircles of growing size with centers alternately in A − and A + . The commutations occur on a set of semicircles obtained by translation of C− and C+ along x1 . This set of

340

Optimization techniques

semicircles plotted in figure 4-21 forms the switching curve C. The control is u = −1 above the curve C and u = +1 below it. By varying the last switch position on the semicircles C− and C+ , we generate backwards the set of all possible extremals that constitute the phase portrait of the system.

Figure 4-21: Switching curve. Only one extremal passes through each point of the phase plane (associated with given initial conditions). Figure 4-22 shows the extremal starting from the initial conditions: x1 (t 0 ) = −1.77 , x 2 (t 0 ) = −3.36 .

Figure 4-22: Extremal in the phase plane.

Optimal control

341

Abnormal extremals Let us find out if the problem admits extremals. The system is autonomous and has a free final time. The Hamiltonian is therefore constant and zero: H = p0 + p1x 2 + p2 (−x1 + u) = 0 .

x (t ) = 0 At the final time:  1 f  H = p0 + p2 u = 0 with u(t f ) = 1 . x 2 (t f ) = 0 - if p2 (t f )  0 , then p0  0 and the extremal is normal; - if p2 (t f ) = 0 , then p0 = 0 and the extremal is abnormal.

The switches are spaced by  and occur when p2 cancels. For an abnormal extremal, the last semicircle C− or C+ is completely traversed and the switches occur on the axis x1 . The problem admits an infinite number of abnormal extremals, passing through the points with coordinates (x1 = 2k ; x 2 = 0) , k  . Depending on the initial condition, the extremal leading back to the origin can thus be normal or abnormal.

4.3.3 Singular extremal The optimal control is usually obtained by solving the equation: Hu = 0 .

A singular extremal occurs when the derivative H u is not explicit in u. This occurs in the frequent case of an affine controlled system of the form

min J = (xf ,t f ) with x = f (x,t) + g(x,t)u u

(4.119)

In this case, higher order conditions are required to determine the optimal control. These conditions are presented in section 4.4.3. The Goddard problem illustrates the determination of singular extremals.

Example 4-12: Goddard problem (from [R3]) The aim is to maximize the altitude reached by a rocket fired vertically from the ground. Modelling The assumptions about the motion are as follows:

342

• • • • •

Optimization techniques

the state is composed of the rocket altitude h, velocity v and mass m; the rocket takes off from the ground (h 0 = 0 , v0 = 0) and thrusts vertically; the initial total mass m0 and the propellant mass me are fixed; the forces acting on the rocket are the weight W, the thrust T, the drag D; the control is the thrust level varying between 0 and Tmax. When all the propellants are consumed, the thrust cancels. The mass flow rate is: q = T / ve where ve is the gas ejection velocity.

h = v  The state equations are:  v = (T − D − W) / m . m = − T / v e 

The weight is: W = mg . The acceleration of gravity g is assumed to be constant.

1 2

2 The drag is: D = v SCD .

S is the reference surface, C D is the drag coefficient,  is the atmospheric density depending on the altitude by an exponential model:  = 0e



h H

.

0 is the density at the ground, H is the scale factor of the atmosphere. Control problem The objective is to find the thrust law that maximizes the altitude reached by the rocket. The control problem is formulated as h = v h(t 0 ) = 0   min J = − h(t f ) with v = (T − D − W) / m and v(t 0 ) = 0 T,t f m = − T / v  e m(t 0 ) = m0 , m(t f ) = m0 − me  Application of the PMP The Hamiltonian is: H = p h v + p v

T−D−W T − pm with adjoint (ph ,pv ,pm ). m ve

D   +g+ T.  m  mve

Noting  = vepv − mpm , the Hamiltonian is: H = ph v − p v 

T = 0 if   0 and T = ? if  = 0 . Applying the PMP gives: min H   0TTmax T = Tmax if   0 The optimal thrust depends on the switching function:  = vepv − mpm . A singular arc can occur if the function  cancels on an interval.

Optimal control

343

Search for singular arcs Let us look for conditions on the adjoint (ph ,pv ,pm ) to obtain a singular arc. If  cancels on an interval, its successive derivatives are zero. The Hamiltonian is moreover constantly zero, since the system is autonomous with free final time.

 H = 0  We have the system denoted (S):  = 0   = 0 

→ ph v + pv

T−D−W T − pm = 0 m ve

→ ve p v − mp m = 0 → ve p v − mp m − mp m = 0

The adjoint equations are, denoting D h and D v the derivatives of the drag h −  1 2 1 H 2 D =  v SC =  e v SC D  D 0 2 2  D 1 2  D  with D h = = v SC D =− .  h 2  h H  D 2D  D v = v = vSCD = v  We replace m,pv ,pm in  , using also  = vepv − mpm = 0 to replace pm .

p v Dh  p h = − H h = m  pvDv  p v = − H v = − p h + m  T−D  p m = − H m = p v m 2 

pD  T T − D pv  v    = ve pv − mpm − mpm = ve  −ph + v v  + pm − p v = 1 + 2 e  D − v e p h m  ve m m v   ph v − p v D + W =0 m   p v ve − pm m = 0 The system (S) reduces to:   p m − p  2 + 1  D = 0  v  h  v ve  According to the PMP the adjoint (ph ,pv ,pm ) cannot be identically zero. For a non-zero solution to exist, the matrix of the linear system (S) must be singular. Its determinant is

v 0



D+W m ve

2 1  m − + D  v ve 

0  v − m = mW − mD 1 +  = 0  ve  0

344

Optimization techniques



When the function  = W − D 1 +



v  cancels, a singular arc is possible. ve 

The singular surface is the set of states (h , v, m) such that

 v  = W − D 1 +  = 0 .  ve  Let us study the evolution of the function  along the flight. The velocity is zero at the beginning of the flight (take-off) and at the end of the flight (apogee). (t 0 ) = m0g  0 Since the drag is zero at these times, we have:  . (t f ) = mf g  0 At the beginning of the flight, the weight W decreases (loss of mass), while the velocity and drag increase. The function  is therefore decreasing and it may cancel or not. According to the evolution of  and  , the three possible control structures are

Tmax → 0  Tmax → Tsin g → 0  Tmax → Tsin g → Tmax → 0 Expression of the singular thrust Let us find the expression for the thrust on a singular arc. To do this, we derive the switching function  until the control T appears. The first derivative has already been calculated:  = This derivative is constantly zero on the singular arc. 2 1   = 0  p vG − mph = 0 with G =  +  D def v ve  

pv  ve  1 + 2  D − ve p h . m v

We derive a second time: pvG + pvG − mph − mph = 0 with G = Gh h + G v v . Using the state and adjoint equations giving (h,v,m,ph ,pv )

 G D Tsin g  G v +  = G + (D + W)G v − mvG h + mDh ve  ve 

then replacing G and its derivatives, we get the thrust formula on a singular arc.  mv2  v Tsin g 1 + 4 + 2 2 = D(1 + 2) +  2D + 2W + = e  (1 + ) with  def H  v 

(

)

Optimal control

345

The trajectory necessarily starts with a regular arc with maximum thrust T max (because (t 0 )  0 ). A singular arc is possible if the functions  (switching) and  (singular surface) cancel simultaneously. The thrust becomes then variable Tsin g (h, v,m) and the trajectory follows the singular surface. The singular arc is followed as long as Tsin g  Tmax or until the propellants are exhausted. The following application shows a solution of the form Tmax → Tsin g → Tmax → 0. Numerical application The numerical data are summarized in the following table. m0

me

100 kg

90 kg

Tmax

ve

SCD

0

H

g

2 000 N 2 000 m/s 0.1 m2 1.2 kg/m3 5 000 m 10 m/s2

The solution of the form Tmax → Tsin g → Tmax → 0. is plotted in figure 4-23.

Figure 4-23: Thrust law with a singular arc (for me = 90 kg). The structure of the solution depends on the available propellant mass: - if me  81.3 kg , the solution is of the form: Tmax → Tsin g → Tmax → 0 ; - if 16.1 kg  me  81.3 kg , the solution is of the form: Tmax → Tsin g → 0 ; - if me  16.1 kg , the solution is of the form: Tmax → 0 .

346

Optimization techniques

In the case me = 90kg shown in figure 4-23 a regular control Tmax → 0 would give a burn time of 90 s (instead of 125 s) and would terminate at a maximum altitude of 236.8 km (instead of 300.6 km). The solution Tmax → 0 is in this case less good than Tmax → Tsin g → Tmax → 0 . These two solutions are compared in figure 4-24.

Figure 4-24: Comparison of singular solution and maximum thrust solution.

4.3.4 Neighboring extremals Consider a free final time problem with final constraints.

 x = f (x, u, t)  min J =  L(x, u, t)dt + (x f , t f ) with x(t 0 ) = x 0 u,t f t0 (x , t ) = 0 f f  tf

(4.120)

The solution is an extremal satisfying the equations x = Hp  p = − H x H = 0  u



q

  x(t f ), t f  = 0  with p(t f ) =  x [x(t f ), t f , ] H(t ) = − [x(t ), t , ] f t f f 

(4.121)

is the final constraint multiplier. The function  is defined by

[x(t f ), t f , ] = [x(t f ), t f ] +  T [x(t f ), t f ] def

(4.122)

This extremal is associated with the initial state x 0 and the constraints  = 0 . We will call it the nominal or reference extremal.

Optimal control

347

Assume that the initial state and the constraint threshold vary by x 0 and f .

x(t 0 ) = x 0 x(t 0 ) = x 0 + x 0 (4.123) →   (x f , t f ) = 0 (x f , t f ) =  f The new extremal is close to the nominal extremal as shown in figure 4-25. We will call it a neighboring extremal.

Figure 4-25: Neighboring extremal. The neighboring extremal can be calculated from the nominal extremal as follows. Property 4-6: Neighboring extremal The deviations (x , p, ) between the nominal extremal (x0 ,  = 0) and the neighboring extremal (x 0 + x 0 ,  = f ) follow the differential equations

x = (f xT − f uT H −uu1 H xu )x − f uT H −uu1f u p  −1 −1 p = (H ux H uu H xu − H xx )x + (H ux H uu f u − f x )p and satisfy the final conditions   xx  T  x  T  x

x 0 T

 x   x f   pf   =  +  T   def          =   f  with  = t + H =  + L  def    t f   0 

(4.124)

(4.125)

348

Optimization techniques

Demonstration (see [R3]) We expand the equations of the extremal (4.121) to order 1. Differential equations For the differential equations and the derivative H u , we have

x = H Tpx x + HTpu u + HTppp x = f xT x + f uT u x = Hp     T T T p = − H x → p = −H xx x − H xu u − H xpp → p = −H xx x − H ux u − f x p H = 0   −1 T T T  u u = −H uu (H xu x + f u p) 0 = H ux x + H uu u + H upp The last equation gives u as a function of x , p assuming Huu is invertible. Replacing u in the first two equations gives (4.124).

Final conditions Variations x 0 and f lead to variations t f , x f , pf ,  .

dx f = x(t f )t f + x f . dpf = p(t f )t f + pf

The total changes in the state and the final adjoint are:  The transversality condition on x f is expressed with

 =  +  T → x [x(t f ), t f , ] = p(t f ) The transversality condition on t f is expressed with  = t + H → [x(t f ),t f , ] = 0 T We observe that  can be written with the total derivative:  = x x + t .

 = t + H = ( − Tx x) + (L + pT x) =  + L because x = p at t f Each equation is expanded to order 1 using x = x and   =  =  .

  x(t f ), t f  =  f  Tx x f +  Tx x(t f )t f +  Tt t f =  f   x [x(t f ), t f , ] = p(t f ) →  xx x f +  xx x(t f )t f +  xt t f +  x  =pf + p(t f )t f [x(t ), t , ] = 0  T T T T f f  x x f +  x x(t f )t f +  t t f +   = 0 

Grouping the terms into x f , t f ,  , we obtain

 Tx x f + t f =  f   xx x f + ( x − p)t f +  x  = p  T +  T  = 0  x x f + t f

Optimal control

349

The term  x − p is simplified by using x = p at t f .

 x =  xt +  xx x =  xt +  xx f      x − p = ( t + L +  x f ) = ( t + H) =  T T x x x −p = H x = L x + f x p = L x + f x  x Replacing  x − p in the second equation gives (4.125). Equations (4.124) and (4.125) defining the neighboring extremal form a two-point boundary value problem with x 0 given and pf constrained. This problem is solved by the transport method. Transport method The system (4.124) and the final constraints (4.125) are linear of the form  x = Ax − Bp  T p = −Cx − A p  pf    xx    T   f  =   x  0   T    x

x 0 T

A = f xT − f uT H −uu1 H xu  −1 with B = f uT H uu fu  −1 C = H xx − H ux H uu H xu  x   x f   =  +  T         with   =  t + H =  + L    t f 

(4.126)

The variations (x0 , f ) are fixed, the unknowns are (p0 , t f , ) . The transport method (section 3.5.4) consists in searching for a linear solution in the same form as the final conditions (the solution is known to be of this form).  p(t)   S    T   f  =  M  0   T   

M    x(t)    N      T    t f 

(4.127)

The matrices S,M, N,  ,  ,  satisfy the differential system S = − SA − A TS + SBS − C  T M = (SB − A )M  N = M T BM   T  = (SB − A )  T  = M B   =  T B

S(t f ) =  xx (t f ) M(t ) =  (t ) f x f   N(t f ) = 0 with  (t f ) =  x (t f ) (t f ) = (t f )    (t f ) =  (t f )

(4.128)

350

Optimization techniques

Demonstration (see [R3]) The final conditions can be deduced directly from (4.126) by identification. The differential equations are obtained by deriving (4.127).

 p(t)   S M    x(t)     T     f  =  M N      T    T    0        t f   p   S M    x   S M    x            0  =  M T N      +  M T N    0   0    T T    t    T T    0        f 

 x = Ax − Bp and replacing x , p :  with p(t) = Sx(t) + M + t f . T p = −Cx − A p

The nominal extremal has been previously calculated and the nominal values of (xf ,pf ,t f , ) are known. The matrices S,M, N,  ,  ,  at the final time t f are calculated by (4.128). Backward integration yields the matrices at the initial time. The unknowns (p0 , t f , ) are then solutions of the system (4.127) at t 0 .  p0   S    T   f  =  M  0   T   

M   x 0     N   (t 0 )     t  T    f

(4.129)

The solution is expressed in terms of the given variations (x0 , f ) .

 = N  f − M x 0     T T   x 0 +   t f = −   p = (S − MN −1M T )x + MN −1 0 f  0 −1

T

 T M = M −    T with  N = N −     T S = S −  

(4.130)

Optimal control

351

Reduced transport method A possible simplification is to eliminate t f from the third final condition (4.127).

t f = − −1  Tx x f +  T  . The final conditions are reduced to

 S(t f ) M(t f )T   x f   pf    xx −  x  −1 Tx  x −  x  −1 Tx   x f  = =          T −1 T −   −1 T     def  M(t f ) N(t f )          x −    x

The transport method is then applied to the reduced form. S = −SA − A T S + SBS − C   p(t)   S M   x(t)   T = with M = (SB − A )M       T   M N       T  N = M BM 

The matrices S,M, N follow the same differential equations as S,M, N . If the final time is fixed, we find:  =  =  = 0 and S = S , M = M , N = N .

Figure 4-26 depicts the calculation of the neighboring extremal from the nominal extremal and from the variations (x0 , f ) .

Figure 4-26: Calculation of the neighboring extremal.

352

Optimization techniques

4.3.5 State feedback control The backward integration of (4.128) gives the matrices S,M, N,  ,  ,  (4.130) as a function of time. These matrices allow to express the corrections on the control u(t) and on the final time t f to be applied at time t as a function of the state deviations x(t) and constraints deviations  observed at this same time.

u = −H −uu1 ( H xu + f u (S − MN −1M T ) ) x + f u MN −1      −1 T T −1 T T −1 t f = − ( −  N M )x −  N  

(4.131)

Demonstration The final time variation t f is given by (4.130) by replacing  . −1 The variation u is given by Hu = 0 to order 1: u = −Huu (H xu x + f u p) .

Equations (4.127) allow to express p,  , t f as a function of x, f at time t. The calculation is similar to the one performed at the initial time, giving the formulas (4.130). Substituting p,  , t f , we obtain the formula (4.131).

The formulas (4.131) can be put into the more compact form

 u(t) = −K x (t)x(t) − K  (t)   t f = −k x (t) x(t) − k  (t) 

(4.132)

The matrices Kx ,K ,k x ,k  are the gains calculated along the nominal trajectory and stored as a function of the elapsed time t − t 0 or of the remaining time t f − t (also called time-to-go). The state deviations x(t) between the actual and nominal states are estimated from measurements made by sensors. The constraint deviations  represent an optional change of target that may occur during the trajectory. The feedback control in the form of (4.132) allows the trajectory to be corrected in real time according to the perturbations encountered. Figure 4-27 illustrates the state feedback correction process.

Optimal control

353

Figure 4-27: Control correction in state feedback.

Example 4-13: Launch into orbit (from [R3]) Let us retrieve the launch into orbit problem of example 4-5. The aim here is to reach the orbit altitude z c with a zero vertical velocity, while maximizing the final horizontal velocity at a fixed final time. The acceleration of constant modulus a is oriented by the pitch angle  . The problem is formulated as tf z(t f ) = zc z = v z min J = −v x (t f ) = −a  cos  dt with  and    vz = a sin  − g vz (t f ) = 0 t0 Nominal extremal This problem is solved in the same way as the minimum time problem solved in example 4-5. The control (t) follows a linear tangent law of the form

tan f − tan  = −c(t f − t) . Switching to the variable  , we obtain the trajectory equations of example 4-5. Neighboring extremals The matrices S, M , N involved in the transport method (4.128) must be computed with  =  =  = 0 , as the problem is a fixed time problem. The useful matrices for this calculation are the following.

354

Optimization techniques

Derivatives of f (dynamics)

v   0 0 f =   fx =   , f u = ( 0 , a cos  )  a sin  − g  1 0 

Derivatives of H (Hamiltonian)

0 0 0 a H xx =   , H ux =   , H uu = a cos  − p va sin  = cos  0 0 0

Derivatives of  (constraint)

 z(t f ) − zc  1 0  =   x =    0 1  v(t f )  Matrices A,B,C

A = f xT − f uT H −uu1 H xu  T −1 B = f u H uu f u  −1 C = H xx − H ux H uu H xu

0 1  0 0 3 0 0  A=  , B = a cos    , C=   0 0 0 1  0 0

The matrices S,M, N are calculated by integrating backwards the system (4.128). T 0 0 S = −SA − A S + SBS − C → S(t) =    S(t f ) =  xx (t f ) 0 0  M11 = 0 , M11 (t f ) =1  T M 21 (t f ) = 0 M = (SB − A )M M = 0 , →  21   M12 = − M11 , M12 (t f ) = 0 M(t f ) =  x (t f )  M 22 = − M 21 , M 22 (t f ) =1  1 tf − t  → M(t) =   1  0

 N = M T BM   N(t f ) = 0

 M11 = 1 M = 0  →  21 M12 = t f − t  M 22 = 1

2  N11 N12  tf − t  3  (t f − t) →   = a cos    1   N 21 N 22   tf − t

The terms of the matrix N are integrated by changing to the variable  .

tf − t =

tan  − tan f d  dt = − c ccos2 

Optimal control

355

dN11 dN11 a = a(t f − t)2 cos3   = 3 (tan  − tan f )2 cos  dt d c  a  sin f − sin  1  1   → N11 = 3  + ln  tan f +  − ln  tan  +  2 c  cos f cos f  cos     

Term N11 :

with N11 (t f ) = 0

dN12 dN12 a = a(t f − t)cos3   = (tan  − tan f )cos  dt d c2 a cos(f − ) − 1 → N12 = 2 with N12 (t f ) = 0 c cos f

Term N12 :

dN 22 dN 22 a = a cos3   = − cos  dt d c a → N22 = (sin f − sin ) with N22 (t f ) = 0 c

Term N22 :

Control correction The control correction is given by (4.131), with (S,M, N) = (S,M, N) .

u = −H−uu1 ( H xu + f u (S − MN −1MT ) ) x(t) + f u MN −1 

This yields the correction  as a function of the state and constraint deviation.

 zf   z  .  and the constraint deviation is   v   vf 

Noting v = vz , the state deviation is 

The correction is: = Kz z + (t f − t)v −zf  + K v v −vf 

 cos 2  (N 22 (t f − t) − N12 ) K z = det N with the gains:  2 K = cos  (N − N (t − t)) 12 f  v det N 11 The time-dependent gains K z and K v are calculated on the nominal trajectory.

They are associated with predicted deviations in final altitude and final velocity. If the targeted conditions do not change during the trajectory (zf = 0 , vf = 0) , the correction takes the simpler form K 2 = K z / K1  = K1 (v + K 2z) with  . K1 = K v + K z (t f − t)

356

Optimization techniques

Figure 4-28 shows the evolution of the gains K1 and K 2 along a trajectory aiming at an altitude of 200 km in 300 s with the acceleration a = 3g ( g = 9 m  s −2 ). The nominal solution gives (example 4-5): 0 = 28.08deg and = − 0.0035 . The gains are plotted in logarithmic scale as log(−K) .

Figure 4-28: Gain evolution along the nominal trajectory.

Implicit guidance consists in applying a control correction of the form (4.132) with precalculated gains. This correction based on a local linearization in the neighborhood of the nominal solution does not give the true extremal from the current state. In contrast, explicit guidance consists in recalculating the true extremal from the current state. This strategy is more computationally expensive, but it can be more robust in the presence of strong perturbations.

4.3.6 Hamilton-Jacobi-Bellman equation Consider a free final time problem with final constraints.

 x = f (x, u, t)  min J =  L(x, u, t)dt + (x f , t f ) with x(t 0 ) = x 0 u,t f t0 (x , t ) = 0 f f  tf

(4.133)

The solution and the cost J depend on the initial point (x 0 ;t 0 ) . The value function

V(x, t) is defined as the minimum cost starting from (x;t) .

Figure 4-29 shows four different extremals obtained by varying the initial time and initial state.

Optimal control

357

Figure 4-29: Endpoints and value function.

Property 4-7: Hamilton-Jacobi-Bellman equation The function value V(x, t) satisfies the equation (HJB).

min H(x,u,Vx ,t) + Vt = 0 u

(4.134)

T where H(x,u,p, t) = L(x,u, t) + p f (x,u, t) is the Hamiltonian of problem (4.133)

and Vx =

V V , Vt = are the partial derivatives of the value function. t x

Demonstration Let u* be the optimal control and let us place ourselves at any point (x1;t1 ) of the optimal trajectory. According to Bellman's optimality principle ("Any subpath of an optimal path is itself optimal"), the optimal control from (x1;t1 ) is u*. Otherwise, the solution of problem (4.133) could be improved with another control from (x1;t1 ) . The value function in (x1;t1 ) is obtained with the control u*. tf

V(x1 , t1 ) =  L(x,u*, t)dt + (x f , t f ) t1

358

Optimization techniques

The trajectory from (x1;t1 ) is broken down into two parts:

- the control u* from t1 to t1 + t1 leads to x1 + x1 = x1 + f (x1,u*,t1 )t1 ;

- the optimal path from (x1 +x1 ;t1 +t1 ) has a cost V(x1 +x1 ,t1 +t1 ). The cost on the second part is obtained with the control u* (still according to Bellman's optimality principle). The optimal cost from (x1;t1 ) is the sum of these two contributions.

V(x1 , t1 ) =

t1 +t1



L(x,u*, t)dt + V(x1 + x1, t1 + t1 )

t1

Let us expand each term to order 1 for t1 small.

V(x1 , t1 ) = L(x1 ,u*, t1 )t1 + V(x1, t1 ) + VxTx1 + Vt t1 with x1 = f (x1,u*,t1)t1 T After simplification, we obtain: L(x1 ,u*, t1 ) + Vx f (x1 ,u*, t1 ) + Vt = 0

which can be written as:

H(x1 ,u*,Vx ,t1) + Vt = 0

The point (x1;t1 ) on the optimal trajectory is arbitrary. According to the PMP, the control u* minimizes the Hamiltonian at any point on the optimal path. This gives the equation HJB (4.134).

If we can solve the HJB equation, we can then define the adjoint by: p = Vx . We thus retrieve the influence functions (4.25) and the adjoint equations.

Adjoint equations from HJB Let us calculate the derivative of the adjoint.

p = Vx  p = Vx = Vxx x + Vxt = Vxx f (x,u*, t) + Vxt

The HJB equation gives

Vt = −H(x,u*,Vx , t) = −L(x,u*, t) − VxTf (x,u*, t)

We derive with respect to x.

Vtx = −Lx (x,u*, t) − Vxx f (x,u*, t) − VxTf x (x,u*, t) Replacing in p , we obtain p = −Lx (x,u*, t) − VxTf x (x,u*, t) = −L x (x,u*, t) − p Tf x (x,u*, t) which is the adjoint equation: p = −Hx (x,u*,p,t) .

Optimal control

359

Non-differentiable solution Equation HJB (4.134) assumes the value function to be of class C1. This strong assumption is not necessarily satisfied as example 4-14 shows.

Example 4-14: Non-differentiable HJB solution

x = xu Consider the problem with fixed final time: min J = x(t f ) with  −1u +1 x(t 0 ) = x 0 The HJB equation for this problem is: min (Vx xu) + Vt = 0  − Vx x + Vt = 0 −1u +1

Let us look for the optimal control by examining the sign possibilities of x 0 : - if x 0  0 , we should take u = +1 to have x  0 and thus minimize x(t f ) :

 x = + x  x(t f ) = x 0e+ (tf −t0 ) - if x 0  0 , we should take u = −1 to have x  0 and thus minimize x(t f ) :  x = − x  x(t f ) = x 0e−(tf −t0 ) - if x 0 = 0 , then x(t f ) = 0 , u .

The value function is thus defined by  xe+ (t f − t ) if x  0 → Vx x = V  0 , Vt = −V  V(x, t) =  0 if x = 0  − (t f − t ) if x  0 → Vx x = V  0 , Vt = + V  xe This function satisfies the HJB equation, but it is not differentiable in x = 0 . The HJB equation of this problem does not have a differentiable solution on

.

Sub-gradient and over-gradient To generalize the HJB equation to non-differentiable solutions, we define the suband over-gradient of a function. n → in x 0 is a vector g n satisfying locally A sub-gradient of f :

f (x)  f (x 0 ) + g T (x − x 0 ) n

An over-gradient of f :



in x 0 is a vector g

n

satisfying locally

T

f (x)  f (x 0 ) + g (x − x 0 ) − The sub-differential f (x 0 ) of f in x 0 is the set of its sub-gradients.

The over-differential f (x 0 ) of f in x 0 is the set of its over-gradients. These definitions are illustrated in figure 4-30. +

360

Optimization techniques

Figure 4-30: Sub- and over-gradient, sub- and over-differential. If the function f is differentiable in x 0 , then its gradient f (x 0 ) is the unique sub− + and over-gradient: f (x0 ) = f (x 0 ) = f (x 0 ) .

Example 4-15: Sub-gradient and over-gradient Consider the function

 0 if x  0  f (x) =  x if 0  x  1   1 if 1  x

This function is derivable except in 0 and 1. Let us calculate its sub-differential and over-differential in 0 and 1.

f − (0) = [0; + [ For x 0 = 0 :  + . f (0) =  f − (1) =  For x 0 = 1 :  + . f (1) = [0;0,5]

Optimal control

361

Viscosity solution Consider a partial differential equation (PDE): F x,f (x), f (x) = 0 . The unknown is the function f :

n

→ . n

n

→ . The equation (PDE) is defined by the function F :   A continuous function f is called: + - a sub-viscosity solution if: F x,f (x),g  0 , x , g f (x) ;

- an over-viscosity solution if: F x,f (x),g  0 , x , g f (x) ; - a viscosity solution if it is both a sub-viscosity and an over-viscosity solution. −

Example 4-16: Viscosity solution Consider the partial differential equation: 1 − f (x) = 0 with f :

→ .

For this PDE, the function F is defined as: F(x,f ,g) = 1 − g . A classic solution of class C1 is: f (x) =  x + c . Let us show that there is also the solution of viscosity: f (x) = x : - this function is continuous; - for x  0 , the function f is derivable and it satisfies the equation; - for x = 0 , we need to examine the sub- and over-gradients of f. − Sub-gradient in x 0 = 0 : f (x 0 ) = [−1, + 1]

→ F(x0 ,f (x 0 ),g) = 1 − g  0 , g f − (x 0 ) → f is an over-viscosity solution in x 0 = 0 . + Over-gradient in x 0 = 0 : f (x 0 ) = 

→ f is a sub-viscosity solution in x 0 = 0 . f is therefore both a sub-viscosity and an over-viscosity solution.

The notion of a viscosity solution extends the set of solutions of the HJB equation to continuous functions. It can then be shown that the value function V(x, t) is the unique viscosity solution of the HJB equation.

362

Optimization techniques

4.4 Optimality conditions of second order This section presents the sufficient conditions of optimality derived from the auxiliary minimum problem and the conditions associated with singular arcs.

4.4.1 Auxiliary minimum problem Consider a free final time problem with final constraints.

 x = f (x, u, t)  min J =  L(x, u, t)dt + (x f , t f ) with x(t 0 ) = x 0 u,t f t0 (x , t ) = 0 f f  tf

(4.135)

The augmented cost J a is defined with the adjoint p and the multipliers  . tf

J a =   L + pT (f − x)  dt +  +  T

(4.136)

t0

We define the normal Hamiltonian H (with p0 = 1 ) and functions  and  .

H = L + pT f  T  =  +     =  + L

(4.137)

The optimality conditions are established from the first and second variations of the augmented cost considering variations x, u, p, t f , x f . These variations must be feasible with respect to the final constraints (x f , t f ) = 0 . To generalize the results, we also consider variations x 0 on the initial state and

f on the final constraints which become: (xf ,t f ) = f . The conditions of optimality of an extremal will be established for x 0 = 0 and f = 0 . Property 4-8: First and second variation of the augmented cost The first variation J a is given by

J a =

tf

 (H

t0

x

+ p)T x + H Tu u + (f − x) T p  dt T f

T

T 0

(4.138) T

+ ( x − p) x f +  f t f +   + p x 0 −   f

Optimal control

363

The second variation  2 J a in the neighborhood of an extremal is given by T

tf

T

 x   H xx H ux   x   x   Ja =        dt +   u   H xu H uu   u   t f t0  2

  xx  x   x   T     x    t f

(4.139)

Demonstration The augmented cost (4.136) is put into the form: J a =

tf

 ( H − p x ) dt +  . T

t0

Let us show successively the formulas giving the first and second variation of the augmented cost. First variation We apply variations x, u, p, x f , t f ,  and also x 0 , f . tf

 (H x + H u + f

J a =

T x

T u

T

p − p T x − x T p)dt

t0

+ (H − p T x)f + Tx (x f + x f t f ) +  t t f +  T −  T f

including the variation of the integral bound and the contribution xf t f on x(t f ). We integrate by parts the term:

tf

 p x dt = (p x) T

T

t0

tf

tf

− (p x) t0 −  pT x dt . T

t0

T x

By introducing the total derivative:  =  x + t and with  =  , we obtain J a =

tf

 (H

t0

x

+ p)T x + H Tu u + (f − x) T p  dt

+ ( x − p)fT x f +  f t f +  T  + p 0T x 0 −  T f

The stationarity conditions are (for x 0 and f fixed)

J a = 0 , x, u, p, x f , t f , 

x = f  f = 0    p = − H x ,   f = 0 H = 0 p =  x  u  f

(equations E)

364

Optimization techniques

Second variation We apply again variations x, u, p, x f , t f ,  and x 0 , f on J a .

2 J a =

tf

 x

T

(H xx x + H ux u + H px p + p) + u T (H xu x + H uu u + H pu p)

t0

+ p T (f xT x + f uT u − x)  dt + (H x + p)T x + H Tu u + (f − x) T p  t f f

(integral bound)

+ x Tf   xx (x + xt) +  xt t +  x  − p − pt f + t f   Tx (x + xt) +  t t +  Tu u +  T   f +  T ( Tx x + t)f + p T0 x 0 −  T  f We integrate by parts the term:

tf

tf

t0

t0

T T T T  x pdt = (x p)f − (x p)0 −  x pdt .

2

The variation  J a is to be evaluated in the neighborhood of an extremal. Using equations (E) satisfied on the extremal and expressing the derivatives of  , 

 =  Tx x +  t    ( ) x = = Txx f + Tx f x +  tx =  x + Tx f x T T   =  x x +  t =  x f +  t  x ,     =   = d x = T f +  x xx tx  =  dt    we obtain after grouping the terms 2 J a =

tf

 x

t0

T

H xx x + x T H ux u + u T H xu x + u T H uu u + 2p T (f xT x + f uT u − x)  dt

+ x fT ( xx x +  x t)f + t f ( Tx x + t)f + 2 T ( Tx x + t −  )f

The first-order expansion of the state equation and of the constraint (considering x = f xT x + f uT u  x = f (x, u, t)  the variation f ) gives:   T  x x f + t f =  f (x f , t f ) =  f which eliminates the associated terms in 2 J a . There remains in matrix form T

T

tf  x   H xx H ux   x   x    xx  x   x  2 J a =          dt +    T u   H xu H uu   u   t f   x    t f t0 

Optimal control

365

J a = 0 , u , t f feasible . The optimality conditions of order 1 and 2 are:  2  J a  0 The variations u and t f are feasible if they satisfy the final constraints. The first-order condition leads to the extremal equations (4.121) recalled here.

x = f  f = 0    p = − H x ,  f = 0 H = 0 p =  x  u  f

J a = 0 , u , t f

(4.140)

To verify the second-order condition, we look for the minimum value that the second variation (4.121) can take for feasible variations u and t 0 in the neighborhood of an extremal. The deviations x propagated to the final time must satisfy the final constraints (value f ). This leads to the following accessory minimum problem. T

T

t 2 J a 1 f  x   H xx H ux   x  1  x  min =       dt +   u,t f 2 2 t 0  u   H xu H uu   u  2  t f

  xx  x   x   T     x    t f

x = f xT x + f uT u with  T  x x f + t f =  f

(4.141)

The problem is formulated here in a general way for fixed variations x 0 and f of the initial state and of the final constraints. The optimality conditions will be established by considering zero variations: x 0 = 0 and f = 0 . The derivatives of H,  and  are evaluated on the reference extremal. The variables are the deviations u and t f from the reference extremal. Property 4-9: Solution of the auxiliary minimum problem The solution of the auxiliary minimum problem is the neighboring extremal defined by (4.124) and (4.125), and the cost variation at order 2 is given by tf

T

 x 0   S − M N −1M T  J a =  v H uu v dt +    −1 T   f   N M t0 2

T

with v = u + H def

−1 uu

M N −1   − N −1  t

 x 0      f  0

(4.142)

(H xu + f uS)x + f u M + f u t f 

where the matrices S, M and N are determined by equations (4.128) and (4.130).

366

Optimization techniques

Demonstration (from [R3]) Stage 1 Let us first show that the solution of (4.141) is the neighboring extremal associated with x 0 and f . The auxiliary problem (4.141) is a problem with final constraints and with a parameter t f involved in the final cost. We write its optimality conditions by noting pq the adjoint and H q the Hamiltonian. T

1  x   H xx Hux   x  T T T Hq =       + pq (f x x + f u u) 2  u   H xu Huu   u  The optimal control u minimizes the Hamiltonian H q . −1 min Hq  Huu u + H xu x + f u pq = 0  u = −Huu (H xu x + f u pq ) u

The adjoint equations are: pq = −

H q x

= −H xx x − H ux u − f x pq .

We introduce the multipliers  q of the final constraints. The transversality conditions (4.53) give: pq (t f ) = xx x f +  x t f + xq . The condition (4.35) on the parameter t f gives tf

 x f + t f + q +  T x

Hq

t f t0

dt = 0   Tx x f + t f +  q = 0

Let us group these optimality conditions by noting pq = p and  q =  . noted

noted

 x f +  t f x = f x + f u =  f   p = −H xx x − H ux u − f x p with  xx x f +  x t f +  x  = p(t f )   T −1 u = −H uu (H xu x + f u p)  x x f +  t f +   = 0 We retrieve the equations of the neighboring extremals (4.124) and (4.125). T x

T u

T x

Stage 2 2 Next, let us calculate the value of  J a . 2 We need to calculate the value of  J a given by (4.139) on the neighboring

extremal associated with x 0 and f .

Optimal control

367

The following relation is used

 x T  S M    x    x   H xx H ux   x  d    T    T    = v H uu v −     M N          dt    T  u   H xu H uu   u   T    t f   t  f    −1 with v = u + H uu (H xu + f uS)x + f u M + f u t f  T

def

This relation is verified by deriving and using equations (4.126) and (4.128) giving the derivatives of x and of the matrices S,M, N, , ,  . The (very long) calculation is not detailed here. With this formula and by expressing the final term as a function of the matrices S, ,  , the second variation (4.139) takes the form tf

 x T  S M   x   T    T     x   S    x  2 T  J a =  v H uu v dt −     M N      +    T    (t f ) t0  t    T T   t    t f       t f   f   t  f   0 tf

which becomes by simplifying the terms in S, ,  at t f tf

T

tf  x   S 2 J a =  vT H uu v dt +    T  t f    t0

 x T  0 M 0  x      T    x        (t 0 ) −     M N         t f   t   0 T 0  t    f   t  f  

0

T

The last term is expressed using (4.127): f = M x + N + t f .

 x        t   f

T

 0 M  T M N  0 T  T The term   f tf

0  x        = 2 T (M T x + t f ) +  T N = 2 T f −  T N  0   t f  is constant and N(t f ) = 0 according to (4.128). There remains

 x   J a =  v H uu v dt +    t f  t0

T

 S    x  T  T    (t 0 ) −  N(t 0 )      t f  With the relations (4.130) giving t f ,  as a function of x 0 , f , we have 2

T

T

T

 x 0   S − M N−1MT M N−1   x 0   x   S    x  T (t ) −  N(t )  =          T   0 0 −1 T − N−1 t  f   t f       t f   f   N M 0

which leads to the formula (4.142).

368

Optimization techniques

4.4.2 Sufficient conditions of minimum Consider an extremal of the problem (4.135), defined by equations (4.140). The matrices S, M and N associated with neighboring extremals are defined by equations (4.128) and (4.130). Theorem 4-10 gives sufficient conditions for the extremal to be a minimum. Theorem 4-10: Sufficient conditions of local minimum An extremal is a local minimum if it satisfies the following conditions: •

convexity condition (Legendre-Clebsch condition) (4.143)

Huu  0 , t [t 0 ;t f ] •

normality condition (4.144)

N  0 , t [t 0 ;t f ] •

no conjugate point condition (Jacobi condition)

S − M N−1 MT finite , t [t 0 ;t f ]

(4.145)

Demonstration 2 It must be shown that, under conditions (4.143)-(4.145), the minimum of  J a (4.142) is obtained for u = 0 which corresponds to the nominal extremal. 2

If Huu  0 (convexity condition),  J a (4.142) is minimum for v = 0 . The matrix Huu defined positive is invertible and the control variation u is then given by: v = 0  u = −H−uu1 (Hxu + f uS)x + f u M + f u t f  .

If N  0 (normality condition), the matrix N is invertible. With the neighboring extremal equations (4.130), the variation u is given in state feedback (4.131). u = −H−uu1  H xu + f u (S − M N −1 MT ) x + f u M N −1  If the matrix S − M N −1 M T remains finite, then the variations u and x remain zero on the reference extremal (for x 0 = 0 and  = 0 ). The only solution

(

)

2 giving  J a = 0 is then the reference extremal (u = 0) which is a local minimum.

Optimal control

369

Note on the normality condition The matrix N is obtained by backward integration from equations (4.128). −1 f u  0 and N = M T BM  0 (reduced transport method). If Huu  0 , then B = f uT H uu

T and N(t f ) = 0 .  We have then: N(t)  N(t f )  0 . The normality condition strengthens this If (t f )  0 , then N(t f )  0 because N = N −

inequality N  0 to ensure that N is invertible.

Conjugate point The extremal has a point conjugate point C at time tc if: ( S − M N −1 M T ) (t c ) =  . The state feedback control (4.131) is then no longer necessarily zero at t c. A pulse u gives a non-zero derivative x(t c ) and a feasible path different from the reference extremal OCF associated with x = 0 (plotted in figure 4-31). This path reaches the final conditions  = 0 at a point F' different from the reference point 2

F and with a cost variation  J a zero on CF' (because v = 0 ). There may then exist a direct path OF' not passing through C and of lower cost than the OCF path (because the intermediate point constraint C is removed).

Figure 4-31: Conjugate point. Example 4-17 (already solved by calculus of variations in example 3-5) illustrates the notion of conjugate points for the geodesics on a sphere.

370

Optimization techniques

Example 4-17: Geodesics on a sphere We seek the minimum distance curves between points O and F on the unit sphere. The axes are chosen so that the two points are on the equator.

 0 = 0   f  O  , F   f = 0   0 = 0  The problem is formulated with:

 x1     x = = ;  x2     = u1  u1  - the control vector: u =   →  .  = u 2  u2  - the state vector:

2 2 2 2 2 2 The distance element is: ds = d + d cos  = u 2 + u1 cos x 2 dt .

Formulation of the control problem

min J = u,t f

tf



t0

u 22 + u12 cos2 x 2 dt

x(t 0 ) = x O x1 = u1 with  and  x 2 = u 2 x(t f ) = x F

Search for extremals The optimal control minimizes the Hamiltonian.

min H = u 22 + u12 cos 2 x 2 + p1u1 + p 2 u 2 u1 ,u 2

u12 cos2 x 2 (cos2 x 2 − p12 ) − u 22p12 =0 Hu = 0   2 2 2 − u 22 (1 − p22 ) = 0 u1 cos x 2 (p2 )  x 2 = 0 , p1 = 1 One possible solution (among others) is:  . u 2 = 0 , p 2 = 0 This extremal is a great circle arc following the equator (x 2 =  = 0) . Let us check whether this extremal satisfies the sufficient minimum conditions. Conditions of second order Since the solution is along the equator, the problem can be reformulated with the variable  instead of t. The state is reduced to a single component () , which simplifies the study of the second-order conditions.

Optimal control

371

The reduced formulation is

(0 ) = 0 = 0 d = u and  u d (f ) = f = 0 0 The extremal has the equation: u = 0 ,  = 0 . The matrices A, B, C, S, M and N given by (4.126) and (4.128) are calculated. min J =

f



u 2 + cos 2  d with  ' =

Derivatives of f:

f = u  f = 0 , f u = 1

Derivatives of H:

H = u 2 + cos 2  + pu = L + pu

with L = u 2 + cos 2 

− sin 2 u , Lu = 2L L 2Lcos 2  − L sin 2  L 1 L − uL u  H  = − , H u = −u 2 , H uu = 2 2 L L L2 L = 1 H = − 1 u = 0    L = 0  Hu = 0 Values on the extremal:   = 0   L u = 0 H uu = 1 A = 0 , B = 1 , C = −1 Matrices A, B, C: H  = L , H u = L u + p

with L =

Matrices S, M, N S = S2 + 1 with S( f ) =  xx (t f ) = 0 → S() = − tan( f − )  1  with M( f ) =  x (t f ) = 1 → M() = M = SM cos( f − )   N = M T BM with N(t ) = 0 → N() = − tan( f − ) f  State feedback control 1  −1 T S − MN M = tan( −  )  f  −1 MN −1 =  sin( f − )

→ u = −

  f + tan( f − ) sin( f − )

1 =. tan( f − ) The extremal passes through a conjugate point if the angle OF reaches 180° (distance greater than a half circle). It is not optimal in this case, because the path in the opposite direction is shorter). −1 T A conjugate point appears if:  f −  =   S − MN M =

372

Optimization techniques

Derivatives of optimal the cost Formulas (4.138) and (4.142) have been used to express the sufficient minimum conditions on the reference extremal (x 0 = 0 , f = 0) . They also give the first and second derivatives of the optimal cost with respect to variations of the initial state x 0 and the final constraints f .

J  2J (t 0 ) = p(t 0 ) , (t 0 ) = S − M N −1 M T 2 x x 2 J J  2J −1 = − , = − N , = N −1 M T   2 x

(4.146)

4.4.3 Singular arcs Consider a minimum time problem with bounded linear control.

min J = t f

−1u+1

with x = f (x) + g(x)u

(4.147)

The state is of dimension n. We consider here a control u of dimension 1. The Hamiltonian is expressed with the adjoint p and the multiplier p0. (4.148)

H = p0 + pT (f + ug)

The optimal control minimizes the Hamiltonian. It depends on the sign of the switching function  defined by

 = Hu = pTg(x) →



u = +1 if   0 , u = ? if  = 0 u = −1 if   0

(4.149)

Regular arcs with u = 1 are called "bang" arcs. A singular arc occurs if  is identically zero on an interval. The successive derivatives  ,  , are then all zero. The order on the singular arc is determined by the first explicit derivative in u. The questions arise about the optimality of a singular arc, as well as its junction to regular arcs. Kelley's condition The following Kelley condition (or generalized Legendre-Clebsch condition) is a necessary condition for optimality of a singular arc of the system (4.147).

(−1)k

  d 2k H    0 u  dt 2k u 

 (−1)k ( (2k) )u  0 with  = H u

(4.150)

Optimal control

373

The derivative (2k) is the first explicit derivative in u. It can be shown that this derivative is necessarily even. The integer k is called the order of the singular arc. Lie derivatives and brackets To study singular arcs, Lie derivatives and brackets are introduced. A vector field X is a function of n in n . The components of X are n functions of n in . The gradient of X noted X is defined by

 X1    X=  X   n

→ X = ( X1 ,

The Lie derivative of a function  : function noted LX of

n

in

 X1  x  1 , X n ) =    X1  x  n n



X n  x1     X n  x n 

(4.151)

along the vector field X is the

defined by

LX  = XT

(4.152)

def

This function, also noted LX = X , is associated with the vector field X. noted

It represents the directional derivative of  along X at any point x  n . The Lie bracket of the vector fields X and Y is the operator defined by

 X,Y def= XY − YX

(4.153)

This operator consists in applying successively the Lie derivatives L X and L Y to functions  :

n

→ . It is equivalent to the Z operator defined by (4.154)

Z = YT X − XT Y

Demonstration (see [R17]) Let us apply the operator [X,Y] to a function  :

X,Y = XY− YX = LX (LY) − LY (LX)

n

→ .

374

Optimization techniques

Developing the Lie derivatives defined by (4.152), we obtain  X, Y   = LX (Y T) − L Y (X T) = X T(Y T) − Y T(X T)

= X T (Y  +  2 Y) − Y T (X  +  2 X) = (X TY − Y TX) 

because the Hessian  2 is symmetrical

= (Y T X − X T Y)T  = L Z = Z by posing Z = Y T X − X T Y

The Lie bracket has the following properties, which are easily proven.

 X, X = 0  X, Y = −  Y, X  X,  Y, Z +  Y,  Z, X  +  Z,  X, Y  = 0

(4.155)

The third equality is the Jacobi identity. Derivative of a function along an extremal Lie brackets are useful to express the successive derivatives  ,  , of the switching function in a compact form. The system (4.147) has the state equation: x = f (x) + ug(x) . By associating to the functions f and g the respective vector fields F and G on n , the extremals of the problem (4.147) have the equations f (x) + ug(x)  x = H p = F + uG x = (4.156)    p = − (F + uG)p p = − H x = −  f x (x) + ug x (x)  p Consider a vector field Z and a function  :

(t) = p(t)T Z[x(t)]



of the form (4.157)

The derivative of  along an extremal is then expressed with the Lie bracket.

 = pT  F + uG, Z = pT f + ug, Z noted

(4.158)

Demonstration (see [R17])

p = − (F + uG)p The derivative of  is:  = pT Z + pT Z with  T T  Z = Z x = Z (F + uG) where the derivatives of x and p are taken along the extremal of equations (4.156).

Optimal control

375

T T T T The result is:  = − p (F + uG) Z + p Z (F + uG)

which is written using the Lie bracket:  = pT  F + uG, Z = pT f + ug, Z . noted

Derivatives of the switching function Let us apply the formula (4.158) to calculate the successive derivatives of the T T switching function (4.149):  = p g = p G . The first derivative is given by

 = pT g

→  = pT [f + ug,g] = pT [f ,g]

(4.159)

The second derivative is given by

 = pT [f ,g] →  = pT [f + ug,[f ,g]] →  = pT [f ,[f ,g]] + upT [g,[f ,g]]

(4.160)

The successive derivatives of  are all zero along a singular arc. T If p [g,[f ,g]]  0 , the explicit second derivative in u determines the control.

u sing = −

p T [f ,[f ,g]] p T [g,[f ,g]]

(4.161)

The singular arc obtained with this control is of order 1. T If p [g,[f ,g]] = 0 , then we must continue to derive  until an explicit expression in u is obtained. The singular arc is of higher order. Singular arc of order 1 The order on a singular arc of order 1 is determined by (4.161). To be feasible, this control must satisfy the bounds: −1  using  +1 . To be optimal, it must satisfy the Kelley condition (4.150) for k = 1 .



  d 2 H   T  2   0  −   0  p [g,[f ,g]]  0 u  dt u  u

(4.162)

Property 4-11: Junction between a singular arc of order 1 and a bang arc A singular arc satisfying the Kelley condition in the strict sense can be connected to a bang arc (u bang = 1) at a time  such that: −1  using ()  +1 .

376

Optimization techniques

Demonstration (see [R17]) Suppose that the singular arc connects to a bang arc at time  such that −1  using ()  +1 . −

If the bang arc precedes the singular arc, it stops at time  . + If the bang arc follows the singular arc, it starts at time  .  Let us show that this junction satisfies the minimum principle at  .

T T The Hamiltonian is given by: H = p0 + p (f + ug) = p0 + p f + u . T T The functions  = p g and  = p [f ,g] are continuous, since they depend only  on x and p. They are zero in  (on the singular arc), so also in  by continuity.

T T The second derivative of  is given by (4.160):  = p [f ,[f ,g]] + up [g,[f ,g]] .

T T On the singular arc at  : () = p [f ,[f ,g]] + u sin g p [g,[f ,g]] = 0  On the arc bang at  :

( ) = pT [f ,[f ,g]] + u bang pT [g,[f ,g]]

1st case: u bang =−1  u sin g ()  T We have: ( )  () because p [g,[f ,g]]  0 (strict Kelley condition)

  (  )  0

because () = 0

(on the singular arc)

Let us write the expansion of  to order 2 in  using  () = 0 and  () = 0 .

1 1 ( ) = () + ( − )() + ( − ) 2 ( ) = ( − ) 2 ( )  ( )  0 2 2  Let us apply the PMP at  . min H = p0 + pTf + u  u(t  ) = −1 because   0 −1u +1

We obtain the control u bang =−1 , consistent with the assumption. This junction is therefore possible. 2nd case: u bang =+1  usin g () The verification is carried out in a similar way.    The PMP at  gives: ( )  0 and u(t ) = +1 .

Optimal control

377

Example 4-18 illustrates a composite solution including a junction to a singular arc of order 1.

Example 4-18: Junction with a singular arc of order 1 Formulation The problem is a double integrator in dimension 2 to be brought back to the origin by minimizing a quadratic cost. The initial state and the final time are fixed. The control is not bounded. t   1 f 2 x1 = x 2 + u x1 (t f ) = 0 min J =  x1 dt with  and  u 2 t 0 =0   x 2 = − u x 2 (t f ) = 0 The Hamiltonian H is constant (autonomous system), with the adjoint (p1 ,p2 ) .

p1 = − x1 1 1 H = x12 + p1 (x 2 + u) − p 2 u = x12 + p1x 2 + u →  2 2 p 2 = −p1 The switching function is defined by:  = p1 − p2 . Search for singular arcs A singular arc occurs if the function  remains identically zero.   p1 = x 1  = −x 1 + p1 = 0  = p1 − p2 = 0       = − x 2 − u − x1 = 0 u = − (x1 + x 2 )  The singular arc is of order 1, because the second derivative is explicit in u. This arc can be optimal, as it satisfies the Kelley necessary condition (4.162).   d 2k H   Indeed, for k = 1 : (−1)k  2k  = −  =1  0 u  dt u  u According to property 4-11, this arc of order 1 can be connected to a regular arc. The equations of the singular arc are obtained from the Hamiltonian.

1 H = x12 + p1x 2 + u = C te 2

 = 0 with  p1 = x1

We obtain an arc of hyperbola of equation: x1 (x1 + 2x 2 ) = 2H having for asymptotes: x1 = 0 and x1 + 2x 2 = 0 .

378

Optimization techniques

Let us determine the temporal evolution of x1 and x 2 : • •

p1 = − x1  x1 = − x1 for x1 :  p1 = x1 H 1 for x 2 : x 2 = − x1 x1 2

 x1 (t) = ae− t

 x 2 (t) =

H t 1 −t e − ae a 2

Searching for junctions Composite solutions connecting regular and singular arcs are considered.  x1 (t 0 ) = x10  x (t ) = 0 The initial and final times and states are fixed:  and  1 f .  x 2 (t 0 ) = x 20  x 2 (t f ) = 0

The control is not bounded and does not appear in the cost J. We can consequently apply "free" impulses u moving the state from (x1 , x 2 ) to (x1 +u, x 2 −u). te These instantaneous shifts follow the lines of equation: x1 + x 2 = C .

We can thus define a solution composed of three arcs as follows: - an impulse at t 0 changes (x10 ,x 20 ) to (x10 +x 0 ,x 20 −x 0 ) ;

- the singular arc is travelled from t 0 to t f with the control u = −(x1 + x 2 ) ; - an impulse at t f changes (x1f ,x 2f ) to (x1f +xf ,x 2f −xf ) = (0 , 0) . Let us note (y10 , y20 ) and (y1f , y2f ) the states at beginning and end of the singular arc. These endpoint conditions determine the equations of the singular arc.  y10 = a a = y10 −t    y1f = y10e f      H 1 1 2 t y 20 = − a H = y10 + y10 y 20  y 2f = y 20e f + y10 sh t f    a 2 2   Let us write the junction conditions at t 0 and t f .  y10 + y 20 = x10 + x 20 = c at t 0  y1f = y10e− t f   def    t  y 2f = y 20e f + y10 sh t f  y1f + y 2f = x1f + x 2f = 0 at t f   The state at the beginning and end of the singular arc is obtained. c = x10 + x 20 fixed e2tf 1 + e2t f y10 = 2c 2tf , y20 = c with  2t f e −1 1− e t f fixed

The cost of this solution is: J =

t

t

1 f 2 1 f 2 −2t c2 . x1 dt =  y10 e dt =  2 t 0 =0 2 t 0 =0 1 − e−2t f

Optimal control

379

This solution is not necessarily the best. It must be compared with other solutions (combinations of regular and singular arcs) to establish its global optimality. However, we observe that a solution of the same type arriving earlier at the end point would be less good, as J is a decreasing function of t f . Numerical application

 x10 = 1 The initial state is set at:  . The final time is set to: t f = 1.5 .  x 20 = 3.28  y10  9.01 y  2 The initial and final states on the singular arc are:  and  1f .  y 20  − 4.72  y 2f  − 2 The cost is equal to: J  19.28 . Figure 4-32 shows the trajectory in the phase plane with the initial impulse leading to the hyperbola (singular arc) and the final impulse leading to the origin.

Figure 4-32: Composite solution pulse−singular arc–pulse.

380

Optimization techniques

Let us now turn our attention to singular arcs of order greater than 1. Singular arc of higher order T A singular arc is of order greater than 1 if: p [g,[f ,g]] = 0 . T

Since the second derivative of  is zero, we also have: p [f ,[f ,g]] = 0 . These very restrictive conditions are rarely met in practice. However, there are systems for which we have: [g,[f ,g]] = 0 . Let us calculate the derivatives of  in this case by applying formula (4.158). To simplify the equations, we introduce the notation:  X,Y = adX (Y) . The operator adX (called adjoint operator) is associated with the vector field X. Using the Jacobi identity (4.155), the derivatives of  are expressed as

(3) = pT ad3f (g) , (4) = pTad f4 (g) + upT [g,ad3f (g)]

(4.163)

The singular arc is of order k if the first explicit derivative in u is (2k) . It can be shown that this derivative is necessarily even. The control on a singular arc of order k is determined by the cancellation of the derivative (2k) . To be feasible, this control must satisfy the bounds: −1  using  +1 . To be optimal, it must satisfy the Kelley condition (4.150).

(−1)k

  d 2k H  k T 2k −1   = (−1) p [g,ad f (g)]  0 u  dt 2k u 

(4.164)

Property 4-12: Junction between a singular arc of order 2 and a bang arc A singular arc of order 2 satisfying the Kelley condition in the strict sense cannot connect to a bang arc (u bang = 1) at a time  such that −1  using ()  +1 .

Demonstration (see [R17]) Suppose that the singular arc connects to a bang arc at time  such that

−1  using ()  +1

Optimal control

381

− If the bang arc precedes the singular arc, it stops at time  .

+ If the bang arc follows the singular arc, it starts at time  .  Let us show that this junction does not satisfy the minimum principle at  .

T T The Hamiltonian is given by: H = p0 + p (f + ug) = p0 + p f + u

(i) T i The functions  = p ad f (g)

i =0,1,2,3

are continuous, because they depend only

 on x and p. They are zero in  (on the singular arc), so also in  by continuity.

(4) T 4 T 3 The fourth derivative of  is given by (4.163):  = p ad f (g) + up [g,ad f (g)]

On the singular arc at  :

(4) () = pT ad f4 (g) + u sin g pT [g,ad 3f (g)] = 0

 On the arc bang at  :

(4) ( ) = pT ad f4 (g) + u bang pT [g,ad3f (g)]

1st case: u bang =−1  u sin g () (4)  (4) T 3 We have:  ( )   () because p [g,adf (g)]  0 (strict Kelley condition)

  (4) ( )  0

because (4) () = 0 (on the singular arc) Let us write the expansion of  to order 4 in  , using () = () = (2) () = (3) () = 0 1 ( ) = ( − )4  (4) ( )   (  )  0 . 24 T   Apply the PMP at  : min H = p0 + p f + u  u(t ) = +1 because   0 −1u +1

This result is in contradiction with the assumption u bang =−1 . This junction is therefore not possible. 2nd case: u bang =+1  usin g ()  The verification is done in a similar way. The PMP at  gives

( )  0 and u(t  ) = −1 .

A junction between a singular arc of order 2 and a bang arc is incompatible with the PMP. This type of situation leads to the phenomenon of chattering with an infinite number of commutations (u bang = 1) on approaching the junction. The Fuller problem illustrates this phenomenon, which can occur in concrete applications.

382

Optimization techniques

Example 4-19: Fuller's problem (from [R17]) Formulation The Fuller problem (FP) is a double integrator in dimension 2, that has to be brought back to the origin by minimizing a quadratic cost. The final time is free and the control is bounded: −1  u  1 . The (FP) problem is formulated as t   1 f x1 = x 2 x1 (t f ) = 0 min J =  x12dt with  ,  , − 1  u  +1 (FP problem) u,t f 2 t0 x 2 = u x 2 (t f ) = 0   The Hamiltonian H, with an adjoint (p1 ,p2 ) and an abnormal multiplier p0 , is

1 p1 = −p0 x1 H = p0 x12 + p1x 2 + p 2 u →  2 p 2 = −p1 The optimal control minimizes the Hamiltonian.  u = +1 if p 2  0  min H →  u = −1 if p 2  0 u  u = ? if p 2 = 0 To study the extremals, an equivalent minimum time problem is formulated. Minimum time problem Consider the following minimum time (MT) problem.  x1 (t f ) = 0  x1 = x 2 tf   min K =  1dt with  x 2 = u , x 2 (t f ) = 0 , − 1  u  +1 (MT problem) u,t f t0   2  x 3 = x1 / 2  x 3 (t f ) = 0 The Hamiltonian Hq, with an adjoint (q1,q2 ,q3 ) and an abnormal multiplier q0 is q1 = −q 3 x1  1 H q = q 0 + q1x 2 + q 2 u + q 3 x12 → q 2 = −q1 2  q 3 = 0 We observe that the extremals of the (MT) and (FP) problems have the same equations in (x1 ;x 2 ) , because the adjoint q3 is constant and plays the same role

as the abnormal multiplier p0 . The Hamiltonians Hq and H are therefore identical.

1 1 q 0 = 0 q 0 + q1x 2 + q 2 u + q 3 x12 = p1x 2 + p 2 u + p0 x12 = 0 , x1 , x 2   2 2 q 3 = p0

q1 = p1 , q 2 = p 2

Optimal control

383

The adjoints (q1 ,q 2 ) and (p1 ,p2 ) coincide. Moreover, the extremals of (FP) are

abnormal extremals (q0 = 0) of (TM). This is because the solution of (FP) is unique (not shown here) and there exists only one final time to reach the origin. Let (u *, t f *) be the solution to (FP), J * its cost, and choose x3 (t 0 ) = −J*  0 . The solution of (FP) is then the solution of (TM) for this specific initial condition. Indeed, with the control u* we obtain

x 3 (t f *) = x 3 (t 0 ) +

1 2

tf *

2  x1 dt = −J * +

t0

1 2

tf *

 x dt = 0 2 1

t0

Singular extremals We look for the singular extremals of (MT) by using Lie brackets.  x1 = x 2  x2   0      → x = f (x) + ug(x) with f =  0  , g =  1  x 2 = u   x2 / 2  0 2  1     x 3 = x1 / 2

 0 0 x1   0 0 0     → fx =  1 0 0  , gx =  0 0 0   0 0 0 0 0 0     

The first-order brackets are  −1 0 0       [f ,g] = g Tx f − f xT g =  0  , [f ,[f ,g]] =  0  , [g,[f ,g]] =  0  0 x  0    1  

Since the bracket [g,[f ,g]] is zero, there is no singular arc of order 1. The second-order brackets are 0  0     3 3 ad f (g) = [f ,[f ,[f ,g]]] =  0  , [g,ad f (g)] = [g,[f ,[f ,[f ,g]]]] =  0  x  1  2   The bracket [g,ad 3f (g)] does not cancel. Singular arcs are of order 2. The Kelley condition [g,ad3f (g)]  0 is satisfied. These singular arcs can therefore

be optimal. To determine them, the switching function  = q2 = p2 is derived using the adjoint equations and the state equations until the control u appears.

 = p2 →  = − p1 →  = p0 x1 → (3) = p0 x 2 → (4) = p0u The function  and all its derivatives are zero along a singular arc.

384

Optimization techniques

According to the PMP, the adjoint (p1 ,p2 ) and the abnormal multiplier p0 cannot simultaneously be zero.  p1 = p 2 = 0  The only singular solution is therefore:  x 1 = x 2 = 0 with p0  0 u = 0  sin g This singular arc of order 2 reduces to the origin which is the targeted end point. According to property 4-12, there is no possible junction with a bang arc. The origin can therefore only be reached by chattering, i.e. with an infinite number of switches u = 1 . Regular extremals All extremals of (FP) are regular (except the origin). The solution of (FP) is a sequence of bang arcs defined by  x1 = x 2 1 p1 = −p0 x1 ,  , H = p0 x12 + p1x 2 + p 2 u = 0 , u = 1  2  x 2 = u p 2 = −p1 If p0 = 0 (abnormal case), then p1 is constant and p2 is linear. There is only one switch and the junction to the end point (singular arc of order 2) cannot be optimal. The bang arcs are therefore normal and we can pose p0 = 1 . • First integrals Bang arcs (u = 1) have the following two first integrals. 1 I1 = x1 − ux 22 (Verification: I1 = x1 − ux 2 x 2 = x 2 − u 2 x 2 = 0 ) 2 1 I2 = −p1 − ux1x 2 + x 32 3 (Verification: I2 = − p1 − ux1x 2 − ux1x 2 + x 22 x 2 = x1 − ux 22 − u 2 x1 + ux 22 = 0 ) • Switching sense Switching from u = −1 to u = +1 occurs for x 2  0 . Switching from u = +1 to u = −1 occurs for x 2  0 . Let us check this property relating to the sense of the commutations. The switching sense depends on the sign of the first non-zero derivative of  . 1 At a switching time, we have:  = p2 = 0  H = x12 + p1x 2 = 0 . 2

Optimal control

385

If p1 = 0 , then x1 = 0 (because H = 0 ) and x 2  0 (because the origin cannot be on a regular arc). Then we have:  =  =  = 0 →  (3) = x 2 , determines the switching sense.

1 If p1  0 , then x1  0 (otherwise x1 = x 2 = 0 ) and H = 0  p1x 2 = − x12  0 . 2 The switching sense is determined by  = −p1 which has the sign of x 2 . Invariant extremals Consider the change of variable (u,x1,x 2 ,p1,p2 ) → (v, y1, y2 ,q1,q2 ) defined with a parameter  by t t t v(t) = − u   , y1 (t) = − 2 x1   , y 2 (t) = −x 2          t t q1 (t) = − 3p1   , q 2 (t) = − 4 p 2     Remark: we use here the notation (q1,q2) without any link with adjoints of (MT). If (u,x1,x 2 ,p1,p2 ) is an extremal

1  x1 = x 2 p1 = − x1 ,  , H = x12 + p1x 2 + p 2 u = 0  2  x 2 = u p 2 = −p1 then (v, y1, y2 ,q1,q2 ) is also an extremal 1  y1 = y 2 q1 = − y1 ,  , H = y12 + q1y 2 + q 2 v = 0  2  y 2 = v q 2 = −q1 This is verified directly by substitution. The extremal is said to be point-invariant if

(u,x1,x 2 ,p1,p2 )(t) = (v, y1, y2 ,q1,q 2 )(t) , t We are looking for the smallest value of  giving an invariant extremal. If t k is a switching time, we have  2 (t k ) = p2 (t k ) = q 2 (t k ) = − 4p 2 ( t k /  ) = 0 The switching times therefore form a geometric series. t t t 0  t1 = 0  t 2 = 1   t f   Consider a bang arc u = +1 on [t0 ; t1] followed by a bang arc u = −1 on [t1 ; t2].

386

Optimization techniques

1 We use the first integral: I1 = x1 − ux 22 . 2 1 1 • On the arc from t0 to t1 : x1 (t1 ) − x 22 (t1 ) = x1 (t 0 ) − x 22 (t 0 ) 2 2 2  x (t ) = y (t ) = − x1 ( t 0 /  ) = −2 x1 (t1 ) 1 0  1 0 By invariance of the extremal:   x 2 (t 0 ) = y2 (t 0 ) = − x 2 ( t 0 /  ) = − x 2 (t1 ) 1 2 − 1 Replacing x1 (t 0 ) and x 2 (t 0 ) : x1 (t1 ) = −x 22 (t1 ) with  = 2 2 + 1 1 1 • On the arc from t1 to t2 : x1 (t 2 ) + x 22 (t 2 ) = x1 (t1 ) + x 22 (t1 ) 2 2 2 2  x1 (t1 ) = y1 (t1 ) = − x1 ( t1 /  ) = − x1 (t 2 ) By invariance of the extremal:   x 2 (t1 ) = y2 (t1 ) = − x 2 ( t1 /  ) = − x 2 (t 2 ) 1 2 − 1 Replacing x1 (t1 ) and x 2 (t1 ) : x1 (t 2 ) = +x 22 (t 2 ) with  = 2 2 + 1 The following relations are obtained at the switching times t1 and t2.

x1 (t1 ) = −x 22 (t1 ) with x 2 (t1 )  0 for switching from u = +1 to u = −1 at t1 x1 (t 2 ) = +x 22 (t 2 ) with x 2 (t 2 )  0 for switching from u = −1 to u = +1 at t2 2 +  C : x = +x 2 , x 2  0 The switching curves have the equations:  − 1 . 2  C : x1 = −x 2 , x 2  0

Values of  and  Let us place ourselves on the arc from t1 to t2 with u = −1 . The Hamiltonian allows p1 to be expressed in terms of x1 and x 2 .

1 x2 H = x12 + p1x 2 + p2 u = 0 with p2 = 0 at each switching → p1 = − 1 2 2x 2 1 Then let us use the first integral: I2 = −p1 − ux1x 2 + x 32 . 3 1 1     I2 =  −p1 + x1x 2 + x 32  (t1 ) =  −p1 + x1x 2 + x 32  (t 2 ) 3 3     2 2  x1 (t1 ) = −x 2 (t1 ) x with  and p1 = − 1 2 2x 2  x1 (t 2 ) = +x 2 (t 2 )

Optimal control

387

By invariance of the extremal, we have x 2 (t1 ) = y2 (t1 ) = −x 2 ( t1 /  ) = −x 2 (t 2 ) Replacing x1 (t1 ) and x 2 (t1 ) in the first integral I2 , we obtain

1 1 1 1 2 −1 1 + 2 1 −3  2 −  +  =  2 +  +  with  =  2 = 2 3  2 3 2  +1 1 − 2 2 2 which results in a second-degree equation in  .

4 +

1 2 1  − =0 → = 12 18

33 − 1 1 + 2  0.44462 and  =  4.13016 24 1 − 2

Summary The invariant extremals allow the construction of a complete solution. Switching times:

t k = t k+1

→ converging to t f = 0

2  C : x = +x 2 Switching curves:  − 1 2  C : x1 = −x 2  u = +1 if State feedback control:   u = −1 if +

with the constants:  =

, x 2  0 → switching from u = −1 to + 1 , x 2  0 → switching from u = +1 to − 1

x1  −x 22 sgn(x 2 ) x1  −x 22 sgn(x 2 )

33 − 1 1 + 2  0.44462 ,  =  4.13016 24 1 − 2

This synthesis is obtained by connecting the bang arc associated with the invariant extremals. It can be shown [R17] that this synthesis is the optimal synthesis of the Fuller problem, which means that these invariant extremals are the only ones and that their junction is optimal. Figure 4-33 shows the switching curves C+ and C− in the phase plane (x1,x 2 ) and a dotted path with 4 successive bang arcs. Unlike the double integrator problem (example 4-7), the switching curves are not optimal trajectories. These curves are crossed an infinite number of times, thus causing chattering.

388

Optimization techniques

Figure 4-33: Optimal synthesis of the Fuller problem. Figure 4-34 illustrates the chattering as the end point is approached. The initial + conditions have been chosen on the switching curve C : x1 = 88.92 , x 2 = −20 . The first bang arc with u = +1 goes from t0 to t1. x 2 (t1 ) − x 2 (t 0 ) = u.(t1 − t 0 ) From the equation of this initial arc: and from the switching conditions in t1 : x 2 (t 0 ) = −x 2 (t1 ) , t 0 = t1  +1 x 2 (t 0 )  −32.779 . the initial time (for t f = 0 ) is determined: t 0 =  −1

Figure 4-34: Optimal control with chattering.

Optimal control

389

Value function The value function V(x1 ,x 2 ) of the problem (FP) can be obtained by solving the HJB equation. V  V  min H  x, u, ,t  + =0 u x  t   V  1 with H = x12 + p1x 2 + p2 u and min H → u = − sgn   − 1  u + 1 2  x 2 

V V 1 2 − + x1 = 0 . x1 x 2 2 It can be shown [R17] that the solution is The HJB equation is in the form: x 2

1 5 1 V (x1 , x 2 ) = x 2 + x1x 32 15 3

1 2 1 x1 x 2 + A  x 22 2 2

5

2 x1   3

− V = V+ if x1  −x 22 sgn(x 2 ) 1 2 1 2  2  with A = + 2  +   +      0.382 2 5 3 2   V = V− if x1  −x 2 sgn(x 2 )

4.5 Conclusion 4.5.1 The key points •

The Pontryaguin minimum principle gives the necessary first-order conditions that the optimal control must satisfy;



final, interior or path constraints induce additional conditions that can cause control discontinuities;



determining the optimal control and trajectory requires solving a two-point boundary value problem;



the transport method allows to determine the neighboring extremals of a reference solution and to construct a state feedback control;



the optimal trajectory may contain singular arcs whose determination requires optimality conditions of order greater than 1.

390

Optimization techniques

4.5.2 To go further •

Contrôle optimal – Théorie et applications (E. Trélat, Vuibert 2005) This book presents the theory of optimal control in a very pedagogical way, while maintaining a very high level of rigor. The author is one of the world's leading specialists in the field. Numerous commented exercises help to understand how to apply the optimality conditions to concrete problems.



Les mathématiques du mieux-faire (J.B. Hiriart-Urruty, Ellipses 2008) The second volume explains step by step the establishment of the principle of the minimum with all the demonstrations and many remarks in the margin which help the understanding.



Applied optimal control (A.E. Bryson, Y.C. Ho, Hemisphere Publishing Corporation 1975) This book is aimed at the practical application of optimal control for engineers. The very progressive presentation in the chapters allows a good familiarization with the computational techniques, especially thanks to many very detailed examples.



Calculus of variations and optimal control theory (D. Liberzon, Princeton University Press, 2012) This rather theory-oriented book explains the transition from calculus of variations to optimal control. The presentation is very didactic and clear and remains rigorous without excessive formalism. A book to be recommended to get familiar with the theoretical aspects of functional optimization.



Optimal control theory for applications (D.G. Hull, Springer, 2003) This book is based on the variational approach to optimal control. It offers the interest of developing in a detailed way the optimality conditions associated with the different formulations (parameters, constraints...). Three application examples are used throughout the book to illustrate the results.



Geometric optimal control (H. Schättler, U. Ledzewicz, Springer, 2012) This book deals with geometric methods of optimal control and investigate especially the properties of singular arcs. The focus is more on theory with proofs of results. Although the subject is difficult, the content remains accessible without excessive formalism.

Numerical methods in optimal control

391

5. Numerical methods in optimal control The numerical solution of an optimal control problem requires the discretization of the state and the control. This chapter is an introduction to the usual approaches. Section 1 introduces the transcription methods, which consist in formulating a finite-dimensional problem "equivalent" to the control problem. The two main choices concern the solution of the differential equations and the use or not of the optimality conditions of the control problem. Section 2 is devoted to Runge-Kutta methods that solve a differential system by progressing through time steps. These single-step methods use only the current state at each step. The accuracy depends on the order of the method and can be controlled by setting the time step. Section 3 is devoted to Adams methods. Like Runge-Kutta methods, the solution is assessed by time steps, but using several previous steps to construct the solution at the next step. These multi-step methods are more accurate, but more complex to implement. Section 4 introduces collocation methods. The solution of the differential equation is approximated by polynomials satisfying conditions on their derivatives at certain points. The accuracy of these methods depends on the degree of the polynomials and the number of discretization points. Section 5 presents the direct methods that reduce the problem to finite dimension. Depending on the method of solving the differential equations, either the control (Runge-Kutta) or the control and the state (collocation) are discretized. The discretized problem of large size is solved by a nonlinear programming algorithm or by a variational method based on the deviation equations. Section 6 presents indirect methods that solve the optimality conditions of the minimum principle. The problem is reduced to a system of equations solved by the shooting method (Newton's method with state propagation and adjoint). This method is fast and accurate if one has a good initialization, which can be very difficult. The multiple shooting or the variational approaches alleviate this difficulty, but by increasing the size of the problem.

392

Optimization techniques

5.1 Transcription We seek to solve a free final time control problem of the form t

f x(t) = f (x,u, t) , x(t 0 ) = x 0 (5.1) min J(u) =  L(x,u, t)dt + (x f , t f ) with  u,t f (x f , t f ) = 0 t0

The state x is of dimension n, the control u is of dimension m, the number of final constraints is q. The problem is said in infinite dimension, because the unknown is a function u(t). An analytical solution is rarely possible, even for simple problems. Numerical methods must be used which give an approximate solution in a finite number of dates. Transcription consists in formulating a finite-dimensional "equivalent" problem and solving it numerically. The finite-dimensional problem can be formulated in different ways. The main choices are how to solve the differential equations (by propagation or collocation) and how to use the optimality conditions of the control problem (direct or indirect method).

Figure 5-1: Transcription process.

Numerical methods in optimal control

393

5.1.1 Differential equations A Cauchy problem or initial value problem (IVP) consists in solving a first order differential system with a given initial condition.

x(t) = f  x(t), t  , t 0  t  t f  x(t 0 ) = x 0

(5.2)

The unknown is the function x(t)t0 ttf of dimension n.

The problem is reduced to a finite-dimensional problem by dividing the integration interval [t 0 ;t f ] into N segments: t 0  t1   t i   t N = t f and looking for the values taken by x at times (t i )i=0 to N . The sequence of values

(xi )i=0 to N is an approximate solution of the differential equation (5.2). This solution can be constructed by propagation or by collocation. Propagation methods The propagation methods calculate the solution by progressing in time. The value x i+1 is determined by quadrature formulas from the previous values: •

single-step methods (Runge-Kutta type) only use the previous value x i ;



multi-step methods (Adams type) use the values of several previous steps xi−k , ,xi as shown in figure 5-2.

Figure 5-2: Single or multi-step propagation method.

394

Optimization techniques

Collocation methods The collocation methods construct a piecewise polynomial solution. The unknown solution x(t) is approximated by a polynomial (t) of degree K on each time interval [t i ;t i+1 ] . This polynomial satisfies connection conditions at the ends and

its derivative satisfies the differential equation at intermediate times (k )k=1 to K . The solution accuracy depends on the polynomial degree and on the positioning of the intermediate points called collocation points (figure 5-3). The complete solution on [t 0 ;t f ] is obtained globally by solving a large nonlinear system.

Figure 5-3: Collocation method.

Well-posed problem and conditioning Solving problem (5.2) may be mathematically or numerically difficult. The problem is said to be mathematically well-posed if the exact solution is unique and depends continuously on the initial condition x 0 . The problem is said to be numerically well-posed if the numerical solution is not sensitive to rounding errors. The problem is said to be well-conditioned if an accurate numerical solution can be obtained without excessive reduction of the time step.

Numerical methods in optimal control

395

Example 5-1: Well-posed problem and conditioning Example 1 Consider the differential equation: x = 2 x with x(t 0 = 0) =  . −(t −  )2 if t  

 If   0 , a possible solution is: x(t) = 

2  +(t −  ) if t   If  = 0 , there is an infinite number of solutions of the form for t   0 x(t) =  2 (t − ) for t   The solution is not unique for  = 0 , and it is not continuous when  → 0 . The problem is mathematically ill-posed.

 x = ax + b .  x(t 0 = 0) = x 0

Example 2 Consider the differential equation:  The general solution is: x(t) =

1 (ax 0 + b)eat − b  . a

A rounding error  on x(t 0 ) produces an error eat on x(t) .

− ln  . a The problem is numerically ill-posed for a  0 if the time t f is too large. If a  0 , the error becomes significant (> 1) from t 

Example 3 Let us apply Euler's method with a time step h to the previous problem.

b b     x i+1 +  = (1 + ah)  x i +  a a   b b n The solution after n time steps is given by: x n = (1 + ah)  x 0 +  − . a a  If a  0 , the exact solution converges to 1 b lim x(t) = lim (ax 0 + b)eat − b  = − t →+ t →+ a a For the numerical solution to have the same limit, the step h must satisfy 1 + ah  1 . If a is large, the time step must be reduced proportionally to obtain an accurate solution. The problem is ill-conditioned (steep problem).

xi+1 = xi + hf (xi ,t i ) = (1 + ah)xi + bh

396

Optimization techniques

5.1.2 Direct and indirect methods The control problem (5.1) can be solved either "directly" by discretization or "indirectly" by using optimality conditions. Direct methods The direct methods transform the optimal control problem into an "equivalent" finite-dimensional problem. The interval [t 0 ;t f ] is divided into N segments with times: t 0  t1 

values (ui )i=0 to N

 ti 

 t N = t f . The function u(t) is approximated by its at the times (t i )i=0 to N with an interpolation method to be chosen

(constant, linear, splines...). We are thus reduced to a finite-dimensional optimization problem with (N + 1)  m variables, where m is the dimension of the control vector u. The state differential equation is solved by propagation or by collocation, using or not the same discretization (t i )i=0 to N . In the case of an integration by collocation, the states (xi )i=1 to N at times (t i )i=1 to N are added to the problem variables with associated collocation constraints. In this way, a large optimization problem is formulated and solved by classical nonlinear programming methods. Direct methods have the advantage of decoupling optimization and simulation. It is thus possible to modify the dynamic model or the constraints without any specific coding effort. They do not presuppose a particular form of the solution (regular/singular arcs, active/inactive inequality constraints). The unknowns of the problem are physical variables (control law), which facilitates the initialization and interpretation of the results. Direct methods can be easily applied to many problems. Their main drawback is the size of the optimization problem (many variables and constraints) which can lead to slow and sometimes inaccurate convergence. Indirect methods The indirect methods try to solve the optimality conditions of problem (5.1). These conditions involve the adjoint p(t) of same dimension n as the state x(t) and the T

normal Hamiltonian defined by: H(x,u,p, t) = L(x,u, t) + p f (x,u, t) . They lead to the following two-point boundary value problem.

 x = H p , (x f , t f ) = 0  p = − H x , pf = xf +  xf  H = 0 , H = −  −   f tf tf  u

(5.3)

Numerical methods in optimal control

397

The differential system is integrated using the control obtained from Hu = 0 .

The unknowns are the n components of the initial adjoint p(t 0 ) , the q multipliers

 of the final constraints and the final time t f . The equations to be satisfied are the q final constraints, the n transversality conditions on the final adjoint and the transversality condition on the final Hamiltonian. A system of equations of dimension n + q + 1 is thus formulated which can be solved by a Newton method.

Indirect methods have the advantage of reducing the problem to a small system of equations. The solution of this system is generally very fast and precise, provided that a good initialization is available. The disadvantages are the difficulty of initialization (non-physical variables, high sensitivity), the need for a coding specific to the problem treated (adjoint equations, transversality conditions, structure of the solution). The difficulty of initialization can be prohibitive in certain cases. Indirect methods should be reserved for problems with a stable formulation (dynamics, constraints) and a known control structure. It is possible in this context to develop specific initialization strategies. Table 5-1 compares the characteristics of direct and indirect methods. Direct method

Indirect method

Problem

Constrained Optimization

Problem at both ends

Unknown (dimensions)

Discrete control ui (Nn), tf (1)

Initial assistant, multipliers p0 (n),  (q), tf (1)

Initialization

Easy (physical variables) Not very sensitive

Difficult (abstract variables) Very sensitive

Convergence

Slow (large size problem)

Fast (few unknowns)

Accuracy

According to discretization

Very precise

Coding

Non-intrusive if propagation Intrusive if collocation

Intrusive (adjoint) Problem specific

Table 5-1: Direct and indirect methods.

398

Optimization techniques

5.2 Runge-Kutta methods The Runge-Kutta methods are single-step methods for numerically solving a first order differential system of the form

x(t) = f  x(t),t  , t 0  t  t f

(5.4)

The state vector x is of dimension n and the function f :

n



n

is assumed to

be of class C1. The initial condition is given: x(t 0 ) = x0 . The interval [t 0 ;t f ] is divided into N segments: t 0  t1  - the times t i are the nodes;

 t i  t i+1 

 t N = tf :

- the segments [t i ;t i+1 ] are the integration steps; - the unknowns are the values x(t i ) noted x i .

The differential equation is integrated on each segment [t i ;t i+1 ] .

x = f (x, t) on [t i ; t i+1 ]  x i+1 = x i +

t i+1

 f (x, t)dt

(5.5)

ti

The integral is approximated by a quadrature formula. Starting from the given initial state x 0 , we calculate successively x1 , then x 2 ... until x N . This gives an approximate solution at N discretization times.

5.2.1 Quadrature formulas A quadrature consists in approximating an integral by a sum. The interval [t i ;t i+1 ] is divided into K+1 segments: t i  1  2 

 k  k+1 

The times (k )k=1 to K are not necessarily distinct:

 K  t i+1 .

- the length of the interval [t i ;t i+1 ] is noted h i : hi = t i+1 − t i ;

- the times k are of the form: k = t i + hik with increasing coefficients 0  1  2   k  k+1   K  1 ; - the segments [k ; k+1 ] are the integration stages.

The integral is approximated by a quadrature formula of the type

x i+1 − x i =

t i+1

K

ti

k =1

 f (x, t)dt  h i kf (k , k )

(5.6)

Numerical methods in optimal control

399

This formula requires the states (k )k=1 to K at the intermediate times (k )k=1 to K . The intermediate states (k )k=1 to K are evaluated by a second quadrature. k

K

ti

j=1

k − x i =  f (x, t)dt  h i   kjf ( j ,  j )

(5.7)

A Runge-Kutta method is thus defined as its combination of two quadrature methods with a particular choice of coefficients k , k and  kj . The quadratures (5.6-7) are required to be exact if the function f is constant. K   x i+1 − x i = (t i+1 − t i )f = h i  k f  k =1  K  − x = ( − t )f = h k i k i i   kjf  j=1



K

 k =1



k

K

 j=1

kj

=1 (5.8)

=  k , k = 1 to K

Explicit or implicit method The K intermediate values (k )k=1 to K satisfy a system of K equations. K

k = x i + h i   kjf ( j ,  j ) , k = 1 to K

(5.9)

j=1

If the coefficients  kj are zero for j  k , the state k depends only on the previous states ( j ) jk . In this case, the k can be calculated successively and the method is said to be explicit. Otherwise, one must solve the nonlinear system (5.9) of dimension K whose unknowns are (k )k=1 to K . All values k are obtained simultaneously and the method is said to be implicit. This system of equations (5.9) is solved in two steps: - the initialization (prediction) is done by an explicit method; - iterations (correction) are performed by a fixed point or a Newton method. An implicit method is more stable (as shown in example 5-2), but more difficult to implement as a nonlinear system must be solved at each time step. When the states k have been determined, we obtain x i+1 by the quadrature (5.6).

400

Optimization techniques

Example 5-2: Stability of forward and backward Euler methods −t Consider the differential equation: x = − x whose solution is: x(t) = x 0e .

The solution has a limit: lim x(t) = 0 . t →+

Let us compare the stability of the forward (explicit) and backward (implicit) Euler methods as a function of the step size h: • the forward Euler method with a step h leads to xi+1 = xi − hxi = (1 − h)xi (explicit formula) The method is stable if: 1 − h  1  h  2 (then we retrieve lim xi = 0 ); •

i→+

the backward Euler method with a step h leads to

1 x i (by solving the implicit equation) 1+ h The method is stable for any step h (and we obtain lim xi = 0 ). x i+1 = x i − hx i+1  x i+1 =

i→+

Implicit methods are generally more stable than explicit methods. They allow larger time steps at the cost of more calculations at each step to solve the equation giving x i+1 .

Butcher's array A Runge-Kutta method is completely defined by the number of stages K (for the intermediate states) and the choice of coefficients k , k ,  kj . These coefficients are grouped in the Butcher array. Each row of the array corresponds to an integral approximated by a quadrature, as shown below.

1 K

11  K1 1

1K

 →

k = t i + h i  k

 KK K

 →

k = x i + h i   kjf ( j ,  j ) , k = 1 to K

K

j=1

 →

K

x i+1 = x i + h i  k f (k , k ) k =1

For an explicit method, the elements of the array on the diagonal and above are zero: ( kj ) jk = 0 . The simplest Runge-Kutta methods are: - Euler explicit, implicit → K = 1 stage; - modified Euler, Heun, Crank-Nicolson → K = 2 stages.

Numerical methods in optimal control

401

Explicit Euler method (or forward Euler method) This one-stage method uses the following array and intermediate states.

0 0 1

1 = t i  1 = x i

→ x i+1 = x i + h i f (1 , 1 )

We obtain the explicit formula: xi+1 = xi + hif (xi ,t i ) . This is equivalent to assuming that the solution is linear on [t i ;t i+1 ] with the derivative taken at the known initial point (x i ;t i ) , as illustrated in figure 5-4.

Figure 5-4: Explicit Euler method. Implicit Euler method (or backwards Euler method) This one-stage method uses the following array and intermediate states.

1 1 1

1 = t i + h i = t i+1 → x i+1 = x i + h i f (1 , 1 )  1 = x i + h i f (1 , 1 )

We obtain the implicit formula: xi+1 = xi + hif (xi+1,t i+1 ) , which gives an equation in x i+1 . This is equivalent to assuming that the solution is linear on [t i ;t i+1 ] with the derivative taken at the unknown end point (xi+1;t i+1 ) , as shown in figure 5-5.

Figure 5-5: Implicit Euler method.

402

Optimization techniques

Modified Euler method (or midpoint method) This one-stage method uses the following array and intermediate states.

0 0 0 1/ 2 1/ 2 0 0 1

1  1 = t i , 2 = t i + 2 h i → x i+1 = x i + h i f (2 , 2 )   = x ,  = x + 1 h f ( ,  )  1 i 2 i 2 i 1 1

1

1   This is equivalent to assuming that the solution is linear on [t i ;t i+1 ] with the derivative taken at the unknown midpoint (2 ; 2 ) , as shown in figure 5-6.  

We obtain the explicit formula: x i+1 = x i + h i f  x i + h i f (x i , t i ) , t i + h i  . 2 2

Figure 5-6: Modified Euler method. Heun's method This two-stage method uses the following array and intermediate states.

0 1

0 0 1 0 1/ 2 1/ 2

1 = t i , 2 = t i + h i = t i +1  1 = x i , 2 = x i + h i f (1 , 1 ) 1 1 → x i+1 = x i + h i f (1 , 1 ) + h i f ( 2 , 2 ) 2 2

We obtain the explicit formula

1 1   x i+1 = x i + h i f (x i , t i ) + h if  x i + h if (x i , t i ) , t i+1  2 2  

This is equivalent to assuming a piecewise linear solution on [t i ;t i+1 ] and calculating the integral by the trapezoidal method. The point 2 is estimated at

t i+1 by the explicit Euler method, as shown in figure 5-7.

Numerical methods in optimal control

403

Figure 5-7: Heun's method. Crank-Nicolson method (or trapezoidal method) This two-stage method uses the following array and intermediate states.

0 0 0 1 1/ 2 1/ 2 1/ 2 1/ 2

1 = t i , 2 = t i + h i = t i+1   1 1 1 = x i , 2 = x i + 2 h if (1 , 1 ) + 2 h if (2 , 2 ) 1 1 → x i+1 = x i + h i f (1 , 1 ) + h if (2 , 2 ) 2 2

1 2

1 2

We obtain the implicit formula: x i+1 = x i + h if (x i , t i ) + h if (x i+1, t i+1 ) which gives an equation in x i+1 .

This is equivalent to assuming a piecewise linear solution on [t i ;t i+1 ] and

calculating the integral by the trapezoidal method. The point 2 = x i+1 is such that the tangents from x i and x i+1 meet at the midpoint, as shown in figure 5-8.

Figure 5-8: Crank-Nicolson method. Example 5-3 compares the accuracy of these methods on a simple case.

404

Optimization techniques

Example 5-3: One and two-stage method t −t

Consider the differential equation: x = x whose solution is: x(t) = x 0e 0 . Let us apply the previous methods to solve this equation numerically on the interval from t 0 = 0 to t1 = 1 with the initial condition: x(t 0 ) = 1 . The interval is divided into N equidistant steps of length: h = Explicit Euler

xi+1 = xi + hxi

→ xi+1 = (1 + h)xi

Implicit Euler

xi+1 = xi + hxi+1

x i+1

x +x = x i + h i i+1 2

→ x i+1

→ x N = (1 + h) N x 0 N

1 xi 1− h

 1  → xN =   x0  1− h 

2+h = xi 2−h

 2+h  → xN =   x0  2−h 

→ x i+1 =

Crank-Nicolson

1 . N

N

Table 5-2 gives the error made as a function of the number of steps.

Table 5-2: Comparison of Euler and Crank-Nicolson methods. We observe that the error is of the order of h for the Euler methods and of the order of h² for the Crank-Nicolson method. Consequently, a large number of steps is needed to obtain a very accurate solution. The error depends on the order of the method, as analyzed in section 5.2.2.

Numerical methods in optimal control

405

5.2.2 Error analysis A Runge-Kutta method produces an approximate solution of the differential equation. This section introduces the concepts for quantifying the deviation between the approximate and the exact solution. Consistency error Consider the differential equation: y = f (y, t) . By performing a time step from t i

to t i+1 = t i + hi with a Runge-Kutta method from the initial condition (t i ;x i ) , we obtain the state x i+1 in the form

xi+1 = xi + hi(t i ,xi ,hi )

(5.10)

We note yi (t) the exact (unknown) solution from the initial condition (t i ;x i ) . This exact solution takes the value yi (t i+1 ) at t i+1 .

The consistency error noted ei+1 is the deviation over one time step between the numerical and the exact solution from the same initial condition (figure 5-9). (5.11)

ei+1 = yi (t i+1 ) − xi+1

Figure 5-9: Consistency error.

Global error The global error noted Ei is the deviation at t i between the numerical solution

x i and the exact solution y0 (t i ) obtained from the initial condition x(t 0 ) = x0 . It differs from the consistency error ei+1 at step h i which assumes that the initial condition at t i is reset on the exact solution y0 (t i ) at that time.

406

Optimization techniques

This consistency error does not take into account the difference in initial value between y0 (t i ) and x i coming from previous steps. The global error comes from the accumulation of the consistency errors at each time step as well as the shift of the initial condition at each step as illustrated in figure 5-10.

Figure 5-10: Global error.

Consistency, stability, convergence and order A numerical method generates at each step consistency errors: (ei )i=1 to N and rounding errors: (i )i=1 to N . We note:

,x N ) the solution without rounding errors: xi+1 = xi + hi(t i ,xi ,hi ) ; - (x1 ,x 2 , ,x N ) the solution with rounding errors: xi+1 = xi + hi(t i ,xi ,hi ) + i . The initial point is also subject to rounding error: x 0 = x 0 + 0 . - (x1 ,x 2 ,

We define the notions of consistency, stability, convergence and order as follows: •

the method is consistent if:

N

e i =1

i

⎯⎯⎯⎯ → 0 h max → 0

The sum of the consistency errors tends to 0 when the step size is reduced; •

the method is stable if:

N

max x i − x i  S  i 0i N

i =0

Rounding errors produce a bounded final error. The constant S  0 is the stability constant of the method;

Numerical methods in optimal control





407

max y 0 (t i ) − x i ⎯⎯⎯⎯ → 0 h max → 0

the method is convergent if:

0 i  N

The exact solution can then be approached within the desired accuracy by reducing the step size; p +1 the method is of order p if the consistency error is upper bounded by Ch with a constant C  0 .

These notions are linked by the following properties (see [R4], [R9]): • the method defined by: xi+1 = xi + hi(t i ,xi ,hi ) is of order p if

• • •

k 1 dkf (5.12) (t, x,0) = (x, t) , k = 0 to p − 1 h k k + 1 dt k a method is consistent if it is at least of order 1: (t, x,0) = f (x, t) ; a consistent and stable method is convergent; if the function (t, x,h) is Lipschitzian in x, then the method is stable. L(t − t )



The stability constant is S = e f 0 where L is the Lipschitz constant of  ; the global error of a stable method of order p is upper bounded by p max y 0 (t i ) − x i  SCTh max where T = t f − t 0 , S is the stability constant of  0 i  N

and C is the constant associated with the consistency error in h p+1 . Proof of property (5.12) (see [R4]) The consistency error is the difference over a time step between: y = f (y,t) with y(t i ) = xi ; - the exact solution satisfying: - the approximate solution obtained by: xi+1 = xi + hi(t i ,xi ,hi ) .

We write the Taylor expansion of y and x with respect to the step in h i = 0 : •

expansion of y to order p+1 in h i = 0



p +1 k h ik d k y h i d k −1f p +1 (t ) + o(h ) = x + (x i , t i ) + o(h ip+1 )  i i i k k −1 k! dt k! dt k =1 k =1 dy (t i ) = f  y(t i ), t i  = f (x i , t i ) using y(t i ) = xi and dt expansion of x to order p in h i = 0 p +1

y(t i+1 ) = y(t i ) + 

 p hk k  x i+1 = x i + h i  i (t i , x i ,0) + o(h ip )  k  k =0 k! h  The consistency error is the difference: ei+1 = y(t i+1 ) − xi+1 .

408

Optimization techniques

The term in hk+1 in the expansion of ei+1 is

 h k +1  1 d k f k (x , t ) − (t i , x i ,0)  i i  k k k!  k + 1 dt h  p+1

The method is of order p if: ei+1 = y(t i+1 ) − xi+1  Chi . The terms of order less than p must be zero, which leads to the relations (5.12).

Example 5-4 gives the order of the simplest methods.

Example 5-4: Methods of order 1 and 2 Let us look for the order of the explicit Euler, midpoint and Heun methods. For this purpose, we have to express the function (x, t, h) , derive it with respect to the step h and check up to which order p the relation (5.12) is satisfied. The formulas xi+1 = xi + hi(t i ,xi ,hi ) for these methods have been determined above. Explicit Euler: xi+1 = xi + hif (xi ,t i )

→ h (t,x,0) = 0 (t, x, h) = f (x, t) The relation (5.12) does not hold for k = 1 . The method is of order p = 1 . 1 1   x i+1 = x i + h i f  x i + h if (x i , t i ) , t i + h i  2 2   1   1 (t, x,h) = f  x + hf (x, t) , t + h  2 2   1 1 1 → h (t, x,0) = f x f + f t = f 2 2 2 The relation (5.12) holds for k = 1 . The method is of order p = 2 . 1 1 x i+1 = x i + h i f (x i , t i ) + h if  x i + h if (x i , t i ) , t i+1  Heun: 2 2 1 1 (t, x,h) = f (x, t) + f  x + hf (x, t) , t + h  2 2 1 1 1 → h (t, x,0) = f x f + f t = f 2 2 2 The relation (5.12) holds for k = 1 . The method is of order p = 2 . Midpoint:

Numerical methods in optimal control

409

Step adjustment Consider a stable method of order p over N time steps from t 0 to t f .

The theoretical error is bounded, depending on the step: h max = max(h1,

xi+1 = xi + hi(t i ,xi ,hi )



,h N ) .

max y 0 (t i ) − x i  SCTh pmax 0 i  N

The rounding errors (1 )i=1 to N generate an additional bounded error.

xi+1 = xi + hi(t i ,xi ,hi ) + i



N

max x i − x i  S  i  SNmax 0i N

i =0

The total error (theoretical + rounding) is bounded by p max y0 (t i ) − x i  S CTh max + Nmax  0i N

With equidistant steps: h =

= E max

noted

T  p  , the total error is: E max = ST Ch +  h N 

The optimal step that minimizes the total error is then 1

h opt

   p+1 =   pC 

(5.13)

Example 5-5: Optimal step for the midpoint method Consider the differential equation: x = x whose solution is: y(t) = y 0e

t −t0

.

The midpoint method is applied from t 0 = 0 to t f = 1 starting from: x(t 0 ) = 1 .

The consistency error on the step [t i ;t i+1 ] with the initial condition x i is the difference between the exact and the approximate solution.

  h i2 h i3 t i+1 −t i hi y(t ) = y(t )e = x e = x 1 + h + + + o(h i3 )  Exact: i +1 i i i i 2 6   2  h h  h   Approximate: x i+1 = x i + h i f  x i + i f (x i , t i ) , t i + i  = x i 1 + h i + i  2 2 2   x 3 3 The error is in h3 : ei+1 = y(t i+1 ) − x i+1 = i h i + o(h i ) . The method is of order 2. 6 t −t 1 The interval is divided into N equidistant steps: h = f 0 = . N N

410

Optimization techniques

The consistency error is bounded by: ei+1  Ch3 with C = e/ 6 (because xi  e). 1

The optimal step size is (5.13): h opt

   =   p+1 where  is the machine accuracy.  pC 

Numerical application Assume that the calculation accuracy is:  = 10−7 . The tables below give the total error obtained as a function of the number of steps N varying from 10 to 106 (first table), then refined from N = 100 to N = 1 000 (second table). Number of steps 10 100 1000 10 000 100 000 1000 000

Total error 4.20 10-3 5.37 10-5 8.35 10-5 8.60 10-4 8.58 10-3 8.45 10-2

The optimal step is determined by

Number of steps 100 150 200 250 300 350 400 450 500

Total error 5.37 10-5 3.17 10-5 2.84 10-5 2.84 10-5 2.87 10-5 3.40 10-5 3.63 10-5 4.15 10-5 4.40 10-5

1

p = 2    p+1 → h opt =   = 4.8 10−3 for  = 10−7   pC  C = e / 6 which gives an optimal number of steps: N = 208. Figure 5-11 shows the error as a function of the number of steps.

Figure 5-11: Error as a function of the number of steps.

Numerical methods in optimal control

411

5.2.3 Order conditions The order of a Runge-Kutta method depends on the coefficients k , k and  kj . Here we analyze the conditions on these coefficients to obtain a given order in the case of explicit Runge-Kutta methods: ( kj ) jk = 0 . Each intermediate point k of the quadrature depends only on the previous points ( j ) j=1 to k−1 . k = t i + h i  k  k −1 with f ( j ,  j ) = f j and  noted  = x + h  k i i   kjf j j=1 

K

x i+1 = x i + h i  k f k k =1

(5.14)

The method is of order 1 at least if k −1

  kj =  k , j=1

K

 k =1

k

=1

(5.15)

The method is of order 2 at least if K

  k =1

k k

=

1 2

(5.16)

The method is of order 3 at least if K

  k =1

2 k k

=

1 , 3

K



k =1, jk

 jk  kj =

1 6

(5.17)

The method is of order 4 at least if K

 3kk = k =1

1 , 4

K



k =1, j k

1  = ,  12 k =1, j k K

2 j k kj

 j kk  kj =

1 8

1  ik  kj ji =  12 k =1, jk K

(5.18)

Demonstration (see [R4], [R9])

k 1 dkf (t, x,0) = (x, t) . h k k + 1 dt k We calculate the derivatives with respect to h of the function  defined by These relations are established from (5.12): K

k −1

k =1

j=1

(t i , x i , h) =  k f (k , k ) with k = x i + h   kjf ( j ,  j ) and k = t i + h k

412

Optimization techniques

Value of  (k = 0) In h = 0 , we have: k = xi and k = t i . K

The value of  in h = 0 is: (t, x,0) =  k f (x, t) . k =1

The condition: (t, x,0) = f (x, t) gives:

K

 k =1

k

= 1.

This condition has already been imposed on the quadratures (5.8). The conditions (5.15) ensure that the quadratures are exact if the function f is constant. First derivative of  (k = 1) The formula for  is derived with respect to h.  K f (k , k ) K   k   =  k =  k f x + ft k  h k =1 h h   h k =1 k −1 k −1 k  k with =   kjf ( j ,  j ) + h   kjf ( j ,  j ) and = k h h j=1 h j=1 In h = 0 :

 k −1  k k −1 =   kjf ( j ,  j ) =    kj  f (x, t) =  k f (x, t) h j=1  j=1  k −1

because

 j=1

kj

=  k (order 1)

K   K  df . (t, x,0) =  k (f x f k + f t  k ) =    kk  h k =1  k =1  dt  1 df The condition: (t, x,0) = (x, t) gives the condition (5.16): h 2 dt

The result is:

K

  k =1

k

k

1 = . 2

Second derivative of  (k = 2) Again, the formula for  is derived with respect to h. 2 2  2 K  2f (k , k ) K   k  k k  2 k   k  =  =  f + 2f + f + f     k k xx  xt tt  x   h 2 k =1 h 2 h h h 2   h  k =1   h 

with

 2k  k −1 2 =   kjf ( j ,  j ) h 2 in h =0 h j=1

and

 k −1  df  2k = 2    j kj  2 h  j=1  dt

and

In h = 0 :

f ( j ,  j ) h

= fx

 j h

k =  k f (x, t) h

+ ft

 j h

= j

in h =0

df dt

Numerical methods in optimal control

413

The result is  K  2  2  K 2  2 =   + + + (t, x,0) (f f 2f f f ) 2    jk  kj  (f x f + f x f t )  k k  xx xt tt  2 h  k =1   k =1, jk 

d 2f  2 1 d 2f = f xx f 2 + 2f xt f + f tt + f x (f x f + f t ) (t, x,0) = with dt 2 h 2 3 dt 2 K K 1 1 2 gives the conditions (5.17):   kk = and   jk  kj = . 3 6 k =1 k =1, j k The calculation of the third derivative is similar and leads to the fourth order conditions (5.18). This very long calculation is not detailed here. The condition:

A Runge-Kutta method is defined by the number of stages K (number of intermediate evaluations of f) and the choice of k , k and  kj . The conditions (5.15) to (5.18) allow to choose these coefficients to obtain a given order. Let us look at the most common possibilities for the 1 to 4 stages methods. Explicit methods with 1 stage (K = 1) The method is explicit: 11 = 0 Order 1 conditions:

1 = 0 , 1 = 1

We obtain the explicit Euler method whose array is:

0 0 1

Explicit methods with 2 stages (K = 2) The method is explicit: 11 = 12 =  22 = 0 Order 1 conditions:

 11 + 12 = 1  1 = 0   21 +  22 =  2    =  =  2  21  +  = 1 noted  1 2

Order 2 conditions:

11 + 22 =

1 1 1  2 = , 1 = 1 − 2 2 2

414

Optimization techniques

This results in methods of order 2 with a parameter 

0 

associated with the array opposite.

0 

The midpoint method corresponds to  = 0.5 .

1−

The Heun method of order 2 corresponds to  = 1 .

1 2

0 0 1 2

Methods with 3 or 4 stages (K = 3 or 4) The most commonly used 3- or 4-stage methods are the following:











explicit 3-stage Heun of order 3

0 0 0 0 1/ 3 1/ 3 0 0 2/3 0 2/3 0 1/ 4 0 3/ 4

implicit 3-stage Hermite-Simpson of order 3

0 0 0 0 1 / 2 5 / 24 1 / 3 −5 / 24 1 1/ 6 2 / 3 1/ 6 1/ 6 2 / 3 1/ 6

explicit 4-stage Runge of order 3

explicit 4-stage 3/8 method of order 4

explicit 4-stage Runge-Kutta of order 4

0 0 0 1/ 2 1/ 2 0 1 0 1 1 0 0 1/ 6 2 / 3 0 0 1/ 3 1/ 3 2 / 3 −1 / 3 1 1 1/ 8

0 0 0 0 0 0 1 0 0 1/ 6

0 0 0 0 0 0 1 0 0 −1 1 0 3 / 8 3 / 8 1/ 8

0 0 0 0 0 1/ 2 1/ 2 0 0 0 1/ 2 0 1/ 2 0 0 1 0 0 1 0 1/ 6 2 / 6 2 / 6 1/ 6

This last method, called the "classical Runge-Kutta method of order 4", is widely used in practice, as it is easy to program and extremely robust. This is due to its L(t − t ) stability constant S = e f 0 , where L is the Lipschitz constant of the function f.

Numerical methods in optimal control

415

The detailed formulas of the Runge-Kutta method of order 4 are as follows.

k1 = h i f (x i , t i )  k = h f  x + 1 k , t + 1 h  i  i 1 i i  2 2 2    k = h f  x + 1 k , t + 1 h  i  i 2 i i  3 2 2    k 4 = h i f (x i + k 3 , t i+1 )

1 → x i+1 = x i + (k1 + 2k 2 + 2k 3 + k 4 ) 6

(5.19)

The quadratures associated with the Butcher array can be interpreted as follows.

5.2.4 Embedded methods Error estimation To estimate the error on a step from t 0 to t1 , the calculation is made in two ways: - the integration in a single step of length 2h = t1 − t 0 gives a solution x1 ; - the integration in two successive steps of length h gives a solution x 2 .

If the method is of order p, the consistency error is Ch p+1 . The consistency errors e1,e2 between the solutions x1, x 2 and the exact solution y(t1 ) are then

e1 = y(t1 ) − x1 = C(2h) p+1 + o(2h p+1 )  p+1 + o(h p+1 ) e2 = y(t1 ) − x 2 = 2C(h)

(5.20)

By observing the difference  between x 2 (2 steps of h) and x1 (1 step of 2h), we can assess the constant C and choose a step h max to obtain a given error max . 1

 = x 2 − x1 = 2Ch p+1 (2p − 1) + o(h p+1 )



h max

   p+1   max  h   

(5.21)

416

Optimization techniques

The deviation  also allows the elimination of the term in hp+1 in x 2 (5.20) giving a solution x 2 of order p + 1 from x 2 (local extrapolation method).

 = 2Ch p+1 (2p − 1)

→ x2 = x2 +

 with y(t1 ) − x 2 = o(h p+1 ) (5.22) 2 −1 p

Embedded method The embedded methods Runge-Kutta use this double evaluation process at each step to estimate the error and adapt the integration step. A K-stage method performs K evaluations of f to construct the solution. If the coefficients of the method are well chosen, it is possible to reuse these evaluations to construct a second solution of different order (embedded method). The difference between the two solutions gives an error estimate without further evaluation. The step size is then adjusted so that the error remains within a given tolerance. The evaluations are also used to construct a dense output. The dense output is an interpolation to a given order of the solution over the time step. It allows a discretized solution to be generated without necessarily going through all the intermediate times. There are numerous ways of constructing embedded methods. These methods are denoted as p(p') where p and p' are the respective orders of the computed solution and the embedded solution to control the error. It can be shown that at least 6 steps are needed to construct a embedded method of order greater than 4. The most commonly used methods of order 4 and 5 are listed below. For each * method, the column k corresponds to the calculated solution and the column k to the error estimate. •

Cash-Karp method of order 5(4) k

 kj

0

0

1 5 3 10 3 5

1 5 3 40 3 10 11 − 54 1631 55296

1 7 8

0

0

0

0

0

0

0

0

9 0 0 40 9 6 0 − 10 5 5 70 35 − 2 27 27 175 575 44275 512 13824 110592

k 37 378

*k 2825 27648

0

0

18575 48384 13525 0 55296 277 0 0 14336 253 512 1 4096 1771 4 0

250 621 125 694

Numerical methods in optimal control



417

Fehlberg method of order 4(5) k

 kj

0

0

1 4 3 8 12 13

1 4 3 32 1932 2197 439 216 8 − 27

1 1 2

0

0

0

0

0

0

0

0

0

0

0

0

0

9 32 7200 − 2197 −8 2

7296 2197 3680 513 3544 − 2565

845 4104 1859 4104

0





11 40

k 25 216

*k 16 135

0

0

1408 2565 2197 4104 1 − 5

6656 12825 28561 56430 9 − 50 2 55

0

The most successful higher order methods include: - the 5(4) method with 7 stages of Dormand-Prince (DOPRI5 software); - the 8(6) method with 16 stages of Dormand-Prince (DOPR86 software); - the 8(5,3) method with 17 stages of Dormand-Prince (DOP853 software). The DOP853 software includes a fifth-order error estimate and another third-order error estimate (which improves the estimate) as well as a dense seventh-order output. The reference work for the development of these methods is [R9]. Extrapolation method An alternative approach to controlling the integration error is to apply a method of order p on the interval [t i ;t i+1 ] with n k steps equal to h i / n k . By varying the number of steps (n1  n 2 

 n k ) , K evaluations of x i+1 are constructed.

A Richardson extrapolation (Volume I section 1.2) allows then to calculate the limit solution when the step h tends to 0. We thus obtain an extrapolated solution x i+1 of order p + K − 1 . This method makes it possible to obtain a very accurate numerical solution at the cost of a larger number of function evaluations. The Gragg-Bulirsch-Stoer (GBS) methods Gragg-Bulirsch-Stoer (GBS) methods use this principle with the step defined by a Romberg sequence (n k = 2k) or by a harmonic sequence (n k = k) . The ODEX software based on this choice allows to obtain solutions up to order 18.

418

Optimization techniques

5.3 Adams methods Adams methods are multi-step methods for numerically solving a first order differential system of the form

x(t) = f  x(t),t  , t 0  t  t f

(5.23)

It is assumed that the solution has been calculated at K + 1 previous times t i−K  t i−K+1   t i−1  t i . The values of x at these times are: The values of f at these times are:

xi−K , xi−K+1 , fi−K , fi−K+1 ,

The value of x at time t i+1 is defined by: x i+1 = x i +

, xi−1 , xi , fi−1 , fi

t i+1

 f (x, t)dt

.

ti

To calculate the integral, we replace f by its interpolation polynomial P or P*: - the polynomial P is based on the K + 1 known values (fk )k=i−K to i at (t k )k=i−K to i ; - the polynomial P* additionally uses the unknown value f i+1 at time t i+1 . These two polynomials are shown in figure 5-12.

Figure 5-12: Interpolation polynomial. The Adams-Bashford methods (section 5.3.1) use the polynomial P, which depends only on the known previous values of the function. These methods are explicit. The Adams-Moulton methods (section 5.3.2) use the polynomial P*, which depends on the unknown value of the function at the new time. These methods are implicit. Multi-step methods require an initialization of the first K + 1 points by a singlestep method. An explicit Runge-Kutta method of the same order as the chosen Adams method is usually used.

Numerical methods in optimal control

419

5.3.1 Adams-Bashford methods The polynomial P of degree K takes the values (fk )k=i−K to i at times (t k )k=i−K to i . It is formed from Lagrange polynomials (Lk )k=0 to K associated with (t k )k=i−K to i . t − t i− j

K

L k (t) = 

t i−k − t i − j

j=0 j k

K

P(t) =  f i−k L k (t) k =0

0 if j  k → L k (t i− j ) =   1 if j = k

(5.24)

→ P(t i− j ) = f i− j

The Adams-Bashford method with K + 1 steps approximates x i+1 by

x i+1  x i +

t i+1

K

ti

k =0

 P(t)dt = xi + hi kfi−k

with k =

1 hi

t i+1

 L (t)dt k

(5.25)

ti

This explicit formula gives x i+1 as a function of the previous K + 1 values. This method noted ABK+1 is of order K + 1. Its stability constant for a Lipschitzian K

function of constant L is: S = ebL(t f −t 0 ) with b =  k . k =0

The stability is low as the number of steps K increases (because b and S become large). Let us detail the Adams-Bashford methods with 1, 2, 3 and 4 steps: • method AB1 The interpolation polynomial is constant: P(t) = fi . Formula (5.25) gives: xi+1 = xi + hifi (explicit Euler method); •

method AB2

The interpolation polynomial is affine: Its integral on [t i ;t i+1 ] gives:

P(t) = f i +

t i+1



 P(t)dt = h f i

ti

i

+

f i − f i−1 (t − t i ) . t i − t i−1

 hi (f i − f i−1 )  . 2h i−1 

The steps hi−1 = t i − t i−1 and hi = t i+1 − t i are not necessarily identical. 3f − f With a constant step size h, formula (5.25) gives: x i+1 = x i + h i i−1 ; 2

420



Optimization techniques

method AB3 with constant step

Formula (5.25) gives: x i+1 = x i + h •

method AB4 with constant step

Formula (5.25) gives: x i+1 = x i + h

23fi −16fi−1 + 5fi−2 ; 12 55fi − 59fi−1 + 37f i−2 − 9f i−3 . 24

The Nyström method is a variant of the Adams-Bashford method in which the point x i+1 is calculated from the point x i−1 (instead of x i ). With a constant step size h, formula (5.25) becomes t i+1

K

t i−1

k =0

 P(t)dt = x i−1 + h kfi−k

x i+1  x i−1 +

with k =

t

1 i+1 Lk (t)dt h ti−1

(5.26)

• Nyström method with 1 or 2 steps Formula (5.26) gives: xi+1 = xi−1 + 2hfi (midpoint method); •

Nyström method with 3 steps

Formula (5.26) gives: x i+1 = x i−1 + h

7fi − 2fi−1 + fi−2 . 3

5.3.2 Adams-Moulton methods The polynomial P* of degree K + 1 takes values (f k )k=i−K to i+1 at times (t k )k=i−K to i+1 The point (t i+1 ;fi+1 ) is not known (we are looking for x i+1 ). P* is expressed with the K + 2 Lagrange polynomials (L*k )k =−1 to K associated with (t k )k=i−K to i+1 . t − t i− j

K

L*k (t) = 

t

− t i− j

f

L*k (t)

j=−1 i − k j k

P* (t) =

K

k =−1

i−k

0 if j  k → L*k (t i− j ) =   1 if j = k

(5.27)

→ P* (t i− j ) = f i− j

The Adams-Moulton method with K + 1 steps approximates x i+1 by

x i+1  x i +

t i+1

K

ti

k =−1

* *  P (t)dt = xi + hi  kfi−k

with *k =

1 hi

t i+1

 L (t)dt ti

* k

(5.28)

Numerical methods in optimal control

421

The method is implicit, as the second member depends on x i+1 (index k = −1 ). To obtain x i+1 , we have to solve the following nonlinear equation. K

x i+1 = x i + h i  *k fi−k + h i*−1f (x i+1, t i+1 )

(5.29)

k =0

The resolution is done by prediction-correction: - a prediction i+1 is made by an explicit method (e.g. ABK+1); - the function is evaluated in (i+1 ,t i+1 ) : i+1 = f (i+1 , t i+1 ) ; K

- the correction is performed by (5.28): x i+1 = x i + h i  *k fi−k + h i*−1i+1 ; k =0

- the function is evaluated in (xi+1 , t i+1 ) : fi+1 = f (xi+1 ,t i+1 ) . If necessary, the formula (5.28) can be iterated to increase the accuracy (fixed point method). A single correction is generally sufficient if the prediction is of order K + 1. This method is called PECE (Prediction-Evaluation-Correction-Evaluation). The PEC variant omits the evaluation of f i+1 and keeps the value i+1 . The calculation is faster, but slightly less stable. This method noted AMK+1 is of order K + 2. Its stability constant for a Lipschitzian K

function of constant L is: S* = eb L(t f −t 0 ) with b* =  *k . *

k =0

The stability of AMK+1 is better than that of ABK+1, because b*  b . Let us detail the formulas of the Adams-Moulton methods with 1, 2, 3 and 4 steps: •

method AM1

* The interpolation polynomial is affine: P (t) = f i +

Its integral on [t i , t i+1 ] gives:

t i+1

 P (t)dt = h *

ti

i

f i+1 − f i (t − t i ) . t i+1 − t i

fi + fi+1 . 2

fi + fi+1 . 2 We retrieve the Crank-Nicolson method (or trapezoidal method). 1 1 The equation to solve to obtain x i+1 is: x i+1 − h i f (x i+1 , t i+1 ) = x i + h if i . 2 2

Formula (5.28) gives: x i+1 = x i + h i

422

Optimization techniques

A PECE method can be applied using an AB1 predictor (= Euler) of order 1. The algorithm is then identical to the Heun method: - prediction (Euler): i+1 = xi + hifi 1 1 - correction: x i+1 = x i + h if i + h i i+1 2 2 • method AM2 The interpolation polynomial is of degree 2. (t − t i−1 )(t − t i ) (t − t i−1 )(t − t i+1 ) (t − t i )(t − t i+1 ) P* (t) = f i+1 − fi + f i−1 h i (h i−1 + h i ) h i−1h i h i−1 (h i−1 + h i ) Integrating it on [t i ;t i+1 ] gives

3h i−1 + 2h i 3h + h h i2 fi+1 + h i i−1 i fi − h i fi−1 6(h i−1 + h i ) 6h i−1 6h i−1 (h i−1 + h i ) A constant step size h is usually chosen. 8 1 5  Formula (5.28) gives: x i+1 = x i + h i  fi+1 + fi − f i−1  ; 12 12   12 • method AM3 with constant step 9f + 19fi − 5fi−1 + fi−2 Formula (5.28) gives: x i+1 = x i + h i+1 ; 24 • method AM4 with constant step 251fi+1 + 646fi − 264fi−1 + 106fi−2 − 19fi−3 Formula (5.28) gives: x i+1 = x i + h . 720 x i+1 = x i + h i

Like the Nyström method (section 5.3.1), the Milne-Simpson method is a variant of Adams-Moulton in which the point x i+1 is calculated from the point x i−1 (instead of x i ). With a constant step size, the formula (5.28) becomes

x i+1  x i−1 +

t i+1

K

ti

k =−1

* *  P (t)dt = xi−1 + h  kfi−k

with *k =

• Milne-Simpson 1-stage method Formula (5.30) gives: xi+1 = xi−1 + 2hfi (midpoint method); •

Milne-Simpson 2-stage method

Formula (5.30) gives: x i+1 = x i−1 + h

fi + 4fi−1 + fi−2 . 3

t

1 i+1 * Lk (t)dt (5.30) h ti−1

Numerical methods in optimal control

423

5.4 Collocation methods Collocation methods search for a piecewise polynomial solution of a first order differential system of the form

 x(t) = f  x(t), t  , t 0  t  t f   x(t 0 ) = x 0

(5.31)

The interval [t 0 ;t f ] is divided into N segments with times

t 0  t1 

 t i  t i+1 

 t N = tf

The solution on each segment is approximated by a polynomial of degree K.

(t) = a 0 + a1t + a 2 t 2 +

+ a K t K , t i  t  t i+1

(5.32)

The K + 1 coefficients a 0 ,a1 ,

,a K must be determined so that the polynomial is close to the exact solution of the differential equation on the segment [t i ;t i+1 ] .

5.4.1 Collocation conditions To determine the K+1 coefficients of the polynomial (5.32), we choose K times (k )k=1 to K in [t i ;t i+1 ] and impose the K + 1 conditions

(t i ) = x(t i ) ( ) = f ( ,  ) = f , k = 1 to K k k k  k noted

(5.33)

The times (k )k=1 to K called collocation points or nodes are freely chosen between

t i and t i+1 as in figure 5-3: t i  1  2 

 K−1  K  ti+1 .

The conditions (5.33) require that the derivatives of the polynomial satisfy the differential equation x = f (x, t) at the collocation points and that the polynomial takes the known initial value x(t i ) in t i . Link to Runge-Kutta methods The derivative of the polynomial (5.32) is a polynomial of degree K − 1 taking values (f k )k=1 to K at times (k )k=1 to K . This derivative polynomial can be formed from the K Lagrange interpolation polynomials (L j ) j=1 to K associated with (k )k=1 to K .

424

Optimization techniques K

L j (t) =  k =1 k j

0 if k  j → L j ( k ) =   1 if k = j

t − k  j − k

K

(t) =  f jL j (t)

(5.34)

→  ( k ) = f k

j=1

By integrating the derived polynomial (t) on [t i ; k ] , we obtain K

k

j=1

ti

(k ) = (t i ) +  f j  L j (t)dt

with (t i ) = x(t i )

(5.35)

Now suppose that we apply a K-stage Runge-Kutta method with the coefficients k , k and  kj . Formulas (5.6) and (5.7) give K

K

k =1

j=1

x i+1 = x i + h i  k f (k , k ) with k = x i + h i   kjf ( j ,  j ) , k =1 to K (5.36) By choosing the coefficients k , k and  kj such that

1 k = t i +  k h i , k = hi

t i+1



1 k L (t)dt ,  = kj t k t L j (t)dt h i i i

(5.37)

we retrieve the values of the polynomial (t) at the times (k )k=1 to K and t i+1 . A collocation method of degree K can thus be considered as a particular implicit Runge-Kutta method with K stages. It will have the same properties of order and stability.

5.4.2 Collocation points The collocation polynomial (t) can be expressed with the K + 1 interpolation polynomials of Lagrange (L j ) j=0 to K associated with (k )k=0 to K , and noting by convention 0 = t i and 0 = x(t i ) . K

L j (t) =  k =0 k j

K

t − k  j − k

(t) =   jL j (t) j=0

0 if k  j → L j ( k ) =   1 if k = j → (  k ) =  k

(5.38)

Numerical methods in optimal control

425

The unknowns are the values k = (k ) taken by the polynomial at the collocation times. The initial condition is imposed: 0 = x(t i ) . The collocation conditions at times k form a nonlinear system of dimension K. K

  L (  ) = f ( ,  ) j=0

j

j

k

k

k

, k = 1 to K

(5.39)

The solution of equation (5.31) is approximated by a sequence of N polynomials of degree K of the form (5.32) defined on the successive segments [t i ;t i+1 ] and satisfying the conditions (5.39). The quality of the approximation depends on the number N of segments, the degree K of the polynomials and the positioning of the collocation points. Many variants are possible and are detailed in reference [R2]. Local or global collocation Local collocation methods consist in fixing the degree K of the polynomials and varying the number N of segments. Conversely, the global collocation methods consist in fixing the number N of segments (possibly reduced to a single segment) and varying the degree K of the polynomials. The discretization (value of N or K) is progressively refined until a stable solution with a given error tolerance is obtained. Standard or orthogonal collocation The standard collocation uses equidistant times (k )k=1 to K in the interval [t i ;t i+1 ] usually with polynomials of degree 3. This approach can be easily applied to many problems (section 5.4.3). The orthogonal collocation takes as collocation times k the roots of a polynomial of a family of orthogonal polynomials (Legendre, Chebyshev). This positioning increases the accuracy of the quadrature formulas. A frequent choice is to use the Legendre polynomials PK (of degree K) defined t − ti  +1 on [−1; + 1] , coming back to the integration interval [t i ;t i+1 ] by: . = t i+1 − t i 2 For an infinite final time, a global collocation can be applied passing from the 1+  interval [−1; + 1] to the integration interval [t 0 ; + ] by: t − t 0 = . 1−  The main methods for positioning the collocation points are as follows:

426



Optimization techniques

Legendre-Gauss or Legendre-Gauss-Radau method

The Legendre-Gauss method defines the times (k )k=1 to K as the K roots of PK , plus the initial time 0 = −1 . The Legendre-Gauss-Radau method is similar, taking the K roots of (PK−1 + PK ) .

K

The collocation polynomial (t) is defined on [−1; + 1] by: () =   jL j () . j=0

The collocation conditions form a system of dimension K + 1.

(k ) = f (k ), k  , k = 0 to K

(5.40)

The final state at t i+1 is then calculated for  = +1 ; •

Legendre-Gauss-Lobatto method

The times (k )k=1 to K−1 are the K − 1 roots of the derived polynomial PK , plus the initial time 0 = −1 and the final time K = +1 . K

The collocation polynomial (t) is defined on [−1; + 1] by: () =   jL j () . j=0

The collocation conditions form a system of dimension K + 1.

(k ) = f (k ), k  , k = 0 to K

(5.41)

The final state at t i+1 is obtained directly by solving the system, as K = +1 . This is the main difference with the Legendre-Gauss method. Pseudo-spectral methods use a global (on [t 0 ;t f ] ) orthogonal (generally with Legendre-Gauss-Lobatto points) collocation.

5.4.3 Collocation of degree 3 The simplest form of collocation uses polynomials of degree 3. (5.42)

(t) = a 0 + a1t + a 2 t 2 + a 3t 3 on [t 0 ;t1 ] We return to the interval [0; 1] by the change of variable: s =

(s) = 0 + 1s + 2s2 + 3s3 on [0 ; 1]

t − t0 . t1 − t 0 (5.43)

Numerical methods in optimal control

427

The derivative of  with respect to s is denoted  ' .

d d dt (5.44) = = Tf (, t) with t1 − t 0 = T noted ds dt ds The collocation conditions in variable s on the interval [0; 1] are of the form ' =

 '(s) = 1 + 22s + 33s2 = Tf (, t)

(5.45)

The unknowns are the coefficients (0 , 1, 2 , 3 ) . To determine them, three collocation points (s1 ,s2 ,s3 ) are chosen, usually equidistant: - the point s1 = 0 corresponds to the initial time t 0 ; - the point s2 = 0.5 corresponds to the middle time t c ; - the point s3 = 1 corresponds to the final time t1 .

The collocation conditions (5.33) give a system of dimension 4.

 0 = x 0  0 = x 0   1 = T f ( 0 , t 0 )  '0 = T f (0 , t 0 )   3 1 1 1   (5.46)   'c = T f (c , t c ) 1 +  2 + 4  3 = T f   0 + 2 1 + 4  2 + 8  3 , t c   '1 = T f (1 , t1 )   1 + 2 2 + 3 3 = T f (  0 + 1 +  2 +  3 , t1 ) This system is reduced by expressing the unknowns (0 , 1, 2 , 3 ) as a function of (0 , 1 ,  '0 ,  '1 ) .

 0 =  0  0    '0 = 1 1  =  +  +  +    0 1 2 3  1  2  '1 = 1 + 2 2 + 3 3    3

= 0 =  '0 = − 30 − 2 '0 + 31 −  '1

(5.47)

= 20 +  '0 − 21 +  '1

The conditions of collocation in t 0 , t1 give  '0 ,  '1 as a function of 0 , 1 .

 ' = T 0 = T f (0 , t 0 ) = Tf 0  0 noted  = Tf1  '1 = T 1 = T f (1 , t1 ) noted

0 = 0 , 1 = f 0  →  2 = − 30 + 31 − 2f 0 − f1  3 = 20 − 21 + f 0 + f1

(5.48)

The coefficients (0 , 1, 2 , 3 ) thus depend only on the values of (0 , 1 ) : - the initial value is known: 0 = x0 ;

- the unknown final value 1 must satisfy the collocation condition in t c .

428

Optimization techniques

1 1 1  c = 0 + 2 1 + 4  2 + 8 3 (5.49)  'c = T c = T f (c , t c ) with   ' =  +  + 3  1 2 3  c 4 By replacing the coefficients (0 , 1, 2 , 3 ) given by (5.48), we are reduced to an equation with unknown 1 . This equation is called the defect equation.

1 1 1  3 T f  (0 + 1 ) + (f 0 − f1 ) , t c  + (0 − 1 ) + (f 0 + f1 ) = 0 8 4 2  2

(5.50)

Figure 5-13 summarizes the process of determining the polynomial of degree 3.

Figure 5-13: Collocation polynomial of degree 3.

Example 5-6: Collocation of degree 3 Consider the differential equation: x = x on the interval from t 0 = 0 to t1 = 1 . We seek the collocation polynomial of degree 3 for the initial condition: x(t 0 ) = 1.

Numerical methods in optimal control

429

The defect equation associated with the midpoint is 1 1 T = t1 − t 0 = 1 1  3 T f  (0 + 1 ) + (f 0 − f1 ) , t c  + (0 −1 ) + (f 0 + f1 ) = 0 with  8 4 2  2 f (x, t) = x f 0 = T f (0 , t 0 ) = T 0 = 0 Replacing:  , the equation reduces to: 190 − 71 = 0. f1 = T f (1 , t1 ) = T 1 = 1 19 This gives the solution: 1 = 0  2.71429 for the initial condition: 0 = 1 . 7 t −t This solution is close to the exact solution: x(t1 ) = e 1 0 = e  2.71828 . 2 3 The collocation polynomial on [0; 1] is: (t) = 1+ t + 0.42857 t + 0.28571t .

5.4.4 Collocation of degree 5 A more accurate solution can be obtained with polynomials of degree 5. (5.51)

(t) = a 0 + a1t + a 2 t 2 + a 3t 3 + a 4 t 4 + a 5t 5 on [t 0 ; t1 ] We return to the interval [0; 1] by the change of variable: s =

(s) = 0 + 1s +  2s2 + 3s3 +  4s 4 + 5s5 on [0 ; 1]

t − t0 . t1 − t 0

(5.52)

The collocation conditions in variable s on the interval [0; 1] are of the form

 '(s) = 1 + 22s + 33s 2 + 44s3 + 55s 4 = Tf (, t)

(5.53)

The unknowns are the coefficients (0 , 1, 2 , 3 , 4 , 5 ) . To determine them, five collocation points are chosen (s1 ,s2 ,s3 ,s4 ,s5 ) . The interpolation error is minimized by choosing orthogonal Gauss-Lobatto points.

 1 s1 = 0 , s 2 = 1 − 2   1 1  s3 = 2 , s 4 = 2 1 +  

3   0.173 7  3   0.827 , s5 = 1 7 

These points correspond to the times t 0 ,t g1 ,t c ,t g2 ,t1 .

(5.54)

430

Optimization techniques

The collocation conditions (5.33) give a system of dimension 6.  0 =  0  with  '0 = T 0 = T f (0 , t 0 )  '0 = 1  =  +  +  +  +  +  0 1 2 3 4 5  1  ' =  + 2 + 3 + 4 + 5 with  '1 = T 1 = T f (1 , t1 ) (5.55) 1 2 3 4 5  1  1 1 1 1 1 c =  0 + 1 +  2 +  3 +  4 +  5 2 4 8 16 32   3 1 5 with  'c = T  c = T f ( c , t c )  'c = 1 +  2 +  3 +  4 +  5 4 2 16 

This linear system gives (0 , 1, 2 , 3 , 4 , 5 ) as a function of (0 , c , 1 ) : - the initial value is known: 0 = x0 ;

- the values c , 1 must satisfy the collocation conditions in t g1 , t g2 . This reduces to a system of two equations with two unknowns. Figure 5-14 summarizes the process of determining the polynomial of degree 5.

Figure 5-14: Collocation polynomial of degree 5.

Numerical methods in optimal control

431

5.5 Direct methods Direct methods consist in discretizing the control problem in order to formulate an "equivalent" finite-dimensional constrained optimization problem. This problem can then by solved either by a nonlinear programming algorithm or by a variational method.

5.5.1 Discretization We consider the problem with a fixed final time in Mayer form (final cost). Any control problem can be put into this form by a change of variables.

x = f (x,u, t) , x(t 0 ) = x 0 (5.56) min J = (x f ) with  u (x f ) = 0 The PMP necessary conditions of optimality are expressed with the adjoint p, the q multipliers   of the q final constraints and the Hamiltonian defined by:

H(x,u,p, t) = pTf (x,u, t) . x = f x = Hp   T p = − f x p p = − H x    f uT p = 0 H u = 0 (x ) = 0 (x ) = 0 f f   pf = xf +  xf  pf = xf +  xf   Let us discretize the state and control on N intervals: t 0  t1 

(5.57)

 ti 

 t N = tf .

The values of state (xi )i=0 to N and control (ui )i=0 to N define an approximation to the exact solution of the problem (5.56). Considering a piecewise constant control on each interval [t i ;t i+1 ] , the state equation x = f (x, t) can be approximated by xi 

x i+1 − x i = f (x i , u i , t i ) with h i = t i+1 − t i hi

(5.58)

Equations (5.58) are constraints linking the values (xi )i=0 to N and (ui )i=0 to N . These N constraints are of the form

Ci (ui ,xi ,xi+1 ) = xi+1 − xi − hif (xi ,ui ,t i ) = 0

(5.59)

432

Optimization techniques

We thus formulate a finite-dimensional constrained optimization problem.

min F = (x N ) u i ,x i

Ci (u i , x i , x i+1 ) = 0 , i = 0 to N − 1 s.t.  (x N ) = 0

(5.60)

This problem has 2N + 1 variables ( x 0 is fixed) and N + q constraints. Optimality conditions The KKT optimality conditions of problem (5.60) are expressed introducing the N multipliers (i )i=0 to N−1 of the constraints (Ci )i=0 to N−1 , the q multipliers   q of the q final constraints and the Lagrangian defined by N −1

L(u i , x i , i , ) = (x N ) +  iTCi (u i , x i , x i+1 ) +  T(x N ) . i =0

 ui L = 0 f uT (x i , u i , t i ) i = 0   T  xi L = 0  i−1 −  i − h i f x (x i , u i , t i ) i = 0    x N L = 0  x (x N ) +  x (x N ) +  N−1 = 0 for i = 0 to N − 1 (5.61)  C (u , x , x ) = 0  i L = 0  i i i i+1  L = 0  (x N ) = 0   

These optimality conditions form a two-point boundary value discrete system. xi+1 = xi + hif (xi ,ui ,t i ) . The state propagates forwards from x 0 :

 N−1 = − x (x N ) −  x (x N ) . T  i−1 =  i + h i f x (x i , u i , t i ) i

The adjoint propagates backwards from  N−1 : 

Let us look for the limit of the KKT conditions when the step h i tends to 0. The multipliers (i )i=0 to N−1 become a function  (t) and we get

f uT (x, u, t) = 0 f uT (x i , u i , t i ) i = 0   T T  = − f x (x, u, t)  i−1 −  i − h i f x (x i , u i , t i ) i = 0   →  (t f ) = −  x (x f ) −  x (x f ) (5.62) x (x N ) +  x (x N ) +  N−1 = 0 ⎯⎯⎯ h i →0 C (u , x , x ) = 0  x = f (x, u, t)  i i i i+1   (x N ) = 0  (x f ) = 0  

Numerical methods in optimal control

433

The optimality conditions (5.57) of the control problem can be retrieved by setting  = − p . The multipliers (i ) represent thus approximations of the adjoint p at the times (t i ) . The opposite sign comes from the choice of the abnormal multiplier (p0 = 1) used to define the Hamiltonian.

Discretization choice The discretization can be done in different ways. The control represented by its values (ui )i=0 to N at the times (t i )i=0 to N can be interpolated as piecewise constant, piecewise linear, splines... The differential state equation can be solved by propagation or collocation. With a propagation approach, the state is calculated from x 0 by applying the control defined by the values (ui )i=0 to N . A Runge-Kutta type method of

appropriate order (depending on the desired accuracy) is chosen using or not the same discretization times as the control. When it is known from experience that the solution control does not have large variations, a rough discretization (t i )i=0 to N can be applied to limit the number of variables, while applying an accurate integration method with a large number of steps. With a collocation approach, the state is also discretized and the variables (xi )i=1 to N become additional unknowns of the optimization problem. The constraints (5.59) are replaced by the collocation conditions. Thus, a large optimization problem is formulated that can be solved by standard nonlinear programming methods or by the variational method presented in the next section. We observe that each collocation constraint is on a segment [t i ;t i+1 ] and involves only the "local" variables ui ,xi and x i+1 . The Jacobian matrix of these constraints is sparse and has non-zero elements only near the diagonal. Optimization algorithms specific to large-scale problems exploit this characteristic (especially when calculating gradients) in order to reduce the calculation time.

5.5.2 Variational approach We consider a control problem with q final constraints. tf   x = f (x,u, t) , x(t 0 ) = x 0 (5.63) min J =  L(x,u, t)dt + (x f , t f ) with  u,t f  t0  j (x f , t f ) = 0 , j = 1 to q

434

Optimization techniques

Suppose that we choose arbitrary values for the final time t f and for the control

u(t)t0 ttf . This solution will not optimal nor it will satisfy the constraints.

The variational method uses the first variations J and  to find corrections

t f and u(t)t0 ttf improving the solution. Variation in cost and constraints The variation of the cost J is expressed with the adjoint p0 and the Hamiltonian

H 0 (4.17). The notation p0 is used here to denote the cost adjoint (not to confuse

with the abnormal multiplier).

p0 = − H0x  (5.64) J = [L + ]tf t f +  H udt with p0 (t f ) = x (x f , t f ) t0  T H0 (x,u,p0 , t) = L(x,u, t) + p 0 f (x,u, t) tf

T 0u

The same technique is applied to the variation of the constraint  j . For this, we define an adjoint p j and a Hamiltonian H j associated with the constraint. The formula (5.64) is used in a similar way by replacing the final cost  by  j and the integral cost L by 0. tf

 j = [ j ]t f t f +  H Tju udt t0

We note P = (p1 ,

,pq )

nq

p j = − H jx   with p j (t f ) =  jx (x f , t f )  T  H j (x, u, p j , t) = p j f (x, u, t)

the matrix of adjoints and G = (H1 ,

(5.65)

,Hq )T 

q

the vector of Hamiltonians. The equations (5.65) can be put in matrix form

p j = − H jx P = − G x = − f x P   → P(t f ) =  x (x f , t f ) p j (t f ) =  jx (x f , t f )   t T G = P f H j (x, u, p j , t) = p j f (x, u, t) tf

tf

t0

t0

(5.66)

 j = [ j ]t f t f +  H Tju udt →  = [ ]t f t f +  G Tu udt Assume that the initial solution (t f ;u) gives a value of the constraints f  0 . The objective is to find corrections (t f ; u) in order to cancel the constraints  , while minimizing the functional J.

Numerical methods in optimal control

435

Local minimization problem The local minimization problem is formulated as min J s.t.  = −  f

(5.67)

u,t f

This problem in this form has no solution, because the variations J and  are linear in terms of t f and u . To obtain a bounded correction, we convexify the problem by adding quadratic terms in t f and u . t

1 1 f min J c = J + b(t f )2 +  uT Wu dt s.t.  = −  f u,t f def 2 2 t0

(5.68)

The positive real b and the positive symmetric matrix W  mm are weights to control the magnitude of the corrections t f and u . The quadratic-linear problem (5.68) is solved by introducing the multipliers  = (1 , , q )T  q of the constraints and forming the augmented cost J a .

1 b(t f ) 2 + [L +  +  T ]t f t f 2

J a = J c +  T ( +  f ) =

t

1f +  uT Wudt + 2 t0

tf

 (H

t0

T 0u

+  G ) udt +   f T

T u

(5.69)

T

The first and second variations of J a are given by

(

)

T

J a = bt f + [L +  +   ]t f (t f ) + tf

tf

 ( u W + H

t0

T

T 0u

+  T G Tu ) (u)dt (5.70)

 J a = b (t f ) +  (u) W (u)dt 2

2

T

t0

Calculation of the corrections 2 The conditions for a local minimum are: Ja = 0 and  J a  0 . The second variation is always positive, because b  0 and W is positive. The cancellation of the first variation gives the corrections (t f ; u) .

u = − W −1 ( H 0u + G u  )   1 T t f = − [L +  +  ]t f b 

(5.71)

436

Optimization techniques

The corrections (t f ; u) produce variations  of the constraints. t

f 1  = − [L +  +  T]tf []tf −  G Tu W −1 ( H0u + G u  ) dt b t0

(5.72)

These variations are equal to −f (5.68), which determines the multipliers  . tf 1  T  =  []tf []t f +  G Tu W −1G u dt    t0 b 

−1

tf   1   f − [L + ]t f []t f −  G Tu W −1H 0u dt  (5.73)   b t0  

Adjustment of the corrections If the linearized model is reliable, the corrections (5.71) will produce variations in ˆ (expected variations). cost and constraints Jˆ and  t

f 1 T Jˆ = [L + ]t f t f +  H 0u udt = − [L +  +  T ]t f [L + ]t f − ( I JJ + I J ) b t0

tf

ˆ = []t f t f +  G Tu udt t0

1 = − [L +  +  T ]t f [ ]t f b

(5.74)

− ( IJ + I )

where we have introduced the matrices of influence I , IJ ,IJJ defined by tf

tf

tf

T I =  G W G u dt , IJ =  G W H0u dt = I , IJJ =  H0u W −1H0u dt (5.75) T u

−1

t0

t0

T u

−1

T J

t0

ˆ ˆ ), If the observed variations (Jr ; r ) differ from the expected variations (J; the corrections have to be reduced to remain in the linear domain. This is done: - either by changing the weights b and W; - or by aiming at a partial correction of the constraints:  = −f , 0    1 ; - or by partially applying the control correction: u , 0    1 . The optimal solution is obtained when the corrections (t f ; u) and the variations (J;  ) are zero (or small enough). We have then the following relations.

 H = H 0 + G = L + p T f  def  → PMP with  t f = 0 → [L +  +  T ]t f = 0   p = p 0 + P (5.76)  def −1 −1  = 0 →  = − I IJ , J = 0 → I JJ − I J I I J = 0

u = 0 → H 0u + G u  = 0

The first two conditions correspond to the PMP optimality conditions.

Numerical methods in optimal control

437

Implementation The calculation of the corrections (t f ; u) requires a forward and a backward integration: - forward integration of the state x with the control u gives the final state x(t f ) ; - the adjoints p0 and (p j ) j=1 to q are assessed at t f by the derivatives x and  x ; - backward integration of the adjoints yields the matrices I , IJ and IJJ ; - the corrections (t f ; u) are calculated by

u = − W −1 ( H 0u + G u  )   1 T t f = − [L +  +   ]t f b 

(5.77) −1

1 1    with  =  [ ]t f [ ]Tt f + I    f − [L + ]t f [ ]t f − I J  b b    Figure 5-15 summarizes the calculation stages at each iteration. This method of "directly" minimizing the variation of J is called the direct variational method.

Figure 5-15: Direct variational method. Example 5-7 illustrates an iteration of the direct variational method.

438

Optimization techniques

Example 5-7: Direct variational method Let us retrieve the flat earth orbiting problem (examples 4-5 and 4.13). We seek the trajectory maximizing the final horizontal velocity at a fixed altitude and final time. The acceleration of constant modulus a is oriented by the angle  . Noting v = vz the vertical velocity, the problem is formulated as tf

z(t f ) = z c z = v with  and   v = a sin  − g v(t f ) = 0 t0 This problem has been solved in example 4-5. Recall that the optimal control follows a linear tangent law of the form: tan  = tan 0 − ct . min J = −v x (t f ) = −a  cos  dt

To apply the direct variational method, we define the adjoints and Hamiltonians associated with the cost and constraints respectively. The functions defining cost, dynamics and constraints are

 z − zc  (z, v) = 0 v  , f (z, v, ) =     , (z, v) =  L(z, v, ) = − cos   a sin  − g  v 

Cost adjoint The adjoint p0 and the Hamiltonian H 0 are defined by (5.64).

p 0z = 0 H 0 = L + p T0 f = − cos  + p 0z v + p 0v (a sin  − g) →  p 0v = − p0z p 0z (t f ) = 0 (z, v) = 0 → p 0v (t f ) = 0 The Hamiltonian H 0 reduces to: H0 = − cos  .

  0   → p0 (t) =   0   

Altitude constraint adjoint The adjoint p1 and the Hamiltonian H1 are defined by (5.65).

H1 = p1T f = p1z v + p1v (a sin  − g) 1 (z, v) = z − z c

p1z = 0 →  p1v = − p1z p1z (t f ) = 1 →  p1v (t f ) = 0

   1    → p1 (t) =    tf − t    

Numerical methods in optimal control

439

Velocity constraint adjoint The adjoint p2 and the Hamiltonian H 2 are defined by (5.65).

p 2z = 0 H 2 = p T2 f = p 2z v + p 2v (a sin  − g) →  p 2v = − p 2z p 2z (t f ) = 0  2 (z, v) = v →  p 2v (t f ) = 1

    →   

0 p 2 (t) =   1

Influence matrices The adjoints are grouped in matrix form (5.66) in order to calculate the influence matrices (5.75). Let us assume for this example that the weights b and W are unitary (b = 1, W = I) and that the variational method is initialized with a constant control (t) = c . With this constant control, the influence matrices can be calculated analytically.

0 v  1  1 tf − t    t P=  , G=Pf =   1   a sin  − g  0  tf − t 1   tf − t  T and G u : H 0 = − cos  → H 0u = sin  , G u = a cos     1 

Matrices P and G: Matrices H0u Matrix I :

tf

 2t 2 3t f  1 I =  G Tu W −1G u dt = a 2 t f cos 2   f  6  3t f 6  t0 tf

Matrix IJ :

t  1 IJ =  G Tu W −1H0u dt = at f sin  cos   f  2 2 t0

Matrix IJJ :

IJJ =  HT0u W −1H0u dt = t f sin 2 

tf

t0

Control correction We calculate the value of the constraints for the initial constant control (t) = c .

 v(t f ) = (a sin c − g) t f 1   z(t f ) − z c   (a sin c − g) t f2 − z c   → f =   1  =2 2   v(t f )   (a sin  − g) t z(t f ) = 2 (a sin c − g) t f c   f The formulas (5.77) give the multipliers  and the control correction  to achieve a full constraint correction:  = −f .

440

Optimization techniques

−12zc    3  6zc t f + [a sin c (1 − cos c ) − g]t f  g − a sin c 6z  = − W −1 ( H 0u + G u  ) = + 3 c (t f − 2t) a cos c at f cos c

−1  = I ( f − IJ ) =

1 a t cos2 c 2 3 f

Let us assume that we choose c to reach the final velocity: asin c − g = 0 . 6z The corrected control at the first iteration is: (t) = c + 3 c ( t f − 2t ) . at f cos c If the correction is small compared to c : tan (t)  tan c +

6z c ( t f − 2t ) . at 3f cos c

Comparison to the optimal control The optimal control is of the linear tangent form: tan (t) = tan 0 − ct . 1 1 Note m the angle at half flight: t m = t f . We have: tan m = tan 0 − ct f . 2 2 1 The optimal control is expressed as: tan (t) = tan m + c(t f − 2t) . 2 The similarity with the variational corrected control can be seen. The initial constant control c satisfying the final velocity constraint is close to

the "average" value m and the corrective term is linear in (t f − 2t) . The corrected control approaches thus the optimal control.

5.6 Indirect methods Indirect methods consist in solving the two-point boundary value problem associated with the PMP optimality conditions. This system of nonlinear equations can be solved either by a shooting method or by a variational method.

5.6.1 Shooting method We consider a free final time control problem. tf   x = f (x,u, t) , x(t 0 ) = x 0 (5.78) min J =  L(x,u, t)dt + (x f , t f ) with  u,t f  t0  j (x f , t f ) = 0 , j = 1 to q

Numerical methods in optimal control

441

The optimality conditions of the PMP are expressed with the adjoint p, the multipliers  of the final constraints and the normal Hamiltonian defined by H(x, u, p, t) = L(x, u, p, t) + p Tf (x, u, t) . The optimal control minimizes the Hamiltonian: min H → u*(x,p, t) . u

With this control u*(x, p, t) , the Hamiltonian becomes a function of x and p. For

simplicity, we keep the notation H to denote the function H x,u*(x,p,t),p,t  . The state and the adjoint satisfy the following two-point boundary value problem

 x(t 0 ) = x 0   x = H p (x, p)  (x f , t f ) = 0 ,   p = − H x (x, p) p(t f ) =  x +  x   (x f , t f ) H(t ) = −   +    (x , t ) t t f f  f

(5.79)

The unknowns of this system are the initial adjoint p(t 0 ) , the final time t f and the multipliers  . The corresponding equations are the transversality conditions on p(t f ) , on H(t f ) and the constraints (x f , t f ) . The two-point boundary value problem (5.79) shown in figure 5-16 forms a system of nonlinear equations of dimension n + q + 1 .

Figure 5-16: Two-point boundary value problem. The system to be solved is noted in a compact way: S(p0 , ,t f ) = 0 . n +q +1

n +q +1

→ The function S : giving the values of the second members is called the shooting function. Its value measures the deviation from the solution, the target being zero.

442

Optimization techniques

The shooting problem consists in finding the unknowns p0 , , t f to reach the target, as shown in figure 5-17.

Figure 5-17: Shooting problem. The shooting method consists in solving the system of nonlinear equations S(p0 , , t f ) = 0 by a Newton-type method. The critical points are the numerical calculation of the derivatives and the initialization of the adjoint p 0 . Derivatives of the differential system The evaluation of the shooting function S(p0 , ,t f ) requires the numerical integration of the differential equations of the state and the adjoint. To apply a Newton-type method, the gradient of the shooting function with respect to the initial adjoint p0 must be evaluated. Noting z = (x, p) , the differential system is of the form: z = F(z, t) .

Figure 5-18: Calculation of the shooting function.

Three methods can be considered for calculating the transition matrix

z f . z 0

Numerical methods in optimal control



443

External derivation

The external derivation consists in applying an increment k on the kth component of the initial state z0 , integrating until t f and observing the resulting variation of

the final state z f . By successively varying each component as in figure 5-19, we z obtain the set of partial derivatives forming the transition matrix f . z 0 This calculation requires n + 1 successive integrations of the differential system.

Figure 5-19: External derivation. The external derivation is simple to implement, as the integrator of the differential system is used as a "black box". However, this method requires an appropriate choice of increments k (to be adapted according to the problem) and it may give inaccurate derivatives if a variable-step integrator is used.

Example 5-8: Effect of a variable integration step on the derivatives Consider the differential equation: x = f (x) with initial condition: x(t 0 ) = x0 . Let us apply Euler's method to two consecutive steps of lengths h1 and h 2 .

x1 = x 0 + f (x 0 )h1  x 2 = x 0 + f (x 0 )h1 + f  x 0 + f (x 0 )h1  h 2  x 2 = x1 + f (x1 )h 2 By expanding f to order 1 (for h1 small), and noting f0 = f (x 0 ) and f1 = f (x1 ) , we obtain: x 2 = x 0 + f0 (h1 + h 2 + f '0 h1h 2 ) .

444

Optimization techniques

Let us use this formula to calculate the derivative effect of a step change:

x 2 by finite difference and the x 0

• derivative by finite difference An increment x 0 on x 0 produces a variation noted x x 2 on x 2 . By expanding to order 1 the formula giving x 2 with

f (x 0 + x 0 )  f 0 + f '0 x 0 we get: x x 2 =x 0 1+ f 0 (h1 + h 2 ) + (f '02 + f 0f ''0 )h1h 2   f '(x 0 + x 0 )  f '0 + f ''0 x 0 • step variation Let us vary the step h1 by +h and the step h 2 by −h . The solution x 2 varies by: h x 2 = f0f '0 h(h 2 − h1 − h) .

Let us compare these variations x x 2 and h x 2 assuming equal steps: h1 = h 2 .

 x x 2 = x 0 1 + 2hf 0 + h 2 (f '02 + f 0f ''0 )     2 h x 2 = h  −f 0f '0  Assuming that the values and derivatives of f are of the magnitude of 1, it is observed that a variable time step can distort the evaluation of the derivative if

h

x 0 . This integrator-dependent step variation can occur between the nominal evaluation (x0 ) and the evaluation with increment (x 0 + x 0 ) . In practice, if a small increment x 0 is chosen, it is preferable to use a fixed-step integrator to calculate the derivative by finite difference.



Internal derivation

The internal derivation consists in making simultaneously the n + 1 integrations. A vector Z of size (n + 1)  n is propagated, which contains n + 1 copies of the vector z: - the copy number 0 is the nominal solution initialized with z0 ; - the copy number k is the perturbed solution initialized with z0 + k . This internal derivation process is illustrated in figure 5-20.

Numerical methods in optimal control

445

Figure 5-20: Internal derivation.

The transition matrix

z f is obtained by a single integration of the Z vector. z 0

Since the n + 1 integrations are simultaneous, they use the same time step and do not exhibit any consistency error, even if the integrator uses a variable step. However, this method requires modifying the implementation of the differential system in order to propagate the state vector Z of dimension (n + 1)  n . • Variational derivative The variational equations of the system z = F(z, t) are the differential equations of the deviations. They are obtained by an expansion to order 1.

z nom + z = F(z nom + z, t)  z =

F z z

with Fz =

F (z nom , t) z

(5.80)

The matrix of this linear system is evaluated on the nominal solution znom . Integrating (5.80) from an initial deviation z 0 gives the final deviation z f . 1 2 k n z f . For z0 =  0 , 0 , , 1 , , 0  , the final deviation z f is the derivative  (z 0 ) k   The n partial derivatives are obtained by integrating the matrix Z of size n  n .

F (5.81) Z with Z0 = I z This method is more accurate than the external or internal derivation, but it requires on the one hand to precompute and store the matrix Fz , and on the other hand to implement and propagate the variational equations that are specific to the given problem. Z=

446

Optimization techniques

Example 5-9: Derivatives of a differential system Consider the differential equation: x = −x 2 with: x(t = 0) = x 0 . We seek the derivative of x(t) with respect to the initial condition. Exact derivative The exact solution is: x =

x x0 1 and its derivative is: . = x 0 (x 0 t + 1) 2 x 0 t + 1

External derivative An increment x 0 perturbs the solution by x : x + x = The result is: x =

x 0 + x 0 . (x 0 + x 0 )t + 1

x 0 . (x 0 + x 0 )t + 1 (x 0 t + 1)

The external derivative tends to the exact value as the increment x 0 decreases.

The error with respect to the exact derivative depends on the increment x 0 which in practice cannot be too small (to be adapted according to the problem and the numerical integration method). Variational derivative The variational equation is: x = −2x nomx

with x nom =

x0 . x 0 t + 1

2x 0 x 1 x → = . x 0 t + 1 x 0 (x 0 t + 1) 2 The variational derivative gives the exact derivative with respect to the initial condition. In practice, the analytical solution is not available and the variational equation must be numerically integrated from a unitary initial condition. This equation is integrated: x = −

If the control problem depends on parameters  (hybrid problem), the derivatives of the differential system with respect to  are calculated in a similar way by one of the three previous methods. The variational equations are then of the form: z =

F F z +  . z 

The final time can also be treated as a parameter by changing the variable.

Numerical methods in optimal control

447

The normalized time  varying between 0 and 1 is defined as

=

t − t0 dz 1 dz 1 = (t − t 0 ) → = = F(z, , t) tf − t0 d  dt 

(5.82)

The control problem is then at fixed final time (f = 1) with the parameter  to be optimized. Sensitivity to initial conditions Evaluating the shooting function implies to integrate the Hamiltonian system   x = H p (x, u, p, t) (5.83) with H(x, u, p, t) = L(x, u, t) + p Tf (x, u, t)  p = − H (x, u, p, t)  x  Let us write the equations of this system with the deviations (x; p) in the vicinity of a reference trajectory.

x = H Tpx x + H Tppp = f xT x (5.84)  T T T T p = − H xx x − H xpp = − f x p − H xx x The derived matrices of f and H are evaluated on the reference path. We observe T that the linear equations in x and p share the same matrix f x , but with opposite T

sign. The negative eigenvalues of f x have a convergent effect on the equation in x and a divergent effect on the equation in p . The effect of positive eigenvalues is the opposite. It is therefore not possible for the evolutions of x and p to be simultaneously stable. The Hamiltonian system is by nature very sensitive to changes in initial conditions. Due to this intrinsic characteristic, the radius of convergence of a shooting method is quite small around the solution and the initial adjoint p0 requires a very accurate initialization. In some cases (especially when the propagation time is large), numerical errors related to the integration method may be sufficient to cause divergence, even when the initial adjoint corresponds to the optimal solution. The following quadratic-linear example illustrates this high sensitivity.

448

Optimization techniques

Example 5-10: Sensitivity of the Hamiltonian system Consider the quadratic-linear control problem with fixed final time and state. t x(t 0 ) = x 0 , t 0 = 0 1 f min J =  u 2dt s.t. x = ax + bu with  u 2 t0 x(t f ) = x f , t f fixé This problem is solved analytically: 1 • Hamiltonian: H = u 2 + p(ax + bu) ; 2 → u = −bp ; • control: Hu = u + bp = 0 •

adjoint:



state:

→ p = p0e− at ; p = − Hx = − ap x = ax + bu = ax − b2p0e− at

→ x = x 0eat + p 0

b 2 − at at (e − e ) . 2a

The unknown of the shooting problem is the initial adjoint p0 .

The final constraint is on the state x(t f ) . The shooting function is defined by

b 2 − at f (e − e at f ) + x 0e at f − x f 2a dS b 2 − at f The derivative of S is given by: = (e − eat f ) . dp0 2a S(p0 ) = x(t f ) − x f = p 0

This exponential function of t f takes a strong value if the final time is large, independently of the sign of a. Even a small deviation from p0 in the vicinity of the solution can then produce a very high value of the shooting function, or even its numerical explosion.

Multiple shooting The intrinsic sensitivity of the Hamiltonian system makes the shooting method numerically inapplicable in some cases, especially if the final time is large. The multiple shooting method aims to reduce this sensitivity by splitting the trajectory into N segments: t 0  t1   t i   t N = t f . Each segment [t i ;t i+1 ] is independently integrated starting from a freely chosen initial state x i and initial adjoint p i . The integration results in conditions at the

Numerical methods in optimal control

449

− − end of segment i, noted x(t i+1 ) and p(t i+1 ) . These final conditions differ from the

conditions (xi+1 ,pi+1 ) considered at the beginning of the next segment. +  x = Hp , x(t i ) = x i  +  p = − H x , p(t i ) = pi

x(t i−+1 )  ⎯⎯⎯⎯⎯⎯⎯⎯⎯ →  −  p(t i+1 ) int egration from t i to t i+1

(5.85)

The variables (xi ,pi )i=1 to N become additional unknowns of the shooting problem. We seek to satisfy the continuity conditions on the state and the adjoint between successive segments. −  x(t i ) = x i (5.86) , i = 1 to N − 1  −  p(t i ) = pi Let z = (x , p) be the 2n-dimensional vector formed by the state and the adjoint.

The additional (N − 1)  2n unknowns are (z1 ,z2 ,

,z N−1 ) to which the continuity

conditions are imposed: zi = z(t ) − zi = 0 as shown below. − i

Figure 5-21: Multiple shooting method. The simple shooting method is associated with the two-point boundary value problem (5.79).

 (x f )   →q   S(p 0 , , t f ) =  p f − (xf +  xf  )  → n  H + ( +   )  → 1 tf tf  f 

(5.87)

450

Optimization techniques

The multiple shooting function on N segments is defined by

 S(p 0 , , t f )  → n + q + 1   z1   → 2n (5.88) SN (p 0 , , t f , z1 , , z N −1 ) =      z N −1  → 2n The multiple shooting problem is the system of dimension n + q + 1 + (N − 1)  2n. (5.89)

SN (p0 , , t f ,z1, ,z N−1 ) = 0

The splitting of the trajectory into several independently integrated segments has the effect of reducing the sensitivity of the shooting function. This is achieved at the expense of increasing the dimension of the shooting problem. The choice of the number of segments results from a sensitivity/dimension trade-off.

5.6.2 Variational approach Let us retrieve the control problem (5.78) with q final constraints. tf   x = f (x,u, t) , x(t 0 ) = x 0 (5.90) min J =  L(x,u, t)dt + (x f , t f ) with  u,t f  t0  j (x f , t f ) = 0 , j = 1 to q

The optimality conditions given by the PMP yield the Hamiltonian system

x = Hp  T p = − H x with H = L + p f H = 0  u and the final conditions (transversality and constraints):  x = p   = 0  = 0 

(5.91)

with  =  +  T  with  =  t + H =  + L

at t f

(5.92)

Let us take an arbitrary solution defined by a control u(t)t0 ttf , a final time t f and multipliers  and perform the following calculations: - the forward integration (5.91) of the state x with the control u gives x(t f ) ; - the final adjoint p(t f ) is evaluated by (5.92) with the multipliers  ;

- the backward integration (5.91) of the adjoint allows to evaluate Hu (t)t0 ttf .

Numerical methods in optimal control

451

If the solution (u, t f , ) is not optimal, the conditions (Hu = 0,  = 0,  = 0) are not met. The variational method consists in looking for corrections (u, t f , ) using the equations (5.91) and (5.92) expanded to order 1. These variational equations (or neighboring equations) deal with the deviations (x, p, u, t f , ) .

x = Hp →  p = − H x →  H u = 0 →  x = p →   = 0 →  = 0 → 

x = H Tpx x + H Tpu u + H Tppp =

f xTx + f uTu

p = −H Txx x − H Txu u − H Txpp = −H xx x − H ux u − f x p H u = H Tux x + H Tuu u + H Tupp = H xu x + H uu u + f u p pf =  xx x f +  xt t f +  x  =  xx x f +  xt t f +  x 

(5.93)

 =  Tx x f +  Tt t f +  T  =  Tx x f +  Tt t f +  T  =  x x f +  t t f

The first stage is to reduce the variational system (5.93). Reduction of the variational system We note (Huc , c , c ) the values obtained with the arbitrary initial solution (u, t f , ) . Since the objective is to cancel (Hu ,  , ) , we look for correction

(u, t f , ) such that H u = −H uc   = − c   = − c

H xu x + H uu u + f u p = −H uc    Tx x f +  Tt t f +  T = − c   x +  t = − c t f  x f

(5.94)

The equation in Hu gives the control correction u as a function of (x, p) .

u = − H −uu1 (H uc + H xu x + f u p)

(5.95)

Replacing u in the differential equations (5.93) yields

x = f xT x + f uT u = Ax − B p + DH uc  T p = −H xx x − H ux u − f x p = −Cx − A p + EH uc

(5.96)

452

Optimization techniques

with the matrices A, B, C, D, E given by

A = f xT − f uT H −uu1 H xu −1 D = − f uT H uu  T −1 B = f H f ,   u uu u −1 E = −H ux H uu  −1 = − C H H H H xx ux uu xu 

(5.97)

The endpoint conditions of the differential system (5.96) are as follows: - the initial state change x 0 is zero, as x(t 0 ) = x0 is fixed; - the final adjoint variation pf is given by (5.93).

x 0 = 0  pf = xx x f + xt t f +  x 

(5.98)

Equations (5.96) and (5.98) define a two-point boundary value system. For given corrections (x f , t f , ) , the equations (5.96) in (x, p) can be integrated

backwards to obtain the value of x 0 . The objective is then to find the unknowns

(x f , t f , ) to satisfy the last two equations of (5.94). x 0 = 0  T T T  x x f +  t t f +   = − c   x +  t = − c t f  x f

(5.99)

Solving the variational system To solve the system (5.99), we try to express x 0 in terms of (x f , t f , ) . The linear differential system (5.96) is non-homogeneous because of the term in Huc . Its general solution is of the form

x(t) = X(t)x(t f ) + P(t)p(t f ) + (t)

(5.100)

The matrices X(t) and P(t) are the unit solution matrices obtained by integrating the homogeneous system (with Huc = 0 ) backwards from unit final conditions.

For each integration, the vectors x(t f ) and p(t f ) are zero, except for one component of x (to generate the matrix X) or p (to generate the matrix P). The particular solution (t) is obtained by integrating (5.96) backwards from

x(t f ) = 0 , p(t f ) = 0 and with Hu = − Huc (targeted correction on H u ).

Numerical methods in optimal control

453

With (5.100), the change in initial state is expressed as a function of (x f , pf ) . x0 = X(t 0 )x f + P(t 0 )pf + (t 0 ) = X0x f + P0pf + 0 noted

(5.101)

Replacing pf with its expression (5.98), equations (5.99) yield a linear system in terms of the unknowns (x f , t f , ) .

 X 0 + P0 xx   Tx    Tx 

P0 xt  Tt t

P0 x   x f   0   0       T   t f  +  0  =  − c 0      0   − c

    

(5.102)

Control correction Solving the linear system (5.102) gives (x f , t f , ) . The evolution of the deviations (x, p) is obtained with the unit solutions (X , P, ) already calculated starting from x f and pf given by (5.98). The control correction u can be deduced from (5.95). The application of these corrections produces actual variations (Hur , r , r ) which may differ from the expected ones (5.94). If the difference is too large, the corrections must be reduced in order to remain in the linear domain. This can be done: - by aiming at a partial correction (Hu ,  , ) = −(Huc , c , c ) , 0    1 ; - or by partially applying the control correction: u , 0    1 . A constant or time-increasing  coefficient can be chosen to limit the sensitivity to corrections applied at the beginning of the trajectory. The optimal solution is obtained when the corrections (u, t f , ) and the values of (Hu ,  , ) are zero or small enough.

Implementation The corrections (u, t f , ) are calculated in the following stages: - the forward integration of the state x by (5.91) with the control u gives x(t f ) ; -

the final adjoint p(t f ) is evaluated by (5.92) with the multipliers  ; backward integration of the adjoint by (5.91) gives A, B, C, D, E (5.97); the unit matrices X, P are calculated by backward integration of (5.96); the linear system (5.102) is solved to find (x f , t f , ) ; the deviations (x, p) are calculated with the unit solutions (X , P, ) ; the control correction u is given by (5.95).

454

Optimization techniques

These corrections are accepted or not depending on the differences between the observed and expected variations. Figure 5-22 summarizes the calculation stages at each iteration. This method for reaching the PMP optimality conditions is called the indirect variational method.

Figure 5-22: Indirect variational method. An iteration of the indirect variational method can be interpreted as solving the auxiliary minimum problem (section 4.4.1) formulated by expanding the cost to order 2, the dynamics and the constraints to order 1. T

T

t 2 J a 1 f  x   H xx H ux   x  1  x  min =    dt +      u,t f 2 2 t 0  u   H xu H uu   u  2  t f

  xx  x   x   T     x    t f

(5.103) x = f xT x + f uT u , x 0 fixed  T s.t.  =  x x f + t f ,  fixed  T  =  x x f + t f ,  fixed As with the shooting methods, the numerical difficulties arise from the high sensitivity of the adjoint equations. Similarly to the multiple shooting approach, differential dynamic programming (DDP) methods alleviate these difficulties by splitting the trajectory into several segments with junction conditions.

Numerical methods in optimal control

455

5.7 Conclusion 5.7.1 The key points •

Differential equations can be solved by propagation methods (Runge-Kutta type) or collocation methods approximating the solution by polynomials;



direct methods transform the control problem into a finite-dimensional constrained optimization problem. They do not use the optimality conditions of the minimum principle;



indirect methods solve the two-point boundary value problem arising from the optimality conditions of the minimum principle;



direct methods can be easily applied to any type of problem (dynamics, control and constraints). Their disadvantage is the compromise to be found between the resolution time (size of the discretized problem) and the desired accuracy of the solution;



indirect methods give a very fast and accurate solution. Their disadvantage is the difficulty of implementation (adjoint equations) and of use (initialization).

5.7.2 To go further •

Analyse numérique et équations différentielles (J.-P. Demailly, EDP Sciences 2006) This book presents in detail the numerical methods for solving differential equations. The properties of the methods are demonstrated in a rigorous manner, while remaining at a very accessible mathematical level. The presentation is very clear and the reading is very pleasant.



Solving ordinary differential equations (E. Hairer, S.P. Norsett, G. Wanner, Springer 1993) This two-volume book is an essential reference written by the best specialists in the field. It provides an exhaustive presentation of the numerical methods for solving differential equations with their history, demonstrations of their properties, detailed examples of applications and numerical comparisons. The book is divided into short, almost independent chapters, allowing direct access to the information required. The listings of the different softwares developed by the authors are given in the appendix and can be downloaded from their website.

456

Optimization techniques



Practical methods for optimal control and estimation using nonlinear programming (J.T. Betts, Siam 2010) This book is devoted to numerical methods in optimal control. After a review of nonlinear programming algorithms, it compares direct and indirect methods. The advantages and disadvantages of both approaches are discussed in detail, with examples of applications and many practical tips to overcome difficulties. The author is a well-known specialist in direct methods (and does not hide his preference for them). This book is recommended for anyone wishing to go deeper into the subject and apply these direct methods.



A survey of numerical methods for optimal control (A.V. Rao, AAS 09-334 Preprint 2010) This article gives a comprehensive overview of numerical methods in optimal control. It discusses successively the propagation and collocation methods for differential equations, then the direct and indirect approaches. The presentation is very clear and easy to read. This article gives a very good overview of the methods.



Applied optimal control (A.E. Bryson, Y.C. Ho, Hemisphere Publishing Corporation 1975) This book is aimed at the practical application of optimal control for engineers. The very progressive presentation in the chapters makes it possible to become familiar with the computational techniques, especially thanks to many very detailed examples. One chapter is devoted to numerical methods, especially those based on the variational approach.

457

Index absorbing circuit ................................................................................................ 98 action ....................................................................................................... 244, 286 adjoint ............................................................................................. 259, 272, 304 algorithm A* ............................................................................................................... 110 Bellman ......................................................................................................... 99 complexity .................................................................................................... 91 Demoucron and Floyd ................................................................................. 124 Dijkstra ....................................................................................................... 107 Ford....................................................................................................... 95, 147 Ford-Fulkerson............................................................................................ 154 polynomial .................................................................................................... 91 Roy-Busacker-Gowen ......................................................................... 144, 157 arc...................................................................................................................... 84 bang ............................................................................................................ 372 direct, indirect ............................................................................................. 138 regular ......................................................................................................... 372 saturated ...................................................................................................... 138 singular ....................................................................................... 343, 372, 375 bracket Lie ............................................................................................................... 373 Poisson ........................................................................................................ 239 Butcher array ................................................................................................... 400 canonical variable ............................................................................................ 237 chain augmenting ................................................................................................. 138 elementary ................................................................................................... 138 chattering ......................................................................................................... 381 chromatic number.............................................................................................. 66 clique ................................................................................................................. 66 condition collocation ............................................................................423, 427, 430, 433 controllability .............................................................................................. 262 convexity..................................................................................................... 368 corner .......................................................................................................... 206 Jacobi .......................................................................................... 200, 218, 368 junction ....................................................................................................... 375 Legendre ..................................................................................... 184, 200, 218 normality ..................................................................................................... 368 observability................................................................................................ 261

458

Optimization techniques

order ............................................................................................................ 411 transversality ........................................................ 222, 224, 284, 305, 441, 450 Weierstrass .................................................................................................. 219 Weierstrass-Erdmann .......................................................................... 210, 219 conservation angular momentum ..................................................................................... 246 energy ......................................................................................................... 245 momentum .................................................................................................. 246 consistency error ............................................................................................. 405 constraint final ............................................................................................................. 224 integral ................................................................................................ 226, 310 integrity ......................................................................................................... 12 interior ........................................................................................................ 311 order k ......................................................................................................... 319 path ............................................................................................................. 232 potential ...................................................................................................... 129 state ............................................................................................................. 319 terminal ....................................................................................................... 305 control bang ............................................................................................................ 317 linear tangent................................................................ 296, 298, 307, 353, 438 proportional navigation ............................................................................... 326 state feedback ...................................................................................... 326, 352 velocity-to-gain ........................................................................................... 326 convexification .......................................................................................... 75, 435 cost augmented ............................................................ 226, 232, 281, 289, 362, 435 final ............................................................................................................. 270 integral ........................................................................................................ 270 critical path ...................................................................................................... 130 cut flow ............................................................................................................. 142 mixed ............................................................................................................ 24 on cost ........................................................................................................... 14 on variable .................................................................................................... 13 dynamic programming .................................................................................... 102 edge ................................................................................................................... 84 equation adjoint ................................................................................................. 260, 283 defect .......................................................................................................... 428 Euler-Lagrange ....................................................................184, 187, 200, 218 Hamilton-Jacobi-Bellman ................................................................... 241, 357

459

Jacobi .......................................................................................................... 196 Lagrange ..................................................................................................... 287 Riccati ......................................................................................................... 328 state ..................................................................................................... 249, 270 variational .................................................................... 250, 256, 445, 447, 451 extremal ................................................................................................... 187, 337 abnormal ..............................................................................337, 338, 341, 383 neighboring ......................................................................................... 196, 347 regular ................................................................................................. 337, 384 singular ............................................................................................... 337, 341 first integral ...................................................................... 187, 236, 239, 242, 293 function generating ................................................................................................... 240 influence ............................................................................................. 260, 358 Lyapunov .................................................................................................... 255 shooting............................................................................................... 441, 449 switching ..................................................................................... 317, 342, 372 value.................................................................................................... 241, 356 Weierstrass .......................................................................................... 214, 218 gain L2 ............................................................................................................. 335 geodesic....................................................................................194, 195, 202, 369 graph bipartite ....................................................................................................... 149 complete ........................................................................................................ 87 connected ...................................................................................................... 87 density ................................................................................................... 85, 110 deviation ..................................................................................................... 144 directed ......................................................................................................... 84 planar .................................................................................................... 87, 110 valued............................................................................................................ 85 guidance .......................................................................................................... 356 Hamiltonian ...................................................................... 237, 245, 272, 286, 304 augmented ................................................................................................... 316 heuristic A* ............................................................................................................... 110 bin packing.................................................................................................. 165 consistent .................................................................................................... 123 feasible ........................................................................................................ 122 set covering ................................................................................................. 166 stacking ....................................................................................................... 164 integration step ................................................................................................ 409 invariant functional ......................................................................................... 236 junction ........................................................................................................... 320

460

Optimization techniques

Lagrangian ...................................................................................... 181, 245, 286 augmented ........................................................................................... 226, 232 Lie derivative .................................................................................................. 373 margin ............................................................................................................. 136 matrix Boolean ......................................................................................................... 88 controllability .............................................................................................. 262 covariance ................................................................................................... 258 incidence ....................................................................................................... 68 influence ..................................................................................................... 436 observability................................................................................................ 261 symplectic ................................................................................................... 257 transition ............................................................................................. 256, 443 unimodular ...................................................................................... 63, 68, 160 method Adams-Bashford ......................................................................................... 419 Adams-Moulton .......................................................................................... 420 collocation ........................................................................................... 394, 423 direct ................................................................................................... 396, 431 embedded .................................................................................................... 416 explicit ........................................................................................ 399, 411, 419 extrapolation ............................................................................................... 417 greedy ............................................................................................... 37, 56, 71 Hungarian ................................................................................................... 152 indirect ........................................................................................................ 440 Legendre-Gauss .......................................................................................... 426 MPM ........................................................................................................... 132 PERT .......................................................................................................... 129 Runge-Kutta ........................................................................................ 398, 424 transport .............................................................................................. 328, 349 variational .................................................................... 281, 305, 313, 434, 451 minimum principle ...................................................................................................... 273 strong .......................................................................................... 180, 214, 218 time ............................................................................................. 294, 316, 382 weak ............................................................................................ 180, 184, 218 momentum .............................................................................................. 237, 245 multiplier abnormal ..................................................................................... 272, 337, 372 Lagrange .............................................. 159, 226, 305, 312, 316, 330, 362, 432 neighborhood .................................................................................................. 179 network capacity ......................................................................................................... 85

461

sink ............................................................................................................... 85 source ............................................................................................................ 85 node adjacent ......................................................................................................... 84 ascendant....................................................................................................... 88 degree............................................................................................................ 85 descendant..................................................................................................... 88 marking ....................................................................................................... 139 predecessor ................................................................................................... 84 successor ....................................................................................................... 84 norm ................................................................................................................ 178 phase plane.................................................................................................... 251, 338 portrait ................................................................................................ 251, 340 point conjuguate ................................................................................... 198, 200, 369 equilibrium .................................................................................................. 252 polynomial collocation ................................................................................... 423, 426, 429 Lagrange ............................................................................................. 419, 423 Legendre ..................................................................................................... 425 principle Bellman ....................................................................................... 101, 285, 357 Pontryaguin ................................................................................................. 273 virtual works ............................................................................................... 288 problem assignment .................................................................................................... 62 bin packing.................................................................................................. 165 Bolza ........................................................................................................... 270 brachistochrone ................................................................................... 189, 249 catenary ....................................................................................................... 211 coloring ................................................................................................. 66, 168 Didon .......................................................................................................... 228 flow ............................................................................................................... 69 Goddard ...................................................................................................... 341 knapsack ....................................................................................................... 37 Lagrange ..................................................................................................... 270 Mayer .................................................................................................. 270, 431 NP ................................................................................................................. 93 quadratic assignment ..................................................................................... 80 quadratic-linear ........................................................................................... 323 relaxed .....................................................................................2, 12, 15, 21, 23 set covering ................................................................................................. 166

462

Optimization techniques

shooting............................................................................................... 442, 450 stable set........................................................................................................ 67 TPBVP ................................................................. 264, 292, 293, 324, 349, 441 travelling salesman ........................................................................................ 58 quadrature........................................................................................................ 398 regulator .......................................................................................................... 329 separation .......................................................................................................... 33 on binary variable ......................................................................................... 35 on integer variable......................................................................................... 42 simplex dual ............................................................................................................... 15 pivoting ......................................................................................................... 35 solution viscosity ...................................................................................................... 361 sub-differential ................................................................................................ 359 sub-gradient ..................................................................................................... 359 system autonomous ................................................................................................. 293 Hamiltonian ........................................................................................ 292, 450 transformation of Legendre ............................................................................. 238 tree .................................................................................................................... 87 exploration .............................................................................................. 51, 53 root ................................................................................................................ 32 rooted ............................................................................................................ 87 truncation .......................................................................................................... 13 variation first .......................................................................................179, 282, 289, 362 second ......................................................................................... 180, 286, 363 warm start .......................................................................................................... 34

463

Short bibliography [R1] [R2] [R3] [R4] [R5] [R6] [R7] [R8] [R9] [R10] [R11] [R12] [R13] [R14] [R15] [R16] [R17]

Optimisation discrète (A. Billionnet, Dunod 2007) Practical methods for optimal control and estimation using nonlinear programming (J.T. Betts, Siam 2010) Applied optimal control (A.E. Bryson, Y.C. Ho, Hemisphere Publishing Corporation 1975) Analyse numérique et équations différentielles (J.-P. Demailly, EDP Sciences 2006) Calculus of variations with applications (G.M. Ewing, Dover 1985) Précis de recherche opérationnelle (R. Faure, B. Lemaire, C. Picouleau, Dunod 2009) Calculus of variations (I.M. Gelfand, S.V. Fomin, Dover 1963) Programmation linéaire (C. Guéret, C. Prins, M. Sevaux, Eyrolles 2003) Solving ordinary differential equations (E. Hairer, S.P. Norsett, G. Wanner, Springer 1993) Les mathématiques du mieux-faire (J.B. Hiriart-Urruty, Ellipses 2008) Optimal control theory for applications (D.G. Hull, Springer, 2003) Algorithmes de graphes (P. Lacomme, C. Prins, M. Sevaux, Eyrolles 2007) The variational principles of mechanics (C. Lanczos-Urruty, Dover 1949) Calculus of variations and optimal control theory (D. Liberzon, Princeton University Press 2012) Programmation mathématique (M. Minoux, Lavoisier 2008, 2e édition) A survey of numerical methods for optimal control (A.V. Rao, AAS 09-334 Preprint 2010) Geometric optimal control (H. Schättler, U. Ledzewicz, Springer 2012)

464

[R18] Stochastic optimization (J.J. Schneider, S. Kirkpatrick, Springer 2006) [R19] Contrôle optimal – Théorie et applications (E. Trélat, Vuibert 2005)

Optimization techniques