Study On Simplex Method and Design & Development of Application For Solving Simplex Problem Using Python
Study On Simplex Method and Design & Development of Application For Solving Simplex Problem Using Python
ISSN No:-2456-2165
AAM19MY09 www.ijisrt.com 39
Special Issue - (AAM - 2019) Advances in Applied Mathematics (AAM - 2019)
ISSN No:-2456-2165
II. MATERIALS & METHODS 2. If the constraint inequalities are ′ ≥’ then subtract
surplus (𝑆) variable and add artificial variable(𝐴) to the
The simplex method can be easily applies to real world left hand side of the inequality and write it as equation.
problems. The problem is converted into mathematically 3. If the constraint inequalities is′ =’ then add artificial
linear model to keep it into standard form. Simplex method variables (𝐴) to the left hand side of the inequality and
procedure which is been followed in this study is given write it as equation.
below with an example 4. If in case right hand side is negative then multiply the −1
throughout and make it positive and then follow rules(1-
Example: 𝑀𝐼𝑁 𝑍 = 𝑥1 + 𝑥2 + 3𝑥3 3)
5. In the objective function coefficient of slack variable,
Subject to constraints. surplus variable is 0 and artificial variable is -1
3𝑥1 + 2𝑥2 + 𝑥3 ≤ 3
2𝑥1 + 𝑥2 + 2𝑥3 ≥ 3 𝑀𝑎𝑥 𝑍 = −𝑥1 − 𝑥2 − 3𝑥3 + 0𝑆1 + 0𝑆2 − 𝐴1 − 𝐴2
𝑥1 + 𝑥2 + 𝑥3 = 3/2 3𝑥1 + 2𝑥2 + 𝑥3 + 𝑆1 = 3
𝑥1 , 𝑥2 , 𝑥3 ≥ 0 2𝑥1 + 𝑥2 + 2𝑥3 − 𝑆2 + 𝐴1 = 3
𝑥1 + 𝑥2 + 𝑥3 + 𝐴2 = 3/2
Step 1: Make sure that objective function is Maximization.
If it is minimization then convert it into maximization by Step 3: Non-negativity constraints are
multiplying -1 and write 𝑀𝑎𝑥 𝑍 = 𝑀𝑖𝑛(−𝑧). 𝑥1 , 𝑥2 , 𝑥3 , 𝑆1, 𝑆2, , 𝐴1, 𝐴2, ≥ 0
𝑀𝑎𝑥 𝑍 = −𝑥1 − 𝑥2 − 3𝑥3 Step 4: Initial basic feasible solution can be found by
equating 𝑛 − 𝑚 variable to zero (𝑛 = number of variable
Step 2: Convert the inequalities to equalities by employing and 𝑚 = number of constraints). That is 6 − 3 = 3 variables
following rule. are equated to zero those are 𝑥1 = 𝑥2 = 𝑥3 = 0, therefore
we Basic variables 𝑆1 = 3, 𝐴1 = 3, 𝐴2 = 3/2. Write the
1. If the constraint inequalities is′ ≤’ then add slack linear problem in tabular as shown below,
variables (𝑆) to the left hand side of the inequality and
write it as equation.
𝑪𝒋 -1 -1 -3 0 0 -1 -1
𝟑
0 𝑺𝟏 3 2 1 1 0 0 0 3 =𝟏
3 𝟑
𝟑
-1 𝑨𝟏 2 1 2 0 -1 1 0 3 = 𝟏. 𝟓
𝟐
𝟑
-1 𝑨𝟐 1 1 1 0 0 0 1 3/2 = 𝟏. 𝟓
𝟐
𝒁𝒋 -3 -2 -3 0 1 0 0 −𝟗/𝟐
Table 1:- Table for example input
In the table, 𝐶𝑗 are coefficients of objective function pivot column ratios is found, which is shown in the right
and 𝑎𝑖 are coefficients of basic variable in the objective hand side. The row, which has, has lowest ratio that will be
function. 𝑍𝑗 − 𝐶𝑗 is calculated by the formula ∑𝟑𝒊=𝟏 𝒂𝒊 𝒙𝒊𝒋 𝑗 = pivot row, and the variable is departing variable (𝑆1 ). and
1, 2 … .7. coinciding number is called pivot element(3).
AAM19MY09 www.ijisrt.com 40
Special Issue - (AAM - 2019) Advances in Applied Mathematics (AAM - 2019)
ISSN No:-2456-2165
The above picture depicts how the excel sheet looks
The process continues until the optimality condition after doing the operations on the entered equations. The red
reached that is all 𝒁𝒋 − 𝑪𝒋 ≥ 𝟎. cells contain the value, which is least in the Zj-Cj row, and
the yellow cells contain the key values and the green cells
III. SIMPLEX APPLICATION USING PYTHON contain the values of the variables and Z after doing the
simplex method.
The application is created using the programming
language python. The python code takes input from the user B. How does it work??
in the console. Every input has a proper-labelled question The first thing the code does is, it takes the number of
and the user has to enter the values of what is asked. The equations and variables as input, so now we know how
input console will look like the figure shown below (The many equations are there and the number of variables and
given input is for the above specified example). slack variables. After this, we find out the least value, which
is there in the Zj-Cj row. That is done by the following code:
In the above picture depicts how the program takes the Fig 4:- Code to find key row
inputs. The program first asks the user the number of
equations and number of variables (i.e. x1, x2, x3, etc.). From the above code, we have found the least row and
Then the program asks the user to enter the coefficients of the key value. The next step is to generate the next iteration.
each variable in each question. Then the user enters the After generating the next iteration the above steps for the
R.H.S value of the equation i.e. the “xb” value in the above simplex method is followed and when the answer is found
picture. Then the user is asked if the equation inequality the, it is shown in the excel file.
which are l(<=) less than or equal to inequality (or) g(>=)
greater than or equal to inequality (or) e(=) equality and the C. Examples:
input is case insensitive. After taking all the equation, the
user enters the coefficient of variable in the objective 1)
function. After entering these values and the code generates 𝑀𝑎𝑥 𝑍 = 2𝑥1 + 4𝑥2 + 3𝑥3
the excel file which is stored in the documents folder in the
user system. Subject to constraints,
The excel file contains all the iteration of the above 3𝑥1 + 4𝑥2 + 2𝑥3 ≤ 60
entered equation using simplex method. 2𝑥1 + 𝑥2 + 2𝑥3 ≤ 40
𝑥1 + 3𝑥2 + 2𝑥3 ≤ 80
A. Output 𝑥1 , 𝑥2 , 𝑥3 ≥ 0
Fig 2:- Excel file Fig 5:- Excel output for above example
AAM19MY09 www.ijisrt.com 41
Special Issue - (AAM - 2019) Advances in Applied Mathematics (AAM - 2019)
ISSN No:-2456-2165
2) FUTURE SCOPE
𝑀𝑖𝑛 𝑍 = 12𝑥1 + 20𝑥2
This application can be used for multiple purposes in
Subject to constraints future. It can use for feed formulation, linear programming
and integer programming. The application currently runs on
6𝑥1 + 8𝑥2 ≥ 100 a console, but in future, it can be upgraded with a
7𝑥1 + 12𝑥2 ≥ 120 completely user-friendly interface to make finding solution
𝑥1 , 𝑥2 ≥ 0 easier.
REFERENCES
[1]. https://www.imse.iastate.edu/files/2015/08/Explanation-
of-Simplex-Method.docx
[2]. J. Reeb., S. Leavengood., operations research, October
1998. Performance excellence in wood products
industry
[3]. S. Kalavathy., 2013. Operations research 4th Edition.
Vikas publishing house pvt.ltd.
[4]. https://maklaboratory.com/
Fig 6
System Requirements:
Any Windows system with Microsoft Excel can be used.
No particular
Requirement for hardware or RAM.
V. CONCULSION
AAM19MY09 www.ijisrt.com 42