Professional Documents
Culture Documents
GCC111 Projeto e Análise de Algoritmos: Mayron César O. Moreira
GCC111 Projeto e Análise de Algoritmos: Mayron César O. Moreira
GCC111 Projeto e Análise de Algoritmos: Mayron César O. Moreira
mayron.moreira@dcc.ua.br
6 de maio de 2015
GCC111 PAA
6 de maio de 2015
1 / 23
Contedo
Algoritmos Gulosos
GCC111 PAA
6 de maio de 2015
2 / 23
Algoritmos Gulosos
Contexto
Utilizados com frequncia na resoluo de problemas de otimizao;
GCC111 PAA
6 de maio de 2015
3 / 23
Discrete Optimization
a r t i c l e
i n f o
Article history:
Received 30 May 2013
Accepted 27 June 2014
Available online 8 July 2014
Keywords:
Multiobjective optimization
Biobjective optimization
GRASP
Path Relinking
a b s t r a c t
In this paper we review and propose different adaptations of the GRASP metaheuristic to solve multiobjective combinatorial optimization problems. In particular, we describe several alternatives to specialize
the construction and improvement components of GRASP when two or more objectives are considered.
GRASP has been successfully coupled with Path Relinking for single-objective optimization. Moreover, we
propose different hybridizations of GRASP and Path Relinking for multiobjective optimization. We apply
the proposed GRASP with Path Relinking variants to two combinatorial optimization problems, the
biobjective orienteering problem and the biobjective path dissimilarity problem. We report on empirical
tests with 70 instances and 30 algorithms, that show that the proposed heuristics are competitive with
the state-of-the-art methods for these problems.
2014 Elsevier B.V. All rights reserved.
GCC111 PAA
6 de maio de 2015
4 / 23
art ic l e i nf o
a b s t r a c t
Article history:
Received 2 October 2014
Received in revised form
1 April 2015
Accepted 7 April 2015
Software requirements selection is a problem which consists of choosing the set of new requirements
which will be included in the next release of a software package. This NP-hard problem is an important
issue involving several contradictory objectives which have to be tackled by software companies when
developing new releases of software packages. Software projects have to stick to a budget, but they also
have to satisfy the highest number of customer requirements. Furthermore, when managing real
instances of the problem, the requirements tackled suffer interactions and other restrictions which make
the problem even harder. In this paper, a novel multi-objective teaching learning based optimization
(TLBO) algorithm has been successfully applied to several instances of the problem. For doing this, the
software requirements selection problem has been formulated as a multiobjective optimization problem
with two objectives: the total software development cost and the overall customer's satisfaction. In
addition, three interaction constraints have been also managed. In this context, the original TLBO
algorithm has been adapted to solve real instances of the problem generated from data provided by
experts. Numerical experiments with case studies on software requirements selection have been carried
out in order to prove the effectiveness of the multiobjective proposal. In fact, the obtained results show
that the developed algorithm performs better than other relevant algorithms previously published in the
literature.
& 2015 Elsevier Ltd. All rights reserved.
Keywords:
Software requirements selection
Multi-objective evolutionary algorithm
Teaching learning based optimization
Search Based Software Engineering
Next Release Problem
Swarm intelligence
GCC111 PAA
6 de maio de 2015
5 / 23
INTERNATIONAL
TRANSACTIONS
IN OPERATIONAL
RESEARCH
Department of Mathematics and Applications R. Caccioppoli, University of Napoli FEDERICO II, Compl. MSA, Via
Cintia, 80126 Napoli, Italy
Algorithms and Optimization Research Department, AT&T Labs Research, 180 Park Avenue, Room C241, Florham Park
NJ 07932, USA
E-mail: danieleferone@gmail.com [Ferone]; paola.festa@unina.it [Festa]; mgcr@research.att.com [Resende]
Received 29 January 2014; received in revised form 23 January 2015; accepted 7 March 2015
Abstract
Among the sequence selection and comparison problems, the far from most string problem (FFMSP) is one
of the computationally hardest with applications in several fields, including molecular biology where one
is interested in creating diagnostic probes for bacterial infections or in discovering potential drug targets.
In this paper, we describe several heuristics that hybridize GRASP with different path-relinking strategies,
such as forward, backward, mixed, greedy randomized adaptive forward, and evolutionary path relinking.
Experiments
on a(UFLA)
large set of both real-world
and randomly
indicate
these hybrid
Mayron Csar
O. Moreira
GCC111
PAA generated test instances
6 de
maio that
de 2015
6 / 23
Algoritmos Gulosos
Contexto
Utilizados com frequncia na resoluo de problemas de otimizao;
Toma a melhor deciso local, independente do que v acontecer no
futuro;
Possui abordagem top-down;
Em problemas com subestrutura tima, garante a otimalidade da
soluo.
GCC111 PAA
6 de maio de 2015
7 / 23
Algoritmos Gulosos
Conjunto guloso(Conjunto C ) {
S = ;
while((C 6= && not soluo(S))) {
x = seleciona(C );
C = C x;
if(vivel(S + x)) S = S + x;
}
if(soluo(S)) return S;
else return (No existe soluo);
}
GCC111 PAA
6 de maio de 2015
8 / 23
S = {a1 , a2 , ..., an }:
conjunto de
recurso;
ai possui um tempo
si < fi < ;
Cada atividade
trmino fi , 0
Se selecionada, a atividade
ai
de incio
si
e um tempo de
[si , fi ).
Restrio
As atividades no podem ser realizadas em um mesmo intervalo de
tempo, isto , o recurso disponvel para apenas uma atividade por
vez.
GCC111 PAA
6 de maio de 2015
9 / 23
ai e aj so compatveis
si fj ou sj fi
As atividades
ou seja,
i
si
fi
12
10
14
16
12
11
GCC111 PAA
10
11
6 de maio de 2015
10 / 23
ai e aj so compatveis
si fj ou sj fi
As atividades
ou seja,
i
si
fi
10
11
12
10
14
16
12
11
Atividades compatveis:
GCC111 PAA
6 de maio de 2015
10 / 23
ai e aj so compatveis
si fj ou sj fi
As atividades
ou seja,
i
si
fi
1
1
4
2
0
6
3
5
9
10
11
12
10
14
16
12
11
Atividades compatveis:
a1 , a3 ;
GCC111 PAA
6 de maio de 2015
10 / 23
ai e aj so compatveis
si fj ou sj fi
As atividades
ou seja,
i
si
fi
1
1
4
2
0
6
10
14
6
12
16
10
3
5
11
12
11
Atividades compatveis:
a1 , a3 ;
a2 , a6 ;
GCC111 PAA
6 de maio de 2015
10 / 23
ai e aj so compatveis
si fj ou sj fi
As atividades
ou seja,
i
si
fi
12
10
14
16
7
3
5
10
12
11
8
11
Atividades compatveis:
a1 , a3 ;
a2 , a6 ;
a7 , a11 ;
etc.
Mayron Csar O. Moreira (UFLA)
GCC111 PAA
6 de maio de 2015
10 / 23
Objetivo
Selecionar um subconjunto de tamanho mximo de atividades mutuamente
compatveis.
Ideia
Ordenar as atividades em ordem crescente de tempo de trmino:
f1 f2 ... fn1 fn .
GCC111 PAA
6 de maio de 2015
11 / 23
Ideia
Ordenar as atividades em ordem crescente de tempo de trmino:
f1 f2 ... fn1 fn .
i
si
fi
10
11
12
10
11
12
14
16
GCC111 PAA
6 de maio de 2015
11 / 23
Ideia
Ordenar as atividades em ordem crescente de tempo de trmino:
f1 f2 ... fn1 fn .
i
si
fi
3
0
6
10
11
GCC111 PAA
9
8
12
10
2
14
11
12
16
6 de maio de 2015
11 / 23
Ideia
Ordenar as atividades em ordem crescente de tempo de trmino:
f1 f2 ... fn1 fn .
i
si
fi
1
1
4
2
3
5
3
0
6
4
5
7
10
11
GCC111 PAA
9
8
12
10
2
14
11
12
16
6 de maio de 2015
11 / 23
ai
Sij
Tomemos
Sij = , i j
(Por que?
S10,2
aj .
faria sentido?).
GCC111 PAA
6 de maio de 2015
12 / 23
ai
Sij
Tomemos
Sij = , i j
Considere
Aij
(Por que?
S10,2
aj .
faria sentido?).
Sik
ak .
Skj ;
GCC111 PAA
6 de maio de 2015
12 / 23
ai
Sij
Tomemos
Sij = , i j
Considere
Aij
(Por que?
S10,2
aj .
faria sentido?).
Sik
ak .
Skj ;
e
GCC111 PAA
6 de maio de 2015
12 / 23
ai
Sij
Tomemos
Sij = , i j
Considere
Aij
(Por que?
S10,2
aj .
faria sentido?).
Sik
Sejam
Ento
ak .
Skj ;
e
GCC111 PAA
6 de maio de 2015
12 / 23
ai
Sij
Tomemos
Sij = , i j
Considere
Aij
(Por que?
S10,2
aj .
faria sentido?).
Sik
ak .
Skj ;
Sejam
Ento
0
onde A kj
>
GCC111 PAA
A0 kj
Akj ;
6 de maio de 2015
12 / 23
ai
Sij
Tomemos
Sij = , i j
Considere
Aij
(Por que?
S10,2
aj .
faria sentido?).
Sik
ak .
Skj ;
Sejam
Ento
A0 kj
0
> Akj . Poderamos utilizar A kj ao invs de Akj ;
0
Assim, |Aik | + |A kj | + 1 > |Aik | + |Akj | + 1 = |Aij |, o que contrdiz a
Pelo argumento usual de recortar e colar, suponha que exista
0
onde A kj
hiptese que
Aij
a tima;
GCC111 PAA
6 de maio de 2015
12 / 23
(
c[i, j] =
0,
max {c[i, k]
ak Sij
+ c[k, j] + 1},
GCC111 PAA
Sij = ,
Sij 6= .
6 de maio de 2015
13 / 23
Dvida
A escolha gulosa sempre parte de alguma soluo tima?
GCC111 PAA
6 de maio de 2015
14 / 23
Dvida
A escolha gulosa sempre parte de alguma soluo tima?
Sk 6=
e seja
am
am
uma atividade em
Sk
GCC111 PAA
Sk .
6 de maio de 2015
14 / 23
REC-SELECAO-ATIV(s, f , k, n)
m =k +1
while(m n e s[m] < f [k])
m =m+1
if m n
return {am } Rec-Selecao-Ativ(s, f , m, n)
else
return
GCC111 PAA
6 de maio de 2015
15 / 23
REC-SELECAO-ATIV(s, f , k, n)
m =k +1
while(m n e s[m] < f [k])
m =m+1
if m n
return {am } Rec-Selecao-Ativ(s, f , m, n)
else
return
Primeira chamada recursiva: REC-SELECAO-ATIV(s, f , 0, 11)
i
si
fi
10
11
GCC111 PAA
10
11
12
12
14
16
6 de maio de 2015
15 / 23
SELECAO-ATIV(s, f )
A = {a1 }
k=1
for m = 2 to n
if s[m] f [k]
A = A {am }
k =m
return A
GCC111 PAA
6 de maio de 2015
16 / 23
SELECAO-ATIV(s, f )
A = {a1 }
k=1
for m = 2 to n
if s[m] f [k]
A = A {am }
k =m
return A
i
si
fi
10
11
12
10
11
12
14
16
GCC111 PAA
6 de maio de 2015
16 / 23
Perguntas
Em vez de priorizar a primeira atividade a terminar, e se escolhermos a
ltima a atividade a comear. O que mudaria?
Outras formar de selecionar uma tarefa, tais como priorizar a que
possui menor durao ou a que se sobrepe ao menor nmero de
outras atividades, possuem o mesmo efeito quanto otimalidade?
GCC111 PAA
6 de maio de 2015
17 / 23
GCC111 PAA
6 de maio de 2015
18 / 23
GCC111 PAA
6 de maio de 2015
18 / 23
GCC111 PAA
6 de maio de 2015
18 / 23
Subestrutura tima
Devemos mostrar que uma soluo tima para o subproblema,
combinada com a escolha gulosa j feita, produz uma soluo tima
para o problema original;
Uso implcito do princpio da induo: fazer a escolha gulosa em cada
etapa produz uma soluo tima.
GCC111 PAA
6 de maio de 2015
19 / 23
n
vi , wi Z+ .
wi
quilos, em que
itens. O
i -simo
item vale
vi
deve levar?
GCC111 PAA
6 de maio de 2015
20 / 23
n
vi , wi Z+ .
wi
quilos, em que
itens. O
i -simo
item vale
vi
deve levar?
GCC111 PAA
6 de maio de 2015
20 / 23
w3 = 30kg .
vi
wi ;
GCC111 PAA
6 de maio de 2015
21 / 23
w3 = 30kg .
vi
wi ;
GCC111 PAA
vi
wi ;
6 de maio de 2015
21 / 23
w3 = 30kg .
vi
wi ;
vi
wi ;
GCC111 PAA
6 de maio de 2015
21 / 23
w3 = 30kg .
vi
wi ;
vi
wi ;
GCC111 PAA
6 de maio de 2015
21 / 23
w3 = 30kg .
vi
wi ;
vi
wi ;
Soluo:
f =
vi wi = $240.
GCC111 PAA
20
30 do item 3, com
6 de maio de 2015
21 / 23
w3 = 30kg .
vi
wi ;
vi
wi ;
Soluo:
f =
vi wi = $240.
Complexidade: O(nlgn).
20
30 do item 3, com
GCC111 PAA
6 de maio de 2015
21 / 23
Exemplo
Consideremos 3 itens no problema da mochila tais que
w3 = 30kg .
GCC111 PAA
$160;
6 de maio de 2015
22 / 23
Exemplo
Consideremos 3 itens no problema da mochila tais que
w3 = 30kg .
$160;
$180;
GCC111 PAA
6 de maio de 2015
22 / 23
Exemplo
Consideremos 3 itens no problema da mochila tais que
w3 = 30kg .
$160;
$180;
Soluo 3 (tima):
GCC111 PAA
$220.
6 de maio de 2015
22 / 23
Outros exemplos
GCC111 PAA
6 de maio de 2015
23 / 23