Você está na página 1de 9

Caixeiro viajante

Algoritmos Genéticos

aula 2 - exemplos

prof. Luis Otavio Alvares prof. Luis Otavio Alvares

Caixeiro viajante Exemplo: recombinação de 2 pontos


1 2
• representação intuitiva de indivíduo: o próprio
caminho
A B CDE F GHI A B CA HGF HI
D E B A H G F I C
DE B A HGF I C DE B DE F GI C

Cidades repetidas - inválido!!!


• problema:
bl crossover

prof. Luis Otavio Alvares prof. Luis Otavio Alvares


PMX - partially mapped crossover OX - ordered crossover
1 2
1 2

A B CDE F GHI x x x A HGF x x A B CDE F GHI x x x A HGF x x

DE B A HGF I C x x x DE F Gx x DE B A HGF I C x x x DE F Gx x

3
3 4

x B CA HGF x I DB CA HGF E I CDE A HGF I B 3- partindo do segundo ponto de


quebra,
b as cidades
id d ddo outro
t paii são
ã
copiadas na mesma ordem, omitindo
as cidades já presentes no filho
x x B DE F GI C A HB DE F GI C B A HDE F GI C
prof. Luis Otavio Alvares prof. Luis Otavio Alvares

exemplos de mutação 2opt method


• inversão: de duas cidades adjacentes AB e CD fazem parte do percurso
• inserção: seleciona uma cidade e a coloca se AB + CD > AC + BD então faço a troca
aleatoriamente em algum ponto para AC e BD
• deslocamento: seleciona um sub
sub-percurso
percurso e o
C
A
coloca aleatoriamente em algum ponto
• troca
t recíproca:
í troca de posição entre duas
D B
cidades
A C

D B
prof. Luis Otavio Alvares prof. Luis Otavio Alvares
Caixeiro viajante Trabalho de Jorge Meinhardt
Exemplos de programa • “O presente trabalho pretende mostrar a
possibilidade de uso de uma ferramenta
p
de inteligência artificial utilizando a
abordagem de algoritmo genético para
http://www.mac.cie.uva.es/~arratia/cursos/UVA/GeneticTSP/JAVASimultn/TSP.html auxílio ao projeto altimétrico de rodovias.”
http://www.dna-evolutions.com/dnaappletsample.html

prof. Luis Otavio Alvares prof. Luis Otavio Alvares

Outros exemplos De Jong e Otimização de Funções


• Robocup: p/ melhorar o drible, para melhorar a • De Jong, em sua tese “An analysis of the
condução da bola, etc...
behavior of a class of g
genetic adaptive
p
• ChicuxBot – Genetic Algorithm Configured Behavior
Network Multi-Agent for Quake II systems”, fez uma investigação cuidadosa
• tese de André Schneider: controle de robôs
da aplicação de algoritmos genéticos à
otimização de funções.

prof. Luis Otavio Alvares prof. Luis Otavio Alvares


prof. Luis Otavio Alvares prof. Luis Otavio Alvares

prof. Luis Otavio Alvares prof. Luis Otavio Alvares


An Evolutionaryy Behavior Tool for
Reactive Multi-agent Systems

Andre Zanki Cordenonsi Luis Otávio Alvares


andrezc@unifra.br alvares@inf.ufrgs.br
Centro Universitário Franciscano Universidade Federal do Rio Grande do Sul
Área de Ciências Exatas Instituto de Informática
Rua dos Andradas 1614 Av. Bento Gonçalves, 9500
Centro - Santa Maria – RS Bairro Agronomia - Porto Alegre - RS -Brasil
CEP 97010 - 032 CEP 91501-970 Caixa Postal: 15064

prof. Luis Otavio Alvares prof. Luis Otavio Alvares

1. Introduction (…)
( ) 1. Introduction (…)
( )

Wh tto use an E
Why Evolutionary
l ti R
Reactive
ti M Multi-agent
lti t Systems
S t ? P i
Previous work:
k th
the Si
Simula
l TTool!
l! [F
[Frozza]]
- adaptation to dynamically environments A graphical tool to teach the multi-agent technology
developed in the Instituto de Informática – UFRGS by
- adaptation to unknown environments
Rejane Frozza and Luis Otávio Alvares

Objective of this paper: shows the specification and


A tool to simulate reactive multi-agent
g systems,
y , using
ga
implementation of an Evolutionary Reactive Multi
Multi-agent
agent
graphical interface to build the agents behavior and to shows
Systems where the behavior of the agents can be modified
the simulation.
during the simulation

prof. Luis Otavio Alvares prof. Luis Otavio Alvares


3. Simula ++ 3. Simula ++ (…)
( )

Cl
Class off agents
t and
d th
the B
Behavior
h i
- Reactive Multi-agent Systems Agent 00
- Didactic tool Rule A
Class X Agent 01
Rule B
- Graphical User Interface Rule A R l A
Rule
Rule C Agent 02
Rule B Rule B
Rule A
Rule C Rule C
Rule B
Rule C

Initial State

prof. Luis Otavio Alvares prof. Luis Otavio Alvares

3. Simula ++ (…)
( ) 3. Simula ++ (…)
( )

E hA
Each Agentt has
h I d
Independent
d t Elements
El t ( equall ffor allll agents
t off the
th same class
l )
- Set of Independent Elements - Initial Energy
- Chromosome ( set of rules ) - Energy Amount
- Maximum Life Time
- Life Time
- Sexual Maturity Time
- New Generation Time

prof. Luis Otavio Alvares prof. Luis Otavio Alvares


3. Simula ++ (…)
( ) 3. Simula ++ (…)
( )
The new Generation Algorithm
Ch
Chromosome: th
the rule
l characteristics
h t i ti
yes
- declarative LT > SMT reach NGT
no
RULE A
- precondition priority = 7 no
no yes

- action if (not perceive agent A) then


LT == SMT Execute Action
random_move();
- priority
yes

Insert Agent Fertile Agents New Offspring !

prof. Luis Otavio Alvares prof. Luis Otavio Alvares

4. Genetic Operators
p 4. Genetic Operators
p ((…))

O P i tE
One-Point External
t lCCrossover T
Two-Point
P i tEExternal
t lCCrossover I t
Internal
l Crossover
C
Agent 00
Agent 00 Agent 01 Agent 00 Agent 01 IF perceive
i Agent
A A AND not perceive
i A Agent B

Rule A Rule E Rule A Rule E THEN random move


IF is Load Offspring
p g
Rule B Rule F Rule B Rule F
THEN search base IF perceive Agent A OR not perceive Agent B
Rule C Rule G Rule C Rule G
THEN random move
Agent
g 01 IF is not Load
Offspring Offspring IF not perceive Agent A OR not perceive Agent B THEN search base
Rule A Rule A THEN search mine
Rule F Rule F IF is
i nott Load
L d
Rule G Rule C THEN search mine

prof. Luis Otavio Alvares prof. Luis Otavio Alvares


4. Genetic Operators
p ((…)) 5. Food Foraging
g g Problem

M t ti
Mutation - C ll t allll minerals
Collect i l ffrom an unknown
k environment
i t
- between 1% and 2% - The environment is a grid ( 100 x 100 )
- change pieces of a rule (respecting the semantic value) - Base is fixed
AND/OR - All agents known where is the base
Agent A, Agent B, Agent C, … - There are three mines, with 100 units of mineral
perceive_agent, search_agent, escape_from_agent,…

prof. Luis Otavio Alvares prof. Luis Otavio Alvares

5. Food Foraging
g g Problem ((…)) 5. Food Foraging
g g Problem ((…))

It was defined
d fi d six
i simulation
i l ti groups: St d d Group
Standard G (evolved
( l d by
b th
the evolutionary
l ti algorithm)
l ith )
IF NOT perceive (Mine) AND NOT perceive (Robot)
- Petit Poucet I [Drougol]
THEN random move
- Petit Poucet II [Drougol] IF NOT perceive (Mine) AND perceive (Robot)
THEN follows (Robot)
- Petit Poucet III [Drougol]
IF NOT perceive (Mine) AND reach (Robot)
- Dockers [Drougol] THEN flee (Robot)
IF perceive (Mine)
- Evolutionary Group
THEN load AND return to base AND leave (Mark Track)
- Standard Group IF perceive (Mark Track)
THEN follows(Mark Track) AND remove(Mark Track)

prof. Luis Otavio Alvares prof. Luis Otavio Alvares


5. Food Foraging
g g Problem ((…))
12000
Simulation steps
Programação Genética
10000

8000
• Programação
P ã genética
é i é uma técnica
é i automática
ái dde programação
ã
E Group
S Group que propicia a evolução de programas de computadores que
6000
resolvem (ou aproximadamente resolvem) problemas
4000

2000
• Na programação genética, os indivíduos da população não são
0 seqüências de bits,
bits mas sim programas de computador
1

11

16

21

26

31

36

41

46

51

56

61

66

71

76

81

86

91

96
armazenados na forma de árvores sintáticas. Tais programas é que
Number of Robots
são os candidatos à solução do problema proposto.
PP1 PP2 PP3 Doc. E S
Time to collect all minerals 3351 5315 3519 1746 2303 2217

Minimum time to collect all minerals 1113 1607 1075 695 770 540

Number of Robots for the minimum time 64 98 87 84 95 95

prof. Luis Otavio Alvares prof. Luis Otavio Alvares

Programação genética
Referências

Koza, J.R. 1990, Genetic Programming: A Paradigm for Genetically Breeding


Populations of Computer Programs to Solve Problems, Stanford University
Computer Science

Koza, John R. 1992. Genetic Programming: On the Programming of


Computers by Means of Natural Selection. Cambridge, MA: The MIT Press.

Congressos e workshops específicos sobre o assunto

prof. Luis Otavio Alvares prof. Luis Otavio Alvares

Você também pode gostar