Chapter 11 Boolean calculator problem (postfix notation)

Here, we give an overview of the boolean-logic calculator problem, and we provide our data analyses for related experiments. All of our source code for statistical analyses and data visualizations is embedded in this document. The raw data can be found on the OSF project associated with this work (Lalejini, Moreno, and Ofria 2020).

Please file an issue or make a pull request on github to report any mistakes, ask questions, request more explanation, et cetera.

11.1 Overview

We use a modified version of the Boolean-logic calculator problem to further investigate the potential for our implementation of tag-based regulation to impede adaptive evolution. Our previous experiments with the Boolean-logic calculator problem provided inputs in prefix notation: the operator (e.g., AND, OR, XOR, etc.) is specified first, followed by the requisite number of numeric operands. As such, the final input signal does not differentiate which type of computation a program is expected to perform (e.g., AND, OR, XOR, etc.). This requires programs to adjust their response to the final input signal based on the context provided by the previous two signals, thereby increasing the value of regulation.

We explore whether the calculator problem’s context-dependence is driving the benefit of tag-based regulation that we identified in previous experiments. We can reduce context-dependence of the calculator problem by presenting input sequences in postfix notation. In postfix notation, programs receive the requisite numeric operand inputs first and the operator input last. As such, the final signal in an input sequence will always differentiate which bitwise operation should be performed. Successful programs must store the numeric inputs embedded in operand signals, and then, as in the independent-signal problem, a distinct signal will differentiate which of the response types a program should execute.

11.2 Analysis Dependencies

Load all required R libraries.

These analyses were conducted in the following computing environment:

##                _                           
## platform       x86_64-pc-linux-gnu         
## arch           x86_64                      
## os             linux-gnu                   
## system         x86_64, linux-gnu           
## status                                     
## major          4                           
## minor          0.4                         
## year           2021                        
## month          02                          
## day            15                          
## svn rev        80002                       
## language       R                           
## version.string R version 4.0.4 (2021-02-15)
## nickname       Lost Library Book

11.3 Setup

Load data, initial data cleanup, configure some global settings.

data_loc <- paste0(working_directory, "data/max_fit_orgs.csv")
data <- read.csv(data_loc, na.strings="NONE")

# Specify factors (not all of these matter for this set of runs).
data$matchbin_thresh <- factor(
  data$matchbin_thresh,
  levels=c(0, 25, 50, 75)
)

data$TAG_LEN <- factor(
  data$TAG_LEN,
  levels=c(32, 64, 128, 256)
)

data$notation <- factor(
  data$notation,
  levels=c("prefix", "postfix")
)

# Define function to summarize regulation/memory configurations.
get_con <- function(reg, mem) {
  if (reg == "0" && mem == "0") {
    return("none")
  } else if (reg == "0" && mem=="1") {
    return("memory")
  } else if (reg=="1" && mem=="0") {
    return("regulation")
  } else if (reg=="1" && mem=="1") {
    return("both")
  } else {
    return("UNKNOWN")
  }
}

# Specify experimental condition for each datum.
data$condition <- mapply(
  get_con,
  data$USE_FUNC_REGULATION,
  data$USE_GLOBAL_MEMORY
)

data$condition <- factor(
  data$condition,
  levels=c("regulation", "memory", "none", "both")
)

# Given knockout info, what strategy does a program use?
get_strategy <- function(use_reg, use_mem) {
  if (use_reg=="0" && use_mem=="0") {
    return("use neither")
  } else if (use_reg=="0" && use_mem=="1") {
    return("use memory")
  } else if (use_reg=="1" && use_mem=="0") {
    return("use regulation")
  } else if (use_reg=="1" && use_mem=="1") {
    return("use both")
  } else {
    return("UNKNOWN")
  }
}

# Specify experimental conditions (to make labeling easier).
data$strategy <- mapply(
  get_strategy,
  data$relies_on_regulation,
  data$relies_on_global_memory
)

data$strategy <- factor(
  data$strategy,
  levels=c(
    "use regulation",
    "use memory",
    "use neither",
    "use both"
  )
)

# Filter data to include only replicates labeled as solutions
sol_data <- filter(data, solution=="1")

####### Load instruction execution data #######
inst_exec_data <- read.csv(paste0(working_directory, "data/exec_trace_summary.csv"), na.strings="NA")

inst_exec_data$condition <- mapply(
  get_con,
  inst_exec_data$USE_FUNC_REGULATION,
  inst_exec_data$USE_GLOBAL_MEMORY
)

inst_exec_data$condition <- factor(
  inst_exec_data$condition,
  levels=c("regulation", "memory", "none", "both")
)

inst_exec_data$notation <- factor(
  inst_exec_data$notation,
  levels=c("prefix", "postfix")
)

####### Load network data #######
reg_network_data <- read.csv(paste0(working_directory, "data/reg_graphs_summary.csv"), na.strings="NA")
reg_network_data <- filter(reg_network_data, run_id %in% data$SEED)

get_notation <- function(seed) {
  return(filter(data, SEED==seed)$notation)
}

reg_network_data$notation <- mapply(
  get_notation,
  reg_network_data$run_id
)

reg_network_data$notation <- factor(
  reg_network_data$notation,
  levels=c("prefix", "postfix")
)

####### misc #######
# Configure our default graphing theme
theme_set(theme_cowplot())

11.4 Problem-solving success

The number of successful replicates by condition:

Test for significance using Fisher’s exact test.

##              success fail
## reg-enabled      120   80
## reg-disabled     151   49
## 
##  Fisher's Exact Test for Count Data
## 
## data:  perf_table
## p-value = 0.001286
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3093253 0.7635173
## sample estimates:
## odds ratio 
##  0.4876392

11.5 How many generations elapse before solutions evolve?

Test for statistical difference between conditions using a Wilcoxon rank sum test.

## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  update by condition
## W = 7175.5, p-value = 0.003285
## alternative hypothesis: true location shift is not equal to 0
## 95 percent confidence interval:
##  -1422  -310
## sample estimates:
## difference in location 
##                   -872

11.6 Evolved strategies

11.6.3 Gene regulatory networks

Looking only at successful programs that rely on regulation. At a glance, what do gene regulatory networks look like?

First, the total edges found in networks:

Next, let’s look at edges by type.

Test for a statistical difference between edge types using a wilcoxon rank sum test:

## [1] "Median # repressed edges: 41"
## [1] "Median # promoting edges: 43"
## 
##  Wilcoxon signed rank test with continuity correction
## 
## data:  reg_edges_cnt by reg_edge_type
## V = 1550.5, p-value = 0.02192
## alternative hypothesis: true location shift is not equal to 0
## 95 percent confidence interval:
##  -4.000025 -0.499968
## sample estimates:
## (pseudo)median 
##      -2.000018

11.6.4 Program instruction execution traces

11.6.4.1 Execution time

How many time steps do successful programs take to solve the boolean calculator problem?

Test for significant difference between conditions using Wilcoxon rank sum test:

## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  total_execution_time by condition
## W = 9737, p-value = 0.2912
## alternative hypothesis: true location shift is not equal to 0
## 95 percent confidence interval:
##  -78.00002 274.00000
## sample estimates:
## difference in location 
##               96.00004

11.6.4.2 What types of instructions to successful programs execute?

Here, we look at the distribution of instruction types executed by successful programs. We’re primarily interested in the proportion of control flow instructions, so let’s look at that first.

Test for significant difference between conditions using a Wilcoxon rank sum test:

## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  control_flow_inst_prop by condition
## W = 8043, p-value = 0.1127
## alternative hypothesis: true location shift is not equal to 0
## 95 percent confidence interval:
##  -0.011679066  0.001195076
## sample estimates:
## difference in location 
##            -0.00543344

In case you’re curious, here’s all categories of instructions:

11.7 Visualizaing an evolved regulatory network

Let’s take a closer look at a successful gene regulatory network.

Specifically, we’ll be looking at the solution evolved in run id 2.539210^{4} (arbitrarily selected).

11.7.1 Evolved regulatory network

We use the igraph package to draw this program’s gene regulatory network.

## png 
##   2

References

Lalejini, Alexander M, Matthew A Moreno, and Charles Ofria. 2020. “Tag-Based Genetic Regulation for Genetic Programming.” OSF. https://doi.org/10.17605/OSF.IO/928FX.