1 logic aided lamarckian evolution evelina lamma (1), fabrizio riguzzi (2), luís moniz pereira (3)...
Post on 18-Dec-2015
216 views
TRANSCRIPT
1
Logic Aided Lamarckian Evolution
Evelina Lamma(1), Fabrizio Riguzzi(2), Luís Moniz Pereira(3)
(1) DEIS, University of Bologna, Italy(2) DI, University of Ferrara, Italy
(3) CENTRIA, Departamento de Informática Universidade Nova de Lisboa, Portugal
2
Summary
Genetic algorithms Lamarckian operator Multi-agent genetic algorithms Genes and Memes Multi-agent Crossover Belief revision Evolutionary approach to belief revision Example Experiments Conclusions
3
Genetic Algorithms
Darwinian operators: selection mutation crossover
4
Lamarckian operator
Given a chromosome: express it as a phenotype modify the phenotype in order to
improve its fitness translate back the phenotype into a
genotypeModel of cultural evolutionConcept of “meme”
5
GA in Multi Agent Systems (MAS)
MAS: communication of knowledge by means of explicit messages
New: communication of knowledge by exchange of genes and memes
If the number of agents is fixed, each has a pool of chromosomes of its own; or each agent is a single chromosome and there is a single pool of agents
6
Genetic Operators
Crossover: used in order to exchange genes and memes among agents a chromosome in an agent is crossed
with chromosomes from other agents
Lamarckian operator: used to locally improve the fitness by experience-directed self-mutation
7
Genes and Memes
Genes are modified only by Darwinian operators individual “physical” features are fixed inherited irrespective of parental learning
Memes are modified by Darwinian and Lamarckian operators individual “cultural” features are changeable inherited via parental learning
8
Asymmetrical flow of memes
Memes only go from teacher to learnerIn crossover:
genes are copied from both parents
memes are copied from another agent only if that agent has “accessed” and “tagged” them:
• accessed: confirmed or modified after an application of the Lamarckian operator
• tagged: an extra bit is associated to each meme in order to code whether the meme has been accessed.
9
Multi-agent crossover
A new agent offspring is produced from two parent chromosomes one parent comes from the pool of another agent bits from each parent are copied according to a
mask
The mask is such that: genes are selected randomly, half from each parent memes are selected randomly, half from memes in
the other agent, but only if they have been accessed
10
Multiagent crossover
1 0 0 0 1 1 1
0 1 1 1
0 1 0 1 1 1 0
1 1 0 0
1 1 0 0 1 1 0
0 1 0 0 1 1 1
0 0 0 0
Mask
1 – take from Ag1
0 – take from Ag2
Ag1
tags
Ag2
tags
child in Ag1pool
genesmemes
11
Genetic algorithm (GA)
GA(max_gen, p, r ,m, l, Fitness)
max_gen : maximum number of generations before termination
p : number of individuals in the population
r : fraction of population to be replaced by crossover at each step
m : fraction of population to be mutated
l : fraction of population that evolves Lamarckianly
Fitness : fitness function F(hi)
12
Genetic algorithm
GA(max_gen, p, r ,m, l, Fitness)Initialize population P := set of p hypotheses randomly
generatedgen :=0while gen <= max_gen
Generate PS by applying the following operators to P :
selectioncrossovermutationLamarck
update: P := PS
return the hypothesis from PS with the highest fitness
13
Genetic operators
select: select (1- r) p hypotheses from P with a probability Pb proportional to their fitness and add them to PS
crossover: for i:=1 to r pselect h1 from P with probability Pb
select h2 from another agent chosen at random
crossover h1 with h2 obtaining h’1, add h’1 to PS
mutate: choose m percent of the members of PS with uniform probability
and, for each, invert randomly one bit
Lamarck: choose l p hypotheses from PS with uniform probability and apply to them the Lamarckian operator
14
How to mutate and tag memes
Use belief revison to tag memes
Follow the chain of logical steps forward, from assumptions (memes) to conclusions (predictions)
When predictions differ from experience (observation), follow the logical steps backward to those assumptions (memes) supporting the predictions
Confirm or mutate, and tag those memes
15
Simple revision example (1)
P: flies(X) bird(X), not ab(X). bird(a) .
ab(X) penguin(X).• We learn penguin(a).
P {penguin(a)} is consistent. Nothing more to be done.• We learn instead ¬flies(a).
P {¬flies(a)} is inconsistent. What to do?
Since the inconsistency rests on the assumption not ab(a), remove that assumption (e.g. by adding the fact ab(a), or forcing it undefined with ab(a) u) obtaining a new program P’.
If an assumption supports contradiction, then go back on that assumption.
16
Simple revision example (2)P: flies(X) bird(X), not ab(X). bird(a) .
ab(X) penguin(X).
If an assumption supports contradiction, then go back on that assumption.
If later we learn flies(a).
P’ {flies(a)} is inconsistent.
The contradiction does not depend on assumptions.
Cannot remove contradiction!
Some programs are non-revisable.
17
What to remove?
Which assumptions should be removed?normalWheel not flatTyre, not brokenSpokes.
flatTyre leakyValve. ¬normalWheel wobblyWheel.
flatTyre puncturedTube. wobblyWheel .
Contradiction can be removed by either dropping not flatTyre or not brokenSpokes
We’d like to delve deeper in the model and (instead of not flatTyre) either drop not leakyValve or not puncturedTube.
18
Revisables
Revisables = not {leakyValve, punctureTube, brokenSpokes}
Revisions in this case are {not lv}, {not pt}, and {not bs}
Solution: Define a set of revisables:
normalWheel not flatTyre, not brokenSpokes.
flatTyre leakyValve. ¬normalWheel wobblyWheel.
flatTyre puncturedTube. wobblyWheel .
19
Integrity Constraints
For convenience, instead of:¬normalWheel wobblyWheel
we may use the denial: normalWheel, wobblyWheel
Can further generalize ICs into:L1 … Ln Ln+1 … Lm
where Lis are literals (possibly not L).
20
ICs and Contradiction
In an ELP with ICs, add for every atom A: A, ¬A
A program P is contradictory iff P
where is the paraconsistent derivation of SLX
21
ExampleRev = not {a,b,c}
p, q
p not a.
q not b, r.
r not b.
r not c.
p q
not a r not b
not b not c
Support sets are:{not a, not b}and {not a, not b, not c}.
Removal sets are: {not a} and {not b}.
22
Example
In 2-valued revision: some removals must be deleted; the process must be iterated.
p. a. b, not c.p not a, not b.
a
X
p
not a not bb not c
XThe only support is {not a, not b}.Removals are {not a} and {not b}.
• P U {a} is contradictory (and unrevisable).• P U {b} is contradictory (though revisable).
But:
23
Algorithm for 2-valued revision
1 Let Revs={{}}2 For every element R of Revs:
Add it to the program and compute removal sets. Remove R from Revs For each removal set RS:
Add R U not RS to Revs3 Remove non-minimal sets from Revs4 Repeat 2 and 3 until reaching a fixed point of Revs. The revisions are the elements of the final Revs.
24
• Choose {b}. The removal set of P U {b} is {not c}. Add {b, c} to Rev. • Choose {b,c}. The removal set of P U {b,c} is {}. Add {b, c} to Rev.
• Choose {}. Removal sets of P U {} are {not a} and {not b}. Add them to Rev.
Example of 2-valued revision p. a. b, not c.p not a, not b.
Rev0 = {{}}
Rev1 = {{a}, {b}}
• Choose {a}. P U {a} has no removal sets.
Rev2 = {{b}}
Rev3 = {{b,c}}
•The fixed point had been reached. P U {b,c} is the only revision.
= Rev4
25
Revision and Diagnosis
In model based diagnosis one has: a program P with the model of a system
(the correct and, possibly, incorrect behaviors)
a set of observations O inconsistent with P (or not explained by P).
The diagnoses of the system are the revisions of P U O.
26
Diagnosis Example
1
1
1
10
c1=0
c3=0
c6=0
c7=0
c2=0
0
1
g10
g11
g16
g19
g22
g23
27
Diagnosis Program Observablesobs(out(inpt0, c1), 0).obs(out(inpt0, c2), 0).obs(out(inpt0, c3), 0).obs(out(inpt0, c6), 0).obs(out(inpt0, c7), 0).obs(out(nand, g22), 0). obs(out(nand, g23), 1). Predicted and observed values cannot be different
obs(out(G, N), V1), val(out(G, N), V2), V1 V2.
Connectionsconn(in(nand, g10, 1), out(inpt0, c1)).conn(in(nand, g10, 2), out(inpt0, c3)).…conn(in(nand, g23, 1), out(nand, g16)).conn(in(nand, g23, 2), out(nand, g19)).
Value propagationval( in(T,N,Nr), V ) conn( in(T,N,Nr), out(T2,N2) ), val( out(T2,N2), V ).val( out(inpt0, N), V ) obs( out(inpt0, N), V ). Normal behaviorval( out(nand,N), V ) not ab(N), val( in(nand,N,1), W1), val( in(nand,N,2), W2),
nand_table(W1,W2,V). Abnormal behaviorval( out(nand,N), V ) ab(N), val( in(nand,N,1), W1), val( in(nand,N,2), W2),
and_table(W1,W2,V).
Run
28
Diagnosis Example
c1=0
c3=0
c6=0
c7=0
c2=0
0
1
g10
g11
g16
g19
g22
g23
Revision are:{ab(g23)}, {ab(g19)}, and {ab(g16),ab(g22)}
1
1
1
1 1
0
1
1
0
1 1
0
1
1
1
0 1
0
29
Belief Revision
Important functionality of agents.Problem definition. Given
an extended logic program containing integrity constraints, i.e.:
B1,…,Bn, not C1,…,not Cm
a set of revisable literals, i.e., literals for which the revision is allowed. They must not have any definition
Find…
30
Belief Revision
Find: a truth value for the revisable literals so
that the program is not contradictory, i.e., does not belong to the model of the program
31
GAs for Belief Revision
Genetic Algorithms can be used for Belief Revision: each revisable is encoded with a
meme the meme has value 1 if the revisable
is true and 0 if it is false each set of assumptions about the
values of revisables is coded as a chromosome
32
Fitness function
ni number of integrity constraints satisfied by hypothesis hi
n total number of integrity constraints
n
nhF i
i )(
33
Example
Digital circuit diagnosis
Revisable literals indicate the assumed behaviour mode of each gate:
not ab(gate) : gate behaves normally ab(gate): gate behaves abnormally
34
Example: circuit c17
g10
g11
g22
g16
g19g23
g6
g1
g3
g2
g7
0
0
0
1
0
0
1
1
1
0
11
1
obs
obs
35
Example: circuit c17
val( in(Type,Name,Nr), V ) :-
conn( in(Type,Name,Nr), out(Type2,Name2) ), val( out(Type2,Name2),
V ).
val( out(nand,Name), V ) :- not ab(Name), val( in(nand,Name,1), W1), val( in(nand,Name,2), W2), nand_table(W1,W2,V).
nand_table(0,0,1).…...
val( out(nand,Name), V ) :- ab(Name), val( in(nand,Name,1), W1), val( in(nand,Name,2), W2), and_table(W1,W2,V).
val( out(inpt0, Name), V ) :- obs( out(inpt0, Name), V ).
36
Topology
conn(in(nand, g10, 1), out(inpt0, g1)).
conn(in(nand, g10, 2), out(inpt0, g3)).
conn(in(nand, g11, 1), out(inpt0, g3)).
conn(in(nand, g11, 2), out(inpt0, g6)).
conn(in(nand, g16, 1), out(inpt0, g2)).
conn(in(nand, g16, 2), out(nand, g11)).
conn(in(nand, g19, 1), out(nand, g11)).conn(in(nand, g19, 2), out(inpt0, g7)).
conn(in(nand, g22, 1), out(nand, g10)).conn(in(nand, g22, 2), out(nand, g16)).
conn(in(nand, g23, 1), out(nand, g16)).conn(in(nand, g23, 2), out(nand, g19)).
37
Observations and constraints :- obs(out(nand, g22), 0), val(out(nand, g22), 1). :- obs(out(nand, g22), 1), val(out(nand, g22), 0). :- obs(out(nand, g23), 0), val(out(nand, g23), 1). :- obs(out(nand, g23), 1), val(out(nand, g23), 0).
obs(out(inpt0, g1), 0).obs(out(inpt0, g2), 1).obs(out(inpt0, g3), 0).obs(out(inpt0, g6), 0).obs(out(inpt0, g7), 0).obs(out(nand, g22), 0).obs(out(nand, g23), 1).
38
Diagnosis
One of the integrity constraints is violated: the observed output for g22 is
different from the computed output.
Contradiction is removed by assuming ab(g22)
which is a diagnosis for the circuit.
39
Belief Revision
Support Set: a support set of a literal L of a program P, denoted by SS(L), is a set of revisables sufficient to support a derivation of L in P
40
Belief Revision
Hitting set: a hitting set of for a collection of SS(L) is the union of one non-empty subset from each SS(L). It is minimal iff no proper subset is a hitting set.
A contradiction removal set is a hitting set for the SS().
41
Lamarckian operator
The Lamarckian operator uses techniques similar to BR ones.
It differs from BR because it starts from an arbitrary chromosome C
The Lamarckian support sets are all the support sets that are subsets of the current chromosome C
42
Lamarckian operator
find all the Lamarckian support sets for with respect to C
find a hitting set HS() for themchange in C all its literals which are
in HS().
43
Example: circuit c17
Suppose, initially: C={ab(g10), not ab(g11), ab(g16),
not ab(g19), not ab(g22), not ab(g23)}In this case, two constraints are
violated because out(g22)=1 and out(g23)=0
44
Example: circuit c17
A BR operator would return as changes to C: {not ab(g10), not ab(g11),
not ab(g16), not ab(g19), ab(g22), not ab(g23)}
these are consistent with both ICs
45
Example: circuit c17
Lamarckian support sets of : [not ab(g11),not ab(g19),not ab(g11),ab(g16),not ab(g23)] [not ab(g11),ab(g16),ab(g10),not ab(g22)]
Lamarck returns these changes to C, one for each hitting set: C={ab(g10), ab(g11), ab(g16),
not ab(g19), not ab(g22), not ab(g23)} C={ab(g10), not ab(g11), not ab(g16),
not ab(g19), not ab(g22), not ab(g23)} one constraint in either case is still violated
46
Experiments
ISCAS85 collection of benchmark digital circuits
Four algorithms considered:S-L: single agent GA without the
Lamarckian operatorM-L: as S-L but multi agentM+L-A: as M-L plus Lamarck, without
asymmetryM+L+A: as M+L-A plus asymmetry
47
Results
alu4_flat circuit 100 gates (100 revisables) 8 outputs (16 constraints) 4 agents, with same observations and
constraints 10 chromosomes each, l=0.6 5 experiments
Average fitness:
S-L M-L M+L-A M+L+A
Fitness 0.8958 0.9375 0.9583 0.9791
48
Conclusions
Framework for solving problems represented with logic: belief revision dynamic world, control of observable outputs
Performance improvement by distributed agents Lamarckian operator asymmetric crossover on memes
49
Future work
Situations where: agents do not have the same observations,
constraints or revisables observations change over time
Three-valued memes for expressing irrelevancy
Integrating Lamarckism with other agent features
50
THE END
[ab(c11gat),ab(c19gat),ab(c11gat),ab(c16gat),ab(c23gat)],[not ab(c11gat),ab(c19gat),ab(c11gat),ab(c16gat),ab(c23gat)],[ab(c11gat),not ab(c19gat),ab(c11gat),ab(c16gat),ab(c23gat)],[not ab(c11gat),not ab(c19gat),ab(c11gat),ab(c16gat),ab(c23gat)],[ab(c11gat),ab(c19gat),not ab(c11gat),ab(c16gat),ab(c23gat)],[not ab(c11gat),ab(c19gat),not ab(c11gat),ab(c16gat),ab(c23gat)],[ab(c11gat),ab(c19gat),ab(c11gat),not ab(c16gat),ab(c23gat)],[not ab(c11gat),ab(c19gat),ab(c11gat),not ab(c16gat),ab(c23gat)],[ab(c11gat),ab(c19gat),not ab(c11gat),not ab(c16gat),ab(c23gat)],[not ab(c11gat),ab(c19gat),not ab(c11gat),not ab(c16gat),ab(c23gat)],[ab(c11gat),not ab(c19gat),not ab(c11gat),not ab(c16gat),ab(c23gat)],[not ab(c11gat),not ab(c19gat),not ab(c11gat),not ab(c16gat),ab(c23gat)],[ab(c11gat),not ab(c19gat),not ab(c11gat),ab(c16gat),not ab(c23gat)],[not ab(c11gat),not ab(c19gat),not ab(c11gat),ab(c16gat),not ab(c23gat)],[ab(c11gat),not ab(c19gat),ab(c11gat),not ab(c16gat),not ab(c23gat)],[not ab(c11gat),not ab(c19gat),ab(c11gat),not ab(c16gat),not ab(c23gat)],[not ab(c11gat),ab(c16gat),not ab(c10gat),ab(c22gat)],[ab(c11gat),not ab(c16gat),not ab(c10gat),ab(c22gat)],[ab(c11gat),ab(c16gat),ab(c10gat),not ab(c22gat)],[not ab(c11gat),ab(c16gat),ab(c10gat),not ab(c22gat)],[ab(c11gat),not ab(c16gat),ab(c10gat),not ab(c22gat)],[not ab(c11gat),not ab(c16gat),ab(c10gat),not ab(c22gat)],[ab(c11gat),ab(c16gat),not ab(c10gat),not ab(c22gat)],[not ab(c11gat),not ab(c16gat),not ab(c10gat),not ab(c22gat)]
52
Belief Revision
Support Set: a support set of a literal L of a program P, denoted by SS(L), is obtained as follows: if L is not a revisable literal, then, for
each rule L B in P, there is one SS(L) given by the union of SS(Bi) for each Bi B. If B is empty then SS(L)={}
if L is a revisable literal then SS(L)={L}
53
Lamarckian operator
Lamarckian support set: given an hypothesis C, a Lamarckian support set of a literal L of a program P, denoted by SS(L), is obtained as follows:
if L is not a revisable literal, then, for each rule L B in P there is one SS(L) given by the union of SS(Bi) for each Bi B. If B is empty then SS(L)={}if L is a revisable literal then
if L belongs to C, then SS(L)={L}if L is not in C or the default complement belongs to C then the SS(L) under construction is not a support set
54
Results, single agent
Single agent, with and without the Lamarckian operator
Fitness function:
fi number of revisables of hi that are false
5.0)( i
iii h
f
n
nhF
Circuit l Fitness Correct solution0 1.175 100%voter
0.6 1.218 100%
0 1.296 0%alu4_flat
0.6 1.310 30%
55
Logic Programs RevisionThe problem:
A LP represents consistent incomplete knowledge;
New factual information comes.
How to incorporate the new information?
The solution: Add the new facts to
the program If the union is
consistent this is the result
Otherwise restore consistency to the union
The new problem: How to restore consistency to an
inconsistent program?
56
Algorithm for 3-valued revision
Find all derivations for , collecting for each one the set of revisables supporting it. Each is a support set.
Compute the minimal hitting sets of the support sets. Each is a removal set.
A revision of P is obtained by adding{A u: A R}
where R is a removal set of P.
57
2-valued Revision
In diagnosis one often wants the IC:ab(X) v not ab(X)
With these ICs (that are not denials), 3-valued revision is not enough.
A two valued revision is obtained by adding facts for revisables, in order to remove contradiction.
For 2-valued revision the algorithm no longer works…
58
Simple diagnosis exampleinv(G,I,0) node(I,1), not ab(G).inv(G,I,1) node(I,0), not ab(G).node(b,V) inv(g1,a,V).node(a,1).¬node(b,0).
%Fault modelinv(G,I,0) node(I,0), ab(G).inv(G,I,1) node(I,1), ab(G).
a=1 b0g1
The only revision is:P U {ab(g1) u}
It does not conclude node(b,1).
In diagnosis applications (when fault models are considered) 3-valued revision is not enough.
59
Abduction as Revision
For abductive queries:
Declare as revisable all the abducibles If the abductive query is Q, add the IC:
not Q The revision of the program are the
abductive solutions of Q.
60
Revision and Debugging
Declarative debugging can be seen as diagnosis of a program.
The components are: rule instances (that may be incorrect). predicate instances (that may be uncovered)
The (partial) intended meaning can be added as ICs.
If the program with ICs is contradictory, revisions are the possible bugs.
61
Debugging Transformation
Add to the body of each possibly incorrect rule r(X) the literal not incorrect(r(X)).
For each possibly uncovered predicate p(X) add the rule:
p(X) uncovered(p(X)).
For each goal G that you don’t want to prove add: G.
For each goal G that you want to prove add: not G.
62
Debugging example
a not b
b not c
WFM = {not a, b, not c}
b should be false
a not b, not incorrect(a not b)
b not c, not incorrect(b not c)a uncovered(a)b uncovered(b)c uncovered(c) bRevisables are incorrect/1 and uncovered/1
Revision is:
{incorrect(b not c)}
{uncovered(c)}
BUT a should be false!
Add a
Revisions now are:
{inc(b not c), inc(a not b)}
{unc(c ), inc(a not b)}
BUT c should be true!
Add not c
The only revision is:
{unc(c ), inc(a not b)}