Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor...

66
1/100 Universidad Politécnica de Madrid–Escuela Técnica Superior de Ingenieros Industriales Grado en Ingeniería en Tecnologías Industriales-3º Matemáticas de Especialidad–Ingeniería Eléctrica Programación Entera José Luis de la Fuente O’Connor [email protected] [email protected] Clase_Entera.pdf

Transcript of Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor...

Page 1: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

1/100Universidad Politécnica de Madrid–Escuela Técnica Superior de Ingenieros IndustrialesGrado en Ingeniería en Tecnologías Industriales-3º

Matemáticas de Especialidad–Ingeniería Eléctrica

Programación Entera

José Luis de la Fuente O’[email protected]@upm.es

Clase_Entera.pdf

Page 2: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

2/100

Índice

� Introducción, formulación y ejemplos

� Resolución gráfica del problema

� Relajaciones en la formulación

� El algoritmo de los cortes de Gomory

� Algoritmos Branch and Bound

� Programación no lineal en variables enteras

Page 3: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

3/100Introducción� La programación entera se ocupa de los problemas de optimizar una función dediversas variables sujeta a condiciones de igualdad y/o desigualdad,restringiéndose todas o alguna de esas variables a tomar valores enteros.

� Sus orígenes se remontan a los años 50 del siglo XX. El pionero fue RalphGomory, EE.UU. 1929.

� Las áreas de aplicación práctica son muchas donde hay que asignar recursos sólodisponibles en cantidades discretas: distribución de mercancías, programación dela producción en factorías, secuenciación de maquinaria en procesos industrialesy productivos, asignación de grupos generadores de energía eléctrica, cadenas desuministro, logística, programación de rutas de vuelos, etc.

Page 4: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

4/100

� La formulación general del problema lineal de Programación Entera es

maximizarx2Zn y2Rp

cT x C hT y

sujeta a Ax CGy � b

x; y � 0:

Este problema es un programa entero mixto.

� Al conjunto S D fx 2 Zn; y 2 Rp W Ax CGy � b; x � 0; y � 0g se ledenomina región factible.

� Un punto ŒxT ; yT �T 2 S se denomina factible. Al punto Œx�T ; y�T �T 2 S , talque

cT x� C bT y� � cT x C hT y; para todo ŒxT ; yT �T 2 S;

se le denomina solución óptima del problema.

Page 5: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

5/100� Al problema en el que todas las variable son enteras,

max.x2Zn

cT x

s. a Ax � b

x � 0;

se le conoce como programa entero puro, programa lineal en variables enteras o,simplemente, programa entero. Un caso particular de programa entero es aquelen el que las variables sólo pueden tomar valores 0 ó 1.

� En programación entera no existe un método universal, como el simplex deprogramación lineal, que obtiene la solución sirviéndose de las propiedades deconvexidad del problema a resolver.

� Esto es así porque en programación entera la convexidad desaparece, nopudiéndose utilizar por tanto la noción de gradiente para caracterizar y buscar elóptimo de un problema, haciéndose necesario emplear métodos de resoluciónespecíficos del aspecto combinatorio de las variables enteras.

Page 6: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

6/100

� Es más, los programas enteros, como muestran los dos primeros ejemplos de lafigura, si se quiere minimizar �y, no tienen por qué tener el óptimo cerca delóptimo del programa con variables continuas, ni siquiera el óptimo es un enteropróximo a ese óptimo continuo (la segunda figura).8.10. OPTIMISATION WITH INTEGER CONSTRAINTS 405

Figure 8.55: A linear programmingproblem where we restrict our atten-tion to integer values of the decisionvector x meaning that the allowablevalues of x fall on a regular grid.Here the optimum of the linear pro-gram and the optimum of the integerlinear program are not the same.

and worth to place in our small suitcase to maximise value, (the ’knapsack’ problem), andwhether we should or should not install a new pump between two storage tanks, (you can’tinstall half a pump!).

In all these cases, the decision variable must be an integer, since we cannot stop 1.3 times orbuild 2.7 distillation columns, or in the latter existence/non-existence example, the variablewill be a binary decision variable. Constrained optimisation problems where the decisionvariables are integers are known as integer programming, or a binary linear program if thevariables are constrained to be either zero or one, or finally if only some are required to beintegers, then it is known as a mixed-integer linear programming or MILP problem.

Surprisingly binary or integer programming problems are much harder to solve than opti-misation problems with real number solutions. The reason for this is that being discrete, wecannot use gradients or search directions, and therefore the number of possible solutionsgrows combinatorially. Explicit enumeration therefore is quickly out of the question. Onemay be tempted in this instance to simply first solve the LP problem in the normal man-ner, and then subsequently round this optimum result to the nearest integers. However, asillustrated in Fig. 8.56 that solution may not be reasonable, or even feasible.

Figure 8.56: Note that integer opti-mum is not simply the truncated orrounded version of the real-valuedoptimum, but could in fact be ‘arbi-trarily’ far away.

There can be other complications as well. Consider the example shown in Fig. 8.57 whichshows a perfectly valid linear optimisation problem with a convex feasible region. Clearlysomewhere in that region there will be an optimum, irrespective of what our particularobjective function happens to be. However when we restrict our attention to just integer

8.10. OPTIMISATION WITH INTEGER CONSTRAINTS 405

Figure 8.55: A linear programmingproblem where we restrict our atten-tion to integer values of the decisionvector x meaning that the allowablevalues of x fall on a regular grid.Here the optimum of the linear pro-gram and the optimum of the integerlinear program are not the same.

and worth to place in our small suitcase to maximise value, (the ’knapsack’ problem), andwhether we should or should not install a new pump between two storage tanks, (you can’tinstall half a pump!).

In all these cases, the decision variable must be an integer, since we cannot stop 1.3 times orbuild 2.7 distillation columns, or in the latter existence/non-existence example, the variablewill be a binary decision variable. Constrained optimisation problems where the decisionvariables are integers are known as integer programming, or a binary linear program if thevariables are constrained to be either zero or one, or finally if only some are required to beintegers, then it is known as a mixed-integer linear programming or MILP problem.

Surprisingly binary or integer programming problems are much harder to solve than opti-misation problems with real number solutions. The reason for this is that being discrete, wecannot use gradients or search directions, and therefore the number of possible solutionsgrows combinatorially. Explicit enumeration therefore is quickly out of the question. Onemay be tempted in this instance to simply first solve the LP problem in the normal man-ner, and then subsequently round this optimum result to the nearest integers. However, asillustrated in Fig. 8.56 that solution may not be reasonable, or even feasible.

Figure 8.56: Note that integer opti-mum is not simply the truncated orrounded version of the real-valuedoptimum, but could in fact be ‘arbi-trarily’ far away.

There can be other complications as well. Consider the example shown in Fig. 8.57 whichshows a perfectly valid linear optimisation problem with a convex feasible region. Clearlysomewhere in that region there will be an optimum, irrespective of what our particularobjective function happens to be. However when we restrict our attention to just integer

406 CHAPTER 8. OPTIMISATION

decision variables, (circles in Fig. 8.57), we see in fact there is no feasible region at all,despite the fact that the relaxed linear problem did have a non-zero feasible region.

Figure 8.57: Depending on the spac-ing, a perfectly well-formed linear pro-gram may not have a feasible integersolution at all. Note in this example,there are no integers, ◦, inside the fea-sible region.

To solve integer linear programming problems we could do an exhaustive search over allthe feasible integers. For large problems, this is combinatorially large, so a better solutionstrategy, in fact one of the only known practical solution strategies, is to use what is knownas a branch and bound technique, [45, p411–415]. Here we start by solving a relaxed ver-sion of the original problem, namely we simply ignore the integer constraints, and solvethe linear program as usual. The term ‘relaxed’ means that we have deliberately relaxedsome of the constraints in order to achieve a solution, albeit perhaps an infeasible one. Ifwe happen fortuitously to stumble across an integer solution, we are done. However inmost cases, we will not get an integer solution, but we do have an under-estimator of theminimum cost function. In the case of Fig. 8.56, we can see that the real-valued optimumis about x = 3.5, y = 5.8. In this case we can take one of the non-integer variables, say xand resolve the linear program twice, but this time with an additional constraint, the firstre-solution adds the bound x > 4, and the second adds x < 3.

This continual spawning of optimisation problems is known as branching and would soonoverwhelm us if we were not to somehow do some pruning. Obviously if any of the newsolutions are integer, we can terminate that particular branch (or prune), or if the objectivefunction is worse than an integer solution already established, then we can also termi-nate that branch as well. This strategy continues until we have fathomed all the possiblebranches. Note however, that we have not necessarily solved an LP at every possible com-bination; that is something we are trying hard to avoid.

Problem 8.3 An integer LP exampleIf we minimise J (x) = −53x1 − 94x2

subject to:

−x1 + 5x2 ≤ 99

5x1 + 8x2 ≤ 210

4x1 − x2 ≤ 21

−5x1 + x2 ≤ −10

and the non-negative requirement, x ≥ 0, then the (real-valued) optimum point is,

x⋆ ≈[

7.6774 21.4516]T, with a cost of J = −2423, x ∈ ℜ

as shown by a ⋆ in Fig. 8.58. However if we impose the requirement that the decision vectormust be all integers, x ∈ I , then the optimum shifts to

x⋆ =[

10 20]T, with a cost of J = −2410, x ∈ I

� También puede que la región factible no registre ni un sólo entero factible,existiendo dicho espacio en el sentido tradicional.

Page 7: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

7/100

Ejemplos

Gestión de un servicio hospitalario

� En un determinado servicio de asistencia hospitalaria hay i enfermos a la esperade una operación. Cada enfermo necesita una operación de duración Di .

� Dada una disponibilidad de cirujanos, la suma de las duraciones de lasoperaciones que pueden hacerse cada día j del período de estudio es igual a Tj .

� Se trata de minimizar una función económica que refleja la suma de laspenalizaciones por esperas de los diferentes enfermos (esta penalización es unafunción lineal creciente de la espera).

Page 8: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

8/100

� El problema se formula de la siguiente manera:

max.X

i

Xj

cij xij

s. aX

i

Dixij � Tj para todo jXj

xij D 1 para todo i

xij D 0 ó 1 para todo i y j .

La variable de decisión xij es 1 si el enfermo i se le opera el día j y 0 en elcaso contrario.

Page 9: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

9/100

El problema de la mochila

� Este problema es el más clásico de la programación entera.

� Trata de un transportista que dispone de un vehículo con capacidad volumétricade transporte b, en el que se pueden alojar diferentes objetos j de volúmenesaj y valores económicos cj , y que quiere maximizar el valor de lo transportadoen cada viaje.

� Su formulación es:max.

Xj

cj xj

s. aX

j

aj xj � b

xj D 0 ó 1:

Page 10: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

10/100Resolución gráfica del problema

� Recordemos de programación lineal que las condiciones de

maximizarx2Zn y2Rp

cT x C hT y

sujeta a Ax CGy � b

x; y � 0

en el caso en que x 2 Rn y y 2 Rp, definen un politopo (poliedro si esacotado) en uno de cuyos puntos extremos la función objetivo cT x C hT y

alcanza el máximo.En general, desafortunadamente, las variables xj es ese punto extremo notienen por qué ser enteras.

� El politopo contiene todas las soluciones en las que x es entero. Gráficamentese puede determinar la solución mediante el punto extremo óptimo considerandolas variables como continuas y luego, desplazando cT x C hT y hacia dentro delpolitopo, encontrando el primer punto ŒxT ; yT �T en el que x sea entero.

Page 11: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

11/100

Ejemplo Consideremos el problema de programación entera

max. 32x1C x2

s. a �x1C 4x2 � 16

x1C x2 � 10

5x1C x2 � 36

x1; x2 � 0

x1 y x2 enteras.D

f.O.

C

B

A

0 x 1

x 2

x ∗

5x 1 + x 2 ≤ 36

−x 1 + 4x 2 ≤ 16

x 1 + x 2 ≤ 10

� Sin tener en cuenta la condición de que las variables han de ser enteras, laregión factible es el poliedro convexo que generan los vértices 0; A; B; C y D

de la figura.

� El valor máximo de la función objetivo en este poliedro se alcanza en C .Como la auténtica región factible la constituyen los puntos interiores enteros deese poliedro, el máximo del problema se alcanza en el punto x� D Œ6; 4�T . u

Page 12: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

12/100

Índice

� Introducción, formulación y ejemplos

� Resolución gráfica del problema

� Relajaciones en la formulación

� El algoritmo de los cortes de Gomory

� Algoritmos Branch and Bound

� Programación no lineal en variables enteras

Page 13: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

13/100

Relajaciones en la formulación

� La idea es tratar de sustituir el programa entero original por otro más fácil deresolver en el que se relajan algunas de las condiciones.La solución de éste proporciona una cota de la función objetivo del problemaoriginal.

� Mediante un proceso iterativo que integre estas relajaciones y la resolución delos subproblemas se puede acotar cada vez más la función objetivo hastaobtener la solución final.

Page 14: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

14/100

� Una relajación del programa entero

.PE/ max.˚cT x W x 2 S

la constituye cualquier subproblema de la forma

.PR/ max. fzPR.x/ W x 2 SPRg

con las propiedades siguientes:

SPR � S y cT x � zPR.x/ para x 2 S:

Proposición Si el problema (PR) no es factible, tampoco lo es (PE). Si (PR) esfactible, los valores de las funciones objetivo cumplen que zPE � zPR.

Page 15: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

15/100

Relajación lineal

� La relajación más inmediata resulta de omitir la condición de que las variableshan de ser enteras.

� Si el conjunto o región factible del programa entero es S D P \ Zn, larelajación lineal es

.PL/ max.˚cT x W x 2 P

; P D fx 2 Rn

W Ax � b; x � 0g

Proposición Si (PL) es no acotado, el programa entero (PE) es no factible o noacotado.

Page 16: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

16/100

Algoritmo tipo

Paso 0 – Inicialización Hacer i D 1, w� D 1 y z� D �1. Escoger un S.1/R � S tal que

z.1/R � cT x para x 2 S .

Paso 1 – Relajación Resolver el problema PE relajado:�R.i/

�max.

nz

.i/R .x/ W x 2 S

.i/R

o:

Paso 2 – Comprobación de óptimo Sea x.i/ la solución del problema anterior. Si x.i/ 2 S :PARAR; ésta es la solución óptima de .PE/ con función objetivo w� D cT x.i/ D

z�; si no, seguir.Paso 3 – Mejora de la solución Hacer w� D z

.i/R , z� D cT x.i/ si x.i/ 2 S y i i C 1.

Escoger S.iC1/R tal que S � S

.iC1/R � S

.i/R y z

.iC1/R .x/ tal que cT x � z

.iC1/R .x/ �

z.i/R .x/ para x 2 S con S

.iC1/R ¤ S

.i/R o z

.iC1/R .x/ ¤ z

.i/R .x/.

Ir al paso 1

Page 17: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

17/100

Índice

� Introducción, formulación y ejemplos

� Resolución gráfica del problema

� Relajaciones en la formulación

� El algoritmo de los cortes de Gomory

� Algoritmos Branch and Bound

� Programación no lineal en variables enteras

Page 18: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

18/100Algoritmo de planos o cortes de Gomory

� Este algoritmo, formulado por Gomory en 1960, es uno de los primeros que seemplearon para resolver el problema general de programación entera.

� Consideraremos que el problema que resuelve –notación original– es

max.˚cT x W x 2 S .e/

; donde S .e/

D fx 2 ZnW Ax D b; x � 0g;

y está escrito de la siguiente forma:

.PE/ max.nx0 W

�x0; xT

�T2 S .0/

o;

donde

S .0/D˚x0 2 Z; x 2 Zn

W x0 � cT x D 0; Ax D b; x � 0

:

� Supondremos que se dispone de una solución y base óptimas de la relajaciónlineal del programa entero.

Page 19: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

19/100

� El problema se puede escribir así:

maximizar x0

s. a xBiC

Xj2H

Naij xj D Nai0 para i D 0; 1; : : : ; m

xB02 Z; xBi

2 ZC; para i D 1; : : : ; m

xj 2 ZC para j 2 H;

(1)

x0 D xB0, xBi

; i D 1; : : : ; m, son las variables básicas y xj , j 2 H � N D f1; : : : ; ng, lasno básicas (xB D B�1b �B�1NxN y z D cBB�1bC .cN � cBB�1N /xN .).

� Como esta base es factible en el programa primal y dual se cumple que Nai0 � 0

para i D 1; : : : ; m, y que Na0j � 0, para j 2 H .

� Suponiendo existe un i tal que Nai0 … Z, se tiene el siguiente resultado.

Proposición Corte Fraccionario de Gomory Si Nai0 … Z,P

j2H fij xj D fi0C xnC1; xnC1 2 ZC,es una desigualdad válida en S .0/, donde fij D Naij � bNaij c para j 2 H y fi0 D Nai0 � bNai0c.

Page 20: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

20/100

� Ejemplo Considérese el programa entero

.PE/ maximizar 7x1 C 2x2

s. a �x1 C 2x2 � 4

5x1 C x2 � 20

�2x1 � 2x2 � �7

x 2 Z2C

:

� Introduzcamos las variables de holgura x3, x4 y x5. El programa1 queda:

maximizar 7x1 C 2x2

s. a �x1 C 2x2 C x3 D 4

5x1 C x2 C x4 D 20

�2x1 � 2x2 C x5 D�7

x1; x2 2 ZCI x3; x4; x5 � 0:

1Aunque las variables de holgura serán enteras, no hay ninguna necesidad de restringirlas a tomar valoresenteros.

Page 21: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

21/100

� Restringiendo las variables x3, x4 y x5 a tomar valores enteros el problema es:

maximizar x0

s. a x0 � 7x1 � 2x2 D 0

� x1 C 2x2 C x3 D 4

5x1 C x2 C x4 D 20

� 2x1 � 2x2 C x5 D �7

x0 2 Z; xj 2 ZC para j D 1; : : : ; 5:

� La solución de la relajación lineal de este programa entero es

x0 C311

x3 C1611

x4 D33211

x1 �111

x3 C211

x4 D3611

x2 C511

x3 C111

x4 D4011

811

x3 C611

x4 C x5 D7511

:

El corte de Gomory que se puede obtener de la primera ecuación

3

11x3 C

5

11x4 D

2

11C x6; x6 2 ZC:

Page 22: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

22/100Paso 0 – Inicialización Hacer

S.1/R D

˚x0 2 R; x 2 Rn

W x0 � cT x D 0; Ax D b; x � 0

;

i D 1 y z.1/R D x0.

Paso 1 – Resolución de la relajación lineal Resolver el programa entero relajado

.PR.i// max.nx0 W Œx0; xT �T 2 S

.i/R

o:

Si PR.i/ es factible y tiene solución óptima, Œx.i/0 ;

�x.i/

�T�T , continuar.

Paso 2 – Comprobación de óptimo Si x.i/ 2 ZnC, ésta es la solución óptima del programa entero.

Paso 3 – Comprobación de no factibilidad Si PR.i/ no es factible, el programa entero original no es factible.Paso 4 – Adición de un corte de Gomory Escoger una fila xBi

CP

j2H .i/ Na.i/ij xj D Na

.i/i0 con Na.i/

i0 … Z. Hacer

Xj2H .i/

fkj xj � xnCi D fk0; k D 1; : : : ; m; xnCi 2 ZC;

el corte de Gomory de esa fila. Hacer

S.iC1/R D S

.i/R \

8<:x0 2 R; x 2 RnCiW

Xj2H .i/

fkj xj � xnCi D fk0; x � 0

9=; :

Hacer i i C 1 e ir al paso 1.

Algoritmo de los planos o cortes de Gomory

Page 23: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

23/100

� Cuando se añade un corte, la nueva base, que incluye xnCi como variablebásica, es factible del dual.

� La factibilidad del primal se incumple sólo en que xnCi es negativa.

� Para reoptimizar el problema lo más adecuado es usar el método dual delsimplex.

� Si PR.i/ es no acotado, el programa entero, PE, es no acotado o no factible.

Page 24: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

24/100� Ejemplo, continuación. La última solución de PR.1/ a la que hacíamosreferencia era

x0 C311

x3 C1611

x4 D33211

x1 �111

x3 C211

x4 D3611

x2 C511

x3 C111

x4 D4011

811

x3 C611

x4 C x5 D7511

;

donde x3 D x4 D 0.Es decir

hx

.1/0 ;

�x.1/

�T iD Œx

.1/0 ; x

.1/1 ; : : : ; x

.1/5 � D

�33211

; 3611

; 4011

; 0; 0; 7511

�.

� El corte de Gomory respecto de la tercera ecuación es 511

x3 C111

x4 D711C x6,

x6 2 ZC. Añadiéndolo a PR.1/ se obtiene PR.2/ cuya solución es

x0 C75x4 C

35x6 D

1495

x1 C15x4 �

15x6 D

175

x2 C x6 D 325x4 C x5 C

85x6 D

295

x3 C15x4 �

115

x6 D75

:

Page 25: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

25/100

� El corte de Gomory correspondiente a la primera de estas ecuaciones es25x4C

35x6 D

45C x7, x7 2 ZC. Añadiéndolo a PR.2/ se obtiene PR.3/, de solución:

x0 C x4 C x7 D 29

x1 C13x4 �

13x7 D

113

x2 �23x4 C

53x7 D

53

53x4 C x5 �

113

x7 D133

x3 �23x4 C

83x7 D

113

23x4 C x6 �

53x7 D

43

:

� El siguiente corte se elige de la fila x2 �23x4 C

53x7 D

53. Es2

1

3x4 C

2

3x7 D

2

3C x8; x8 2 ZC:

� La solución óptima de PR.4/ –también del problema original–, eshx

.4/0 ; x

.4/1 ; : : : ; x

.4/6 ; x

.4/7 ; x

.4/8

iD Œ28; 4; 0; 8; 0; 1; 3; 1; 0�:

2Recordemos��

23

˘D �

23� .�3

3/ D 1

3.

Page 26: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

26/100

� En términos de las variables originales, los tres cortes añadidos al problema sonx2 � 3, 2x1 C x2 � 9 y 3x1 C x2 � 12.

x 1

x 2

x(1)

x(2)

Corte 1

x(3)

Corte 2Corte 3

x(4)

1 2 3 4

1

2

3

Page 27: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

27/100

Índice

� Introducción, formulación y ejemplos

� Resolución gráfica del problema

� Relajaciones en la formulación

� El algoritmo de los cortes de Gomory

� Algoritmos Branch and Bound

� Programación no lineal en variables enteras

Page 28: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

28/100

Algoritmos de ramificación y acotamientoo Branch and Bound

� La idea que los anima es dividir la región factible, S , como si las variables que ladefinen fuesen las ramas de un árbol e ir acotando la solución del estudio deesas ramas.

� El conjunto fS .i/ W i D 1; : : : ; kg se denomina división de la región factible, S ,de un programa entero, si [k

iD1S.i/ D S .

� Una división se denomina partición si S .i/ \ S .j / D ; para i; j D 1; : : : ; k,i ¤ j .

Page 29: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

29/100

� La división se suele hacer de forma recursiva así:S = S(0)

S(2)S(1)

S(21)S(22)

S(13)S(12)S(11)

S(121) S(122)

Page 30: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

30/100

� Cuando S � Zn y las variables han de ser 0 ó 1, la forma más simple de hacerla división recursiva apuntada es la indicada en la figura.

S

S(1)S(0)

S(11)S(10)S(01)S(00)

S(000) S(001) S(010) S(011) S(100) S(101) S(110) S(111)

x 1 = 1x 1 = 0

x 2 = 1x 2 = 0x 2 = 1x 2 = 0

x3 = 1x3 = 0x3 = 1x3 = 0x3 = 1x3 = 0x3 = 1x3 = 0

Page 31: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

31/100� En la práctica estos métodos necesitan algún procedimiento para eliminar ramasdel árbol de búsqueda que se forma –podarlo–.

Proposición El árbol de búsqueda se puede podar a partir del nudo correspondientea S .i/ si se cumplen cualquiera de las siguientes condiciones:

1. No factibilidad: S .i/ D ;.

2. Optimalidad: se ha llegado al óptimo de PE.i/.

3. Existencia de un valor dominante z.i/PE � zPE .

� Para no tener que resolver PE.i/ se resuelve su relajación lineal; esto es PL.i/

con S .i/ � S.i/PL y z

.i/PL.x/ � cT x para x 2 S .i/.

Proposición El árbol de búsqueda puede podarse a partir del nudo correspondiente aS .i/ si se cumple cualquiera de las condiciones siguientes:

1. El programa PL.i/ no es factible.

2. El óptimo x.i/PL de PL.i/ cumple que x

.i/PL 2 S .i/ y que z

.i/PL D cT x

.i/PL.

3. z.i/PL � zPE , donde zPE es alguna solución factible de PE.

Page 32: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

32/100� Ejemplo Considérese el programa entero

.ZPE/ maximizar �100x1 C 72x2 C 36x3

s. a �2x1 C x2 � 0

�4x1 C x3 � 0

x1 C x2 C x3 � 0

x 2 Z3.0; 1/:

S

S(1)S(0)

S(11)S(10)

S(111)S(110)

x 1 = 1x 1 = 0

x 2 = 1x 2 = 0

x 3 = 1x 3 = 0

La división de este ejemplo y su árbol de búsqueda son los de la figura.

� La solución de la relajación lineal es Œ1=2; 1; 1�T ; la f.o. 58.

� Usando la última proposición para podar el árbol de búsqueda,

S .0/D fx � 0 W x1 D 0; x2 � 0; x3 � 0; x2 C x3 � 1g D ;;

por lo que el nudo S .0/ se desecha.

Page 33: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

33/100

� La condición de óptimo de los nudos S .110/ y S .111/ se cumple pues estosconjuntos contienen las soluciones Œ1; 1; 0�T y Œ1; 1; 1�T , respectivamente.

� Como, z.110/PE < z

.111/PE D 8, se tendrá que zPE D z

.111/PE D 8.

� Aplicando la tercera condición de la mencionada proposición al nudo S .10/ se veque z

.10/PL D �64 < zPE, por lo que se desecha.

� Como resultado final se obtiene que x D Œ1; 1; 1�T es la solución óptima delprograma entero.

� El valor de su función objetivo es ZPE D 8. u

Page 34: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

34/100

Paso 0 – Inicialización Hacer L D fPEg, S .0/ D S , z.0/D1 y zPE D �1.

Paso 1 – Comprobación de final Si L D ;, la solución x que daba la función objetivo zPE D cT x es laóptima.

Paso 2 – Selección de problema, relajación lineal y resolución Seleccionar y borrar de L un problema PE.i/.Resolver su relajación lineal PL.i/. Sea z

.i/PL el valor óptimo de la función objetivo de este problema

y x.i/PL su solución óptima (si existe).

Paso 3 – Poda Si z.i/PL � zPE ir al paso 1 (nótese que si la relajación se resuelve por un algoritmo dual, este

paso es aplicable tan pronto como el valor de la función objetivo del programa dual se haceinferior a zPE).Si x

.i/PL … S .i/ ir al paso 4.

Si x.i/PL 2 S .i/ y cT x

.i/PL > zPE , hacer zPE D cT x

.i/PL. Borrar de L todos los problemas tales

que z.i/� zPE . Si cT x

.i/PL D z

.i/PL ir al paso 1; si no, al paso 4.

Paso 4 – División Sea fS .ij /gkjD1 una división de S . Añadir los problemas fPE.ij /gkjD1 a L, donde z.ij /D

z.i/PL para j D 1; : : : ; k.Ir al paso 1.

Algoritmo Branch and Bound

� L designa una colección de programas enteros, PE.i/, cada uno tiene la formaz

.i/PE D max. fcT x W x 2 S .i/g, donde S .i/ � S .

Page 35: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

35/100

Branch-and-bound con relajación lineal

� Consideraremos los programas enteros generales

.PE/ max.˚cT x W x 2 S

; con S D fx 2 Zn

W Ax � b; x � 0g ;

y la forma de resolverlos

� Mediante esta relajación, el conjunto factible, S , se reemplaza por

S.0/PL D fx 2 Rn W x � 0; Ax � bg,

haciéndose en cada relajación zPL.x/ D cT x.

Page 36: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

36/100División de ramas

� Como se usa relajación lineal, la división se debe hacer con condiciones lineales.La forma más conveniente de hacerlo es como indica la figura.

680 Capıtulo 13. Algoritmos generales de relajacion

Si el programa lineal PL(i) tiene solucion optima, designemosla para facilitar la notacion porx(i). Las condiciones para eliminar, rechazar o “podar”7 el nudo i, y por tanto sus nudos hijos,son:

1. S(i)PL = ∅ (no factibilidad);

2. x(i) ∈ Zn+ (optimo) y

3. z(i)PL ≤ zPE , donde zPE es el mejor valor (valor dominante) de las soluciones factibles de

PE encontradas hasta ese momento. Observese que si se resuelve PL(i) por el algoritmodual del simplex, el rechazo se puede llevar a cabo antes de encontrar el optimo de PL(i).

Tambien se puede usar un criterio del tipo z(i)PL ≤ zPE + ε, para una tolerancia ε > 0

dada.

13.2.1.2 Division

Como se usa relajacion lineal en cada nudo del arbol enumerativo, la division se debe haceranadiendo condiciones lineales. Una forma evidente de hacer esto es tomar S = S(1) ∪ S(2) conS(1) = S ∩ {x ∈ �n : x ≥ 0, dT x ≤ d0} y S(2) = S ∩ {x ∈ �n : x ≥ 0, dT x ≥ d0 + 1}, donde[dT , d0]

T ∈ Zn+1. Si x(0) es la solucion del programa lineal (relajacion inicial) inicial:

(PL(0)) max.{cT x : x ∈ �n, x ≥ 0, Ax ≤ b

},

el vector [dT , d0]T se puede escoger de tal manera que d0 < dT x(0) < d0 +1. Proceder ası es lo

mas recomendable pues se obtiene un x(0) /∈ S(1)PL ∪ S

(2)PL, lo que permite la posibilidad de que,

para i = 1, 2, z(i)PL = max. {cT x : x ∈ S

(i)PL} < z

(0)PL.

En la practica solo se usan vectores [dT , d0]T muy concretos:

• Dicotomıas de variables. En este caso d = ej para algun j ∈ N . El punto x(0) sera no

factible en las relajaciones resultantes si x(0)j /∈ Z y d0 = xj� (ver figura 13.5). Notese

que si xj ∈ B la rama izquierda hace xj = 0 y la derecha xj = 1.

xj ≥ xj� + 1xj ≤ xj�

Figura 13.5

Division, por dicotomıa de la variable xj , en un arbol enumerativo

Una importante ventaja practica de esta division es que las condiciones que se anadena la relajacion lineal correspondiente son simples cotas inferiores o superiores. Solo sera

7Usaremos indistintamente estos terminos.

Es decir, desde el nudo que define la solución correspondiente, si esta no tienealguno de sus elementos, j , que ha de ser entero, entero, se hace partir dosramas: una en la que ese xj se acote superiormente por su entero inmediatoinferior; otra que se acote inferiormente por su entero superior.

� Los dos nuevos programas se pueden resolver mediante el método dual delsimplex; el tamaño de la base seguirá igual.

Page 37: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

37/100

Selección del nudo a estudiar

Proposición Si P D fx 2 Rn W Ax � b; x � 0g es acotado, el árbol de búsquedadesarrollado a partir de dicotomías de las variables es finito. En particular, si !j D dmKaxfxj W

x 2 P ge, ningún camino del árbol de búsqueda puede contener más deP

j2N !j ramas.

Proposición Si el nudo t del árbol de búsqueda con conjunto de condiciones S .t/ estal que max. fcT x W x 2 S

.t/PLg > zPE , ese nudo no se puede podar o rechazar.

� Dada una lista L de subárboles del árbol de búsqueda con nudos no rechazados,qué nudo elegir como el próximo a examinar.

� Dos opciones:

8<:Analizar uno siguiendo unas reglas preestablecidas; oEscogerlo según la información disponible en ese punto sobrecotas de las variables, número de nudos activos, etc.

� Existen varias reglas preestablecidas que se pueden utilizar. La más extendida esla denominada LIFO (del inglés Last In First Out).

Page 38: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

38/100� LIFO: Primero analizar todos los nudos “hijos"de uno determinado y luegovolver hacia atrás y escoger otro del mismo nivel del nudo “padre” que no hayasido analizado.

7 8

3 4 6 9

2 5

1

Los nudos subrayados son los podados o rechazados.

� Ventajas:

8<:

La relajación lineal de un nudo hijo se obtiene de la lineal del nudo padre sin más queañadir una cota en una variable. El método dual del simplex, sin reinvertir la base nimodificar las estructuras de datos sustancialmente, obtiene muy rápidamente la soluciónque define el nudo hijo.La experiencia dice que las soluciones factibles se encuentran más bien en puntos pro-fundos del árbol de búsqueda.

� Otra regla: Búsqueda en amplitud o anchura. Analizar todos los nudos de undeterminado nivel antes de pasar a otro más profundo. En códigosespecializados en variables binarias.

Page 39: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

39/100

� Un código “sencillo” recursivo de Matlab para resolver un Programa Entero:

function [xstar,Jmin] = ilp_bb_1(c,A,b,xlb,xub,xstar,Jmin)% Integer linear programming by (recursive) branch & bound% This algorithm uses linprog.m from the optimisation toolboxtol = 1e-5; % anything less is considered zeroif ~exist(’xlb’,’var’), xlb = 0*c; end % canonical form (for the moment)if ~exist(’xub’,’var’), xub = Inf*ones(size(c)); end % Upper bound defaultsif ~exist(’xstar’,’var’), xstar = []; endif ~exist(’Jmin’,’var’), Jmin = Inf; end % Try to minimise this

% Use the following two line if you prefer OPTI Optimization toolbox% LPrelax = opti(’f’,c,’ineq’,A,b, ’bounds’, xlb, xub);% [x,j,exitflag] = solve(LPrelax);

optns = optimset(’display’,’off’); % turn off diagnostics in Linprog[x,j,exitflag] = linprog(c,A,b,[],[],xlb,xub,[],optns);if exitflag~=1, return, end % if infeasible, branch endedif j>Jmin, return, end % if current cost J=cT x is worse, dropidx = find(abs(x-round(x)) > tol); % which are non-integers ?if isempty(idx) % All integer solutions

if j<Jmin, xstar=round(x); Jmin=j; end % New integer optimumreturn % problem solved

end% Depth first recursion

xnlb = xlb; xnlb(idx(1)) = ceil(x(idx(1))); % Take x<--int. greater than x[xstar,Jmin] = ilp_bb_1(c,A,b,xnlb,xub,xstar,Jmin);xnub = xub; xnub(idx(1)) = floor(x(idx(1))); % Take x<--int. less than x[xstar,Jmin] = ilp_bb_1(c,A,b,xlb,xnub,xstar,Jmin);

end

Page 40: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

40/100

� Ejemplo Resolvamos este problema de programación entera

minimizar x1 C 10x2

s. a 66x1 C 14x2 � 1430

�82x1 C 28x2 � 1306

x1; x2 enteras;� 0:

Con el programa presentado

>> c3=[1;10]>> A3=[-66 -14;82 -28]>> b3=[-1430;-1306]>> [xreal,jreal]=linprog(c3,A3,b3)Optimization terminated.xreal =

7.26168224302531967.909212283785493

jreal =6.863538050808803e+002

>> [xint,j]=ilp_bb_1(c3,A3,b3)xint =

770

j =707

Page 41: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

41/100

� Con la herramienta OPTI Toolbox

>> f1=[1 10]’;>> A1=[-66 -14; 82 -28];>> b1=[-1430 -1306]’;>> lb = [0;0]; ub = [];>> xtype = ’II’;>> Opt=opti(’f’,f1,’ineq’,A1,b1,’lb’,lb,’xtype’,xtype)------------------------------------------------------Mixed Integer Linear Program (MILP) Optimizationmin f’xs.t. rl <= Ax <= ru

lb <= x <= ubxi = Integer / Binary

------------------------------------------------------Problem Properties:

# Decision Variables: 2# Constraints: 6

# Linear Inequality: 2# Bounds: 2# Integer Variables: 2

------------------------------------------------------Solver Parameters:

Solver: CBC------------------------------------------------------>> [xi,fval]=solve(Opt)xi =

770

fval =707

>> plot(Opt)

MILP Optimization Contours + Constraints - Min: [7; 70] Fval: 707

660660

670670

680680

690690

700700

710710

720720

730730

740740

750750

760

2 3 4 5 6 7 8 9 10 11 12

x1

65

66

67

68

69

70

71

72

73

74

75

x 2

Page 42: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

42/100

� Resolvámoslo ahora con el software BBMI de programación entera y lineal. Elfichero de datos que requeriría este problema es el que sigue

PROCESO ITERATIVONAME Ej12.2.3ROWSN OBJG FILA1G FILA2

COLUMNSINT

X1 OBJ 1 FILA1 66X1 FILA2 -82X2 OBJ 10 FILA1 14X2 FILA2 28

RHSRHS FILA1 1430RHS FILA2 1306

ENDATA

Page 43: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

43/100� La gráfica de cómo opera BBMI es esta:Ejercicios 665

c

−82x1 + 28x2 ≥ 1306

66x 1 + 14x 2 ≥ 1430

x 1 = 6 x 1 = 7 x 1 = 8 x 1 = 9

x 2 = 67

x 2 = 68

x 2 = 69

x 2 = 70

x 2 = 71

x 2 = 72

x 2 = 73

x 2 = 74

12

3

4

6=7

8∗

4 8

5 10 9

3 6 7

2

1

11

x 2 ≥ 71 x 2 ≤ 70 x 1 ≤ 6 x 2 ≥ 70 x 2 ≤ 69

x 1 = 7

x 1 ≥ 8 x 1 ≤ 7

x 2 ≥ 68 x 2 ≤ 67

Figura 12.10

Region factible y arbol enumerativo del problema del ejemplo 12.4

d) maximizar x1 + x2 + x3

s. a −4x1 + 5x2 + 2x3 ≤ 4−2x1 + 5x2 ≤ 5

3x1 − 2x2 + 2x3 ≤ 62x1 − 5x2 ≤ 1

10 ≥ x1, x2, x3 ≥ 0 y enteras.

e) minimizar 3x1 + 5x2 + 6x3 + 9x4 + 10x5 + 10x6

s. a −2x1 + 6x2 − 3x3 + 4x4 + x5 − 2x6 ≥ 2−5x1 − 3x2 + x3 + 3x4 − 2x5 + x6 ≥ −2

5x1 − x2 + 4x3 − 2x4 + 2x5 − x6 ≥ 3

x1, x2, x3, x4, x5, x6 ≥ 0 y enteras.

Page 44: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

44/100� El resultado impreso de BBMI se lista a continuación.Problema Ej12.2.3

*** Estadísticas del Problema3 Fila(s)2 Restricción(es)2 Variable(s) de decisión2 Variable(s) de holgura/artificiales6 Elementos no cero2 Variable(s) entera(s)

Densidad de la matriz de coeficientes A: 100.000%

*** Estadísticas de INVERT3 elementos no cero en la base0 columnas estructurales en la base0 vectores columna antes del "bump"3 vectores columna después del "bump"

L: 0 elementos no cero; 0 vectores ETAU: 2 elementos no cero; 2 vectores ETATotal: 0 elementos no en la diagonal; 2 vectores ETAMáximo de transformaciones ETA: 2; máximo número de elementos ETA: 9Error relativo en x: .000000D+00

Ite. Inf. Nopt. Sum.Inf/F.Obj Entra de-a Cost.Red Sale de-aPaso Pivote El.Eta

1 2 1 .2736000D+04 2 L->B -.42D+02 3 B->L .10D+03 -.14D+02 22 0 1 .6863538D+03 1 L->B -.46D+02 4 B->L .73D+01 .21D+03 5

--- SOLUCIÓN INICIAL PROGRAMA LINEAL -----------------------------------

Nombre del problema: Ej12.2.3No. de iteraciones: 3Valor de la función objetivo: 686.353805073431

*** FILAS

No. ..Fila.. en ....Valor.... ...Holgura... .Lí.Inferior. .Lí.Superior. Val.Dual.

1 OBJ BS 686.35381 -686.35381 Ninguno Ninguno 1.0002 FILA1 LI 1430.0000 .00000000 1430.0000 Ninguno .28303 FILA2 LI 1306.0000 .00000000 1306.0000 Ninguno .2156

*** COLUMNAS

No. .Columna en ....Valor.... Coste en F.O. .Lí.Inferior. .Lí.Superior. Cos.Red.

1 X1 BS 7.2616822 1.0000000 .00000000 Ninguno .0002 X2 BS 67.909212 10.000000 .00000000 Ninguno .000

Page 45: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

45/100Variable Nudos Variables Valor

Separación Nivel Dirección en Lista Ent. No Ent.Iteración Func. Obj.

2 1 X> 68 1 2 4 D 6.8724242D+021 2 X> 8 2 1 6 D 7.0871429D+022 3 X> 71 3 1 7 D 7.1800000D+02

* Nueva solución entera; z(PE)= 718.00000; Tiempo desde última: .0001 seg.

--- SOLUCIÓN ENTERA ------------------

Tiempo desde última: .0001 seg.Nombre del problema: Ej12.2.3No. de iteraciones: 7Valor de la función objetivo: 718.000000000000

*** FILAS

No. ..Fila.. en ....Valor.... ...Holgura... .Lí.Inferior. .Lí.Superior. Val.Dual.

1 OBJ BS 718.00000 -718.00000 Ninguno Ninguno 1.0002 FILA1 BS 1522.0000 92.000000 1430.0000 Ninguno .1269E-153 FILA2 BS 1332.0000 26.000000 1306.0000 Ninguno .1349E-16

*** COLUMNAS

No. .Columna en ....Valor.... Coste en F.O. .Lí.Inferior. .Lí.Superior. Cos.Red.

1 X1 LIB 8.0000000 1.0000000 8.0000000 Ninguno 1.002 X2 LIB 71.000000 10.000000 71.000000 Ninguno 10.0

Variable Nudos Variables ValorSeparación Nivel Dirección en Lista Ent. No Ent.Iteración Func. Obj.

2 3 X< 70 2 -Nudo desechado en BKTRAK- 1.0000000D+201 2 X< 7 1 0 9 P 6.9842857D+022FIJ 1 3 X> 70 3 1 10 D 7.0700000D+02

* Nueva solución entera; z(PE)= 707.00000; Tiempo desde última: .0001 seg.

--- SOLUCIÓN ENTERA ------------------

Tiempo desde última: .0001 seg.Nombre del problema: Ej12.2.3No. de iteraciones: 10Valor de la función objetivo: 707.000000000000

*** FILAS

Page 46: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

46/100No. ..Fila.. en ....Valor.... ...Holgura... .Lí.Inferior. .Lí.Superior. Val.Dual.

1 OBJ BS 707.00000 -707.00000 Ninguno Ninguno 1.0002 FILA1 BS 1442.0000 12.000000 1430.0000 Ninguno .1269E-153 FILA2 BS 1386.0000 80.000000 1306.0000 Ninguno .1349E-16

*** COLUMNAS

No. .Columna en ....Valor.... Coste en F.O. .Lí.Inferior. .Lí.Superior. Cos.Red.

1 X1 EQB 7.0000000 1.0000000 7.0000000 Ninguno 1.002 X2 LIB 70.000000 10.000000 70.000000 Ninguno 10.0

Variable Nudos Variables ValorSeparación Nivel Dirección en Lista Ent. No Ent.Iteración Func. Obj.

2 3 X< 69 2 -Nudo desechado en BKTRAK- 1.0000000D+201 3 X< 6 1 -Nudo desechado en BKTRAK- 7.4457143D+022 1 X< 67 0 -Nudo desechado en BKTRAK- 1.0000000D+20

--- SOLUCIÓN ENTERA OPTIMA -------------------------

Nombre del problema: Ej12.2.3No. de iteraciones: 10Valor de la función objetivo: 707.000000000000

*** FILAS

No. ..Fila.. en ....Valor.... ...Holgura... .Lí.Inferior. .Lí.Superior. Val.Dual.

1 OBJ BS 707.00000 -707.00000 Ninguno Ninguno 1.0002 FILA1 BS 1442.0000 12.000000 1430.0000 Ninguno .1269E-153 FILA2 BS 1386.0000 80.000000 1306.0000 Ninguno .1349E-16

*** COLUMNAS

No. .Columna en ....Valor.... Coste en F.O. .Lí.Inferior. .Lí.Superior. Cos.Red.

1 X1 EQB 7.0000000 1.0000000 7.0000000 Ninguno .0002 X2 LIB 70.000000 10.000000 70.000000 Ninguno 10.0

Tiempo total de CPU en cálculos: .0603 segundos

Page 47: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

47/100

� Para darnos una idea de las prestaciones de estos algoritmos, resolvamos unproblema relativamente difícil de Programación Entera con 50 variables, todasenteras, y cuya matriz de condiciones tiene este esquema:

0 10 20 30 40 50

nz = 221

0

5

10

15

20

25

30

35

40

� Lo vamos a resolver con el solver de PE de OPTI Toolbox y con ilp_bb_1

Page 48: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

48/100� Con Intlinprog de Matlab:

>> problem = mpsread(’DEMOS5_noint.mps’)problem =

f: [50x1 double]Aineq: [41x50 double]bineq: [41x1 double]

Aeq: [0x50 double]beq: [0x1 double]lb: [50x1 double]ub: [50x1 double]

intcon: [50x1 double]solver: ’intlinprog’

options: [1x1 optim.options.Intlinprog]>> options = optimoptions(’intlinprog’,’Display’,’final’,’PlotFcns’,@optimplotmilp);>> problem.options = options;>> tic,[x,fval,exitflag,output] = intlinprog(problem),tocLP: Optimal objective value is -1171.225417.

Cut Generation: Applied 5 Gomory cuts, 10 clique cuts, and 5 cover cuts.Lower bound is -1046.000000.Relative gap is 0.00%.

Optimal solution found.

Intlinprog stopped at the root node ..

x =1.00001.00001.00001.0000

01.00001.0000

01.0000

00

1.00001.00001.00001.0000

01.00001.00001.0000

00

1.00001.0000

01.00001.0000

01.00001.00001.00001.00001.0000

01.0000

00000

1.000000

1.0000000

1.00000

1.00001.0000

fval =

-1.0460e+03

exitflag =

1

output =

relativegap: 0absolutegap: 0

numfeaspoints: 1numnodes: 0

constrviolation: 1.5543e-15message: ’Optimal solution found’

Elapsed time is 0.446243 seconds.>>

Page 49: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

49/100� Con OPTI Toolbox:

>> prob_1 = coinRead(’DEMOS5_noint.mps’);>> spy(prob_1.A);>> Opt_1 = opti(’f’,-prob_1.f,’ineq’,prob_1.A,prob_1.ru,’bounds’,prob_1.lb,prob_1.ub,’xtype’,xtype)------------------------------------------------------Mixed Integer Linear Program (MILP) Optimizationmin f’xs.t. rl <= Ax <= ru

lb <= x <= ubxi = Integer / Binary

------------------------------------------------------Problem Properties:

# Decision Variables: 50# Constraints: 191

# Linear Inequality: 41# Bounds: 100# Integer Variables: 50

------------------------------------------------------Solver Parameters:

Solver: CBC------------------------------------------------------>> tic,[x,fval,exitflag,info] = solve(Opt_1),tocx =

1.00001.00001.00001.0000

01.00001.0000

01.0000

00

1.00001.00001.00001.0000

01.00001.00001.0000

00

1.00001.0000

01.00001.0000

0

1.00001.00001.00001.00001.0000

01.0000

00000

1.000000

1.0000000

1.00000

1.00001.0000

fval =-1046

exitflag =

1info =

Nodes: 2AbsGap: 24.9233RelGap: 0.0238

Time: 0.0581Algorithm: ’CBC: Branch and Cut using CLP’

Status: ’Integer Optimal’

Elapsed time is 0.060537 seconds.>>

Page 50: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

50/100

� Con ilp_bb_1:

>> tic,[xint,j]=ilp_bb_1(-prob.f,A,prob_1.ru,prob_1.lb,prob_1.ub),tocxint =

11110110100111101110011011011111010000010010001011

j =

-1.0460e+03Elapsed time is 7295.551641 seconds.>>

El tiempo empleado es inaceptable.La estrategia es mala al no conside-rar ninguna forma de ahorrarse vi-sitar todos los nudos del árbol debúsqueda.

Page 51: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

51/100Selección de la variable de ramificación

� Es evidente que para mejorar las prestaciones de un algoritmo Branch andBound es necesario hacer algo que evite visitar todos los nudos del árbol debúsqueda de soluciones enteras. Veamos lo que hace BBMI.

� Supongamos que se ha elegido i como el nudo que se va a analizar. Asociado aese nudo habrá un programa lineal de solución x.i/,

xBiD Nai0 C

nXjDmC1

Naij .�xj / para i D 1; : : : ; mI

la función objetivo es x0 D Na00 CPn

jDmC1 Na0j .�xj /: Los Na0j ,j D mC 1; : : : ; n, son los costes reducidos de las variables no básicas.

� El paso siguiente de escoger la variable que va a definir la ramificación o divisiónque parta de i es crítico para las prestaciones del procedimiento. Apuntemosalguna estrategia de mejora.

Page 52: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

52/100

Penalizaciones de variables básicas

� Supongamos que en el nudo i alguna variable básica xp no es entera debiendoserlo, es decir

xp D Nap0 C

nXjDmC1

Napj .�xj / D np0 C fp0;

donde np0 designa la parte entera de xp, bxpc, y fp0 la parte fraccionaria.3

� La división que definirá la variable xp es

xp � np0 C 1 y xp � np0:

3Recordemos b3; 22c D 3; b�4; 12c D �5.

Page 53: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

53/100

� Del algoritmo dual del simplex podemos deducir que la imposición de la nuevacota xp � np0 C 1 a la variable xp implicará un empeoramiento (reducción) delvalor de la función objetivo.

� Como la variable básica xp, realizando una iteración del método dual delsimplex, pasaría como mínimo a ser no básica, otra variable no básica, xj ,que estuviese en uno de sus límites, se incrementaría o decrementaría segúnestuviese en el inferior o superior.

� Es decir, se reduciría el valor de la función objetivo en una cantidad openalización que vendría dada por la expresión

PU D

8<:mKınj; Napj <0.1 � fp0/Na0j

�Napj; si xj D lj ; o por

mKınj; Napj >0.1 � fp0/Na0j

�Napj; si xj D uj :

Page 54: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

54/100� Razonando de manera similar, la imposición de la nueva cota xp � np0 a lavariable xp implicará un empeoramiento (reducción) del valor de la funciónobjetivo que vendrá dado por la expresión

PD D

8<:mKınj; Napj >0 fp0Na0j

Napj; si xj D lj ;

mKınj; Napj <0 fp0Na0j

Napj; si xj D uj :

� Cualquier solución entera que se pudiese obtener partiendo del nudo i estaríapor consiguiente acotada superiormente por

mKaxfx0 � PU ; x0 � PDg:

� Se podrá conseguir una mejor solución desde el nudo i si y sólo si

mKınfPU ; PDg < x0 � zPE

para cada variable básica que no sea entera debiendo serlo.Si esta condición no se cumple se abandona el nudo i .

Page 55: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

55/100

� Si todas las variables xp cumplen esa condición, la cuestión siguiente a solventares qué variable de ramificación se elige.

� Se puede elegir aquella con la penalización asociada más pequeña.

� O escoger aquella variable con una penalización asociada más grande ycomenzar imponiendo el límite opuesto al que determina esa penalización.

� Si, por ejemplo, la penalización más grande asociada a una variable xp es PU ,comenzar analizando el problema que resulte de imponer a esa variable la nuevacota np0 e incluir en la lista de nudos a analizar más adelante el que resulte deimponer la cota np0 C 1.

� Si se almacenan las peores soluciones, una vez que se encuentre una buena, serechazarán rápidamente buena parte de los nudos que queden en la lista.

Page 56: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

56/100Penalizaciones de variables no básicas

� Posibles cambios en variables no básicas que impondrían nuevas cotas en elnudo i . Cualquier solución entera estaría acotada por

mKaxfx0 � P �U ; x0 � P �Dg;

donde ahora

P �U D

8<ˆ:

mKınj; Napj <0

(Na0j .1 � fp0/=.�Napj /; j 2M

mKaxf Na0j ; Na0j .1 � fp0/=.�Napj /g; j 2 J

)si xj D lj

mKınj; Napj >0

(Na0j .1 � fp0/=.�Napj /; j 2M

mKaxf Na0j ; Na0j .1 � fp0/=.�Napj /g; j 2 J

)si xj D uj

y

P �D D

8<ˆ:

mKınj; Napj >0

(Na0j fp0= Napj ; j 2M

mKaxf Na0j ; Na0j fp0= Napj g; j 2 J

)si xj D lj

mKınj; Napj <0

(Na0j fp0= Napj ; j 2M

mKaxf Na0j ; Na0j fp0= Napj g; j 2 J

)si xj D uj :

J es el conjunto de índices de las variables no básicas que han de ser enteras yM el de las no básicas que no han de ser enteras.

Page 57: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

57/100

� El nudo i se podrá desechar si, para cualquier xp a la que se introducen nuevascotas,

mKınfP �U ; P �Dg � x0 � zPE:

� Este criterio no es el único; recordemos el corte de Gomory asociado a xp,

�fp0 C

nXjDmC1

fpj xj � 0;

que se habría de satisfacer en cualquier solución que se obtuviese partiendo delproblema actual.

Page 58: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

58/100� Asociado a ese corte de Gomory se puede derivar la penalización

P �G D

8ˆˆ<ˆˆ:

mKınj

8<ˆ:

fp0 Na0j = Napj si Napj � 0 j 2M

.1 � fp0/ Na0j =.�Napj / si Napj < 0 j 2M

fp0 Na0j =fpj si fpj � fp0 j 2 J

.1 � fp0/ Na0j =.1 � fpj / si fpj > fp0 j 2 J

9>>>>>=>>>>>;si xj D lj I

mKınj

8<ˆ:

fp0 Na0j = Napj si Napj � 0 j 2M

.1 � fp0/ Na0j =.�Napj / si Napj > 0 j 2M

fp0.�Na0j /=fpj si fpj � fp0 j 2 J

.1 � fp0/.�Na0j /=.1 � fpj / si fpj > fp0 j 2 J

9>>>>>=>>>>>;si xj D uj :

� Se puede comprobar queP �G � mKın.P �U ; P �D/;

lo que trae como consecuencia que el nudo i se podrá desechar si, paracualquier xp a la que se introducen nuevas cotas,

P �G � x0 � zPE:

Page 59: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

59/100� Ejemplo Volvamos al ejemplo: maximizar 7x1 C 2x2

s. a �x1 C 2x2 � 4

5x1 C x2 � 20

�2x1 � 2x2 � �7

x 2 Z2C

:

� Con las variables de holgura x3, x4 y x5, la relajación lineal da la solución

x0 C311

x3 C1611

x4 D33211

x1 �111

x3 C211

x4 D3611

x2 C511

x3 C111

x4 D4011

811

x3 C611

x4 C x5 D7511

;

donde x3 D x4 D 0.De aquí que z

.0/PL D x0 D 332=11 y x.0/ D Œ36=11; 40=11; 0; 0; 75=11�T .

� Trabajemos con las penalizaciones que incluye BBMI. Las variables básicas sonx1, x2 y x5. Esta última no se requiere que sea entera. Las variables no básicasde la solución obtenida están todas en su límite inferior.

Page 60: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

60/100

� Para empezar, como todavía no tenemos ninguna solución factible de zPE,determinemos las penalizaciones por bifurcar a:

x1 � 3 W P 0�1D D mKınj; Napj >0f Na0j fp0= Napj ; j 2M g D mKın

�1611�

311

�2

11

�D

2411I

x1 � 4 W P 0C1U D mKınj; Napj <0f Na0j .1 � fp0/=.�Napj /; j 2M g D mKın

�3

11� .1 � 3

11/

�1

11

�D

2411I

x2 � 3 W P 0�2D D mKınj; Napj >0f Na0j fp0= Napj ; j 2M g D mKın

�1611�

711

�1

11; 3

11�

711

�5

11

�D

2155

:

� La penalización P 0C2D la podemos considerar1 pues de la solución del programa

lineal anterior se observa que al incrementar la variable x2, x3 y x4 decrecen.

� De las penalizaciones calculadas, la mejor (menos mala) se obtiene al hacerx2 � 3. Añadamos esa condición, es decir, x2 D

4011�

511

x3 �111

x4 � 3.

Page 61: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

61/100

� La relajación lineal resultante anterior más esta condición queda:

x0 C311

x3 C1611

x4 D33211

x1 �111

x3 C211

x4 D3611

x2 C511

x3 C111

x4 D4011

811

x3 C611

x4 C x5 D7511

�511

x3 �111

x4 C x6 D �711

:

� Después de una iteración del método dual del simplex se llega a la soluciónóptima siguiente:

x0 C75x4 C

35x6 D

1495

x1 C15x4 �

15x6 D

175

x2 C x6 D 325x4 C x5 C

85x6 D

295

x3 C15x4 �

115

x6 D75

:

De aquí que z.1/PL D x0 D 149=5 y x.1/ D Œ17=5; 3; 7=5; 0; 29=5�T , con x6 D 0.

La única variable que debe ser entera en esta solución y no lo es x1.

Page 62: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

62/100� Calculemos ahora las penalizaciones por bifurcar a:

x1 � 3 W P 1�1D D mKınj; Napj >0f Na0j fp0= Napj ; j 2M g D mKın

�75�

25

�15

�D

145

x1 � 4 W P 1C1U D mKınj; Napj <0f Na0j .1 � fp0/=.�Napj /; j 2M g D mKın

�35� .1 � 2

5/

�15

�D

95:

De estas penalizaciones la mejor se obtiene al hacer x1 � 4. Añadamos lacondición x1 D

175�

15x4 C

15x6 � 4.

� La relajación lineal resultante anterior más esta condición queda:

x0 C75x4 C

35x6 D

1495

x1 C15x4 �

15x6 D

175

x2 C x6 D 325x4 C x5 C

85x6 D

295

x3 C15x4 �

115

x6 D75

�15x4 C

15x6 � x7 D

35

:

� Otra iteración del dual del simplex obtiene la primera solución factible enterax.2/ D Œ4; 0; 8; 0; 1�T , con zPE D 28.

Page 63: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

63/100

� Después se analizaría el nudo 3, rechazándose inmediatamente pues del cálculoanterior de penalizaciones se vería que la función objetivo obtenible sería149=5 � P 1�

1D D 135=5 D 27 < 28. Posteriormente también se rechazaría elnudo 4.

Solucion entera.x (2) = [4, 0, 8, 0, 1]T

z(2)PL = zPE = zPE = 28

3 2

1 4

0

x 2 ≥ 4x 2 ≤ 3

x 1 ≥ 4x 1 ≤ 3

Page 64: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

64/100Programación No lineal en variables Enteras

� La dificultad de estos problemas aumenta considerablemente, pero nada impideutilizar la estrategia Branch and Bound utilizando un solver no lineal –fminconpor ejemplo– en vez del lineal que hemos presentado. El código de antesadaptado para resolver un Programa Entero no lineal es éste:

function [xstar,Jmin] = inlp_bb(fun,x0,A,b,xlb,xub,NLCon,xstar,Jmin)% [xstar,Jmin] = ilp_bb(fun,x0,A,b,xlb,xub,NLCon,xstar,Jmin)% Integer Non-linear programming by (recursive) branch & bound% Uses fmincon.m from the optimisation toolbox to solve the relaxed problemoptns = optimset(’display’,’off’); tol = 1e-3; % anything less is zeroif ~exist(’xlb’,’var’), xlb = 0*x0; endif ~exist(’xub’,’var’), xub = Inf*ones(size(x0)); endif ~exist(’xstar’,’var’), xstar = []; endif ~exist(’Jmin’,’var’), Jmin = Inf; end

% Now solve relaxed NL constrained problem[x,j,exitflag] = fmincon(fun,x0,A,b,[],[],xlb,xub,NLCon,optns);if exitflag <1; return, end % disp(exitflag) if infeasible or not OKif j>Jmin + tol; return, end % for robustness; truncateidx = find(abs(x-round(x)) > tol); % which are non-integers?if isempty(idx) % All integer solutions

if j<Jmin, xstar=round(x); Jmin=j; end % New integer optimumreturn % problem solved

end% Depth first recursion

xnlb = xlb; xnlb(idx(1)) = ceil(x(idx(1))); % new lower bound[xstar,Jmin] = inlp_bb(fun,x,A,b,xnlb,xub,NLCon,xstar,Jmin);xnub = xub; xnub(idx(1)) = floor(x(idx(1)));[xstar,Jmin] = inlp_bb(fun,x,A,b,xlb,xnub,NLCon,xstar,Jmin);

end

Page 65: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

65/100� Resolviendominimizar .x1 � 5/2

C .x2 � 7/2� x1x2 .x2 C 1/

sujeta a 0;4 .x1 � 5;7/3� 4;2C x2 � 0

0;53x1 C x2 � 10

�1;1x1 C x2 � 5:

Partiremos del punto x0 D Œ2;5; 1;5�T .

>> A=[0.53 1; -1.1 1]; b=[10,5]’;>> lb=[0;0]; ub=[10;10];>> x0=[2.5,1.5]’;>> fun1=@(x) (x(1)-5).^2+(x(2)-7).^2-x(1)*x(2)*(x(2)+1);>> [xstar,Jmin]=inlp_bb(fun1,x0,A,b,lb,ub,@circlecon)xstar =

38

Jmin =

-211

>> plot(Opt)

MINLP Optimization Contours + Constraints - Min: [3; 8] Fval: -211

-1200-1000

-800

-800

-600

-600

-400

-400

-400

-200

-200

-200

0

0

0

200

-2 -1 0 1 2 3 4 5 6 7 8

x1

3

4

5

6

7

8

9

10

11

12

13

x 2

La rutina con la condición no lineal esfunction [c,ceq] = circlecon(x)c = 0.4*(x(1)-5.7)^3+x(2)-4.2;ceq = [];

end

Page 66: Programación Entera · 2019. 2. 2. · Programación Entera JoséLuisdelaFuenteO’Connor jldelafuente@etsii.upm.es joseluis.delafuente@upm.es Clase_Entera.pdf

h i j

d e f g

a b c

10 8 7

9 4 6 5

1 2 3

66/100

� Con la herramienta OPTI Toolbox

>> fun=@(x) (x(1)-5).^2+(x(2)-7).^2-x(1)*x(2)*(x(2)+1);>> A=[0.53 1; -1.1 1]; b=[10,5]’;>> lb=[0;0]; ub=[10;10];>> nlcon=@(x) 0.4*(x(1)-5.7)^3+x(2);>> nlrhs=4.2;>> x0=[2.5,1.5]’;>> xtype = ’II’;>> Opt=opti(’fun’,fun,’ineq’,A,b,’bounds’,lb,ub,’nlcon’,nlcon,’nlrhs’,nlrhs,’xtype’,xtype)>> [x,fval] = solve(Opt,x0)

x =

38

fval =

-211>> plot(Opt)

MINLP Optimization Contours + Constraints - Min: [3; 8] Fval: -211

-1200-1000

-800

-800

-600

-600

-400

-400

-400

-200

-200

-200

0

0

0

200

-2 -1 0 1 2 3 4 5 6 7 8

x1

3

4

5

6

7

8

9

10

11

12

13

x 2