def generate_tex_template(best_dict,
                          name_list,
                          save="",
                          template_string=template_string,
                          experiment_name="Name",
                          num_evals="\\#eval"):
    tex = StringIO()
    result_values = OrderedDict([(name[0], dict()) for name in name_list])

    means = [np.mean(best_dict[name]) for name in result_values]
    stds = [np.std(best_dict[name]) for name in result_values]
    mins = [np.min(best_dict[name]) for name in result_values]
    maxs = [np.max(best_dict[name]) for name in result_values]

    for name in result_values:
        values = result_values[name]

        values["mean"] = np.mean(best_dict[name])
        values["mean_best"] = True if \
            wrapping_util.float_eq(values["mean"], min(means)) else False

        values["std"] = np.std(best_dict[name])
        values["std_best"] = True if \
            wrapping_util.float_eq(values["std"], min(stds)) else False

        values["min"] = np.min(best_dict[name])
        values["min_best"] = True if\
            wrapping_util.float_eq(values["min"], min(mins)) else False

        values["max"] = np.max(best_dict[name])
        values["max_best"] = True if\
            wrapping_util.float_eq(values["max"], min(maxs)) else False

    if jinja2:
        template = Template(template_string)
        tex.write(
            template.render(result_values=result_values,
                            experiment=experiment_name,
                            evals=num_evals))
    else:
        tex.write("Name & #evals")
        for name in result_values:
            values = result_values[name]
            tex.write(" & ")
            tex.write(values["mean"])
            tex.write("$\\pm$")
            tex.write(values["std"])
            tex.write(" & ")
            tex.write(values["min"])
        tex.write("\\\\")

    tex.seek(0)
    table = tex.getvalue()

    if save != "":
        with open(save, "w") as fh:
            fh.write(table)
    else:
        return table
Exemplo n.º 2
0
def generate_tex_template(best_dict, name_list, save="",
         template_string=template_string, experiment_name="Name",
         num_evals="\\#eval"):
    tex = StringIO()
    result_values = OrderedDict([(name[0], dict()) for name in name_list])

    means = [np.mean(best_dict[name]) for name in result_values]
    stds = [np.std(best_dict[name]) for name in result_values]
    mins = [np.min(best_dict[name]) for name in result_values]
    maxs = [np.max(best_dict[name]) for name in result_values]

    for name in result_values:
        values = result_values[name]

        values["mean"] = np.mean(best_dict[name])
        values["mean_best"] = True if \
            wrapping_util.float_eq(values["mean"], min(means)) else False

        values["std"] = np.std(best_dict[name])
        values["std_best"] = True if \
            wrapping_util.float_eq(values["std"], min(stds)) else False

        values["min"] = np.min(best_dict[name])
        values["min_best"] = True if\
            wrapping_util.float_eq(values["min"], min(mins)) else False

        values["max"] = np.max(best_dict[name])
        values["max_best"] = True if\
            wrapping_util.float_eq(values["max"], min(maxs)) else False

    if jinja2:
        template = Template(template_string)
        tex.write(template.render(result_values=result_values,
                                  experiment=experiment_name, evals=num_evals))
    else:
        tex.write("Name & #evals")
        for name in result_values:
            values = result_values[name]
            tex.write(" & ")
            tex.write(values["mean"])
            tex.write("$\\pm$")
            tex.write(values["std"])
            tex.write(" & ")
            tex.write(values["min"])
        tex.write("\\\\")

    tex.seek(0)
    table = tex.getvalue()

    if save != "":
        with open(save, "w") as fh:
            fh.write(table)
    else:
        return table
Exemplo n.º 3
0
 def _sanity_check(self):
     total_wallclock_time = 0
     finite_instance_results = 0
     for trial in self.trials:
         self._trial_sanity_check(trial)
         # Backwards compability with numpy 1.6
         wallclock_time = np.nansum(trial['instance_durations'])
         total_wallclock_time += wallclock_time if np.isfinite(wallclock_time) else 0
     assert (wrapping_util.float_eq(total_wallclock_time,
                                    self.total_wallclock_time)), \
         (total_wallclock_time, self.total_wallclock_time)
Exemplo n.º 4
0
    def _sanity_check(self):
        total_wallclock_time = 0
        for trial in self.trials:
            self._trial_sanity_check(trial)

            # Backwards compability with numpy 1.6
            with warnings.catch_warnings():
                warnings.simplefilter("ignore")
                wallclock_time = np.nansum(trial['instance_durations'])
                test_wallclock_time = np.nansum(trial['test_instance_durations'])
                total_wallclock_time += wallclock_time if \
                    np.isfinite(wallclock_time) else 0
                total_wallclock_time += test_wallclock_time if \
                    np.isfinite(test_wallclock_time) else 0

        if not wrapping_util.float_eq(total_wallclock_time,
                                       self.total_wallclock_time):
            raise ValueError("Found an error in the time measurement. The "
                             "values %f and %f should be equal, but aren't" %
                             (total_wallclock_time, self.total_wallclock_time))
Exemplo n.º 5
0
    def _sanity_check(self):
        total_wallclock_time = 0
        for trial in self.trials:
            self._trial_sanity_check(trial)

            # Backwards compability with numpy 1.6
            with warnings.catch_warnings():
                warnings.simplefilter("ignore")
                wallclock_time = np.nansum(trial['instance_durations'])
                test_wallclock_time = np.nansum(
                    trial['test_instance_durations'])
                total_wallclock_time += wallclock_time if \
                    np.isfinite(wallclock_time) else 0
                total_wallclock_time += test_wallclock_time if \
                    np.isfinite(test_wallclock_time) else 0

        if not wrapping_util.float_eq(total_wallclock_time,
                                      self.total_wallclock_time):
            raise ValueError("Found an error in the time measurement. The "
                             "values %f and %f should be equal, but aren't" %
                             (total_wallclock_time, self.total_wallclock_time))