




Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Prepara tus exámenes
Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Prepara tus exámenes con los documentos que comparten otros estudiantes como tú en Docsity
Encuentra los documentos específicos para los exámenes de tu universidad
Estudia con lecciones y exámenes resueltos basados en los programas académicos de las mejores universidades
Responde a preguntas de exámenes reales y pon a prueba tu preparación
Consigue puntos base para descargar
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Comunidad
Pide ayuda a la comunidad y resuelve tus dudas de estudio
Ebooks gratuitos
Descarga nuestras guías gratuitas sobre técnicas de estudio, métodos para controlar la ansiedad y consejos para la tesis preparadas por los tutores de Docsity
An introduction to linear programming (lp) by explaining its foundation in solving simultaneous linear equations. It covers the rules for handling equations and the strategy of tidying up the matrix associated with the system of equations. The document also includes examples and graphical representations to illustrate the concepts.
Tipo: Apuntes
1 / 8
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!





Linear Programming (LP) may look very sophisticated, but its basis is nothing else than the solution of simultaneous equations, something that is studied in secondary schools in most countries. This is why we will start by thinking about solutions of simultaneous linear equations. Consider an example that I have taken from Moreno et al (1992).
We have three equations with only two unknowns. We would like to have as many equations as unknowns because we are tidy-minded and this is what we learnt at school, but we go to university in order to complicate our lives. In LP we deal with systems of equations, but we do not have the same number of equations as unknowns. Anyhow, there is one equation too many. We do not want to suffer, and we will just get rid of one of them. Notice that this pragmatic approach of just ignoring what we do not like is what we do in LP all the time. Books use complex reasoning to explain this, but there are simple, more human ways, to explain it. I will just reduce the above problem to one I like better.
We will solve, for example, the system formed by equations E1 and E2. We now have two equations and two unknowns, there is no problem. It is something easy to deal with, perhaps too easy for a degree course in a prestigious university, but we are developing ideas that we will apply to systems with hundreds, perhaps thousands, of equations and we need to have very clear ideas. If we do not develop a systematic solution method our life will become quite messy.
An obvious way of proceeding is to write the system in matrix form, calculate the inverse of the matrix, and to use it to solve the problem. But calculating the inverse of a large matrix is no trivial matter. However, writing the system in matrix form will help us to feed it into a computer package, such as LINGO. LINGO will then solve it. Further down, I will suggest a method to solve this problem with LINGO. You will not find this approach anywhere, I have just invented it.
The system E1, E2 in matrix for reads
This was just deviation from our objective of developing a systematic methodology to solve systems of simultaneous equations. Again, I emphasise that this method is going to be an overkill with just two equations and two unknowns, but it has the advantage of being wonderful within an LP situation because we proceed in steps and we always benefit from the work that has already been done. We need to remember two simple rules
In summary, we can say the same thing in many different ways. As a Catalan poet put it: “there are many names for only one love” (Convenen molt noms a un sol amor, Salvador Espriu).
These two rules will be used “ad nauseam”, a Latin expression that means “until they make us sick”. In fact, we will not even say that we are using them. But we must not forget that in LP all we are doing is to solve systems of simultaneous equations. This is why I like to start by thinking carefully about solution of equations in a simple context. If we ever get confused, or we think that a particular step does not make sense, the best strategy is to go back to the system of simultaneous equations and all will become crystal clear. But we are professional people, and we need to appear to do very sophisticated things, so we will develop a mystical language that will put us in a par with the initiated, and we will talk about “Simplex algorithm”, “basic feasible solutions”, “pivots”, and other crap. This might be good to confuse others, but we must keep clear ideas and not get confused ourselves.
The LP story can also be told with the help of nice pictures, and this greatly clarifies the concepts. We will also do it. We will start by solving the E1 and E2 system of equations.
We proceed in a systematic way. We first think about the first column, and in the first column we think about x 1 .The coefficient x 1 in the first column is 5. We would like to
change it to 1. When we do it, we will think about the second column and we will change the coefficient of x 2 in the second row to 1. If we had a third column, we would look at the coefficient of x 3 in the third column, third row, and we would change it to 1. The strategy is to tidy up the matrix associated with the system of equations so that the main diagonal is made up of ones.
As just said, we look at the first column and we would like to see a 1 where we now see a 5. This is easy, just divide equation E1 by 5 to obtain equation E1(2). My notation indicates that we are still dealing with E1 but that it is now written in a different way. Since we have changed its appearance we will also change its name. We will call it “pivot”. A pivot is a hinge over which something turns. We will use the pivot as a hinge over which we will rotate the vectorial space.
We are still thinking in terms of the first column, and we have dealt with the coefficient of x (^) 1. The next part of our strategy is to make all other coefficients in this column equal to zero. Look at the second row, E2. I want the coefficient of x 1 in this row to be zero. This I achieve by replacing E2 with E2 – 3 E1(2). In this way I obtain:
The original system of equations E1, E2 has now become E1(2), E2(2). But we still have the same system of equations, the information it contains is the same. But something has changed: the coefficients in the first column form a unit vector.
Having tidied up the first column, we now concentrate on the second column. We start by changing the coefficient of x 2 in the second row to 1, and then we change the coefficients of x 2 in the other rows to zero. We see that the coefficient of x 2 in E2(2) is 34/5. To change it to 1 we multiply the second row by 5/34. Then, E2(2) becomes E (3). It will still be E2 but now it has new clothes.
added an extra column named “Basis”. At the momento this is not necessary, but will become important when we deal with LP. The final solution will be seen under the column named “solution”. Finally, I have added another column named “equation” where I write the manipulations that we have to do to move to the next step. I am the only person who does this, but I think it is better from a didactic point of view.
Basis X 1 X 2 Solution Equation
X 1 5 2 10 E
X 2 3 8 12 E
This is the table, or tableau, that will be used in LP, under the Simplex algorithm. There are other algorithms, such as Karmarkar´s internal point method, but Simplex provides, in my opinion, the clearest introduction to the subject.
Now that we know how it works, let us apply the method of pivotal reduction to a slightly more complicated system of equations:
Base X1 X2 X3 Solución
X1 5 -2 6 8 E
X2 1 2 -3 4 E
X3 2 3 -2 3 E
We have a solution with x 1 equal to 26/9, with x 2 equal to -19/9, and with x 3 equal to -16/9. There is no reason why the solution of a system of equations should not contain negative numbers, but in most life situations our equations will be related to a situation in which negative numbers do not make sense.
In general, the system of equations will be associated with constraints that have to be satisfied. There will also be an objective function. We will now go back to our system of equations with only x 1 and x (^) 2. Imagine that there is a function such as E4:
The system of equations becomes:
We are now in a condition to think in terms of LP. In general, in an LP problem the equations take the form of inequalities, so our LP problem might have been:
Normally the equations will be associated with a story, often not a very exciting story. In this case the story would be as follows: product 1 sells at 1€ per unit, and product 2 also sells at 1€ per unit. The manufacturing process uses three resources that exist in limited amounts. There are 10 units of the first resource, 12 units of the second resource, and 10 units of the third resource. To manufacture 1 unit of the first product we use 5 units of the first resource, 3 units of the second resource, and 4 units of the third resource. To manufacture one unit of the second product we use 2 units of the first resource, 8 units of the second resource, and 5 units of the third resource. The quantities to be produced are x 1 units of the first product and x 2 units of the second product. How much should we produce in order to maximise the value of sales?
Notice that the above story is a very naïve one. It could be that the price depends on the quantity produced. If this was the case we would be dealing with Quadratic Programming, a more advanced subject, and we leave it out for the moment.
While I was writing this, I thought of a method of solving a system of simultaneous equations using a package written for LP. I want to share this idea with you. Take the system of equations we have seen already:
I am going to add to each constraint a “slack variable” which could be positive or negative, so I will do a trick that is common in these circumstances, split it in two positive variables.
The P variables will be positive, and the N variables will also be positive. In this way we can have a positive value (P is not zero and N is zero), a negative value (P is zero and N is positive), or a zero value (both P and N are zero). For the system of equations to be solved, all P and N variables need to take the value zero. This suggests that I can have an objective function of the type:
Second corner. Moving towards the right we find the intersection between equation E and the non-negativity condition x2 = 0. There is a simple system of equations to be solved:
The solution is x 1 = 2, x 2 = 0. An the objective function takes the value:
There has been an improvement. If we sell two units of the first product and none of the second product, sales are worth 2€.
We continue moving in the same direction to find the intersection between E1 and E3.
Third corner. We need to solve the following system of equations:
The solution is x 1 = 30/17, x 2 = 10/17. The value of the objective is 40/17 = 2,35.
There has been an improvement.
Fourth corner. It is in the intersection between E2 and E3. We need to solve:
We find x 1 = 20/17 and x 2 = 18/17. The objective function takes the value 38/17= 2.23. There has been a worsening.
Fifth corner. It is the intersection between E2 and the vertical axis, with a solution x 1 = 0 and x 2 = 1,5. The objective function takes the value 1,5. There has been a further worsening.
The optimal solution, after all these calculations, turns out to be at the point x 1 = 30/ and x 2 = 10/17 with a value of 2,35.
We have solved the problem, but if every time that we try to solve a LP we need to identify all the corners in the convex hull it will be a never ending exercise. This is why we need the SIMPLEX algorithm.
I have used LINGO to solve the problem that I programmed as an LP. This was quite easy.
When I open LINGO I get a screen on which to write the model.
The syntax starts with the command MODEL: which is nothing than a wake up call.
I always add comments to remind myself of what I am doing. Comments start with an exclamation mark and, like any other command, ends with a semicolon. Comments appear in green.
I next write the objective function, which is of the MIN (minimise) type.
We have to be careful when writing the constraints. The product must always be made explicit. Products and divisions take priority over sums or subtractions, so there is no need for parenthesis. Remember to complete the instruction with a semicolon.
LINGO expects all the unknowns to take positive values, and we have to say that x1 x and x3 can be positive or negative. We do this with the @FREE (X1) type of command. There are three free variables, so there must be three commands, all of them ending in a semicolon.
We tell LINGO that this is it by entering the command END, without a semicolon.
Those of us who learned computer programming before computer packages existed recognise here a programming language that is not very different from FORTRAN.
When the model has been entered without errors, we hope, we are ready to run it. This can be done either using the solve option in the menu:
Or directly, using the symbol
When you run it, you get
We see that the objective function takes the value zero, which means that the equations hold in the form of equalities. This you can confirm by realising that P1, P2, P3, N1, N2, and N3 all take the value zero.
You also see that X1 takes the value 2.888889, X3 takes the value -2.111111, and X takes the value -1.777778. These are the same results that we obtained by hand, but this time it has been very fast to do.
This is a very simple model and it was easy to program (once you know how to). With larger problems we need to use matrix algebra, but this we leave for later.
The output also generates other information, but we will explore its meaning later on.