optimization techiniques

Embed Size (px)

Citation preview

  • 8/18/2019 optimization techiniques

    1/64

    1

    Dr. Muhammad Naeem

    Dr. Ashfaq Ahmed

    Optimization Techniques

  • 8/18/2019 optimization techiniques

    2/64

    2

     Outline

    Review of Math

    Basics of Optimization

    Review of Matlab

    Eamples of Optimization in !omputer" #elecom and $ower applications

    %raphical Optimization

    Optimization #&pes !onstraint and 'nconstraint

    Optimization $roblem #&pes (inear Non(inear etc

    (inear Optimization

    Non (inear Optimization

    )nte*er and Mied inte*er pro*rammin*

    !ompleit& Anal&sis

  • 8/18/2019 optimization techiniques

    3/64

    Set Theory+ets  A well-defined  collection of ob,ects

    Subset 

     A-/"0"1"2"34" B- x 5 x  is odd4" C -/"0"1"2"3"...4

       A is a proper subset of B" )f A is a subset of B" but A is notequal to B" i.e." there eists at least one element of B which is not an

    element of A

    !ardinalit& of A-1 65 A5-17

     A B⊂

    C  is a subset of B.C B⊆

    #he power set is the set of all subsets of a *iven set.

    8or the set + - /"9"04 this means:

    $6+7 - ;" /4" 94" 04" /"94" /"04" 9"04" /"9"04 4

    5+5-n then 5$6+75 - 9n

    3

    [ ] A B x x A x B⊆ ⇔ ∀ ∈ ⇒ ∈[ ]

    [ ]

     A B x x A x B

     x x A x B

    ⊄ ⇔ ¬∀ ∈ ⇒ ∈⇔ ∃ ∈ ∧ ∉

  • 8/18/2019 optimization techiniques

    4/64

    !onceptuall&" sets ma& be infinite 6i.e., not finite" without end7.

    +&mbols for some special infinite sets:

    N - ;" /" 9"

  • 8/18/2019 optimization techiniques

    5/64

    8or real numbers a"b with ab

    [ , ] { | }a b x R a x b= ∈ ≤ ≤

    ( , ) { | }a b x R a x b= ∈ < <

    [ , ) { | }a b x R a x b= ∈ ≤ <

    ( , ] { | }a b x R a x b= ∈ < ≤

    open interval

    half=open interval

    closed interval

    half=open interval

    Set Theory

    5

     x ∈S 6> x  is in S?7 is the proposition that ob,ect x  is an element  or member  of set S.

    e.g. 0∈

    N, >a?∈

     x 5 x  is a letter of the alphabet4

    !an define set equalit& in terms of ∈ relation:∀S"T : S-T ↔ 6∀ x : x ∈S ↔  x ∈T 7>#wo sets are equal iff  the& have all the same members.?

     x ∉S :≡ ¬6 x ∈S7 > x  is not in S?

  • 8/18/2019 optimization techiniques

    6/64

    Function(et C and be two nonempt& sets.

     A function from C into is a relation that associates with each element of

    C eactl& one element of .

    Domain: )n a set of ordered pairs" 6" &7" the domain is the set of all =

    coordinates.

    Ran*e: )n a set of ordered pairs" 6" &7" the ran*e is the set of all &=

    coordinates.

    Eample:

    Domain: : 14

     f  ( x) =   x − 5

    Range: &: &;4

    Eample: 2( ) 5 f x x= −

    6

  • 8/18/2019 optimization techiniques

    7/64

    Function(et C and be two nonempt& sets.

     A function from C into is a relation that associates with each element of

    C eactl& one element of .

    Domain: )n a set of ordered pairs" 6" &7" the domain is the set of all =

    coordinates.

    Ran*e: )n a set of ordered pairs" 6" &7" the ran*e is the set of all &=

    coordinates.

    Eample:

    Domain: : 14

     f  ( x) =   x − 5

    Range: &: &;4

    Eample: 2( ) 5 f x x= −

    7

    Domain: All Real

    Range: &: &=14

  • 8/18/2019 optimization techiniques

    8/64

  • 8/18/2019 optimization techiniques

    9/64$

    Factorial, ermutation an! Com"inationom"inations are %selections&'

    #here are some problems where the order  of the items is NO#important. #hese are called combinations.

    ou are ,ust maHin* selections" not maHin* different arran*ements.

    Eample:  A committee of 0 students must be %e&e'e from a *roup of 1

    people. Low man& possible different committees could be formed(ets call the 1 people A"B"!"D"and E.

    +uppose the selected committee consists of students $ $ an +. )f

    &ou re=arran*e the names to $ +$ an " its still the same *roup of

    people. #his is wh& the order  is not important.

    Because were not *oin* to use all the possible combinations of E!A" liHe EA!"

    !AE" !EA" A!E" and AE!" there will be a lot fewer committees. #herefore instead of

    usin* onl& 1@0" to *et the fewer committees" we must divide

    ,43

    321

    6Alwa&s divide b& the

    factorial of the number of

    di*its on top of the fraction.7

     Answer: 

    /; committees

  • 8/18/2019 optimization techiniques

    10/641(

    Factorial, ermutation an! Com"ination

     The num"er o) r-com"inations C(n,r) o) a set *ith

    n+S elements is

    !( , )

    !( )!

    n   nC n r 

    r    r n r 

     = = ÷ −  

    Essentiall& unordered permutations <

    Note that C 6n"r 7 - C 6n" nIr 7

    ( , ) ( , ) ( , ) P n r C n r P r r =

    )!(!

    !

    !

    )!/(!

    ),(

    ),(),(

    r nr 

    n

    r nn

    r r  P 

    r n P 

    nr nC 

    −=

    −==  

     

      

     =

  • 8/18/2019 optimization techiniques

    11/6411

    #hinH of a vector as a directed line segment

    in N-dimensionsG 6has >len*th? and>direction?7

    Basic idea: convert *eometr& in hi*herdimensions into al*ebraG Once &ou define a >nice? basis alon*

    each dimension: =" &=" z=ais < ector becomes a / N matriG  - Pa b cQ#

    =c

    b

    a

    v

    &

    -inear .l/e"ra>Al*ebra? means" rou*hl&" >relationships?.

    >(inear Al*ebra? means" rou*hl&" >line=liHe relationships?.

    )f 0 feet forward has a /=foot rise" then *oin* /; as far should *ive a /;

    rise 60; feet forward is a /;=foot rise7

  • 8/18/2019 optimization techiniques

    12/6412

    Vector  in Rn is an ordered

    set of n real numbers. e.*. v - 6/"F"0"@7 is in R@

    >6/"F"0"@7? is a column

    vector:

    as opposed to a row vector:

    m=b&=n matrix  is an ob,ectwith m rows and n columns"

    each entr& fill with a real

    number:

        

     

     

     

     

     

    4

    36

    1

    ( )4361

     

      

     

     

     

     

    239

    6784

    821

    -inear .l/e"ra

  • 8/18/2019 optimization techiniques

    13/64

    13

    (ine equation: & - m J c Matri equation: / - M J c

    -inear .l/e"ra

    e'or +iion: + A

    B

     A

    B

    !

    "%e he hea-o-ai& meho

    o 'omine e'or%

    1 2 1 2 1 1 2 2( , ) ( , ) ( , ) A B x x y y x y x y+ = + = + +

    ),(),( 2121   axax x xaa   ==v  v

    av

    'a&ar ro"': +

    !han*e onl& the len*th 6>scalin*?7" but Heep direction fixed .

    Matri operation 6+7 can chan*e length, direction and also dimensionalit G

  • 8/18/2019 optimization techiniques

    14/64

    14

    -inear .l/e"ra0ectors a/nitu!e -en/th an! hase !irection

    &

    5555

     

     Alternate representations:

      $olar coords: 65555$ )

      !omple numbers: 5555e  

    7#ha%e8

    r unit vectoais,1! 

    1

    2

    ),,2,1(

    vv

    n

    ii

     xv

    n x x xv  T 

    =

    =

    =

    =

    6unit vector - #"re ire'ion7

  • 8/18/2019 optimization techiniques

    15/64

    15

    -inear .l/e"ra0ector norm a )unction that assi/ns a strictly positie length or size to each ector in a ector space *i8ipe!ia9

    1 2"or an n#$i%ensiona& vector [ ''' ]n x x x x  =1/

    te vector nor% * 1,2,'''

     p

     p

    i p pi

     x x x p    ≡ = ÷  ∑:

    %a+ iiSpecial case x x∞  :2 2 2 2

    1 22 '''

    n Most commonly used L norm x x x x x  − = = + +

    roperties

    1' *

    2'

    3'

     x when x x iff x

    kx k x scalar k  

     x y x y

      > ≠ = =  = ∀

    + ≤ +

    ;

  • 8/18/2019 optimization techiniques

    16/64

    16

    -inear .l/e"ra

       

     

     

     

    =   

     

     

     

       

     

     

     5

    5

    1

    1

    5

    5 6stretchin*7

       

      

     −=  

     

      

        

      

      −1

    1

    1

    1

    1

    16rotation7

       

      

     =  

     

      

        

      

     1

    1

    1

    1 6reflection7

       

      

     =   

      

        

      

     

    1

    1

    1

    1 6pro,ection7

    6shearin*7  

     

     

     

      +=  

     

     

     

       

     

     

     

      y

    cy x

     y

     xc

    1

    1

  • 8/18/2019 optimization techiniques

    17/64

    /2

    -inear .l/e"raatrices as sets o) constraints

    22

    1

    =+−

    =++

       y x

       y x   

      

     =

       

     

     

     

     

       

      

     − 2

    1

    112

    111

      

     y

     x

    Special matrices

       

     

     

     

     

     f  

    ed 

    cba

       

     

     

     

     

    c

    b

    a

         

     

     

     

     

     !i

    h "  f  

    ed c

    ba

       

     

     

     

     

     f  ed 

    cb

    a

    dia*onal upper=trian*ular  tri=dia*onallower=trian*ular 

       

     

     

     

     

    1

    1

    1

    ) 6identit& matri7

    #ranspose of A: Matri obtained b& interchan*in* rows and columns of A.

    Denoted b& A or A#. A# - Pa ,iQ

     A# -

    +&mmetric Matri: A# - A

    )dentit& Matri: A square matri whose dia*onal elements are all / and off=

    dia*onal elements are all zero. Denoted b& ).

    Null Matri: A matri whose all elements are zero.

    63

    52

    41

  • 8/18/2019 optimization techiniques

    18/64

    /

    -inear .l/e"ra=eterminants

     #xample ;aluate the !eterminanto) 

    =

    21

    53 A

    21

    53$et   = A   )1)(5()2)(3(   −=   156   =−=

    Def: 9inor%

    (et A -Pai,Q be an nn matri . #he i,th minor of A 6 or the minor of

    ai,7 is the determinant Mi, of the 6n=/76n=/7 submatri after &ou

    delete the ith row and the ,th column of A.

     #xample 8ind

    =

    153

    134

    21

     A

    ,,, 333223   M  M  M 

  • 8/18/2019 optimization techiniques

    19/64

    1$

    -inear .l/e"raDef: ofa'or%

    (et A -Pai,Q be an nn matri . #he i,th cofactor of A 6 or the

    cofactor of ai,7 is defined to be

     #xample 8ind

    =

    153

    134

    21

     A

    ,,, 333223   A A A

    i! !ii!   M  A  +

    −=   )1(

    %ign%

    +−+

    −+−

    +−+

  • 8/18/2019 optimization techiniques

    20/64

    9;

    Fin! all the minors an! co)actors o) A, an! then>n! the !eterminant o) A'

    Sol 

    −=14213

    12

     A

    ,11

    2111   −=

    −= M    ,5

    14

    2312   −== M    4

    4

    1313   =

    −= M 

    '6,3,5

    ,8,4,2

    333231

    232221

    −=−==

    −=−==

     M  M  M 

     M  M  M 

    111   −=C    512 =C    413   −=C 

    '6,3,5

    ,8,4,2

    333231

    232221

    −===

    =−=−=

    C C C 

    C C C 

    14)5(4)2(3)1(

    14)8(2)4)(1()2(3

    14)4(1)5(2)1(

    313121211111

    232322222121

    131312121111

    =+−+−=++==+−−+−=++=

    =++−=++=

    C aC aC a

    C aC aC a

    C aC aC a A

    -inear .l/e"ra

  • 8/18/2019 optimization techiniques

    21/64

    21

    $rincipal Minor 

    $rincipal minor of order H: A sub=matri obtained b& deletin* an& n=H

    rows and their correspondin* columns from an n n matri T.

    !onsider 

    $rincipal minors of order / are dia*onal elements /" 1" and 3.

    $rincipal minors of order 9 are

    Determinant of a principal minor is called principal determinant.

    =

    987

    654

    321

    $

    98

    65 an$ 

    97

    31 ,

    54

    21

    -inear .l/e"ra

  • 8/18/2019 optimization techiniques

    22/64

    22

    -inear .l/e"ra(eadin* $rincipal Minor 

    #he leadin* principal minor of order H of an n n matri is obtained

    b& deletin* the last n=H rows and their correspondin* columns.

     

    (eadin* principal minor of order / is /.

    (eadin* principal minor of order 9 is

    No. of leadin* principal determinants of an n n matri is n.

    =

    987

    654

    321

    $

    54

    21

  • 8/18/2019 optimization techiniques

    23/64

    23

    -inear .l/e"ra

     An nxn matri 9 is said to be positive definite if z T Mz is positive for all

    non=zero column vectors z . Matri 9 is s&mmetric.

    #ests for positive definite matrices

     All dia*onal elements must be positive.

     All the leadin* principal determinants must be positive !"#$%.

    #ests for positive semi=definite matrices

     All dia*onal elements are non=ne*ative !"#&$%.

     All the principal determinants are non=ne*ative.

    #ests for ne*ative definite and ne*ative semi=definite matrices

    #est the ne*ative of the matri for positive definiteness or positivesemi=definiteness.

  • 8/18/2019 optimization techiniques

    24/64

    24

    -inear .l/e"ra

  • 8/18/2019 optimization techiniques

    25/64

    25

    -inear .l/e"ra

  • 8/18/2019 optimization techiniques

    26/64

    26

    -inear .l/e"raEi*envalues

    )f the action of a matri on a 6nonzero7 vector chan*es its ma*nitude but

    not its direction" then the vector is called an eigene'or  of that matri.Each ei*envector is" in effect" multiplied b& a scalar" called the eigena&"e 

    correspondin* to that ei*envector. #he eigen%#a'e correspondin* to one

    ei*envalue of a *iven matri is the set of all ei*envectors of the matri with

    that ei*envalue

    %iven a linear transformation A" a non=zero vector is defined to be an

    ei*envector of the transformation if it satisfies the ei*envalue equation

     A% % λ =for some scalar U. )n this situation" the scalar U is called an eigen'alue of

     A correspondin* to the ei*envector .

  • 8/18/2019 optimization techiniques

    27/64

    27

    -inear .l/e"ra!omputation of ei*envalues" and the characteristic equation

    Vhen a transformation is represented b& a square matri A" the

    ei*envalue equation can be epressed as

    det6 A I U( 7 - ;.

     A% &% λ − =+olve

  • 8/18/2019 optimization techiniques

    28/64

    2#

    -inear .l/e"ra

  • 8/18/2019 optimization techiniques

    29/64

    2$

    -inear .l/e"ra

  • 8/18/2019 optimization techiniques

    30/64

    3(

    -inear .l/e"ra

  • 8/18/2019 optimization techiniques

    31/64

  • 8/18/2019 optimization techiniques

    32/64

    32

    =i?erential CalculusThe !eriatie, or !erie! )unction o) f  x  !enote! f` x is !e>ne! as

    ( ) ( )-( ) &i%

    h

     f x h f x f x

    h→

    + −  = ÷

    ( ) ( ) f x h f x+ −

    h

     x x  @ h

    A

     x 

     y 

    ( ) ( ) P$

     f x h f x

    m h

    + −=

    .eini0 otation -( ) &i%h o

     y dy

     f x  x dx

    δ 

    δ →

     = = ÷

    C l l

  • 8/18/2019 optimization techiniques

    33/64

    33

    Calculus

     The ro!uct Bule ( ) ( )' ( ) , tenk x f x " x= -( ) -( ) ( ) -( ) ( )k x f x " x " x f x= +

    ( )' ( ), ten y f x " x=

    ' ( ) ' ( )dy df d"  

     " x f xdx dx dx

    = + OB - -dy

     f " " f  dx

    = +

    21' ierentiate sin y x x=

    2( ) f x x= ( ) sin " x x=

    -( ) 2 f x x= -( ) cos " x x=- -

    dy f " " f  

    dx= +   22 sin cos x x x x= +

    C l l

  • 8/18/2019 optimization techiniques

    34/64

    34

    Calculus

    2- -dy f " " f    

    dx " −=

     The Auotient Bule

    3

    1' "in$

    sin

    d x

    dx x

     

    ÷3( ) f x x= ( ) sin " x x=

    2-( ) 3 f x x= -( ) cos " x x=

    2

    - -dy f " " f    

    dx " 

    −=

    2 3

    2

    3 sin cos

    sin

     x x x x

     x

    −=

    C l l

  • 8/18/2019 optimization techiniques

    35/64

    35

    Calculus

    35

     A secant line is a strai*ht line ,oinin* two points on a function

     A tan*ent line is a strai*ht line that touches a function at onl& one point.

    #he tan*ent line represents the instantaneous rate of chan*e of thefunction at that one point. #he slope of the tan*ent line at a point on the

    function is equal to the derivative of the function at the same point.

    C l l

  • 8/18/2019 optimization techiniques

    36/64

    36

    Calculus

     A critical point of a function is

    an& point 6a" f 6a77 where f W6a7 -

    ; or where f W6a7 does not eist.

     A stationar& point is an input to a

    function where the derivative is zero

    +tationar& points 6red circles7 andinflection points 6blue squares7.

    #he stationar& points in this *raph

    are all relative maima or relative

    minima.

     An inflection point or +addle point " is

    a point on a curve at which the curvatureor concavit& chan*es si*n from plus to

    minus or from minus to plus.

    f 6 x 7 - x 9 J 9 x  J 0 is differentiable ever&where

     f 6 x 7 - x 9K0 is defined for all x  and differentiable

    for x  X ;" with the derivative f Y 6 x 7 - 9 x I/K0K0.

    C l l

  • 8/18/2019 optimization techiniques

    37/64

    37

    Calculus

    2 2 1

    ( ) 1 2

    11 2 4

    2

     x x

     f x x x

     x x

    − ≤ <= ≤

  • 8/18/2019 optimization techiniques

    38/64

    3$

    CalculusLocal extrema(ocal etreme values occur either at the end points of the function" turnin*

    points or critical points within the interval of the domain.

    !onsider the function"2

    3

    2

    2 3 1

    ( ) 1 1

    2 8 5 1 3

     x x x

     f x x x

     x x x

    + − ≤ < −

    = − ≤

  • 8/18/2019 optimization techiniques

    39/64

    4(

    Calculus#he Nature of +tationar& $oints.

    )f f  W6a7 - ; then a table of values over a suitable interval centred at a 

    provides evidence of the nature of the stationar& point that must eist at a.

     A simpler test does eist.

    )t is the second derivative test.

    W6 7 ; and WW6 7 ; then minimum turnin* point.

    W6 7 ; and WW6 7 ; then maimum turnin* point.

    W6 7 ; and WW6 7 ; then draw a table of si*ns.

    f x f x  

    f x f x  

    f x f x  

    = >= <= =

    )f the second derivative test is easier to determine than maHin* a table ofsi*ns then this provides an efficient technique to findin* the nature of

    stationar& points.

    C l l

  • 8/18/2019 optimization techiniques

    40/64

    41

    Calculus

    -2 -1 0 1 2 3 4-80

    -60

    -40

    -20

    0

    20

    40

    60

    80

    100

    x

          y

     

    Orig

    1st Derv.

    2nd Derv.

    y = x4-4x3+5

    dy = 4 x.3 - 12*x2

    d2y = 12 x2 - 24 x

    - =9:;.;;/:@Z

    & - .[@ = @\.[0 J 1Z

    d& - @ \ .[0 = /9\.[9Z

    d9& - /9 \ .[9 = 9@\Z

    plot6"&"]r]"](ineVidth]"97Z hold onZ

    plot6"d&"]b]"](ineVidth]"97Z hold onZ

    plot6"d9&"]H]"](ineVidth]"97Z hold onZ

    le*end6]Ori*]"]/st Derv.]"]9nd Derv.]7

    raph Theory

  • 8/18/2019 optimization techiniques

    41/64

    42

    raph TheoryNetworH - *raph )nformall& a gra)h is a set of nodes ,oined

    b& a set of lines or arrows.

    / 2 0

    @ 1 F

    /

    @ 1 F

    2 0

    Nodes and ed*es%6" E7'ndirected *raphDirected *raph

    :-/"9"0"@"1"F4

    E:-/"94"/"14"9"04"9"14"0"@4"@"14"@"F44 Man& problems can be stated in terms of a *raph

    #he properties of *raphs are well=studied

    Man& al*orithms eists to solve *raph problems

    Man& problems are alread& Hnown to be intractable

    B& reducing  an instance of a problem to a standard *raph problem" we ma& be

    able to use well=Hnown *raph al*orithms to provide an optimal solution

    %raphs are ecellent structures for storin*" searchin*" and retrievin* lar*e

    amounts of data

    %raph theoretic techniques pla& an important role in increasin* the

    stora*eKsearch efficienc& of computational techniques.

    h Th

  • 8/18/2019 optimization techiniques

    42/64

    43

    raph Theory

    in'ien'e: an ed*e 6directed or undirected7 is incident to a verte that isone of its end points.

    egree of a verte: number of ed*es incident to it Nodes of a di*raph can also be said to have an inegree and an

    o"egree

    aa'en'/: two vertices connected b& an ed*e are ad,acent

    'ndirected *raph Directed *raph

    isolated verte

    loop

    multiple

    ed*es

    *-6V "+ 7

    ad,acent

    loop

    h Th

  • 8/18/2019 optimization techiniques

    43/64

    44

    raph Theory

     x y #ah: no verte can be repeated

    eample path: a=b=c=d=e

    rai&: no ed*e can be repeated

      eample trail: a=b=c=d=e=b=d

    a&;: no restriction

      eample walH: a=b=d=a=b=c

    '&o%e: if startin* verte is also endin*

    verte

    &engh: number of ed*es in the path" trail"or walH

    'ir'"i: a closed trail 6e: a=b=c=d=b=e=d=a7

    '/'&e: closed path 6e: a=b=c=d=a7

    a

    "

    c

    !

    e

    h Th

  • 8/18/2019 optimization techiniques

    44/64

    45

    raph Theory

    %im#&e gra#h: an undirected *raph with no loops or multiple ed*es

    between the same two vertices m"&i-gra#h: an& *raph that is not simple 'onne'e gra#h: all verte pairs are ,oined b& a path i%'onne'e gra#h: at least one verte pairs is not ,oined b& a path 'om#&ee gra#h: all verte pairs are ad,acent

     n: the completel& connected *raph with n vertices

    +imple *raph a

    b

    c

    d

    e

     1

    ab

    c

    d

    e

    Disconnected *raph

    with two components

    raph Theory

  • 8/18/2019 optimization techiniques

    45/64

    46

    raph Theory ree: a connected" ac&clic *raph ire'e a'/'&i' gra#h 6DA%7: a di*raph with no c&cles

    eighe gra#h: an& *raph with wei*hts associated with the ed*es6ed*e=wei*hted7 andKor the vertices 6verte=wei*hted7

    b a

    cd

    e f 

    /;

    1

    =09

    F

    athTerminolo/ies

  • 8/18/2019 optimization techiniques

    46/64

    47

    athTerminolo/ies A #heorem is a ma,or result

     A !orollar& is a theorem that follows on from another theorem

     A (emma is a small results 6less important than a theorem7am#&e: emma!

    #heorem:

    )f m and n are an& two whole numbers and• a - m9 S n9

    • b - 9mn

    • c - m9 J n9

    then a9 J b9 - c9

    roof :

    a9 J b9 - 6m9 S n979 J 69mn79

    - m@ S 9m9n9 J n@ J @m9n9

    - 6m9 J n979

    - c9

    6#hat was a ^ma,or^ result.7

    athTerminolo/ies

  • 8/18/2019 optimization techiniques

    47/64

    4#

    athTerminolo/ies A #heorem is a ma,or result

     A !orollar& is a theorem that follows on from another theorem

     A (emma is a small results 6less important than a theorem7am#&e: emma!

    #heorem:

    )f m and n are an& two whole numbers and• a - m9 S n9

    • b - 9mn

    • c - m9 J n9

    then a9 J b9 - c9

    roof :

    a9 J b9 - 6m9 S n979 J 69mn79

    - m@ S 9m9n9 J n@ J @m9n9

    - 6m9 J n979

    - c9

    6#hat was a ^ma,or^ result.7

    oro&&ar/

    a" b and c" as defined above" are

    a $&tha*orean #riple

    roof :

    8rom the #heorem a9 J b9 - c9" so

    a" b and c are a $&tha*orean #riple

    6#hat result ^followed on^ from the

    previous #heorem.7

    athTerminolo/ies

  • 8/18/2019 optimization techiniques

    48/64

    4$

    athTerminolo/ies)n a nutshell A #heorem is a ma,or result

     A !orollar& is a theorem that follows on from another theorem

     A (emma is a small results 6less important than a theorem7am#&e: emma!

    #heorem:

    )f m and n are an& two whole numbers and• a - m9 S n9

    • b - 9mn

    • c - m9 J n9

    then a9 J b9 - c9

    roof :

    a9 J b9 - 6m9 S n979 J 69mn79

    - m@ S 9m9n9 J n@ J @m9n9

    - 6m9 J n979

    - c9

    6#hat was a ^ma,or^ result.7

    oro&&ar/

    a" b and c" as defined above" are

    a $&tha*orean #riple

    roof :

    8rom the #heorem a9 J b9 - c9" so

    a" b and c are a $&tha*orean #riple

    6#hat result ^followed on^ from the

    previous #heorem.7

    (emma: )f m - 9 and n - /" then we *et the

    $&tha*orean triple 0" @ and 1roof : )f m - 9 and n - /" then

    a - 99 S /9 - @ S / - 3

    b - 9 _ 9 _ / - 4

    c - 99 J /9 - @ J / - ,

    6#hat was a ^small^ result.7

    athTerminolo/ies

  • 8/18/2019 optimization techiniques

    49/64

    5(

    athTerminolo/iesro#o%iion ` a proved and often interestin* result" but *enerall& less

    important than a theorem. if x is odd then x 2 is odd.one'"re ` a statement that is unproved" but is believed to be true.

    Every even nu!er l"rger th"n 2 #"n !e $ritten "s " su of t$o

     %ries.

    +iom?o%"&ae ` a statement that is assumed to be true without proof.

    #hese are the basic buildin* blocHs from which all theorems are proved.

    One of the aioms of arithmetic is that a J b - b J a. ou cant prove that"

    but it is the basis of arithmetic and somethin* we use rather often.

    .T-.D

  • 8/18/2019 optimization techiniques

    50/64

    51

    .T-.D MA#(AB is an interactive environment

    !ommands are interpreted one line at a time !ommands ma& be scripted to create &our own functions or

    procedures ariables are created when the& are used ariables are t&ped" but variable names ma& be reused for different

    t&pes

    Basic data structure is the matri Matri dimensions are set d&namicall&

    Operations on matrices are applied to all elements of a matri atonce Removes the need for loopin* over elements one b& oneG

    MaHes for fast efficient pro*rammes

    .T-.D

  • 8/18/2019 optimization techiniques

    51/64

    52

    .T-.D

    Comman!

    Ein!o*

    Eor8sp

    ace

    Comman!istory

    .T-.D ariables

  • 8/18/2019 optimization techiniques

    52/64

    53

    .T-.D Names !an be an& strin* of upper and lower case letters alon*

    with numbers and underscores but it must be*in with aletter 

    Reserved names are )8" VL)(E" E(+E" END" +'M"etc. Names are case sensitive

    alue #his is the data the is associated to the variableZ the

    data is accessed b& usin* the name. ariables have the t&pe of the last thin* assi*ned to them

    Re=assi*nment is done silentl& S there are no warnin*sif &ou overwrite a variable with somethin* of a differentt&pe.

    #o assi*n a value to a variable use the

    equal s&mbol - A - 09

    #o find out the value of a variable simpl&

    t&pe the name in

    .T-.D

  • 8/18/2019 optimization techiniques

    53/64

    54

    .T-.D

    .T-.D

  • 8/18/2019 optimization techiniques

    54/64

    55

    .T-.D A MA#(AB matri is a rectan*ular arra& of numbers

    +calars and vectors are re*arded as special cases of matrices

    MA#(AB allows &ou to worH with a whole arra& at a time

     Gou can also use "uilt in )unctions to create a matri< HH . + zeros2, 4 creates a matri< calle! . *ith 2 ro*s an! 4 columns

    containin/ the alue ( HH . + zeros5 or HH . + zeros5, 5 creates a matri< calle! . *ith 5 ro*s an! 5 columns

     Gou can also use HH onesro*s, columns

    HH ran!ro*s, columns

    Iote .T-.D al*ays re)ers to the >rst alue as thenum"er o) Bo*s then the secon! as the num"er o)Columns

    .T-.D

  • 8/18/2019 optimization techiniques

    55/64

    56

    .T-.D #he colon : is actuall& an operator" that *enerates a row vector  #his row vector ma& be treated as a set of indices when accessin* a

    elements of a matri #he more *eneral form is Pstart:stepsize:endQ P//:9:9/Q // /0 /1 /2 /3 9/

    +tepsize does not have to be inte*er 6or positive7 P99:=9.;2://Q 99.;; /3.30 /2.F /1.23 /0.29 //.F1

    .T-.D

  • 8/18/2019 optimization techiniques

    56/64

    57

    .T-.Dathematical Operators

    .!! @

    Su"tract J =ii!e 'K ultiply 'L o*er 'M e'/' 'M2 means square!

     Gou can use roun! "rac8ets to speci)y the or!erin *hich operations *ill "e per)orme!

    Iote that prece!in/ the sym"ol K or L or M "y aN' means that the operator is applie! "et*eenpairs o) correspon!in/ elements o) ectors o)matrices

    .T-.D

  • 8/18/2019 optimization techiniques

    57/64

    5#

    .T-.DCom"inin/ this *ith metho!s )rom .ccessin/ atri< ;lements

    /ies *ay to more use)ul operations

    HH results + zeros3, 5

    HH results, 14 + ran!3, 4

    HH results, 5 + results, 1 @ results, 2 @ results, 3 @results, 4

    or

    HH results, 5 + results, 1 'L results, 2 'L results, 3 'L

    results, 4

    .T-.D

  • 8/18/2019 optimization techiniques

    58/64

    5$

    .T-.D-o/ical Operators reater Than H

    -ess Than P reater Than or ;qual To H+

    -ess Than or ;qual To P+

    Qs ;qual ++

    Iot ;qual To R+

    8or eample" &ou can find data that is above a certain limit:

     r - results6:"/7

    ind - r ;.9

    Boolean Operators:

     AND:

    OR: 5

    NO#:

    .T-.D

  • 8/18/2019 optimization techiniques

    59/64

    6(

    .T-.D #here are a number of special functions that provide useful

    constants

    pi - 0./@/139F1

  • 8/18/2019 optimization techiniques

    60/64

    61

    .T-.D #he plot function can be used in different wa&s:

    plot6data7

    plot6" &7

    plot6data" r.=7

    )n the last eample the line st&le is defined

    !olour: r" b" *" c" H" & etc.

    $oint st&le: . J \ o etc. (ine st&le: = == : .=

    . "asic plotHH < +

    (('12Lpi9

    HH y + sin

  • 8/18/2019 optimization techiniques

    61/64

    62

    .T-.D

    >> x = [0:0.1:2*pi];>> y = sin(x);

    >> plot(x, y, '*!')

    >> "ol# on

    >> plot(x, y*2, $r.!')

    >> title('%in &lots');

    >> leen#('sin(x)', '2*sin(x)');

    >> axis([0 .2 !2 2])

    >> xlael($x);

    >> ylael($y);

    >> "ol# o  0 1 2 3 4 5 6-2

    -1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    2Sin Plots

    x

          y

     

    sin(x)

    2*sin(x)

    .T-.D

  • 8/18/2019 optimization techiniques

    62/64

    63

    .T-.D 8or command

    'se a for loop to repeat one or more statements

    #he end He&word tells Matlab where the loop finishes

    ou control the number of times a loop is repeated b& definin* thevalues taHen b& the inde variable

    #his uses the colon operator a*ain" so inde values do not needto be inte*er 

    8or eample for i - /:@   a6i7 - i \ 9   end

    .T-.D

  • 8/18/2019 optimization techiniques

    63/64

    64

    .T-.D #he counter can be used to inde different rows or columns

    E.*.

    results - rand6/;"07 for i - /:0

      m6i7 - mean6results6:" i77

      end

    ..althou*h &ou could do this in one step

    m - mean6results7Z

    .T-.D

  • 8/18/2019 optimization techiniques

    64/64

    .T-.D #he if command is used with lo*ical operators

     A*ain" the end command is used to tell Matlab where the statement

    ends. 8or eample" the followin* code loops throu*h a matri performin*

    calculations on each column

    for i - /:size6results" 97

      m - results6:" i7

      if m /   do somethin*

      else

      do somethin* different

      end

    end