Você está na página 1de 9

UNIVERSIDADE FEDERAL DE VIÇOSA

Pesquisa Operacional 1 – INF280

Resolução de Problemas de
Programação Linear com Software de
Otimização
1)

A – MODELO PROGRAMAÇÃO LINEAR

Max f = 10x1 + 8x2 + 9x3 + 7x4

s.a.

Mão de obra 1: 2x1 + 5x2 + 6x3 + 3x4 <= 80


MO2: 8x1 + 4x2 + 2x3 + 7x4 <= 50
Maquina 1: 5x1 + 4x2 + 8x3 + 7x4 <= 80
MAQ2: 3x1 + 6x2 + 8x3 + 5x4 <= 20
MAQ3 : 3x1 + 2x2 + 9x3 + 6x4 <= 40
Restricoes : x1, x2, x3, x4 > = 0 e x1 <= 70, x2 <= 60, x3 <= 40, x4 <= 20

B – MODELO PROGRAMAÇÃO LINEAR LINDO COM SOLUCAO

MAX 10X1 + 8X2 + 9X3 + 7X4

SUBJECT TO

MO1) 2X1 + 5X2 + 6X3 + 3X4 <= 80


MO2) 3X1 + 4X2 + 2X3 + 7X4 <= 50
MAQ1) 5X1 + 4X2 + 8X3 + 7X4 <= 80
MAQ2) 3X1 + 6X2 + 8X3 + 8X4 <= 20
MAQ3) 3X1 + 2X2 + 9X3 + 6X4 <= 40
X1 <= 70
X2 <= 60
X3 <= 40
X4 <= 20

LP OPTIMUM FOUND AT STEP 1

OBJECTIVE FUNCTION VALUE

1) 66.66666

VARIABLE VALUE REDUCED COST


X1 6.666667 0.000000
X2 0.000000 12.000000
X3 0.000000 17.666666
X4 0.000000 19.666666

ROW SLACK OR SURPLUS DUAL PRICES


MO1) 66.666664 0.000000
MO2) 30.000000 0.000000
MAQ1) 46.666668 0.000000
MAQ2) 0.000000 3.333333
MAQ3) 20.000000 0.000000
7) 63.333332 0.000000
8) 60.000000 0.000000
9) 40.000000 0.000000
10) 20.000000 0.000000

NO. ITERATIONS= 1

C – MODELO SOMATORIO
n = numero de produtos
m = numero de maquinas
k = numero de empregados
lucro = lucro por produto i
restricoes = componentes da producao, soma de m maquinas e k empreg.
potvenda = potencial de venda de cada produto i
x = quantidade de produtos vendidos i

Max f(x1...n) = soma (i de 1..n) Lucro (i) * x (i)

s.a.

para (j de 1..m + k): soma (i de 1..n) modelo (j,i) * x (i) <= restricoes (j)
para (i de 1..n): x (i) >= 0
para (i de 1..n): x (i) <= potvenda (i)

D – MODELO XPRESS

declarations
m = 5 !No de comp. de producao, soma de m maquinas e k tipos de mo
n = 4 !No de produtos

Lucro: array (1..n) of integer


Restricoes: array (1..m) of real
Modelo: array (1..m, 1..n) of real
x: array (1..n) of mpvar
Potvenda: array (1..n) of integer

end-declarations

!Inicio do modelo

Lucro::[10, 8, 9, 7]
Restricoes::[80, 50, 80, 20, 40]
Potvenda::[70, 60, 40, 20]
Modelo:: [2, 5, 6, 3,
8, 4, 2, 7,
5, 4, 8, 7,
3, 6, 8, 5,
3, 2, 9, 6 ]

!Definicao da Funcao Objetivo

Lucrototal:= sum(i in 1..n) Lucro(i)*x(i)

!Restricoes

forall(j in 1..m) sum(i in 1..n) Modelo(j,i)* x(i) <= Restricoes(j)


forall(i in 1..n) x(i)<= Potvenda(i)
forall(i in 1..n) x(i)>= 0

!Resolucao do modelo

maximize(Lucrototal)

!Exibicao dos resultados

writeln("Funcao objetivo:", getobjval)


forall (i in 1..n)
writeln("Valor de x(", i, ") é ", getsol(x(i)))

end-model

Funcao objetivo:63.6207
Valor de x(1) é 6.2069
Valor de x(2) é 0
Valor de x(3) é 0.172414
Valor de x(4) é 0

D – MODELO XPRESS COM n = 5, m = 3 e k = 3

declarations
m = 6 !No de comp. de producao, soma de m maquinas e k tipos de mo
n = 5 !No de produtos

Lucro: array (1..n) of integer


Restricoes: array (1..m) of real
Modelo: array (1..m, 1..n) of real
x: array (1..n) of mpvar
Potvenda: array (1..n) of integer

end-declarations

!Inicio do modelo

Lucro::[10, 8, 9, 7, 7]
Restricoes::[80, 50, 80, 60, 40, 60]
Potvenda::[70, 60, 40, 20, 40]
Modelo:: [2, 5, 6, 3, 3,
8, 4, 2, 7, 7,
5, 4, 8, 7, 7,
3, 6, 8, 5, 5,
3, 2, 9, 6, 6 ]

!Definicao da Funcao Objetivo

Lucrototal:= sum(i in 1..n) Lucro(i)*x(i)

!Restricoes

forall(j in 1..m) sum(i in 1..n) Modelo(j,i)* x(i) <= Restricoes(j)


forall(i in 1..n) x(i)<= Potvenda(i)
forall(i in 1..n) x(i)>= 0

!Resolucao do modelo

maximize(Lucrototal)

!Exibicao dos resultados

writeln("Funcao objetivo:", getobjval)

forall (i in 1..n)
writeln("Valor de x(", i, ") é ", getsol(x(i)))
end-model

Funcao objetivo:93.7313
Valor de x(1) é 2.91045
Valor de x(2) é 5.5597
Valor de x(3) é 2.23881
Valor de x(4) é 0
Valor de x(5) é 0
2)

A - MODELO DE PROGRAMACAO LINEAR POR SOMATORIO

m = quantidade de itens a serem entregues para lavanderia


n = quantidade de lavanderias
custo = custo por fardo de roupa i na lavanderia j
horas = tempo para lavar o fardo i na lavanderia j
itens: = itens a serem lavados
tempo = tempo de funcionamento das lavanderias j
x = variável de decisão

Max f(x1...n) = soma (i in 1..m, j in 1..n) custo(i,j)*x(i,j)

s.a.

para (j de 1..n): soma (i de 1..m) horas (j,i) * x (i,j) <= tempo (j)
para (i de 1..m, j in 1..n) x (i,j) >= 0
para (i de 1..m): soma (j de 1..n) horas (j,i) * x (i,j) = itens (i)

B - MODELO IMPLEMENTADO NO XPRESS – Não existe uma solução possivel


para o modelo devido à restrição “tempo”.

uses "mmxprs"; !gain access to the Xpress-Optimizer solver

!sample declarations section

declarations
m = 3 !quantidade de itens a serem entregues para lavanderia
n = 4 !quantidade de lavanderias
custo: array (1..m, 1..n) of real
horas: array (1..m, 1..n) of real
itens: array (1..m) of real
tempo: array (1..n) of real
x: array (1..m, 1..n) of mpvar
end-declarations

custo:: [ 30, 25, 35, 30,


50, 60, 45, 55,
30, 40, 30, 35]

horas:: [ 1, 1.5, 2, 2,
2.5, 1.5, 3, 3.5,
3, 2.5, 3, 2.5]

itens:: [ 20, 40, 35]

tempo:: [ 12, 12, 12, 12]

!funcao objetivo

Custototal:= sum (i in 1..m, j in 1..n) custo(i,j)*x(i,j)

!Restricoes

!Nao negatividade
forall (i in 1..m, j in 1..n) x(i,j) >= 0

!Demanda

forall (i in 1..m) sum(j in 1..n) x(i,j) = itens (i)

!Tempo

forall (j in 1..n) sum (i in 1..m) horas (i,j)*x(i,j) <= tempo (j)

!solucao do modelo

minimize(Custototal)

writeln("Funcao objetivo:", getobjval)

forall (i in 1..m, j in 1..n)


writeln("x(",i,",",j,")=", getsol(x(i,j)))

end-model
3 – MODELO XPRESS COM SOLUCAO – PARA VIABILIZAR A SOLUCAO O
VETOR B FOI MODIFICADO PARA B = [100, 100, 100, 100, 100]

declarations
m = 5 !quantidade de maquinas
n = 15 !quantidade de tarefas
a: array (1..m, 1..n) of real
c: array (1..m, 1..n) of real
b: array (1..m) of real
x: array (1..m, 1..n) of mpvar

end-declarations

c:: [ 17, 21, 22, 18, 24, 15, 20, 18, 19, 18, 16, 22, 24, 24, 16,
23, 16, 21, 16, 17, 16, 19, 25, 18, 21, 17, 15, 25, 17, 24,
16, 20, 16, 25, 24, 16, 17, 19, 19, 18, 20, 16, 17, 21, 24,
19, 19, 22, 22, 20, 16, 19, 17, 21, 19, 25, 23, 25, 25, 25,
18, 19, 15, 15, 21, 25, 16, 16, 23, 15, 22, 17, 19, 22, 24 ]

a:: [ 18, 19, 15, 15, 21, 25, 16, 16, 23, 15, 22, 17, 19, 22, 24,
19, 19, 22, 22, 20, 16, 19, 17, 21, 19, 25, 23, 25, 25, 25,
16, 20, 16, 25, 24, 16, 17, 19, 19, 18, 20, 16, 17, 21, 24,
23, 16, 21, 16, 17, 16, 19, 25, 18, 21, 17, 15, 25, 17, 24,
17, 21, 22, 18, 24, 15, 20, 18, 19, 18, 16, 22, 24, 24, 16 ]

b:: [ 100, 100, 100, 100, 100 ]

!funcao objetivo

rotina := sum (i in 1..m, j in 1..n) c(i,j)*x(i,j)

!Restricoes

forall(i in 1..m) sum (j in 1..n) a(i,j)*x(i,j) <= b(i)

forall(j in 1..n) sum (i in 1..m) x(i,j) = 1

forall(i in 1..m, j in 1..n) x(i,j) is_binary

minimize(rotina)

writeln("Funcao objetivo:", getobjval )

forall (i in 1..m, j in 1..n)


write("x(",i,",",j,")=", getsol(x(i,j)))

end-model

Funcao objetivo:241

x(1,1)=
x(1,2)=0 x(1,3)=0 x(1,4)=0 x(1,5)=0 x(1,6)=1 x(1,7)=0 x(1,8)=0 x(1,9)=1 x(1,10)=0 x(1,11)=1 x(1,12)=0 x(1,13)=0 x(1,14)=0 x(1,15)=1
0

x(2,1)=
x(2,2)=1 x(2,3)=0 x(2,4)=0 x(2,5)=1 x(2,6)=0 x(2,7)=0 x(2,8)=0 x(2,9)=0 x(2,10)=0 x(2,11)=0 x(2,12)=1 x(2,13)=0 x(2,14)=1 x(2,15)=0
0
x(3,1)=
x(3,2)=0 x(3,3)=0 x(3,4)=0 x(3,5)=0 x(3,6)=0 x(3,7)=0 x(3,8)=0 x(3,9)=0 x(3,10)=0 x(3,11)=0 x(3,12)=0 x(3,13)=1 x(3,14)=0 x(3,15)=0
1

x(4,1)=
x(4,2)=0 x(4,3)=0 x(4,4)=0 x(4,5)=0 x(4,6)=0 x(4,7)=0 x(4,8)=0 x(4,9)=0 x(4,10)=0 x(4,11)=0 x(4,12)=0 x(4,13)=0 x(4,14)=0 x(4,15)=0
0

x(5,1)=
x(5,2)=0 x(5,3)=1 x(5,4)=1 x(5,5)=0 x(5,6)=0 x(5,7)=1 x(5,8)=1 x(5,9)=0 x(5,10)=1 x(5,11)=0 x(5,12)=0 x(5,13)=0 x(5,14)=0 x(5,15)=0
0

Você também pode gostar