Exemplo n.º 1
0
    for board_name in board_names:
        # print("Hello testing for loop")
        if board_name[7:-4] in noSolution_board:

            print('unsolvable board ' + str(board_name[7:]))
            continue

        print("Loading board file %s" % (board_name, ))
        with open(board_name) as file:
            board = Board.read_board(file)

        tableFormat3["Board"].append(board_name[7:])
        bp0 = BloxorzProblem(board)

        # bp0.heuristic = bp0.heuristic1
        searcher = searchGeneric.AStarSearcher(bp0)
        result = searcher.search()

        if result is None:
            print("For board %s, found no solution!" % (board_name, ))
            tableFormat3['AStar_Length'].append(0)
            tableFormat3['Astar_expansions'].append(0)
        else:
            sequence = [arc.action for arc in result.arcs()]
            #print("For board %s, found solution with length %d using %d expansions" % (board_name, len(sequence), searcher.num_expanded))
            tableFormat3['AStar_Length'].append(len(sequence))
            tableFormat3['Astar_expansions'].append(searcher.num_expanded)
            continue
            #dataframe and converion to xml and html file with a average of the lengths and expansions

        df3 = pd.DataFrame(tableFormat3)
Exemplo n.º 2
0
            time = Time[line[-1]]
            cons.append(Constraint((line[1],), end_before_time_(time)))
        elif "ends-after" in line and len(line) == 4:
            time = Time[line[-1]]
            cons.append(Constraint((line[1],), end_after_time_(time)))

# print(task)
# print(cons)
# print(soft_cons)
# print(cost_unit)

# get the csp
csp = Extendedcsp(task, cons, soft_cons)
# print(csp)
# search for path
searcher = searchGeneric.AStarSearcher(Search_with_AC_from_cost_CSP(csp))
result = searcher.search()
# print("-----------")


if result and min(searcher.problem.cost_list)<= MAX_cost:
    # print(solution and cost)
    ans = {m: cspConsistency.select(n) for (m, n) in result.end().items()}
    for x in ans:
        start, _ = ans[x]
        date, time = start
        print(f'{x}:{get_key(Date,date)} {get_key(Time,time)}')

    print(f'cost:{min(searcher.problem.cost_list)}')
else:
    print('No solution')