예제 #1
0
파일: Agent.py 프로젝트: logeyG/7637project
def create_semantic_network(figures, problem):

    if problem.problemType == '3x3':

        H_1A = create_relationship_diagram([figures[0], figures[1]], 'horizontal')
        H_1B = create_relationship_diagram([figures[1], figures[2]], 'horizontal')
        H1 = utility.union(H_1A, H_1B)

        H_2A = create_relationship_diagram([figures[3], figures[4]], 'horizontal')
        H_2B = create_relationship_diagram([figures[4], figures[5]], 'horizontal')
        H2 = utility.union(H_2A, H_2B)

        V_1A = create_relationship_diagram([figures[0], figures[3]], 'vertical')
        V_1B = create_relationship_diagram([figures[3], figures[6]], 'vertical')
        V1 = utility.union(V_1A, V_1B)

        V_2A = create_relationship_diagram([figures[1], figures[4]], 'vertical')
        V_2B = create_relationship_diagram([figures[4], figures[7]], 'vertical')
        V2 = utility.union(V_2A, V_2B)

        D = create_relationship_diagram([figures[0], figures[4]], 'diagonal')
        R = (H1, H2, V1, V2, D)
        return R
    else:
        H1 = create_relationship_diagram([figures[0], figures[1]], 'horizontal', '2x2')
        V1 = create_relationship_diagram([figures[0], figures[2]], 'vertical', '2x2')
        R = (H1, V1)
        return R
예제 #2
0
def generate_and_test(init_network, scores, figures, solutions, problem):

    for i, solution in enumerate(solutions):

        if problem.problemType == '3x3':

            # compare init_network with generated solutions
            H_A = create_relationship_diagram([figures[6], figures[7]],
                                              'horizontal')
            H_B = create_relationship_diagram([figures[7], solution],
                                              'horizontal')
            H = utility.union(H_A, H_B)

            V_A = create_relationship_diagram([figures[2], figures[5]],
                                              'vertical')
            V_B = create_relationship_diagram([figures[5], solution],
                                              'vertical')
            V = utility.union(V_A, V_B)

            D = create_relationship_diagram([figures[4], solution], 'diagonal')

        else:
            H = create_relationship_diagram([figures[2], solution],
                                            'horizontal', '2x2')
            V = create_relationship_diagram([figures[1], solution], 'vertical',
                                            '2x2')
            D = None

        score = agent_compare(init_network, H, V, D, problem, i + 1)
        scores.append(score)

    scores = utility.normalize_scores(scores, problem)
    print(scores)

    if 1.0 not in scores:

        if problem.problemType == '3x3':
            m_diagonal = comparison.compare_diagonal(scores, figures,
                                                     solutions, problem)
            print('comparing diagonals to finalize score')

            possible_scores = [m_diagonal]
            m = min(possible_scores, key=lambda t: t[1])
            scores = utility.get_score(m, problem)
        else:
            m_union = comparison.compare_union(scores, figures, solutions,
                                               problem)
            print('comparing union to finalize score')

            possible_scores = [m_union]
            m = min(possible_scores, key=lambda t: t[1])
            scores = utility.get_score(m, problem)

    return scores
예제 #3
0
파일: Agent.py 프로젝트: logeyG/7637project
def generate_and_test(init_network, scores, figures, solutions, problem):

    for i, solution in enumerate(solutions):

        if problem.problemType == '3x3':

            # compare init_network with generated solutions
            H_A = create_relationship_diagram([figures[6], figures[7]], 'horizontal')
            H_B = create_relationship_diagram([figures[7], solution], 'horizontal')
            H = utility.union(H_A, H_B)

            V_A = create_relationship_diagram([figures[2], figures[5]], 'vertical')
            V_B = create_relationship_diagram([figures[5], solution], 'vertical')
            V = utility.union(V_A, V_B)

            D = create_relationship_diagram([figures[4], solution], 'diagonal')

        else:
            H = create_relationship_diagram([figures[2], solution], 'horizontal', '2x2')
            V = create_relationship_diagram([figures[1], solution], 'vertical', '2x2')
            D = None

        score = agent_compare(init_network, H, V, D, problem, i + 1)
        scores.append(score)

    scores = utility.normalize_scores(scores, problem)
    print(scores)

    if 1.0 not in scores:

        if problem.problemType == '3x3':
            m_diagonal = comparison.compare_diagonal(scores, figures, solutions, problem)
            print('comparing diagonals to finalize score')

            possible_scores = [m_diagonal]
            m = min(possible_scores, key=lambda t: t[1])
            scores = utility.get_score(m, problem)
        else:
            m_union = comparison.compare_union(scores, figures, solutions, problem)
            print('comparing union to finalize score')

            possible_scores = [m_union]
            m = min(possible_scores, key=lambda t: t[1])
            scores = utility.get_score(m, problem)

    return scores
예제 #4
0
def create_semantic_network(figures, problem):

    if problem.problemType == '3x3':

        H_1A = create_relationship_diagram([figures[0], figures[1]],
                                           'horizontal')
        H_1B = create_relationship_diagram([figures[1], figures[2]],
                                           'horizontal')
        H1 = utility.union(H_1A, H_1B)

        H_2A = create_relationship_diagram([figures[3], figures[4]],
                                           'horizontal')
        H_2B = create_relationship_diagram([figures[4], figures[5]],
                                           'horizontal')
        H2 = utility.union(H_2A, H_2B)

        V_1A = create_relationship_diagram([figures[0], figures[3]],
                                           'vertical')
        V_1B = create_relationship_diagram([figures[3], figures[6]],
                                           'vertical')
        V1 = utility.union(V_1A, V_1B)

        V_2A = create_relationship_diagram([figures[1], figures[4]],
                                           'vertical')
        V_2B = create_relationship_diagram([figures[4], figures[7]],
                                           'vertical')
        V2 = utility.union(V_2A, V_2B)

        D = create_relationship_diagram([figures[0], figures[4]], 'diagonal')
        R = (H1, H2, V1, V2, D)
        return R
    else:
        H1 = create_relationship_diagram([figures[0], figures[1]],
                                         'horizontal', '2x2')
        V1 = create_relationship_diagram([figures[0], figures[2]], 'vertical',
                                         '2x2')
        R = (H1, V1)
        return R