l12 optim constrain

Upload: andresboy123

Post on 14-Apr-2018

245 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 L12 Optim Constrain

    1/21

    Constrained Optimization

    - Linear Programming

    - Nonlinear Constrained Optimization

    - MATLABs fmincon Function

    Numerical Methods forNumerical Methods forCivilCivilEngineersEngineers

    Lecture 12

    Mongkol JIRAVACHARADETSchool ofCivil Engineering

    S u r a n a r e eUNIVERSITY OF TECHNOLOGY

    NAKORNRATCHSIMA

  • 7/30/2019 L12 Optim Constrain

    2/21

    LINEAR PROGRAMMINGStandard Form

    Objective Function: MaximizeZ= c1x1+ c2x2+ . . . + cnxn

    where cj = payoff ofjth activity

    xj = magnitude ofjth activity

    Z= total payoff due to all activities

    Constraints: ai1x1 + ai2x2 + . . . + ainxn bi

    where aij = amount ofith resource used byjth activity

    bi = amount ofith resource available

  • 7/30/2019 L12 Optim Constrain

    3/21

    Example: Setting Up the Linear Programming Problem

    Producing product with limited resources: Gas processing plant

    Resource

    Product

    Regular Premium

    Resource

    Availability

    Raw gas

    Production time

    Storage

    Profit

    7 m3/ton 11 m3/ton

    10 hr/ton 8 hr/ton

    9 ton 6 ton

    150 / ton 175 / ton

    77 m3/week

    80 hr/week

    Set x1 = amount of regular gas produced

    x2 = amount of premium gas produced

  • 7/30/2019 L12 Optim Constrain

    4/21

    Total profit = 150x1

    + 175x2

    MaximizeZ = 150x1 + 175x2 Objective function

    Total gas used = 7x1 + 11x2

    cannot exceed 77 m3/week

    7x1 + 11x2 77 Constraints

    10x1 + 8x2 80

    x1 9 x2 6

    x1

    , x2

    0

  • 7/30/2019 L12 Optim Constrain

    5/21

    10x1+8x2 = 80

    7x1+11x2 = 77

    11

    7

    7x1+11x2 = 77

    11

    7

    9

    6

    10x1+8x2 80

    7x1+11x2 77

    Graphical Solution MaximizeZ = 150x1 + 175x2

    1 2

    1 2

    1

    2

    7 11 77 (1)

    10 8 80 (2)

    0 9 (3)

    0 6 (4)

    x x

    x x

    x

    x

    +

    +

    x2

    x10

  • 7/30/2019 L12 Optim Constrain

    6/21

    x2

    x10

    Increasing Objective Function From Z = 150x1

    + 175x2

    ForZ= 0, 150x1 + 175x2 = 0

    Z = 0 Z = 600

    Z = 1400

    Unique solution

  • 7/30/2019 L12 Optim Constrain

    7/21

    Other Possible Outcomes

    x2

    x10

    Objective function parallel

    to constraint.Alternate Solution

  • 7/30/2019 L12 Optim Constrain

    8/21

    x2

    x10

    No Feasible Solution

  • 7/30/2019 L12 Optim Constrain

    9/21

    x2

    x10

    Unbounded Problems

    Z

  • 7/30/2019 L12 Optim Constrain

    10/21

    Simplex Method

    Assumption: optimal solution will be an extreme point

    Extreme points: corner pointswhere two constraints meet

    x2

    x10Z = 0 Z = 600

    Z = 1400Objective function

    isLINEAR

  • 7/30/2019 L12 Optim Constrain

    11/21

    Slack Variables

    Reformulate constraint inequalities as equalities

    1 2 1 2 1

    7 11 77 7 11 77x x x x S+ + + =

    slack variable

    Resource constraint How muchslackof the resource

    is available ?

    IF . . .

    S1

    = + Surplus resource is not fully used.

    S1 = - Exceeded the constraint.

    S1 = 0 Exactly meet the constraint. All resource is used.

  • 7/30/2019 L12 Optim Constrain

    12/21

    Fully Augmented Version

    MaximizeZ = 150x1 + 175x2

    subject to

    1 2

    1 2

    1

    2

    7 11 77

    10 8 800 9

    0 6

    x x

    x xx

    x

    +

    +

    1 2 1

    1 2 2

    1 3

    2 4

    1 2 1 2 3 4

    7 11 77

    10 8 809

    6

    , , , , , 0

    x x S

    x x Sx S

    x S

    x x S S S S

    + + =

    + + =

    + =

    + =

    Linear algebraic equations

    solving 4 equations with 6 unknowns

  • 7/30/2019 L12 Optim Constrain

    13/21

    Algebraic Solution

    Underspecified: more unknowns (6) than equations (4)

    Extreme Point Zero Variables

    A x1, x2

    B x2, S2

    C S1, S2

    D S1, S4

    E x1, S4

    x2

    x1

    x1 = 9, S3 = 0

    9

    6

    0

    10x1 + 8x2 = 80S2 = 0

    7x1 + 11x2 = 77

    S1 = 0

    x2 = 6, S4 = 0

    A B

    C

    DE

    @ Extreme point :

    4 equations with 4 unknowns

    The problem can be solved.

  • 7/30/2019 L12 Optim Constrain

    14/21

    For pointE: Settingx1 = S4 = 0

    The standard form reduced to

    1 2 1

    1 2 2

    1 3

    2 4

    7 11 77

    10 8 80

    9

    6

    x x S

    x x S

    x S

    x S

    + + =

    + + =

    + =

    + =

    0

    0

    0

    0

    2 1

    2 2

    3

    2

    11 77

    8 80

    9

    6

    x S

    x S

    S

    x

    + =

    + =

    =

    =

    which can be solved for

    x1 x2 S1 S2 S3 S4

    0 6 11 32 9 0

    nonbasic variables

    basic variables

  • 7/30/2019 L12 Optim Constrain

    15/21

    Simplex Method Implementation

    Start at pointA : Settingx1 = x2 = 0

    1

    2

    3

    4

    77

    80

    9

    6

    S

    S

    S

    S

    =

    =

    =

    =

    Tableau: Z- 150x1 - 175x2 - 0S1 - 0S2 - 0S3 - 0S4 = 0

    Basic Z x1 x2 S1 S2 S3 S4 Solution Intercept

    Z

    S1

    S2

    S3

    S4

    1

    0

    0

    0

    0

    -150

    7

    10

    1

    0

    -175

    11

    8

    0

    1

    0

    1

    0

    0

    0

    0

    0

    1

    0

    0

    0

    0

    0

    1

    0

    0

    0

    0

    0

    1

    0

    77

    80

    9

    6

    11

    8

    9

  • 7/30/2019 L12 Optim Constrain

    16/21

    Graphical Depiction of Simplex Method

    x2

    x18

    6

    0A B

    C

    DE

    S1

    11F

    S2

    S4

    S3

    Changex1 to basic variable (entering variable)

    Move fromA horizontally

    Intercept(for each S)

    =Solution

    x1

    coeff.

    Check intercept:

    S2 give min. intercept = 8

    Therefore, change S2 to nonbasic(leaving) variable.

  • 7/30/2019 L12 Optim Constrain

    17/21

    Move to pointB : Settingx2 = S2 = 0 1 1

    1

    1 3

    4

    7 77

    10 80

    9

    6

    x S

    x

    x S

    S

    + =

    =

    + =

    =

    Basic Z x1 x2 S1 S2 S3 S4 Solution

    Z

    S1

    x1

    S3

    S4

    1

    0

    0

    0

    0

    -150

    7

    1

    1

    0

    -175

    11

    0.8

    0

    1

    0

    1

    0

    0

    0

    0

    0

    0.1

    0

    0

    0

    0

    0

    1

    0

    0

    0

    0

    0

    1

    0

    77

    8

    9

    6

    Pivot rowS2: Dividing row by 10 and replacing S2byx1

    x -150

    Z 1 0 -55 0 15 0 0 1200

  • 7/30/2019 L12 Optim Constrain

    18/21

    Basic Z x1 x2 S1 S2 S3 S4 Solution

    Z

    S1x1

    S3

    S4

    1

    00

    0

    0

    0

    01

    0

    0

    -55

    5.40.8

    -0.8

    1

    0

    10

    0

    0

    15

    -0.70.1

    -0.1

    0

    0

    00

    1

    0

    0

    00

    0

    1

    1200

    218

    1

    6

    Perform same operation on the remaining rows,

    Intercept

    3.88910

    -1.25

    6

    - From A toB, objective function has increased to 1200

    - S1 give min. positive intercept = 3.889 is entering variable

    - Move fromB to C

  • 7/30/2019 L12 Optim Constrain

    19/21

    Basic Z x1 x2 S1 S2 S3 S4 Solution

    Z

    S1x1

    S3

    S4

    1

    00

    0

    0

    0

    01

    0

    0

    0

    10

    0

    0

    10.19

    0.19-0.15

    0.15

    -0.19

    7.87

    -0.130.20

    -0.20

    0.13

    0

    00

    1

    0

    0

    00

    0

    1

    1414

    3.894.89

    4.11

    2.11

    Final Tableau:

    - No negative coeff. in objective func. row, No more increasing.

    Final solution: x1 = 3.89, x2 = 4.89

    Z= 1414

  • 7/30/2019 L12 Optim Constrain

    20/21

    MATLABs fmincon Function

    ( )1 2 21 2 1 2 2( ) 4 2 4 2 1xf x e x x x x x= + + + +

    subject to the constraints:1 2 1 2

    1 2

    1.5

    10

    x x x x

    x x

    rewrite the constraints in the form c(x) 0 :

    1 2 1 2

    1 2

    1.5 0

    10 0

    x x x x

    x x

    +

  • 7/30/2019 L12 Optim Constrain

    21/21

    Write M-file confun.m for the constraints

    function [c, ceq] = confun(x)

    % nonlinear inequality constraints

    c = [1.5 + x(1)*x(2) - x(1) - x(2);

    -x(1)*x(2) - 10];% nonlinear equality constraints

    ceq = [];

    > x0 = [-1,1];

    > options = optimset(LargeScale,off);

    > [x, fval] = . . .

    fmincon(objfun,x0,[],[],[],[],[],[],confun,options)

    x =

    -9.5474 1.0474

    fval =

    0.0236