Tuesday, October 2, 2012

Defining orderly mutation

How it is done now (or so we thought!)


not_mutated = true          
while not_mutated:          
 for bit in variable:        
  if rand(0,1)<probability:          
   if deselecting root feature: 
    continue         
   else if selecting feature whose parent is not selected:
    continue
   else if deselecting feature that another selected feature requires:
    continue
   else if cardinality violation: 
    continue
   else:
    flip(bit)       
    not_mutated = false     
    if isSelected(bit):     
     reselect(bit.children) 
    else:
     deselect(bit.children) 

How it might be done otherwise:

not_mutated = true     
     
while not_mutated:
 traverseTree(root)
     
function traverseTree(node):
 if rand(0,1)<probability:          
  if deselecting root feature: 
   continue         
  else if selecting feature whose parent is not selected:
   continue
  else if deselecting feature that another selected feature requires:
   continue
  else if cardinality violation: 
   continue
  else:
   flip(node.bit)       
   not_mutated = false     
   if isSelected(node.bit):     
    reselect(node.children) 
   else:
    deselect(node.children)
 if isSelected(node):
  for child in node:
   traverseTree(child)

No comments:

Post a Comment