Sie sind auf Seite 1von 21

Programacin Entera y Ejemplo del

Algoritmo de Branch and Bound


By Investigacin de Operaciones on 8 mayo, 2015 in Investigacin Operativa

Un modelo de Programacin Entera (PE) permite abordar aplicaciones donde la solucin


tiene sentido si una parte o todas las decisiones toman valores restringidos a nmeros
enteros. Por ejemplo, consideremos que tenemos el siguiente problema de Programacin
Lineal:

Si todas las variables restringen sus valores a nmeros enteros, entonces estamos frente a un
modelo de Programacin Entera (puro). Por el contrario, si al menos algn conjunto de
variables no esta acotada a adoptar valores o nmeros enteros, se trata de un modelo de
Programacin Entera (Mixta).
Luego, si consideramos que estamos a un modelo de Programacin Entera (puro o mixto) y
resolvemos el modelo de Programacin Lineal asociado (esto es, admitiendo valores
continuos para las variables), estaremos obteniendo la solucin de la Relajacin Continua del
modelo entero. Para un modelo de maximizacin, la relajacin continua nos proporciona una
cota superior del valor ptimo del modelo de Programacin Entera asociado.
En el caso particular que la Relajacin Continua nos proporcione una solucin entera,
entonces sta ser tambin la solucin del modelo de Programacin Entera asociado. En caso
contrario deberemos utilizar alguna estrategia o algoritmo para obtener la solucin del modelo
de PE.
Una herramienta eficiente para abordar estos casos es el algoritmo de Branch & Bound.
Utilizaremos un ejemplo para explicar este mtodo:
Resuelva el siguiente modelo de Programacin Entera utilizando el Algoritmo de Branch &
Bound:

El dominio de puntos factibles para el modelo de Programacin Lineal asociado es el rea


demarcada con verde. Dicho modelo tiene valor ptimo igual a 39, con X1=1,9 y X2=0. Esto
corresponde a la relajacin continua del PLE y nos proporciona una cota superior del valor
ptimo de dicho problema.
Adems, claramente la solucin de la relacin continua no satisface la condicin de
integralidad del modelo de PLE. Finalmente, en el grfico anterior se han marcado todas
aquellas combinaciones que satisfacen las restricciones del modelo de PLE (A, D, E, B, G, F y
C). Claramente esto corresponde a un subdominio del problema lineal asociado lo que justifica
que la relajacin continua nos entrega una cota superior del valor ptimo del PLE.
Al aplicar el algoritmo de Branch & Bound, el nodo inicial corresponde a la relajacin continua
y se van agregando las ramas o nodos necesarios hasta alcanzar la(s) soluciones que
satisfacen las condiciones de integralidad.

P0: Corresponde a la relajacin continua del PLE.

P1: Po + x1<=1. (solucin inicial X1=1,9 aproximada al entero inferior)

P2: Po + x1>=2 (solucin inicial X1=1,9 aproximada al entero superior). Infactible.

P11: P1 + x2<=1 (solucin ptima X1=1 y X2=1. Valor ptimo Z=33. Debido a que la
solucin satisface las restricciones de integralidad, se termina este nodo).

P12: P1 + x2>=2 (solucin X1=5/7 y X2=2. No es solucin ptima de PLE debido a que X1
es an fraccionario. Se continua el mtodo debido a que el Valor ptimo Z=37 es mayor
que el Valor ptimo de P11, en caso contrario se detiene el mtodo y P11 sera la solucin
ptima de PLE).

P121: P12 + x1<=0 (X1=0 y X2=13/4. Z=35,75. Se continua siguiendo el mismo


razonamiento anterior)

P122: P12 + X1>=1 Infactible.

P1211: P121 + X2<=3 (X1=0 y X2=3. Z=33 es el valor en la funcin objetivo ms alto
obtenido para los nodos con soluciones enteras). Se agota este nodo.

P1212: P121 + x2>=4 Infactible.

Luego la Solucin ptima del PLE) es X1=0 y X2=3 con Valor ptimo Z=33.

Videos

http://proyectofinaldaliaypaco.blogspot.mx/2014/12/video-recomendado.html
http://www.revistavirtualpro.com/biblioteca/branch-and-bound-ramificacion-yacotamiento---programacion-entera
https://www.youtube.com/watch?v=jAl-XtxXVV4
https://www.youtube.com/watch?v=avtF3LAuI1Y
https://www.youtube.com/watch?v=AUEto2BtF_c
https://sites.google.com/site/optimizacionenteraydinamica/introduccion/metodo
s-de-solucion-en-programacion-entera/metodos-de-ramificacion

Un problema de programacin entera es aquel en el que alguna o todas sus


variables deben tomar valores enteros.
Son ms costosos de resolver que los problemas sin esta restriccin
Un modelo entero es igual que el modelo lineal correspondiente (relajacin) pero
con la restriccin adicional de que las variables deben ser enteras
La regin factible del modelo entero est contenida dentro de la del modelo
relajado.
El valor ptimo de la relajacin es una cota superior (prob. Max) del valor ptimo
del modelo entero
Vale como solucin los valores redondeados o truncados del problema relajado?
Posible solucin: enumerar explcitamente todas las soluciones enteras de la
regin factible
Teniendo en cuenta las observaciones anteriores existen varias tcnicas para
desarrollar un problema de programacin entera:

Mtodo Grfico

Enumeracin Implcita

Relajacin

Redondeo

Branch and Bound (Ramificacin y


Acotamiento)

Plano de corte

METODO GRAFICO:

Slo se aplica a problemas de dos variable

ENUMERACION IMPLICITA

Resolver LPs para todas las combinaciones


posibles de las variables enteras y encontrar el
ptimo global.

Si las variables son binarias:

# combinaciones = 2m
m=no. Variables binarias

2m

32

10

1000

20

106

TECNICA DE RELAJACION
Relajar las variables como si fueran
continuas.
Resolver el MILP como si fuera
cualquier problema de programacin
lineal (LP).
En algunos casos, la solucin resulta
ser entera (e.g. Ergies y Nergies).

Slo sucede en ciertos casos


especiales, ya que, en general, al
menos alguna variable ser no entera
en la solucin del LP relajado.
TECNICO REDONDEO

Redondear la solucin del problema


LP a la solucin entera ms cercana
Puede producir soluciones no ptimas
o no factibles.

MTODO BRANCH AND BOUND


(RAMIFICACION Y ACOTAMIENTO)
Hasta el momento solo hemos visto mtodos de resolucin de problemas lineales
continuos.
Sin embargo es muy frecuente que la naturaleza del problema nos diga que las
variables son enteras o binarias. Una alternativa es simplemente aproximar la
solucin hacia el entero ms cercano, pero esta estrategia podra ser bastante
mala como de hecho ocurre para las variables binarias.
El algoritmo de ramificacin y acotamiento (o de branch and bound) comienza con
una relajacin del problema (no considerar restricciones de integralidad) y
construye un rbol con soluciones enteras particionando el conjunto de soluciones
factibles de modo de descartar soluciones fraccionarias. Sin embargo, este solo
hecho de descomponer nos puede llevar a un problema inmanejable por lo que
debemos podar el rbol de manera inteligente.
Es decir:
Enumera de forma implcita todas las
soluciones de un modelo lineal entero y
solucionando subproblemas se van
eliminando conjuntos de soluciones
posibles.
Primero se soluciona el problema
relajado y se obtiene una solucin:
x1,x2,...,xn.

Si xi toma un valor no entero entre k y


k+1 se consideran dos subproblemas
aadiendo al problema original las
restricciones xi<= k y xi >=k+1
Un subproblema puede llegar a no tener
sucesores por tres motivos:
El problema no es factible
El problema tiene una solucin entera
1. Si su valor para la funcin
objetivo es mejor que el de
cualquier otra solucin entera
ya obtenida se convierta en
solucin candidata
2. Si su valor para la funcin
objetivo es peor que el de la
solucin candidata actual se
descarta
El problema tiene una solucin no
entera pero con un valor de la funcin
objetivo peor que el de la solucin
candidata actual: se descarta.
El algoritmo termina cuando se han
resuelto o descartado todos los
subproblemas posibles
Este algoritmo se puede utilizar en
problemas de programacin entera mixta
(solo algunas variables enteras)
En problemas grandes puede ser muy
eficiente gracias a la cota que permite
eliminar un conjunto grande de
soluciones factibles
EJEMPLO:
Max (z) = x1 + 3 x2

sujeto a:
x2 1,87
22 x1 + 34 x2 105
x1 {0,1,2,...}
x2 {0,1,2,...}
La solucin continua del problema es:
x1 = 1,88
x2 = 1,87
z = 7,49
Bound:

Asociamos a esta solucin el


nodo 0.

Cualquier solucin entera


tendr un valor de la funcin
objetivo menor o igual que z =
7,49

Esto se debe a que al poner la


condicin de integralidad el
problema
se
hace
ms
restrictivo.

A partir del nodo 0 se generan


2 problemas aadiendo a uno
de ellos x1 2 (nodo1) y x1 1
(nodo2).

Es decir, buscamos la solucin


a cada lado de la variable que
est ms cercana a tomar un
valor entero

Branch:

Las soluciones
problemas son:

ambos

nodo 1 (x1 2): x1= 2; x2 =


1,79; z = 7,38
nodo 2 (x1 1): x1= 1; x2 =
1,87; z = 6,61

No tenemos soluciones
enteras, por tanto, debemos
seguir.

En el nodo 1 el valor de la
funcin objetivo es mayor.
Seguimos ramificando el nodo
1:

nodo 3 (x2 2)

nodo 4 (x2 1)

nodo
INFACTIBLE

(x2

2):

nodo 4 (x2 1): x1=


3,23; x2 = 1; z = 6,23
Branch:

En el nodo 4 el valor de z es
inferior al del nodo 2. Debemos
seguir por el nodo 2.

A partir del nodo 2 se generan


2 nuevos nodos:

Bound:

nodo 5 (x2 2)

nodo 6 (x2 1)

nodo 5
INFACTIBLE

(x2

2):

nodo 6 (x2 1): x1= 1;


x2 = 1; z = 4

Ya tenemos una solucin


entera, pero el valor de z es
menor que en el nodo 4.

Como el valor de z en el nodo


6 es menor que en el 4,
ramificamos por el 4.

Del nodo 4 surgen dos nuevos


nodos:

Branch:

Bound:

nodo 7 (x1 3)

nodo 8 (x1 4)

nodo 7 (x1 3): x1= 3; x2


= 1; z = 6
nodo 8 (x1 4): x1= 4; x2
= 0,5; z = 5,5
La solucin del nodo 7 es entera y mejor
que la del nodo 6.
La solucin del nodo 8 es continua y peor
que la del nodo 7.
No queda ninguna posibilidad de mejorar
el valor de la funcin objetivo.
Por tanto tenemos la siguiente solucin
entera:
x1= 3

x2 = 1

OTROS EJEMPLOS:
Problema 1

z=6

Resolver el siguiente problema usando el algoritmo de ramificacin y acotamiento:


mn z = 5x1 8x2
s.a

x1 + x2 6

5x1 + 9x2 45
x1, x2 0 y enteros
Solucin
Lo primero que debemos hacer es inicializar el incumbente en z = 1 e inicializar la
lista de problemas pendientes con la relajacin lineal del problema:
(Po) mn z = 5x1 8x2
Como es el nico problema que hay en la lista, lo resolvemos obteniendo la siguiente solucin optima:
zo = 41,25; x1 = 2,25 y x2 = 3,75 2. Notamos que las 2 variables son fraccionarias por lo que podemos
tomar cualquiera de ellas como variable de ramificacin. Escojamos la variable x2 para ramificar
generndose as los siguientes problemas:

(P1) mn z = 5x1 8x2


s.a

x1 + x2 6

(P2) mn z = 5x1 8x2


s.a

5x1 + 9x2 45

x1 + x2 6
5x1 + 9x2 45

x2 4

x2 _ 2

x1 2

x1 1

x1, x2 0

x1, x2 0

Tenemos ahora que la lista esta compuesta por 2 problemas pendientes: L={(P 1),
(P2)}. Sin embargo, an no encontramos una solucin entera por lo que no
actualizamos el incumbente.
Resolviendo primero (P1), se tiene que z1 = 41; x1 = 1,8 y x2 = 4, que tampoco es
solucin entera por lo que ramificamos nuevamente por variable x 1, dando origen
a los problemas:
(P3) mn z = 5x1 8x2
s.a x1 + x2 6
5x1 + 9x2 45

(P4) mn z = 5x1 8x2


s.a

x1 + x2 6
5x1 + 9x2 45

x2 4

x2 4

x1 2

x1 1

x2 4

x2 5

x1, x2 0

x1, x2 0

Tenemos como problemas pendientes L={(P2), (P3), (P4)} y aun ninguna solucin
entera.
Escogemos (P3) para ser resuelto obteniendo que es infactible. Esto significa que
eliminamos a (P3) sin ser ramificado.
Ahora es necesario escoger entre los elementos de la lista pendientes L={(P 2),
(P4)}. Escogemos (P4) para ser resuelto obteniendo que z 4 = 40,55; x1 = 1 y x2 =
4,44. Nuevamente no tenemos una solucin entera y por lo tanto debemos
ramificar segn variable x2 dando paso a los siguientes problemas:
(P5) mn z = 5x1 8x2
s.a

x1 + x2 6
5x1 + 9x2 45

(P6) mn z = 5x1 8x2


s.a

x1 + x2 6
5x1 + 9x2 45

x2 4

x2 4

x1 1

x1 1

x2 4

x2 5

x1, x2 0

x1, x2 0

Notamos que el espacio factible de (P6) es solo el punto (x1 = 0, x2 = 5) y el de (P5)


es el segmento de recta que une el punto (0, 4) con el punto (1, 4). Si se resuelve
(P5) se obtiene la primera solucin entera: z 5 = 37; x1 = 1 y x2 = 4 por lo que
actualizamos el incumbente: z = 37.
Ahora la lista es L={(P2), (P6)}. Resolviendo (P6) se tiene que z6 = 40; x1 = 0 y x2 =
5, que es una solucin entera mejor que la anterior por lo que actualizamos el
incumbente: z = 40.
Resolviendo finalmente el ultimo problema de la lista: (P 2) se obtiene que z2 = 39;
x1 = 3 y x2 = 3, que es una solucin entera peor que la del incumbente por lo cual
no es necesario ramificar.

Como no quedan problemas en la lista, hemos encontrado que el optimo entero


del problema viene dado por z_ = 40; x_1 = 0 y x_2 = 5 El rbol final es el que se
muestra en la figura.

Observacin: Si la solucin de P2 hubiera tenido z6 = 39 y solucin


fraccionaria tampoco hubiramos ramificado porque hubiese tenido un
valor de la funcin objetivo peor que la del incumbente por lo que todos
los problemas hijos tendran una solucin peor que la mejor que ya
tenemos.

Next: Cutting Plane Techniques Up: Solving Integer Programs Previous:


Relationship to Linear Programming
Branch and Bound

We will explain branch and bound by using the capital budgeting example from the
previous section. In that problem, the model is

The linear relaxation solution is


with a value of 22.
We know that no integer solution will have value more than 22. Unfortunately, since is
not integer, we do not have an integer solution yet.
We want to force

to be integer. To do so, we branch on

In one, we will add the constraint


is illustrated in Figure 2.

Figure 2: First Branching

, creating two new problems.

. In the other, we add the constraint

. This

Note that any optimal solution to the overall problem must be feasible to one of the
subproblems. If we solve the linear relaxations of the subproblems, we get the following
solutions:

: objective 21.65,

: objective 21.85,

,
,

;
,

At this point we know that the optimal integer solution is no more than 21.85 (we actually
know it is less than or equal to 21 (Why?)), but we still do not have any feasible integer
solution. So, we will take a subproblem and branch on one of its variables. In general, we
will choose the subproblem as follows:

We will choose an active subproblem, which so far only means one we


have not chosen before, and

We will choose the subproblem with the highest solution value (for
maximization) (lowest for minimization).

In this case, we will choose the subproblem with


, and branch on . After solving
the resulting subproblems, we have the branch and bound tree in Figure 3.

Figure 3: Second Branching


The solutions are:

: objective 18,

: objective 21.8,

,
,

,
,

;
,

We now have a feasible integer solution with value 18. Furthermore, since the
problem gave an integer solution, no further branching on that problem is
necessary. It is not active due to integrality of solution. There are still active subproblems
that might give values more than 18. Using our rules, we will branch on problem
by branching on

to get Figure 4.

Figure 4: Third Branching


The solutions are:

: objective 21,

: infeasible.

Our best integer solution now has value 21. The subproblem that generates that is not active
due to integrality of solution. The other subproblem generated is not active due to
infeasibility. There is still a subproblem that is active. It is the subproblem with solution
value 21.65. By our ``round-down'' result, there is no better solution for this subproblem
than 21. But we already have a solution with value 21. It is not useful to search for another
such solution. We can fathom this subproblem based on the above bounding argument and
mark it not active. There are no longer any active subproblems, so the optimal solution
value is 21.
We have seen all parts of the branch and bound algorithm. The essence of the algorithm is
as follows:
1. Solve the linear relaxation of the problem. If the solution is integer, then
we are done. Otherwise create two new subproblems by branching on a
fractional variable.
2. A subproblem is not active when any of the following occurs:
1. You used the subproblem to branch on,
2. All variables in the solution are integer,
3. The subproblem is infeasible,
4. You can fathom the subproblem by a bounding argument.
3. Choose an active subproblem and branch on a fractional variable.
Repeat until there are no active subproblems.

That's all there is to branch and bound! Depending on the type of problem, the branching
rule may change somewhat. For instance, if x is restricted to be integer (but not necessarily
0 or 1), then if x=4.27 your would branch with the constraints
and x=5).

and

(not on x=4

In the worst case, the number of subproblems can get huge. For many problems in practice,
however, the number of subproblems is quite reasonable.
For an example of a huge number of subproblems, try the following in LINGO:
model:
sets:
a /1..17/: x;
endsets

max = -x0 + @sum(a: 2 * x);


x0 + @sum(a: 2 * x) < 17;
@for (a: @bin(x));
end

Note that this problem has only 18 variables and only a single constraint.
LINDO looks at 48,619 subproblems, taking about 20 minutes on a Sun Sparc
workstation, before deciding the optimal objective is 16. LINGO on a
16MHz 386 PC (with math coprocessor) looks at 48,000+ subproblems and
takes about five hours. CPLEX on a Sun SPARC 10 takes about 50 seconds to
examine 61,497 subproblems (counting those that are fathomed without
solving the LP). The 100 variable version of this problem would take about
subproblems or about
years (at 1000 subproblems per second).
Luckily, most problems take far less time.

Next: Cutting Plane Techniques Up: Solving Integer Programs Previous:


Relationship to Linear Programming

Michael A. Trick
Sun Jun 14 12:49:07 EDT 1998

https://www.youtube.com/watch?v=BbrZsG7zesE

Das könnte Ihnen auch gefallen