Exemplo n.º 1
0
def create_visualizations(evaluations, stream_plan, iteration):
    # TODO: place it in the temp_dir?
    # TODO: decompose any joint streams
    for result in stream_plan:
        create_synthesizer_visualizations(result, iteration)
    filename = ITERATION_TEMPLATE.format(iteration)
    # visualize_stream_plan(stream_plan, path)

    constraints = set()  # TODO: approximates needed facts using produced ones
    for stream in stream_plan:
        constraints.update(
            filter(lambda f: evaluation_from_fact(f) not in evaluations,
                   stream.get_certified()))
    print('Constraints:', str_from_object(constraints))
    visualize_constraints(constraints,
                          os.path.join(CONSTRAINT_NETWORK_DIR, filename))

    from pddlstream.retired.synthesizer import decompose_stream_plan
    decomposed_plan = decompose_stream_plan(stream_plan)
    if len(decomposed_plan) != len(stream_plan):
        visualize_stream_plan(decompose_stream_plan(stream_plan),
                              os.path.join(STREAM_PLAN_DIR, filename))

    #visualize_stream_plan_bipartite(stream_plan, os.path.join(STREAM_PLAN_DIR, 'fused_' + filename))
    visualize_stream_plan(stream_plan,
                          os.path.join(STREAM_PLAN_DIR, 'fused_' + filename))
Exemplo n.º 2
0
def log_plans(stream_plan, action_plan, iteration):
    # TODO: do this within the focused algorithm itself?
    from pddlstream.retired.synthesizer import decompose_stream_plan
    decomposed_plan = decompose_stream_plan(stream_plan)
    with open(PLAN_LOG_FILE, 'a+') as f:
        f.write('Iteration: {}\n'
                'Component plan: {}\n'
                'Stream plan: {}\n'
                'Action plan: {}\n\n'.format(iteration, decomposed_plan,
                                             stream_plan,
                                             str_from_plan(action_plan)))