Results 1 to 10 of 10

Math Help - stuck on matlab simplex method

  1. #1
    Member
    Joined
    Nov 2009
    Posts
    75

    Exclamation stuck on matlab simplex method

    hi all,

    can anyone help me with this?ive been stuck for days!

    im using the matlab code:

    %
    options=optimset('LargeScale','off','Simplex','on' );
    %
    % This code solves the problem:
    %
    % minimise x_1+x_2+x_3
    %
    % subject to the constraints
    %
    % b_11 x_1 + b_12 x_2 + b_13 x_3 >= 1
    % b_21 x_1 + b_22 x_2 + b_23 x_3 >= 1
    % b_31 x_1 + b_32 x_2 + b_33 x_3 >= 1
    % x_1 >=0, x_2 >=0, x_3 >=0
    %

    %
    B=[ 1 -6 -7;
    -1 6 6;
    7 -6 0];
    A=-B;
    f=[1;1;1];
    b=-[1;1;1];
    lb=zeros(3,1); % x_1, x_2 and x_3 are non-negative.
    %
    [x,value]=linprog(f,A,b,[],[],lb)


    to solve for (see attached file)

    my results are (when i run simplex_method.m):
    x1 = 0
    x2 = 0
    x3 = 1/3

    obviously this does not make any sense?? as x1 + x2 + x3 = 1

    what am i doing wrong?? : (


    P.S. im trying to minimise the problem in the second pic
    Attached Thumbnails Attached Thumbnails stuck on matlab simplex method-simplexmethod.jpg   stuck on matlab simplex method-simplexmethod2.jpg  
    Last edited by matlabnoob; January 7th 2011 at 02:20 PM. Reason: want to add more vital info
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Senior Member
    Joined
    Dec 2010
    Posts
    470
    If you want the condition x1 + x2 + x3 = 1, then you need:

    [x,value]=linprog(f,A,b,[1 1 1],[1],lb)
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Member
    Joined
    Nov 2009
    Posts
    75
    Quote Originally Posted by snowtea View Post
    If you want the condition x1 + x2 + x3 = 1, then you need:

    [x,value]=linprog(f,A,b,[1 1 1],[1],lb)



    i did that and now i got:

    x =
    1.4667
    1.5134
    0.0008

    value = 2.9809

    andi got a message saying:
    exiting: one or more of the residuals, duality gap or total relative error has grown 10000 times greater than its minimum value so far: the primal appears to be infeasible (and the dual ubnounded)
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Senior Member
    Joined
    Dec 2010
    Posts
    470
    It is exactly what the message says. The minimum must be unbounded in the region you defined by A and b.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Member
    Joined
    Nov 2009
    Posts
    75
    Quote Originally Posted by snowtea View Post
    It is exactly what the message says. The minimum must be unbounded in the region you defined by A and b.
    i do not quite get what you mean? *thinks*
    im not sure what matlab itself means when it says that...

    all my inputs seem to be correct? and the code
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Senior Member
    Joined
    Dec 2010
    Posts
    470
    There must be no minimum in the region either because the region is empty, or the region does not have a lower bound for x1+x2+x3.

    Actually, I thought you wanted x1+x2+x3=1 as a constraint, but now that I think about it , this does not make sense as you want to minimize x1+x2+x3.

    How do you know that the minimum is x1+x2+x3=1?
    Isn't 0+0+1/3 = 1/3 less than that?
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Member
    Joined
    Nov 2009
    Posts
    75
    Quote Originally Posted by snowtea View Post
    There must be no minimum in the region either because the region is empty, or the region does not have a lower bound for x1+x2+x3.

    Actually, I thought you wanted x1+x2+x3=1 as a constraint, but now that I think about it , this does not make sense as you want to minimize x1+x2+x3.

    How do you know that the minimum is x1+x2+x3=1?
    Isn't 0+0+1/3 = 1/3 less than that?
    ah i see. i know that x1+x2+x3=1 because in the problem x1, x2 & x3 are all the probabilities and they sum up to 1
    which is why am confused to why the code is failing..
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Senior Member
    Joined
    Dec 2010
    Posts
    470
    Well, you need to figure out exactly what you are minimizing.

    The code you wrote uses linear programming to minimize x1+x2+x3. This clearly is not the answer you need, since you already know x1+x2+x3 = 1.

    What exactly are you trying to minimize?
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Member
    Joined
    Nov 2009
    Posts
    75
    im trying to minimise (please see my second attached file in my first post on this page). not sure how to attach files in replies..
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Senior Member
    Joined
    Dec 2010
    Posts
    470
    So you are trying to minimize -w?
    How do you transform this into linear programming with x1,x2,x3?

    Well look at the value of x1 + x2 + x3 + (-w) = 1 + (-w), and minimize this.

    So now you should have a 4 variable vector (x1,x2,x3,-w).
    Also, remember to express the constraint x1+x2+x3=1 (which is the same as 1*x1+1*x2+1*x3+0*(-w) = 1)
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Simplex Method
    Posted in the Advanced Algebra Forum
    Replies: 0
    Last Post: April 24th 2011, 10:47 PM
  2. LPP-Simplex method
    Posted in the Algebra Forum
    Replies: 2
    Last Post: May 21st 2010, 09:38 AM
  3. Simplex method help
    Posted in the Advanced Algebra Forum
    Replies: 0
    Last Post: March 22nd 2010, 04:40 PM
  4. Simplex Method
    Posted in the Advanced Algebra Forum
    Replies: 0
    Last Post: November 30th 2009, 10:45 AM
  5. Simplex method
    Posted in the Math Topics Forum
    Replies: 1
    Last Post: November 23rd 2009, 11:03 PM

Search Tags


/mathhelpforum @mathhelpforum