Esempio n. 1
0
def reduce_methods(all_methods, i):
    original = len(all_methods)
    new_all_methods = []
    for method in all_methods:
        print(method)
        if (method not in new_all_methods):
            new_all_methods.append(method)
    print("Length of the Duplicate-removed methods completion is " +
          str(len(new_all_methods)))

    remove_duplicate = len(new_all_methods)
    index = 0
    import new_tihtn_planner
    new_methods_list = new_tihtn_planner.generate_methods(
        "logistics", new_all_methods)
    while (index < len(new_methods_list)):
        new_methods_list_copy = copy.deepcopy(new_methods_list)
        delete = new_methods_list_copy[index]
        del new_methods_list_copy[index]
        import logistics_method_completion
        time.sleep(1)
        fun_obj_list = []
        for new_method_name in new_methods_list_copy:
            fun_obj = getattr(sys.modules["logistics_method_completion"],
                              new_method_name)
            fun_obj_list.append(fun_obj)
        air_ship = getattr(sys.modules["logistic"], "air_ship")
        city_ship = getattr(sys.modules["logistic"], "city_ship")
        delievery__1 = getattr(sys.modules["logistic"], "delievery__1")
        delievery__2 = getattr(sys.modules["logistic"], "delievery__2")
        delievery__3 = getattr(sys.modules["logistic"], "delievery__3")
        delievery__4 = getattr(sys.modules["logistic"], "delievery__4")
        delievery__5 = getattr(sys.modules["logistic"], "delievery__5")
        removable = True
        for vi in range(1, i + 1):
            exec("import " + "validating_" + str(vi))
            new_tihtn_planner.declare_methods('air_ship', air_ship)
            new_tihtn_planner.declare_methods('city_ship', city_ship)
            new_tihtn_planner.declare_methods('delievery', delievery__1,
                                              delievery__2, delievery__3,
                                              delievery__4, delievery__5)
            exec("validating_" + str(vi) + ".add_methods(fun_obj_list)")
            exec("validating_" + str(vi) + ".reverse_methods()")
            solution, generalized_methods = eval("validating_" + str(vi) +
                                                 ".execute(False)")
            del sys.modules["validating_" + str(vi)]
            if (solution == []):
                removable = False
                break
        if (removable):
            print("A method is removed:")
            print(delete)
            new_methods_list = new_methods_list_copy
        else:
            index += 1

    after_reduce = len(new_methods_list)
    print("Length of the reduced method completion is " + str(after_reduce))
    return original, remove_duplicate, new_methods_list
Esempio n. 2
0
def reduce_methods(all_methods, i):
    original = len(all_methods)
    new_all_methods = []
    for method in all_methods:
        print (method)
        if (method not in new_all_methods):
            new_all_methods.append(method)
    print ("Length of the Duplicate-removed methods completion is " + str(len(new_all_methods)))

    remove_duplicate = len(new_all_methods)
    index = 0
    import new_tihtn_planner
    new_methods_list = new_tihtn_planner.generate_methods("blockworld", new_all_methods)
    while (index < len(new_methods_list)):
        new_methods_list_copy = copy.deepcopy(new_methods_list)
        delete = new_methods_list_copy[index]
        del new_methods_list_copy[index]
        import blockworld_method_completion
        time.sleep(1)
        fun_obj_list = []
        for new_method_name in new_methods_list_copy:
            fun_obj = getattr(sys.modules["blockworld_method_completion"], new_method_name)
            fun_obj_list.append(fun_obj)
        tower5 = getattr(sys.modules["blockworld"], "tower5")
        tower4 = getattr(sys.modules["blockworld"], "tower4")
        tower3 = getattr(sys.modules["blockworld"], "tower3")
        tower2 = getattr(sys.modules["blockworld"], "tower2")
        tower1 = getattr(sys.modules["blockworld"], "tower1")
        make_clear__1 = getattr(sys.modules["blockworld"], "make_clear__1")
        make_clear__2 = getattr(sys.modules["blockworld"], "make_clear__2")

        removable = True
        for vi in range(1, i + 1):
            exec("import " + "validating_" + str(vi))
            new_tihtn_planner.declare_methods('tower5',tower5)
            new_tihtn_planner.declare_methods('tower4',tower4)
            new_tihtn_planner.declare_methods('tower3', tower3)
            new_tihtn_planner.declare_methods('tower2',tower2)
            new_tihtn_planner.declare_methods('tower1',tower1)
            new_tihtn_planner.declare_methods('make_clear', make_clear__1,make_clear__2)
            exec("validating_" + str(vi) + ".add_methods(fun_obj_list)")
            # exec("validating_" + str(vi) + ".reverse_methods()")
            print ("Solving validating_" + str(vi) + ".py......")
            solution, generalized_methods = eval("validating_" + str(vi) + ".execute(False)")
            del sys.modules["validating_" + str(vi)]
            if (solution == []):
                removable = False
                break
        if (removable):
            print ("A method is removed:")
            print (delete)
            new_methods_list = new_methods_list_copy
        else:
            index += 1

    after_reduce = len(new_methods_list)
    print ("Length of the reduced method completion is " + str(after_reduce))
    return original, remove_duplicate, new_methods_list
Esempio n. 3
0
def reduce_methods(all_methods, i):
    original = len(all_methods)
    new_all_methods = []
    for method in all_methods:
        print(method)
        if (method not in new_all_methods):
            new_all_methods.append(method)
    print("Length of the Duplicate-removed methods completion is " +
          str(len(new_all_methods)))

    remove_duplicate = len(new_all_methods)
    index = 0
    import new_tihtn_planner
    new_methods_list = new_tihtn_planner.generate_methods(
        "satellite", new_all_methods)
    while (index < len(new_methods_list)):
        new_methods_list_copy = copy.deepcopy(new_methods_list)
        delete = new_methods_list_copy[index]
        del new_methods_list_copy[index]
        import satellite_method_completion
        time.sleep(1)
        fun_obj_list = []
        for new_method_name in new_methods_list_copy:
            fun_obj = getattr(sys.modules["satellite_method_completion"],
                              new_method_name)
            fun_obj_list.append(fun_obj)
        get_img = getattr(sys.modules["satellite"], "get_img")
        activate = getattr(sys.modules["satellite"], "activate")
        auto_calibrate = getattr(sys.modules["satellite"], "auto_calibrate")

        removable = True
        for vi in range(1, i + 1):
            exec("import " + "validating_" + str(vi))
            new_tihtn_planner.declare_methods('get_img', get_img)
            new_tihtn_planner.declare_methods('activate', activate)
            new_tihtn_planner.declare_methods('auto_calibrate', auto_calibrate)
            exec("validating_" + str(vi) + ".add_methods(fun_obj_list)")
            exec("validating_" + str(vi) + ".reverse_methods()")
            print("Solving validating_" + str(vi) + ".py......")
            solution, generalized_methods = eval("validating_" + str(vi) +
                                                 ".execute(False)")
            del sys.modules["validating_" + str(vi)]
            if (solution == []):
                removable = False
                break
        if (removable):
            print("A method is removed:")
            print(delete)
            new_methods_list = new_methods_list_copy
        else:
            index += 1

    after_reduce = len(new_methods_list)
    print("Length of the reduced method completion is " + str(after_reduce))
    return original, remove_duplicate, new_methods_list