Beispiel #1
0
class Transition:
    def __init__(self, id):
        self.id = id
        self.fromStateID = None
        self.toStateID = None
        self.condition = None
        self.priority = 0
        self.cg = TransitionCodegen(self)
        self.graphic = TransitionGraphic(self)
        self.actions = []

    def parseCfg(self, etreeNode):
        for child in etreeNode:
            if (child.tag == "from"):
                self.fromStateID = int(child.text)
            elif (child.tag == "to"):
                self.toStateID = int(child.text)
            elif (child.tag == "action"):
                newAction = Action()
                newAction.parseCfg(child)
                self.actions.append(newAction)
            elif (child.tag == "condition"):
                self.condition = Comparison()
                self.condition.parseCfg(child)
            elif (child.tag == "priority"):
                self.priority = int(child.text)
            elif (child.tag == "graphic"):
                self.graphic.parseCfg(child)

    def dumpCfg(self):
        return ET.Element(
        )  #TODO: generate XML representation of current object
Beispiel #2
0
def main():
    lotto = Lotto()
    list_lotto = []
    list_lotto = lotto.get_list_of_numbers()
    print("Wyniki przypadkowego losowania, to: ", str(list_lotto))
    url_lotto = UrlLotto()
    list_url_lotto = url_lotto.open_and_write_url()
    comparison = Comparison()
    the_end = comparison.get_comparison(url_lotto.how_much_lines(), list_lotto,
                                        list_url_lotto)
    print("Z porównania wychodzi: ", the_end)
Beispiel #3
0
 def parseCfg(self, etreeNode):
     for child in etreeNode:
         if (child.tag == "from"):
             self.fromStateID = int(child.text)
         elif (child.tag == "to"):
             self.toStateID = int(child.text)
         elif (child.tag == "action"):
             newAction = Action()
             newAction.parseCfg(child)
             self.actions.append(newAction)
         elif (child.tag == "condition"):
             self.condition = Comparison()
             self.condition.parseCfg(child)
         elif (child.tag == "priority"):
             self.priority = int(child.text)
         elif (child.tag == "graphic"):
             self.graphic.parseCfg(child)
def ProcessFrameAxioms(axioms, game_name):
    prefix = 'std_soar_var'
    # standardize all variable names. This is so that if two head literals are the same, they will
    # match string-wise. Also, if any rule has a constant rather than a variable in a variable
    # place, replace it with the variable, and add an extra equality structure to it for later use

    preds_to_bodies = {}  # preds -> [(body, comparisons)]
    preds_to_heads = {}  # preds -> head

    for prefix_i, rule in enumerate(axioms):
        head = rule.head()
        pred = head.term(0).name()
        preds_to_heads[pred] = head
        head_analogue = head.true_analogue()
        body = rule.body()

        arity = head.term(0).num_terms()
        substitutions = ['%s%d' % (prefix, i) for i in range(arity)]
        (const_subs, var_subs) = head.term(0).standardize_vars(substitutions)

        body_var_subs = dict([(v, '%s%d' % (prefix, i))
                              for i, v in var_subs.items()])
        # if a rule has a constant in the place of a variable, that is equivalent
        # to having a constraint that the variable equal the constant
        reg_conds = []
        comp_conds = []
        for i, const in const_subs.items():
            comp_conds.append(Comparison(substitutions[i], '=', const, False))

        for b in body:
            if not same_signature(head_analogue, b):  # ignore frame rule
                PrepareBodyVars(b, body_var_subs, '__r%d__' % prefix_i)
                #				if SentenceIsComp(b):
                #					comp_conds.append(Comparison.make_from_GGP_sentence(b))
                #				else:
                #					reg_conds.append(b)
                # forget about handling comparisons separately
                reg_conds.append(b)

        preds_to_bodies.setdefault(pred, []).append((reg_conds, comp_conds))

    result = []
    # merge the frame axioms into production rules
    for pred, bodies in preds_to_bodies.items():
        result.extend(
            TranslateFrameAxioms(game_name, preds_to_heads[pred], bodies))

    return result
Beispiel #5
0
filename_b = '../13.05/ALL0002/F0002CH1.CSV'
ab_plot(filename_a, filename_b, 'COAX', 'Placa 1')
'''

########################################################################
########################################################################
########################################################################


def print_dict_utf8(dictionary):
    print(json.dumps(dictionary, sort_keys=True, indent=2, ensure_ascii=False))


# Comparison table example:
comparison_csv = '../CEM - 03.05 - Comparison.csv'
comp1 = Comparison(comparison_csv, '13.05')

for i, experiment in enumerate(comp1.experiments):
    print(f'Experimento n°{i+1}:')
    print(f"Título: {experiment['info_dict']['Title']}")
    print(f"Descrição: {experiment['info_dict']['Description']}")
    print(f"Observação:' {experiment['info_dict']['Observation']}")
    print(f'Lista de Arquivos do experimento:')
    print_dict_utf8(experiment['file_list'])
    print('--------------------------------------------\n')

# Example of usage:
filename_a = comp1.experiments[1]['file_list'][0]['File']
filename_b = comp1.experiments[1]['file_list'][1]['File']

ab_plot(filename_a, filename_b, 'BNC', 'COAX')