<commit_before>#!/usr/bin/env python3

#
#  Copyright (C) 2011-2013 <NAME>.
#
#  This Source Code Form is subject to the terms of the Mozilla Public
#  License, v. 2.0. If a copy of the MPL was not distributed with this file,
#  You can obtain one at http://mozilla.org/MPL/2.0/
#

import argparse
import os
import subprocess
import time


verbose = False

# Column meaning / position for dynamic log file.
col_run = 1;
col_gen = 2;
col_fitness = 3;
col_mean_fit = 4;
col_fit_sd = 5;
col_entropy = 6;
col_min_fit = 7;
col_mean_len = 8;
col_len_sd = 9;
col_max_len = 10;
col_mutations = 11;
col_crossovers = 12;
col_functions = 13;
col_terminals = 14;
col_active_functions = 15;
col_active_terminals = 16;

# Column meaning / position for ages log file.
col_p_run = 1;
col_p_gen = 2;
col_p_fit = 3;
col_p_frq = 4;



def plot1(pipe, args):
    pipe.write(b"set xlabel 'GENERATION'\n")
    pipe.write(b"set ylabel 'FITNESS'\n")

    cmd = "plot [{from_gen}:{to_gen}] '{data}' index {from_run}:{to_run} using {col_gen}:{col_fitness} title 'Best' with fsteps linestyle 2, '{data}' index {from_run}:{to_run} using {col_gen}:{col_mean_fit}:{col_fit_sd} title 'Population' with yerrorbars linestyle 1\n".format(
        from_gen = "" if args.from_gen is None else args.from_gen,
        to_gen = "" if args.to_gen is None else args.to_gen,
        data = args.logfile,
        from_run = args.from_run,
        to_run = args.to_run,
        col_gen = col_gen,
        col_fitness = col_fitness,
        col_mean_fit = col_mean_fit,
        col_fit_sd = col_fit_sd)

    if verbose:
        print(cmd)
    pipe.write(str.encode(cmd))


def plot2(pipe, args):
    pipe.write(b"set xlabel 'GENERATION'\n")
    pipe.write(b"set ylabel 'ENTROPY'\n")

    cmd = "plot [{from_gen}:{to_gen}] '{data}' index {from_run}:{to_run} using {col_gen}:{col_entropy} title 'Entropy' with lines\n".format(
        from_gen = "" if args.from_gen is None else args.from_gen,
        to_gen = "" if args.to_gen is None else args.to_gen,
        data = args.logfile,
        from_run = args.from_run,
        to_run = args.to_run,
        col_gen = col_gen,
        col_entropy = col_entropy)

    if verbose:
        print(cmd)
    pipe.write(str.encode(cmd))


def plot3(pipe, args):
    pipe.write(b"set xlabel 'GENERATION'\n")
    pipe.write(b"set ylabel 'EFFECTIVE SIZE'\n")

    cmd = "plot [{from_gen}:{to_gen}] '{data}' index {from_run}:{to_run} using {col_gen}:{col_mean_len}:{col_len_sd} title 'Population' with yerrorbars linestyle 1\n".format(
        from_gen = "" if args.from_gen is None else args.from_gen,
        to_gen = "" if args.to_gen is None else args.to_gen,
        data = args.logfile,
        from_run = args.from_run,
        to_run = args.to_run,
        col_gen = col_gen,
        col_mean_len = col_mean_len,
        col_len_sd = col_len_sd)

    if verbose:
        print(cmd)
    pipe.write(str.encode(cmd))


def plot4(pipe, args):
    pipe.write(b"set xlabel 'GENERATION'\n")
    pipe.write(b"set ylabel 'NR. OF SYMBOLS'\n")

    cmd = "plot [{from_gen}:{to_gen}] '{data}' index {from_run}:{to_run} " \
          "using {col_gen}:{col_functions} title 'Functions' with lines, " \
          "'{data}' index {from_run}:{to_run} " \
          "using {col_gen}:{col_terminals} title 'Terminals' with lines, " \
          "'{data}' index {from_run}:{to_run} " \
          "using {col_gen}:{col_active_functions} title 'Active functions' " \
          "with lines, '{data}' index {from_run}:{to_run} " \
          "using {col_gen}:{col_active_terminals} title 'Active terminals' " \
          "with lines\n".format(
        from_gen = "" if args.from_gen is None else args.from_gen,
        to_gen = "" if args.to_gen is None else args.to_gen,
        data = args.logfile,
        from_run = args.from_run,
        to_run = args.to_run,
        col_gen = col_gen,
        col_functions = col_functions,
        col_terminals = col_terminals,
        col_active_functions = col_active_functions,
        col_active_terminals = col_active_terminals
        )

    if verbose:
        print(cmd)
    pipe.write(str.encode(cmd))


def plot5(pipe, args):
    pipe.write(b"set zrange [0:*]\n")
    pipe.write(b"set yrange [0:*]\n")
    pipe.write(b"set xlabel 'FITNESS'\n")
    pipe.write(b"set ylabel 'GENERATION'\n")
    pipe.write(b"set zlabel 'FREQ.'\n")

    pipe.write(b"set dgrid3d\n")
    #pipe.write(b"set dgrid3d exp\n")
    #pipe.write(b"set dgrid3d cauchy\n")
    pipe.write(b"set hidden3d\n")

    #pipe.write(b"set xyplane at -1\n");
    #pipe.write(b"set pm3d at b\n")
    pipe.write(b"set pm3d at s hidden3d 1\n")

    pipe.write(b"set view ,150\n")

    cmd = "splot [] [{from_gen}:{to_gen}] '{data}' index {from_run}:{to_run} using {col_p_fit}:{col_p_gen}:{col_p_frq} title '' with lines\n".format(
        from_gen = "" if args.from_gen is None else args.from_gen,
        to_gen = "" if args.to_gen is None else args.to_gen,
        data = args.logfile,
        from_run = args.from_run,
        to_run = args.to_run,
        col_p_gen = col_p_gen,
        col_p_fit = col_p_fit,
        col_p_frq = col_p_frq)

    if verbose:
        print(cmd)
    pipe.write(str.encode(cmd))

<commit_msg>plot.py: FREQ. renamed to NR.<commit_after>#!/usr/bin/env python3

#
#  Copyright (C) 2011-2013 <NAME>.
#
#  This Source Code Form is subject to the terms of the Mozilla Public
#  License, v. 2.0. If a copy of the MPL was not distributed with this file,
#  You can obtain one at http://mozilla.org/MPL/2.0/
#

import argparse
import os
import subprocess
import time


verbose = False

# Column meaning / position for dynamic log file.
col_run = 1;
col_gen = 2;
col_fitness = 3;
col_mean_fit = 4;
col_fit_sd = 5;
col_entropy = 6;
col_min_fit = 7;
col_mean_len = 8;
col_len_sd = 9;
col_max_len = 10;
col_mutations = 11;
col_crossovers = 12;
col_functions = 13;
col_terminals = 14;
col_active_functions = 15;
col_active_terminals = 16;

# Column meaning / position for ages log file.
col_p_run = 1;
col_p_gen = 2;
col_p_fit = 3;
col_p_frq = 4;



def plot1(pipe, args):
    pipe.write(b"set xlabel 'GENERATION'\n")
    pipe.write(b"set ylabel 'FITNESS'\n")

    cmd = "plot [{from_gen}:{to_gen}] '{data}' index {from_run}:{to_run} using {col_gen}:{col_fitness} title 'Best' with fsteps linestyle 2, '{data}' index {from_run}:{to_run} using {col_gen}:{col_mean_fit}:{col_fit_sd} title 'Population' with yerrorbars linestyle 1\n".format(
        from_gen = "" if args.from_gen is None else args.from_gen,
        to_gen = "" if args.to_gen is None else args.to_gen,
        data = args.logfile,
        from_run = args.from_run,
        to_run = args.to_run,
        col_gen = col_gen,
        col_fitness = col_fitness,
        col_mean_fit = col_mean_fit,
        col_fit_sd = col_fit_sd)

    if verbose:
        print(cmd)
    pipe.write(str.encode(cmd))


def plot2(pipe, args):
    pipe.write(b"set xlabel 'GENERATION'\n")
    pipe.write(b"set ylabel 'ENTROPY'\n")

    cmd = "plot [{from_gen}:{to_gen}] '{data}' index {from_run}:{to_run} using {col_gen}:{col_entropy} title 'Entropy' with lines\n".format(
        from_gen = "" if args.from_gen is None else args.from_gen,
        to_gen = "" if args.to_gen is None else args.to_gen,
        data = args.logfile,
        from_run = args.from_run,
        to_run = args.to_run,
        col_gen = col_gen,
        col_entropy = col_entropy)

    if verbose:
        print(cmd)
    pipe.write(str.encode(cmd))


def plot3(pipe, args):
    pipe.write(b"set xlabel 'GENERATION'\n")
    pipe.write(b"set ylabel 'EFFECTIVE SIZE'\n")

    cmd = "plot [{from_gen}:{to_gen}] '{data}' index {from_run}:{to_run} using {col_gen}:{col_mean_len}:{col_len_sd} title 'Population' with yerrorbars linestyle 1\n".format(
        from_gen = "" if args.from_gen is None else args.from_gen,
        to_gen = "" if args.to_gen is None else args.to_gen,
        data = args.logfile,
        from_run = args.from_run,
        to_run = args.to_run,
        col_gen = col_gen,
        col_mean_len = col_mean_len,
        col_len_sd = col_len_sd)

    if verbose:
        print(cmd)
    pipe.write(str.encode(cmd))


def plot4(pipe, args):
    pipe.write(b"set xlabel 'GENERATION'\n")
    pipe.write(b"set ylabel 'NR. OF SYMBOLS'\n")

    cmd = "plot [{from_gen}:{to_gen}] '{data}' index {from_run}:{to_run} " \
          "using {col_gen}:{col_functions} title 'Functions' with lines, " \
          "'{data}' index {from_run}:{to_run} " \
          "using {col_gen}:{col_terminals} title 'Terminals' with lines, " \
          "'{data}' index {from_run}:{to_run} " \
          "using {col_gen}:{col_active_functions} title 'Active functions' " \
          "with lines, '{data}' index {from_run}:{to_run} " \
          "using {col_gen}:{col_active_terminals} title 'Active terminals' " \
          "with lines\n".format(
        from_gen = "" if args.from_gen is None else args.from_gen,
        to_gen = "" if args.to_gen is None else args.to_gen,
        data = args.logfile,
        from_run = args.from_run,
        to_run = args.to_run,
        col_gen = col_gen,
        col_functions = col_functions,
        col_terminals = col_terminals,
        col_active_functions = col_active_functions,
        col_active_terminals = col_active_terminals
        )

    if verbose:
        print(cmd)
    pipe.write(str.encode(cmd))


def plot5(pipe, args):
    pipe.write(b"set zrange [0:*]\n")
    pipe.write(b"set yrange [0:*]\n")
    pipe.write(b"set xlabel 'FITNESS'\n")
    pipe.write(b"set ylabel 'GENERATION'\n")
    pipe.write(b"set zlabel 'NR.'\n")

    pipe.write(b"set dgrid3d exp\n")
    #pipe.write(b"set dgrid3d exp\n")
    #pipe.write(b"set dgrid3d cauchy\n")
    pipe.write(b"set hidden3d\n")

    #pipe.write(b"set xyplane at -1\n");
    #pipe.write(b"set pm3d at b\n")
    pipe.write(b"set pm3d at s hidden3d 1\n")

    pipe.write(b"set view ,150\n")

    cmd = "splot [] [{from_gen}:{to_gen}] '{data}' index {from_run}:{to_run} using {col_p_fit}:{col_p_gen}:{col_p_frq} title '' with lines\n".format(
        from_gen = "" if args.from_gen is None else args.from_gen,
        to_gen = "" if args.to_gen is None else args.to_gen,
        data = args.logfile,
        from_run = args.from_run,
        to_run = args.to_run,
        col_p_gen = col_p_gen,
        col_p_fit = col_p_fit,
        col_p_frq = col_p_frq)

    if verbose:
        print(cmd)
    pipe.write(str.encode(cmd))


{'fraction_non_alphanumeric': 0.1342281879194631, 'fraction_numerical': 0.011888782358581016, 'mean_word_length': 2.928813559322034, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4954065', 'n_tokens_mistral': 4043, 'n_tokens_neox': 3894, 'n_words': 895}