SCILAB WORKSHOP...approximation for pour Hessian ๐‘˜ โ€ข ฯ๐‘˜ pour control convergence...

Preview:

Citation preview

1www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.Copyright ยฉ ESI Group, 2017. All rights reserved.

www.esi-group.com

SCILAB WORKSHOP

Optimization in SCILAB

SCILAB TEAM

17th, October 2019

2www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Advanced post-processingAirfoil shape optimization

3www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Quick introduction to Numerical Optimization

4www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Optimization problem

max๐‘ฅโˆŠ๐‘‹

๐‘“ ๐‘ฅ

3 Steps:

1/ Identification of the decision variables: x

2/ Set-up of constraints associated to the variables: X

3/ Definition of a cost/objective function: f

5www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Two formulations, One problem

Solving the problem

min๐‘ฅโˆŠ๐‘‹

๐‘“(๐‘ฅ)

Corresponds to solve the problem

max๐‘ฅโˆŠ๐‘‹

โˆ’๐‘“ ๐‘ฅ

Minimize or Maximize a function?

6www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Numerical optimization

Initialization

Evaluation of cost

function

Choice of direction

New element

Optimal element

!

7www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

1/ Initial approximationโ€“ Influence convergence

2/ Number of iterationsโ€“ Recursive process

3/ Convergence speed

4/ Stopping criteria

โ€ข Maximum number of iterations, โ€ฆ

โ€ข Cost function value under a given threshold, โ€ฆ

๐‘“(๐‘ฅ๐‘›) < ๐œ€1

โ€ข Difference between two consecutive approximations under a giventhreshold, โ€ฆ

๐‘ฅ๐‘›+1 โˆ’ ๐‘ฅ๐‘› < ๐œ€2

Classical set-up parameters for optimization solvers

8www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

General remarks

โ€ข Local extrema are easy to find!

โ€ข Some algorithm are performinglocal search only!

Take care on initial

approximation!

WARNING : Different types of extrema

9www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Direct search

Search for an optimal position usingcost function evaluations, without anycomputation of the function exact orapproximate derivatives.

Interior Points method, simplex

Maximum search methods

Derivatives computation

Search for an optimal position usingcost function derivatives (Jacobian forsteepest ascent direction, Hessian forcritical point type) exact or approximatecomputation.

Gradient method, Newton method

How to make design space exploration?

10www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Optimization problem typology

11www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Travelling salesman problem

Continuous vs Discrete

DISCRETE (Combinatorial Analysis)

Variables are taking values in a finite setor states (IN, ON/OFF, โ€ฆ).

Classical examples: Travelling salesmanproblem which consists in finding theshortest path binding a given set of cities.

12www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Mono vs Multi objective

MULTI OBJECTIVE

min๐‘ฅโˆŠ๐‘‹

(๐‘“1 ๐‘ฅ , ๐‘“2 ๐‘ฅ ,โ€ฆ , ๐‘“๐‘˜ ๐‘ฅ )

Several cost, potentially conflicting,functions minimization.

Found solution is therefore not unique.The complete set of solutions is calledPareto Front.

Choice is about trade-offAn example would be to ensuremaximum efficiency, and minimuminvestment at the same time.

13www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Constrained vs Non Constrained

CONSTRAINTS

Constraints are referring to the limit of the design space we impose

โ€ข Linear

๐ถ๐‘ฅ = ๐‘

โ€ข Non Linear

๐‘ฅ๐‘‡๐ถ๐‘ฅ = ๐‘

โ€ข Equalities๐ถ๐‘ฅ = ๐‘

โ€ข Inequalities๐ถ๐‘ฅ โ‰ฅ ๐‘

โ€ข Lower and Upper bounds๐‘Ž1 โ‰ค ๐‘ฅ โ‰ค ๐‘Ž2

14www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Problem size

Let n be the number of design variables

โ€ข n < 10 : Small problem (s)

โ€ข 10 < n < 100 : Medium problem (m)

โ€ข 100 < n < 1000 : Large problem (l)

Solver speed and memory needsare depending on the problem size

15www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Optimization solvers in SCILAB

16www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

How to choose SCILAB optimization solver

Convex

SemidefiniteLeast squares

Quadratic

Linear

Objective Constraints

[Bnds, Eq, Ineq]

Size Gradient Solver

Linear Y Y Y m karmarkar

Quadratic Y Y Y L qpsolve

SemiDef N Y Y L lmisolver

SemiDef Y N Y L semidef

N.L.S. N N N L optional Leastsq /

lsqrsolve

Non-linear Y N N L Y optim

Non-linear N N N s fminsearch

Objective Single

Objective

Multi

Objective

Use

Continuous/

Differentiable

Fminsearch

Non Smooth optim

Discrete Optim_sa,

optim_ga

Optim_moga

Optim_nsga2

17www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Linear problemmin๐‘ฅ

๐‘“ ๐‘ฅ = ๐‘๐‘‡๐‘ฅ

Linear constraints

โ€ข Equalities๐ถ1๐‘‡๐‘ฅ = ๐‘1

โ€ข Inequalities๐ถ2๐‘‡๐‘ฅ โ‰ฅ ๐‘2

Linear optimization

18www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Interior Points Method

ยซ Affine Scaling ยป

Solve suite of optimization problems onellipsoid.

Ellipsoids size are decreasing at eachiteration by a given scale factor (between 0and 1).

Caracteristic:

โ€ข Polynomial time O(๐‘›๐‘š)

โ€ข Direct search

โ€ข (In)Equalities and bounds constraints

Linear optimization - karmarkar

19www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Quadratic problem

minx๐‘“ ๐‘ฅ =

1

2๐‘ฅ๐‘‡๐‘„๐‘ฅ + ๐‘๐‘‡๐‘ฅ

With Q la ยซ hessian ยป and c ยซ gradient ยป

of a virtual energy function

Linear constraints

โ€ข Equalities๐ถ1๐‘‡๐‘ฅ = ๐‘1

โ€ข Inequalities๐ถ2๐‘‡๐‘ฅ โ‰ฅ ๐‘2

Quadratic optimization

Concave shape, convex problem

20www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Quadratic optimization - qpsolve

Goldfarb-Idnani solver

ยซ Feasible active set method ยป

Find non-constrained global optimum,then add non-respected constraints oneafter the other (activation)

Caracteristics :

โ€ข Strictly convex problems

โ€ข (In)Equalities and bounds constraints

โ€ข Polynomial time O(๐‘›๐‘š)

โ€ข Direct search

21www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Least squares problem

min๐‘ฅ

๐‘“ ๐‘ฅ 2

๐‘“: ๐ผ๐‘…๐‘› โ†’ ๐ผ๐‘…๐‘š

๐‘› number of unknonw, ๐‘š nb of points

๐‘“ non necessarily linear or differentiable

Linear regression (QUADRATIC)

Minimize distance between measurements (๐‘› = 2) and an unknown line (๐‘š = 1)

1

2๐‘„๐‘ฅ โˆ’ ๐‘ 2 =

1

2(๐‘ฅ๐‘‡๐‘„๐‘‡๐‘„๐‘ฅ โˆ’ 2๐‘ฅ๐‘‡๐‘„๐‘‡๐‘ + ๐‘๐‘‡๐‘)

Non Linear Least Squares

22www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Non Linear Least Squares - lsqrsolve

Levenberg-Marquardt algorithm

To find a new direction:

โ€ข Gradient method (green) to provide steepestdescent direction. Efficient when far from theoptimal position.

โ€ข Gauss-Newton (red), approximate the problem aslocally quadratic and solve it to find new position.Efficient when close to the optimal position.

Caracteristics

โ€ข Polynomial time

23www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Non Linear optimization - fminsearch

Nelder-Mead Simplex

Simplex manipulation

Caracteristics

โ€ข Non constrained

โ€ข High complexityBetter suited for small problem

โ€ข Direct search

3D Simplex

24www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Quasi-Newton method

Quasi-Newton statement๐‘ฅ๐‘˜+1 โˆ’ ๐‘ฅ๐‘˜ = ๐ต๐‘˜ ๐‘“ ๐‘ฅ๐‘˜+1 โˆ’ ๐‘“ ๐‘ฅ๐‘˜

โ‡’ ๐‘ฅ๐‘˜+1 โ‰ˆ ๐‘ฅ๐‘˜ โˆ’ ฯ๐‘˜๐ต๐‘˜๐‘“(๐‘ฅ๐‘˜)

โ€ข Broyden-Fletcher-Goldfarbapproximation for pour Hessian ๐ต๐‘˜

โ€ข ฯ๐‘˜ pour control convergence

Caracteristics

โ€ข High memory need to store ๐ต๐‘˜ : O(nยฒ)(O(n) in case of limited method)

โ€ข Gradient info must be provided

โ€ข Polinomial time O(nยฒ) but not accurate

Non Linear optimization - optim

Nota

โ€ข Fsolve (alternative)

โ€ข Datafit / leastsq (built upon optim)

25www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

GA Theory

- Natural selection -

Probabilistics and non deterministics transitons:

Selection, Cross-over et Mutation

Caracteristics

โ€ข Bounds constraints

โ€ข Non Linear, Non Convex

Remarks

optim_ga /optim_moga: Single/Multi objective

pareto_filter: Non-dominated sorting

Genetic Algorithms

26www.esi-group.com

Copyright ยฉ ESI Group, 2017. All rights reserved.

Simulated Annealing

Simulated Annealing optim_sa

Empirical method based on metallurgicalprocess

Alternate slow cooling cycles with heatingcycles (annealing) in order to minimize materialinternal energy (strongest configuration)

Metropolis-Hastings Algorithm

Starting at a given state, we modify systemtowards another state. Either it get better(energy decrease) or it get worse.

Drawbacks:

โ€ข Empirical set-up

โ€ข Bounds constraints only

Benefits:

โ€ข Global optimum

โ€ข Discrete optimization

Recommended