Beispiel #1
0
def main(optimize_config_file_path, output_dir, export, export_file_path, label, bin_size, procs_per_worker, verbose):
    """

    :param optimize_config_file_path: str
    :param output_dir: str
    :param export: bool
    :param export_file_path: str
    :param label: str
    :param verbose: bool
    """
    # requires a global variable context: :class:'Context'
    context.update(locals())
    interface=get_parallel_interface(procs_per_worker=procs_per_worker)
    config_optimize_interactive(__file__, config_file_path=optimize_config_file_path, output_dir=output_dir,
                                export=export, export_file_path=export_file_path, label=label, disp=verbose,
                                interface=interface)
Beispiel #2
0
def main(cli, optimize_config_file_path, output_dir, export, export_file_path,
         label, verbose, debug):
    """

    :param optimize_config_file_path: str
    :param output_dir: str
    :param export: bool
    :param export_file_path: str
    :param label: str
    :param verbose: bool
    :param debug: bool
    """
    # requires a global variable context: :class:'Context'
    context.update(locals())
    kwargs = get_unknown_click_arg_dict(cli.args)
    context.disp = verbose > 0

    context.interface = get_parallel_interface(source_file=__file__,
                                               source_package=__package__,
                                               **kwargs)
    context.interface.start(disp=context.disp)
    context.interface.ensure_controller()
    config_optimize_interactive(__file__,
                                config_file_path=optimize_config_file_path,
                                output_dir=output_dir,
                                export=export,
                                export_file_path=export_file_path,
                                label=label,
                                disp=context.disp,
                                interface=context.interface,
                                verbose=verbose,
                                debug=debug,
                                **kwargs)

    if not context.debug:
        model_id = 0
        if 'model_key' in context() and context.model_key is not None:
            model_label = context.model_key
        else:
            model_label = 'test'

        features = dict()

        # Stage 0:
        sequences = [[context.x0_array], [model_id], [context.export]]
        primitives = context.interface.map(compute_network_features,
                                           *sequences)
        this_features = {
            key: value
            for feature_dict in primitives
            for key, value in viewitems(feature_dict)
        }
        features.update(this_features)

        features, objectives = context.interface.execute(
            get_objectives, features, model_id, context.export)

        sys.stdout.flush()
        print('model_id: %i; model_labels: %s' % (model_id, model_label))
        print('params:')
        pprint.pprint(context.x0_dict)
        print('features:')
        pprint.pprint(features)
        print('objectives:')
        pprint.pprint(objectives)
        sys.stdout.flush()
        time.sleep(.1)

    context.interface.stop()