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.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
example
images
pyggi
sample
test
.gitignore
.style.yapf
.travis.yml
LICENSE
MANIFEST.in
README.md
ast_test.py
line_test.py
setup.py

README.md

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.

Prerequisites

Documentation

You can find the PYGGI's documentation here

Citation

An, G., Kim, J., & Yoo, S. (2018). Comparing Line and AST Granularity Level for Program Repair using PyGGI. In GI. https://doi.org/10.1145/3194810.3194814

  @inproceedings{An2018to,
  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 setup.py install

3. Run the example

1. Improving runtime of Triangle by deleting delay() function call
  • java
$ cd example
$ python improve.py ../sample/Triangle_fast
  • python
$ cd example
$ python improve_python.py ../sample/Triangle_fast_python
2. Repairing the bug of Triangle
$ cd example
$ python repair.py ../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

{target_dir_path}/PYGGI_CONFIG

ex) sample/Triangle_fast/PYGGI_CONFIG

{
  "target_files": [
    "Triangle.java"
  ],
  "test_command": "./run.sh"
}

2. Test script file

{target_dir_path}/run.sh

ex) sample/Triangle_fast/run.sh

#!/bin/sh
set -e

# cd $1

rm -f *.class
javac -cp "./junit-4.10.jar" Triangle.java TriangleTest.java TestRunner.java
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})
    else:
  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                                                                                    

test_triangle.py ....runtime: 0.22184443473815918


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