Python General Framework for Genetic Improvement
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

PYGGI(Python General Framework for Genetic Improvement) Build Status Coverage Status

PYGGI logo

PYGGI is the lightweight and simple framework for Genetic Improvement. It helps one practice or experience GI with only few code lines by reducing the costs of implementing typical GI process such as source code manipulation and patch management.



You can find the PYGGI's documentation here


An, G., Kim, J., & Yoo, S. (2018). Comparing Line and AST Granularity Level for Program Repair using PyGGI. In GI.

  author = {An, Gabin and Kim, Jinhan and Yoo, Shin},
  booktitle = {Proceedings of the 4th Genetic Improvement Workshop},
  series = {GI@ICSE 2018},
  title = {Comparing Line and AST Granularity Level for Program Repair using PyGGI},
  year = {2018},
  doi = {10.1145/3194810.3194814},

Getting Started

1. Clone the repository

$ git clone ~
$ cd PYGGI

2. Install

$ python install

3. Run the example

1. Improving runtime of Triangle by deleting delay() function call
  • java
$ cd example
$ python ../sample/Triangle_fast
  • python
$ cd example
$ python ../sample/Triangle_fast_python
2. Repairing the bug of Triangle
$ cd example
$ python ../sample/Triangle_bug

Program setup convention

Two files should be provided: a configuration file and a test script. You can refer the sample programs in the sample directory.

1. Config file


ex) sample/Triangle_fast/PYGGI_CONFIG

  "target_files": [
  "test_command": "./"

2. Test script file


ex) sample/Triangle_fast/

set -e

# cd $1

rm -f *.class
javac -cp "./junit-4.10.jar"
java -cp "./junit-4.10.jar:./" TestRunner TriangleTest

The output of the test command should look like this,

[PYGGI_RESULT] {runtime: 7, pass_all: true, ...}

or, you can use own result parser when generating a TestResult instance.

See more details in here.

This is the example of a custom result parser,

def result_parser(stdout, stderr):
    import re
    m = re.findall("runtime: ([0-9.]+)", stdout)
    if len(m) > 0:
        runtime = m[0]
        failed = re.findall("([0-9]+) failed", stdout)
        pass_all = len(failed) == 0
        return TestResult(True, {'runtime': runtime, 'pass_all': pass_all})
  return TestResult(False, None)

, when the standard output is following:

======================================== test session starts ========================================
platform linux -- Python 3.6.2, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: /media/ssd/Workspace/PYGGI, inifile:
collected 4 items                                                                             ....runtime: 0.22184443473815918

===================================== 4 passed in 0.23 seconds ======================================