0

How to solve the linear programming maximization problem that contains both <= and >= equations?

For example here's a case:

Maximize:

z = c1x1 + c2x2 + c3x3

Subject to:

a1x1 + a2x2 + a3x3 <= b1
a4x1 + a5x2 + a6x3 <= b2
x1 >= d1
x2 >= d2
x3 >= d3

Where a1, a2, a3, a4, a5, a6, b1, b2, b3, c1, c2, c3 are the constants in the given equations.

What will be the proper Matlab code to solve this problem?

Tiash
  • 109
  • 3
  • 14

1 Answers1

1

That's how :

    z = -[c1 ; c2 ; c3];

    A = [ a1 a2 a3 ; 
          a4 a5 a6]; 

    b=[b1;
       b2];

    Aeq= [ ]; beq= [ ];

    LB = [d1 ; d2 ; d3]; 

    UB = [1 ; 1 ; 1]* inf; % Any relax number

    x = linprog(z, A, b, Aeq, beq, LB, UB)
Sardar Usama
  • 19,536
  • 9
  • 36
  • 58
  • Thanks @Sardar_Usama, How can I get the value of z using matlab? – Tiash May 26 '16 at 19:31
  • By putting the values of constants `c1` , `c2` and `c3` – Sardar Usama May 26 '16 at 19:33
  • Do I have to calculate it manually or is there any built-in function to do that? – Tiash May 26 '16 at 20:03
  • What exactly are you asking? – Sardar Usama May 26 '16 at 20:04
  • It would be a great help if you please add the code that calculates the value of z in your answer. – Tiash May 26 '16 at 20:09
  • 1
    if you're asking for the value of this: `z = c1x1 + c2x2 + c3x3` , it doesn't mean anything since `x1`,`x2` and`x3` are decision variables. You can find the value of `z` by putting the different values of these variables and constants `c1`,`c2` and `c3`. And if you want to find the maximum value of `z`, it is already given in the code. – Sardar Usama May 26 '16 at 20:14
  • Okay, if the results obtained for x1 = m, x2 = n and x3 = p; then is it possible to do sensitivity analysis or post optimization analysis on this problem using MATLAB? – Tiash Jun 04 '16 at 17:01