Exemplo n.º 1
0
class Modulelog(db.Model):
    """
    The Modulelog table
    """
    __tablename__ = 'modulelog'
    __table_args__ = {'schema': DB_SCHEMA}
    id = db.Column(db.Integer, primary_key=True)
    job_id = db.Column(UUID(as_uuid=True), default=uuid4, index=True)
    app_name = db.Column(db.String, nullable=False)
    state = db.Column(db.Enum("STARTED",
                              "FINISHED",
                              "ERROR",
                              name="job_states"),
                      nullable=False)
    timestamp = db.Column(db.String,
                          default=get_timestamp(),
                          onupdate=get_timestamp())
Exemplo n.º 2
0
def analyze():
    global base
    base = 'output/{}'.format(get_timestamp())
    # run analysis
    analyze_results()
    df_analysis.to_csv('{}/analysis.csv'.format(base),
                       encoding='utf-8',
                       index=False)
    print('analysis.csv saved to {}'.format(base))
Exemplo n.º 3
0
def constr_fix_cmd(fitness_type, problem, mutation_seed, selection_seed,
                   with_evosuite):
    # set gp fix type
    if fitness_type == 'original':
        gp_class = 'gin.util.GPFix'
    elif fitness_type == 'decision':
        gp_class = 'gin.util.GPNovelFix'
    elif fitness_type == 'arjae':
        gp_class = 'gin.util.GPArjaEFix'
    elif fitness_type == 'checkpoint':
        gp_class = 'gin.util.GPCheckpointFix'
    else:
        raise ValueError("Illegal fitness type.")

    # method file name
    if with_evosuite:
        method_file = 'quixbugs/quixbugs_method_files/{problem}-evosuite.csv'.format(
            problem=problem)
    else:
        method_file = 'quixbugs/quixbugs_method_files/{problem}.csv'.format(
            problem=problem)

    # result file name
    result_file = '{dir}/{fitness}-{problem}-{mut}-{sel}-{evo}.csv'.format(
        dir='output/{}/results'.format(get_timestamp()),
        fitness=fitness_type,
        problem=problem,
        mut=mutation_seed,
        sel=selection_seed,
        evo=with_evosuite)

    # construct cmd
    cmd = 'java -Dtinylog.level={gp_log} -cp gin.jar {class_name} -d quixbugs -c quixbugs -gn {gen} -in {pop} -m {method} -o {result} -et {edits} -x {timeout} -ms {mut} -is {sel} -rec {rec} -j'.format(
        gp_log=gp_log[0],
        class_name=gp_class,
        gen=generations,
        pop=population_size,
        method=method_file,
        result=result_file,
        edits=','.join(edits),
        timeout=timeout,
        mut=mutation_seed,
        sel=selection_seed,
        rec=record_patch)

    # append reference method file if checkpoint
    if fitness_type == 'checkpoint':
        cmd = '{} -M quixbugs/quixbugs_method_files/{}_correct.csv'.format(
            cmd, problem)

    return cmd
Exemplo n.º 4
0
def run_fix_cmds():
    global base
    base = 'output/{}'.format(get_timestamp())
    # create and overwrite result directory
    result_dir = '{}/results'.format(base)
    if os.path.exists(result_dir):
        shutil.rmtree(result_dir)
    Path(result_dir).mkdir(parents=True)
    # generate and log fix cmds
    write_fix_cmds()
    # read and run fix cmds
    fix_cmds = read_fix_cmds()
    # save run time
    f = open('{}/time.txt'.format(base), 'w')
    for cmd in fix_cmds:
        t_start = perf_counter()
        print(cmd)
        os.system(cmd)
        t_end = perf_counter()
        duration = t_end - t_start
        f.write(cmd + 'time elapsed: ' + str(duration) + '\n')
Exemplo n.º 5
0
def compute_average():
    # base directory
    base = 'output/{}'.format(get_timestamp())

    df = pd.read_csv("{}/analysis.csv".format(base))

    df['ratio of unique fixed patch'] \
        = df['number of unique fixed patch'] / df['number of fixed patch']

    df['ratio of unique fixed patch passed evosuite'] \
        = df['number of unique fixed patch passed evosuite'] / df['number of unique fixed patch']

    df = df.groupby(['problem name',
                     'fitness type'], as_index=False) \
        .agg({'number of fixed patch': [lambda x: x[x > 0].count(),
                                        'sum',
                                        'mean'],  # run with fix, sum of fixed patch, average fixed patch
              'ratio of unique fixed patch': ['sum'],  # need post-process
              'ratio of unique fixed patch passed evosuite': ['sum'],  # need post-process
              'number of evaluations to find first fixed patch': ['min'],
              'minimum number of edits to find a fix': ['min'],
              'ratio of better patches': ['mean'],
              'ratio of equal patches': ['mean']})

    # df.columns = df.columns.droplevel(level=1)

    new_column_names = [
        'problem', 'fitness type', 'run with fix', 'number of all fixed patch',
        'average number of fix patch per run',
        'average ratio of fixed patch is unique',
        'average ratio of unique patch can pass evosuite',
        'number of evaluations to find first fixed patch',
        'minimum number of edits to find a fix',
        'ratio of better fitness patches', 'ratio of same fitness patches'
    ]
    # print(len(new_column_names))

    df.columns = new_column_names

    print(df.columns)

    df['average ratio of fixed patch is unique'] /= df['run with fix']
    df['average ratio of unique patch can pass evosuite'] /= df['run with fix']

    # float to percentage
    df['ratio of better fitness patches'] = df[
        'ratio of better fitness patches'].astype(float).map("{:.2%}".format)
    df['ratio of same fitness patches'] = df[
        'ratio of same fitness patches'].astype(float).map("{:.2%}".format)
    df['average number of fix patch per run'] = df[
        'average number of fix patch per run'].map('{:.2f}'.format)
    df['average ratio of fixed patch is unique'] = df[
        'average ratio of fixed patch is unique'].astype(float).map(
            "{:.2%}".format)
    df['average ratio of unique patch can pass evosuite'] = df[
        'average ratio of unique patch can pass evosuite'].astype(float).map(
            "{:.2%}".format)

    # output file
    filename = 'result'
    df.to_csv('{}/{}.csv'.format(base, filename),
              encoding='utf-8',
              index=False)
    print('{}.csv saved to {}'.format(filename, base))
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
from config import get_timestamp

# problem to analyze density
program = 'quicksort'

# set base directory
base = 'output/{}'.format(get_timestamp())

df = pd.read_csv('{}/fitness.csv'.format(base), index_col=0)

# select program
df = df.loc[df['program'] == program]

# decision fitness
df_decision = df.loc[df['fitness function'] == 'decision']
decision_max = df_decision['fitness score'].max()
df_decision['fitness score'] = df_decision['fitness score'].div(decision_max)

# genprog
df_genprog = df.loc[df['fitness function'] == 'original']
original_max = df_genprog['fitness score'].max()
df_genprog['fitness score'] = df_genprog['fitness score'].div(original_max)

# arjae
df_arjae = df.loc[df['fitness function'] == 'arjae']
arjae_max = df_arjae['fitness score'].max()
df_arjae['fitness score'] = df_arjae['fitness score'].div(arjae_max)