This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.
Linear programming is applied to various fields like business, economics and sometimes to solve certain engineering problems. Transportation, energy, telecommunication and manufacturing industries use linear programming for modeling different type of problems in routing, scheduling, design and so on.
Various methods of solving linear programming problem are:
Artificial Starting Solution
2. Graphical Method
Graphical method is useful while solving two variable linear programming problems where one variable is taken on the x-axis while the other is taken as y axis in a two-dimensional graph.
Suppose an example is taken as follows
Maximize Z= f(x,y)= 3x+2y
subject to 2x+y <= 18
2x+3y <= 42
3x+y <= 24
x>=0 , y>=0
Draw the coordinate system taking one axis as variable x and the other axis as variable y.
Take an appropriate numerical scale that can take the variables in the constraints provided. To do so, remove all the other variables if present other than those being used from the constraints.
Taking the first constraint, 2x+y=18 (using it as equality). Plot this line on the graph and name its edges A-B edge. The region defined by this constraint is below this line and is Yellow in colour in the figure shown below.
Similarly, plot the other two constraints with the regions defined by them in Blue (2x+3y<=42) having C-D edge and Red (3x+y<=24) having E-F edges.
Looking at the graph as whole, a feasible region is visible. Note down the extreme points, these are the possible points for optimal solution. In this example O-F-H-G-C points are the extreme points.
Evaluate the objective function ( 3x+2y) with these extreme points. The calculated values are given in table below;
Objective value (Z)
Looking at the values in the table, point G gives the highest value when substituted in objective function. Therefore, the optimal value is obtained at coordinates (3,12) and the optimal maximized value is 33.
Fig: Graphical Representation of Linear Programming Problem
Simplex Method/Algorithm is a very powerful computational tool capable of solving linear program problems with hundreds of variables systematically and efficiently. Developed by George Dantzig in 1947, simplex algorithm solves linear programming problems by constructing a feasible solution at the vertex of a polytope and moving along the edge of the polytope till optimum solution is obtained.
To solve a standard maximization LPP using simplex method, the following steps are taken:
Write the objective function in the standard form. Introduce slack variables in the constraints accordingly to convert the constraints into system of equations.
Write down the initial tableau.
Select the most negative number with the maximum magnitude from Zj-Cj row leaving the right-hand side, to choose a pivot column. If the numbers in the Zj-Cj row are all zero or positive, optimality has been attained where the RHS of this row gives the optimal value for the objective function. If not, then continue to the next step.
Now to select the pivot from the pivot column, find the b/a ratio also called the min ratio where b is the RHS of constraints in the row. From the calculated b/a ratios, select the smallest most positive value. This is our pivot number.
Next the pivot column is cleared using the pivot number and the pivot row is renamed with the pivot column label. The variable of the pivot row is the leaving variable and the variable of the pivot column is the entering variable.
If all the numbers in Zj-Cj row are either zero or positive leaving the RHS of this row, then optimality has reached. The RHS of this table gives the optimal values for the variables as well as the objective function.
If optimality has not been reached, repeat this process from step-3.
3.1 Simplex Code
code part 1.png
code part 2.png
code part 3.png
code part 4.png
code part 5.png
This simplex code developed in C runs successfully for 3 variable LPPs. The main headers used here are : #include<studio.h> and #include<conio.h>. The main functions used here are:
void minimum(float *array,int *minposarr,int n)- Calculates the minimum valued position among the arrayay array having n elements.
void display (float c,float b,float a[M],int basic)-Display the table.
void dpframe(float c[M])- Displays the frame of the table
void calctemp(float *,float [M],float ,int )-Calculates Zj-Cj
The code starts by:
Initialising variables for storing coefficients of objective function (max (z)) in c[M],constraints in a[N][M], RHS of constraints in b[N] and values of Zj-Cj in temp[M].
Various variables are initialised for storing coming in variable (minpostemp), going out variable (minratiopos), ratio of b[i]/a (miniratio), pivot element (key), column number which goes out (colmnout),value of objective(z),basic variables, non basic variables and so on.
Basic variables x4, x5, x6 are initialised with a for loop.
Next, the code asks the user to enter the coefficients for objective function, constraints and RHS of constraints.
Then it calculates the Zj-Cj row by calling the calctemp() function and printing it on screen.
The incoming column is determined by calling the minimum function and the out going variable by using the miniratio=b[i]/a. It is then printed on the screen.
Once the basic and nonbasic variables are changed, operation is performed to bring similar expressions in in-coming variables as out-going variable by row operations.
This process continues till all the numbers in the Zj-Cj row have either become zero or all positive. Therefore optimality is obtained and the maximized value is displayed on the screen.
An example using simplex code
Let us consider the following problem :
Maximize Z= 5x + 4y+3z
2x +3y+ z <=5
4x + y + 2z <=11
3x +4y + 2z <=8
x>=0 , y>=0
Using the simplex code shown above, this problem is solved. The following snapshots show the step by step solving of this problem:
4. Special Cases of Simplex Method
4.1 Degeneracy or Stalling or Cycling
Degeneracy happens when one or more basic variables are zero. Here, the pivot keeps changing without any change in the objective value. There takes place degeneracy when there is a tie between the minratios and we arbitrarily choose anyone of the minratio value as our pivot value.
4.2 Alternate Solutions
Alternate solution occurs when a non basic variable has the value zero in the Zj-Cj row. This non basic variable can be taken into the basis to obtain a different optimal solution. When two such optimal solutions are calculated, infinite number of optimal solutions can be calculated using the weighted sum of the two optimal solutions.
4.3 Unbounded Solutions
An unbounded solution occurs if at any stage of solving an LPP using simplex method, all the values of a column have negative or zero values. No optimal value is obtained from such a system of equations. Here, as the values of the variables grows, so does the value of the optimal solutions without violating any restrictions.
If an artificial variable is still present in the basis in the final tableau, then it gives an indefinite solution. In such cases 2-phase method has to be used.
Simplex method is a very powerful tool in solving linear programming problems. Apart from its use mathematically, it is also used in transport industry , diet problems and so on. Some other field simplex method is employed to solve day to day problems include:
Irrigation - Here simplex method is used to calculate the amount various crops to be grown so as not to overuse resources (land, water, manpower), to maximise their profits while keeping in mind the market and crop rotation restrictions.
Animal Husbandry - The number of cattle and sheep are determined that can graze in different pastures to maximise their use without overgrazing in one pasture area than the other.
Human & Animal Diets - To calculate the amount of different foods to be incorporated in the diet keeping the diet cost to a minimum along with fulfilling the minimum requirements of nutrients in the diet plan.
Urban Development - To calculate the land acreage to be given to different house types in a housing development scheme to optimise the savings of those to be located depending on the availability of land and the requirements of housing demand.
Transportation - To determine the flow pattern of transportation of different goods to various destinations so as to keep the transportation cost minimised along with fulfilling the goods requirement at different locations.