# How Much Math Do You Need To Be A Programmer Simplex Method – Algorithm of Solving Linear Programming Problems

You are searching about How Much Math Do You Need To Be A Programmer, today we will share with you article about How Much Math Do You Need To Be A Programmer was compiled and edited by our team from many sources on the internet. Hope this article on the topic How Much Math Do You Need To Be A Programmer is useful to you.

Muc lục nội dung

## Simplex Method – Algorithm of Solving Linear Programming Problems

The simplex method is used in linear programming to optimize an objective function subject to a series of linear constraints. If you ever need a tabular representation of data when writing articles for EzineArticles, consider using ASCII art tables inside the HTML Pre tag. I have used them to illustrate simplex algorithm iterations. They can be a source of inspiration for you.

Now let’s see how to solve a linear programming model:

```Maximize: Z = 1x1 + 2x2subject to:
3x1 + 4x2 ≤ 5
6x1 + 7x2 ≥ 8
x1 ≥ 0, x2 ≥ 0********* (1) *********```

This model will be converted to canonical form (all constraints are converted to equations). A constraint of the type “≤ 0” becomes an equation by adding a non-negative variable (slack variable) and a constraint of the type “≥ 0” becomes an equation by subtracting one (surplus variable).

```Maximize: Z = 1x1 + 2x2 + 0x3 + 0x4subject to:
3x1 + 4x2 + 1x3 + 0x4 = 5
6x1 + 7x2 + 0x3 + -1x4 = 8x1 ≥ 0, x2 ≥ 0, x3 ≥ 0, x4 ≥ 0**************** (2)***************```

Keep in mind that max-7, -3, 0, +4, +6 = 6 = –min+7, +3, 0, -4, -6. This is because max(Z(x)) = –min(-Z(x)). In other words, we get the max(Z(x)) calculating the min(-Z(x)) and changing the sign at the end of the algorithm.

The two-phase method for constructing the initial basis needed for the first iteration of the simplex algorithm requires adding an artificial variable for each constraint. In the end, they must all be equal to 0 for the next model to be equivalent to the previous model. This trick allows us to obtain the unit vectors of the vector space and start iterations for a minimal auxiliary model (minimizing the sum of artificial variables). The previous maximum model leads us to the following minimum model:

```Minimize: Z = -1x1 + -2x2 + 0x3 + 0x4 + 0x5 + 0x6subject to:
3x1 + 4x2 + 1x3 + 0x4 + 1x5 + 0x6 = 5
6x1 + 7x2 + 0x3 + -1x4 + 0x5 + 1x6 = 8x1 ≥ 0, x2 ≥ 0, x3 ≥ 0, x4 ≥ 0, x5 ≥ 0, x6 ≥ 0********************** (3) **********************```

As we mentioned, after the calculations, all the artificial variables (“x5”, “x6”) must be 0. Since the artificial variables also satisfy the non-negativity condition (“≥ 0”) we conclude that they are all equal to 0 if and only if their sum is the minimum value 0. Therefore, in the first phase we minimize the sum of artificial variables:

```Minimize: Z' = 0x1 + 0x2 + 0x3 + 0x4 + 1x5 + 1x6subject to:
3x1 + 4x2 + 1x3 + 0x4 + 1x5 + 0x6 = 5
6x1 + 7x2 + 0x3 + -1x4 + 0x5 + 1x6 = 8x1 ≥ 0, x2 ≥ 0, x3 ≥ 0, x4 ≥ 0, x5 ≥ 0, x6 ≥ 0********************** (4) **********************```

Now we start the first iteration of the simplex method.

```.----+----+----+----+---+----+---+---+---+----+---.
|CB *|B * |XB *|cj * 0 * 0 ** 0 * 0 * 1 * 1 * | * |
+----+----+----+----+---+----+---+---+---+----+---+
| ** | ** | ** | ** |a1 |a2↓ |a3 |a4 |a5 |a6 *|θi |
|1 * |a5 *|5 * | ** |3 *|4 * |1 *|0 *|1 *|0 * |5/4|
|1 * |a6← |8 * | ** |6 *|7 * |0 *|-1 |0 *|1 * |8/7|
+----+----+----+----+---+----+---+---+---+----+---+
|Z'1 = 13 **** |zj * 9 * 11 * 1 * -1* 1 * 1 * | * |
+--------------+----+---+----+---+---+---+----| * |
| ************ |Δj * 9 * 11 * 1 * -1* 0 * 0 * | * |
'--------------+----+---+----+---+---+---+----+---'******************** Tableau 1 ********************```

Caption:

```• cj: Objective function (Z') coefficients, j = 1...6• aj: Column vectors of the constraints, j = 1...6• B = a5, a6: Standard basis of R² vector space• XB = (5, 8): Column of the basic feasible solution(the elements of the solutionX = (x1, x2, x3, x4, x5, x6) = (0, 0, 0, 0, 5, 8)corresponding to vectors outside the basis B are all equal to 0)• CB: Coefficients of vectors from basis B of objective function (Z')• Z'1 = ((CB)^T)*(XB) = (1, 1) * ((5, 8)^T)
Z'1 = 1 * 5 + 1 * 8 = 13
(CB)^T: Transpose of column vector CB• zj = ((CB)^T)*(aj), j = 1...6• Δj = zj - cj, j = 1...6
Since not all Δj: 9, 11, 1, -1, 0, 0 elements are ≤ 0,
we have not yet achieved the minimum of the objective function Z'.
Δ2 = 11 = max9, 11, 1, -1, 0, 0
Δ2 ⇒ a2↓• θi = XBi / a2↓i, i ∈ 5, 6  and a2↓i > 0
θi = --, if a2↓i ≤ 0
θ6 = 8/7 = min5/4, 8/7
θ6 ⇒ a6←```

The new vector “a2↓” replaces in base B the old vector “a6←” that leaves base B. The box element where the input vector (“a2↓”) and the vector of output(“a6←”) is known as a pivot element ( 7 ). We need to split all elements of the pivot row 8, 6, 70, -1, 0, 1 by the pivot element to get a +1 at the position of the pivot element 8/7, 6/7, +1, 0, -1/7, 0, 1/7. The remaining elements of the pivot column are converted to zeros.

Now we need to remove all the coefficients from the pivot column except the pivot element. This is done using simple Gaussian operations. To remove the pivot column element in some row “k”, for example, we proceed as follows:

• (new row “k”) = (row “k”) – (pivot column coefficient in row “k”) * (pivot row)

• (3/7, -3/7, 0, 1, 4/7, 1, -4/7) = (5, 3, 4, 1, 0, 1, 0) – 4 * (8/7, 6/7, 1, 0, -1/7, 0, 1/7)

The second iteration begins.

```.----+----+----+----+------+---+----+------+---+------+---.
|CB *|B * |XB *|cj * 0 **** 0 * 0 ** 0 **** 1 * 1 *** | * |
+----+----+----+----+------+---+----+------+---+------+---+
| ** | ** | ** | ** |a1 ** |a2 |a3↓ |a4 ** |a5 |a6 ** |θi |
|1 * |a5← |3/7 | ** |-3/7 *|0 *|1 * |4/7 * |1 *|-4/7 *|3/7|
|0 * |a2 *|8/7 | ** |6/7 * |1 *|0 * |-1/7 *|0 *|1/7 * |-- |
+----+----+----+----+------+---+----+------+---+------+---+
|Z'2 = 3/7 *** |zj * -3/7 * 0 * 1 ** 4/7 ** 1 * -4/7 *| * |
+--------------+----+------+---+----+------+---+------| * |
| ************ |Δj * -3/7 * 0 * 1 ** 4/7 ** 0 * -11/7 | * |
'--------------+----+------+---+----+------+---+------+---'*********************** Tableau 2 ************************```

Since not all elements Δj: -3/7, 0, 1, 4/7, 0, -11/7 are ≤ 0, we have not yet reached the minimum of the objective function Z’.

```.----+----+----+----+------+---+---+------+----+------+---.
|CB *|B * |XB *|cj * 0 **** 0 * 0 * 0 **** 1 ** 1 *** | * |
+----+----+----+----+------+---+---+------+----+------+---+
| ** | ** | ** | ** |a1 ** |a2 |a3 |a4 ** |a5 *|a6 ** |θi |
|0 * |a3 *|3/7 | ** |-3/7 *|0 *|1 *|4/7 * |1 * |-4/7 *| * |
|0 * |a2 *|8/7 | ** |6/7 * |1 *|0 *|-1/7 *|0 * |1/7 * | * |
+----+----+----+----+------+---+---+------+----+------+---+
|Z'3 = 0 ***** |zj * 0 **** 0 * 0 * 0 **** 0 ** 0 *** | * |
+--------------+----+------+---+---+------+----+------| * |
| ************ |Δj * 0 **** 0 * 0 * 0 **** -1 * -1 ** | * |
'--------------+----+------+---+---+------+----+------+---'************************ Tableau 3 ************************```

Since all elements Δj: 0, 0, 0, 0, -1, -1 are ≤ 0, the minimum of the objective function Z’ has been reached. In the last table it turns out that the minimum sum of artificial variables is Z’3 = 0. Therefore, the minimum model below has solutions.

```Minimize: Z = -1x1 + -2x2 + 0x3 + 0x4subject to:
3x1 + 4x2 + 1x3 + 0x4 = 5
6x1 + 7x2 + 0x3 + -1x4 = 8x1 ≥ 0, x2 ≥ 0, x3 ≥ 0, x4 ≥ 0***************** (5)****************```

It is useful to reuse data. In the second phase, we will complete the following table with data from columns “aj”, “XB”, “B” from the previous table and with the coefficients of the new objective function “Z” from the previous model. We will rebuild the other calculations and then resume the iterations:

```.----+----+----+----+-------+----+---+------+----.
|CB *|B * |XB *|cj * -1 **** -2 * 0 * 0 *** | ** |
+----+----+----+----+-------+----+---+------+----+
| ** | ** | ** | ** |a1 *** |a2 *|a3 |a4↓ * |θi *|
|0 * |a3← |3/7 | ** |-3/7 * |0 * |1 *|4/7 * |3/4 |
|-2 *|a2 *|8/7 | ** |6/7 ** |1 * |0 *|-1/7 *| -- |
+----+----+----+----+-------+----+---+------+----+
|Z1 = -16/7 ** |zj * -12/7 * -2 * 0 * 2/7 * | ** |
+--------------+----+-------+----+---+------| ** |
| ************ |Δj * -5/7 ** 0 ** 0 * 2/7 * | ** |
.--------------+----+-------+----+---+------+----.******************** Tableau 4 ******************```

Since not all elements Δj: -5/7, 0, 0, 2/7 are ≤ 0, we have not yet reached the minimum of the objective function Z.

```.----+----+----+----+------+----+------+----+---.
|CB *|B * |XB *|cj * -1 ** -2 ** 0 **** 0 * | * |
+----+----+----+----+------+----+------+----+---+
| ** | ** | ** | ** |a1 ** |a2 *|a3 ** |a4 *|θi |
|0 * |a4 *|3/4 | ** |-3/4 *|0 * |7/4 * |1 * | * |
|-2 *|a2 *|5/4 | ** |3/4 * |1 * |1/4 * |0 * | * |
+----+----+----+----+------+----+------+----+---+
|Z2 = -5/2 *** |zj * -3/2 * -2 * -1/2 * 0 * | * |
+--------------+----+------+----+------+----| * |
| ************ |Δj * -1/2 * 0 ** -1/2 * 0 * | * |
.--------------+----+------+----+------+----+---.******************* Tableau 5 *******************```

Since all elements Δj: -1/2, 0, -1/2, 0 are ≤ 0, the minimum (Z2 = -5/2) of the objective function Z has been reached. Therefore, the maximum of the initial model (1) is Z = -Z2 = -(0 * 3/4 ​​+ (-2) * 5/4) = 5/2. The optimal solution is (x1, x2) = (0, 5/4).

## Question about How Much Math Do You Need To Be A Programmer

If you have any questions about How Much Math Do You Need To Be A Programmer, please let us know, all your questions or suggestions will help us improve in the following articles!

The article How Much Math Do You Need To Be A Programmer was compiled by me and my team from many sources. If you find the article How Much Math Do You Need To Be A Programmer helpful to you, please support the team Like or Share!

Rate: 4-5 stars
Ratings: 5581
Views: 61611429

## Search keywords How Much Math Do You Need To Be A Programmer

How Much Math Do You Need To Be A Programmer
way How Much Math Do You Need To Be A Programmer
tutorial How Much Math Do You Need To Be A Programmer
How Much Math Do You Need To Be A Programmer free
#Simplex #Method #Algorithm #Solving #Linear #Programming #Problems

Source: https://ezinearticles.com/?Simplex-Method—Algorithm-of-Solving-Linear-Programming-Problems&id=6231290

## How Many Questions Does The Math 3 Final Exam Have How to Cure Test Anxiety – 3 Habits You Must Break to Cure Exam Panic!

You are searching about How Many Questions Does The Math 3 Final Exam Have, today we will share with you article about How Many Questions Does The…

## How Many School Allow Students Use Calculators In Math Class http://webcache.googleusercontent.com/search?q=cache:https%3A%2F%2Fezinearticles.com%2F%3FReport-Card-Comments%26id%3D3524667

You are searching about How Many School Allow Students Use Calculators In Math Class, today we will share with you article about How Many School Allow Students…

## How To Ask Students To Draw A Picture For Math Three Ways to Improve Learning Readiness Through Play

You are searching about How To Ask Students To Draw A Picture For Math, today we will share with you article about How To Ask Students To…

## How Much You Charge For Taking An Online Math Class Making Money Online – The New Way to Get Rich Quick

You are searching about How Much You Charge For Taking An Online Math Class, today we will share with you article about How Much You Charge For…

## How Many Hours Do You Get In A Crative Math Turning a Band Into Songwriters – 10 Songs In One Hour

You are searching about How Many Hours Do You Get In A Crative Math, today we will share with you article about How Many Hours Do You…

## How To Get A Better Math Score On The Act 7 Trouble-Free Tips About How To Study For The ACT

You are searching about How To Get A Better Math Score On The Act, today we will share with you article about How To Get A Better…