Extending Test-Time Augmentation with Metamorphic Relations for Combinatorial Problems

Siwei Wei, Xudong Zhang, Zhiyang Zhou, Yan CaiICML 2024

MAGG (Metamorphic Aggregation) is a novel framework that brings the benefits of Test-Time Augmentation (TTA) to the complex world of combinatorial problems. By leveraging "metamorphic relations"—mathematical rules that describe how a problem's output should change when its input is transformed—and aggregating predictions with a Graph Neural Network (GNN), MAGG significantly boosts the accuracy of pretrained models for tasks like SAT solving and the Traveling Salesman Problem without needing to retrain the original model.

The Challenge of Augmenting Combinatorial Problems

In computer vision, Test-Time Augmentation (TTA) is a common trick: to classify an image of a cat, you might rotate, flip, and crop it, then average the model's predictions across all versions. This works because these transformations are "label-preserving"—a flipped cat is still a cat.

However, applying TTA to combinatorial problems (like Boolean Satisfiability or the Traveling Salesman Problem) is much harder for three key reasons:

  1. Label-preserving transforms are rare: Changing a single variable in a logic formula or a single edge in a graph can completely flip the answer from "Satisfiable" to "Unsatisfiable."
  2. Simple averaging is insufficient: Combinatorial problems have strict semantic structures. A simple average of "maybe" doesn't capture the logical relationship between two related problem instances.
  3. Discrete nature: These problems are often NP-hard and discrete, making them brittle to standard continuous data augmentation techniques.
An example of a metamorphic relation in SAT: substituting a variable with 0 creates a new instance with a logical relationship to the original.

To overcome this, the authors move beyond "label-preserving" transforms to Metamorphic Relations (MRs). These are properties where the relationship between the inputs implies a specific relationship between the outputs. For example, in a Boolean Satisfiability (SAT) problem, if formula $A$ is a subset of formula $B$, and $B$ is satisfiable, then $A$ must also be satisfiable.

The MAGG Framework

The authors propose MAGG, a "plug-and-play" method that enhances existing models at inference time without requiring access to their internal weights or training processes. It consists of four main steps:

The MAgg pipeline: generating transformed instances with metamorphic relations, predicting with a base model, and aggregating via a GNN.
  1. Metamorphic Transformation: Given a problem instance $x$, MAGG applies transformations to create several "mutants." These do not have to preserve the label; they just need to follow a known metamorphic relation.
  2. Ego Metamorphic Graph (EMG) Construction: MAGG represents these instances as nodes in a directed graph. An edge from $x$ to $x'$ exists if there is a metamorphic relation between them. This graph can be multi-level, incorporating mutants of mutants.
  3. Base Model Execution: A pretrained "base model" (the one we want to improve) is run on every node in the graph to generate initial predictions.
  4. GNN Aggregation: Instead of simple averaging, these predictions are fed into a Graph Neural Network (GNN). The GNN uses the graph structure to learn how to aggregate the "votes" of the mutants to produce a final, more accurate prediction for the original instance.

Key Insights and Results

Metamorphic relations act as a "sanity check." If a model predicts that a sub-problem is unsatisfiable but the larger problem is satisfiable, it has violated a logical rule. MAGG's GNN learns to recognize these violations and correct the model's "confusion." Furthermore, the use of a trainable GNN allows the system to adapt to different base models, moving beyond the fixed averaging of standard TTA. The researchers also found that "multi-hop" graphs—applying transformations to already transformed instances—performed significantly better than single-step transformations by providing richer context.

The researchers evaluated MAGG on three distinct combinatorial tasks, demonstrating substantial performance gains:

  • Boolean Satisfiability (SAT): Using the $SR(n)$ distribution and the NeuroSAT base model, MAGG achieved up to a 15% relative improvement in accuracy. On the $SR(40)$ dataset, accuracy jumped from 84.4% to 97.6%. It also significantly outperformed standard TTA methods restricted to label-preserving transforms.
  • Decision Traveling Salesman Problem (Decision TSP): Using 2D Euclidean TSP instances and the TSP-GNN base model, MAGG showed a 4% relative improvement in accuracy.
  • Graph Edit Distance (GED): Using the GREED base model, MAGG achieved a massive 42% relative improvement in Root Mean Square Error (RMSE) on the LINUX dataset.

Limitations and Future Work

While powerful, MAGG has limitations. It showed no improvement on the AIDS dataset for GED, likely because random edits in labeled graphs (like molecules) drastically change distances in ways current MRs don't capture well. Additionally, running the base model on multiple mutants and executing a GNN increases computational overhead at inference time. Finally, while the base model doesn't need retraining, the MAGG aggregation GNN does require a small amount of labeled data to learn how to combine predictions.

Future work will explore more complex metamorphic relations and apply the framework to broader classes of machine learning tasks beyond combinatorial optimization.

Summary updated

BibTeX
@inproceedings{wei2024extending,
  author = {Siwei Wei and Xudong Zhang and Zhiyang Zhou and Yan Cai},
  title = {{Extending Test-Time Augmentation with Metamorphic Relations for Combinatorial Problems}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=PNsdnl8blk},
}
Figure