Exemple #1
0
    def __call__(self, obj, out, system, parent_name):
        node_name = "RULE_" + ID(obj)
        name = obj.getName(system)
        out.write("""#  subgraph "%(node_name)s" {
#    label="%(name)s";
    """ % locals())
        operator_node_name = print_dot(obj.operator, out, system, node_name)

        if isinstance(obj.adjective, fuzzy.Adjective.Adjective):
            #out.write("{rank=max;\n")
            adj_node_name = print_dot(obj.adjective, out, system, node_name)
            #out.write("}\n")
            self.make_connection(
                out, operator_node_name, adj_node_name, {
                    "label":
                    name +
                    ("" if obj.certainty == 1.0 else ": %g" % obj.certainty)
                })
        elif isinstance(obj.adjective, list):
            for adj in obj.adjective:
                #out.write("{rank=max;\n")
                adj_node_name = print_dot(adj, out, system, node_name)
                #out.write("}\n")
                self.make_connection(
                    out, operator_node_name, adj_node_name, {
                        "label":
                        name + ("" if obj.certainty == 1.0 else ": %g" %
                                obj.certainty)
                    })
        else:
            raise Exception("rule target not set.")
        return ""
Exemple #2
0
 def __call__(self,obj,out,system,parent_name):
     prefix = (parent_name+"_") if _XXX else ""
     node_name = prefix + "NOT_" + ID(obj)
     self.make_node(out,node_name)
     inp_node_name = print_dot(obj.input,out,system,node_name)
     self.make_connection(out,inp_node_name,node_name)
     return node_name
Exemple #3
0
 def __call__(self, obj, out, system, parent_name):
     prefix = (parent_name + "_") if _XXX else ""
     node_name = prefix + "NOT_" + ID(obj)
     self.make_node(out, node_name)
     inp_node_name = print_dot(obj.input, out, system, node_name)
     self.make_connection(out, inp_node_name, node_name)
     return node_name
Exemple #4
0
 def __call__(self,obj,out,system,parent_name):
     node_name = "VAR_" + ID(obj)
     name = obj.getName(system)
     #rank = "max" if isinstance(obj,fuzzy.OutputVariable.OutputVariable) else "min"
     #out.write("{rank=%(rank)s;\n" % locals())
     self.make_node(out,node_name,{"label":name})
     #out.write("}\n")
     #out.write("subgraph XXX {rank=same;\n")
     for adj in obj.adjectives.values():
         adj_node_name = print_dot(adj,out,system,node_name)
         self.make_connection(out,node_name,adj_node_name)
     #out.write("}\n")
     return ""
Exemple #5
0
 def __call__(self, obj, out, system, parent_name):
     node_name = "VAR_" + ID(obj)
     name = obj.getName(system)
     #rank = "max" if isinstance(obj,fuzzy.OutputVariable.OutputVariable) else "min"
     #out.write("{rank=%(rank)s;\n" % locals())
     self.make_node(out, node_name, {"label": name})
     #out.write("}\n")
     #out.write("subgraph XXX {rank=same;\n")
     for adj in obj.adjectives.values():
         adj_node_name = print_dot(adj, out, system, node_name)
         self.make_connection(out, node_name, adj_node_name)
     #out.write("}\n")
     return ""
Exemple #6
0
    def __call__(self,obj,out,system,parent_name):
        node_name = "RULE_" + ID(obj)
        name = obj.getName(system)
        out.write(
"""#  subgraph "%(node_name)s" {
#    label="%(name)s";
    """ % locals())
        operator_node_name = print_dot(obj.operator,out,system,node_name)

        if isinstance(obj.adjective,fuzzy.Adjective.Adjective):
            #out.write("{rank=max;\n")
            adj_node_name = print_dot(obj.adjective,out,system,node_name)
            #out.write("}\n")
            self.make_connection(out,operator_node_name,adj_node_name,{"label": name + ("" if obj.certainty == 1.0 else ": %g" % obj.certainty) })
        elif isinstance(obj.adjective,list):
            for adj in obj.adjective:
                #out.write("{rank=max;\n")
                adj_node_name = print_dot(adj,out,system,node_name)
                #out.write("}\n")
                self.make_connection(out,operator_node_name,adj_node_name,{"label": name + ("" if obj.certainty == 1.0 else ": %g" % obj.certainty) })
        else:
            raise Exception("rule target not set.")
        return ""
Exemple #7
0
 def __call__(self,obj,out,system,parent_name):
     #out.write("{rank=min;\n")
     input_name = print_dot(obj.adjective,out,system,parent_name)
     #out.write("}\n")
     return input_name
Exemple #8
0
 def __call__(self,obj,out,system,parent_name):
     norm_name = print_dot(obj.norm,out,system,parent_name)
     for i in obj.inputs:
         inp_node_name = print_dot(i,out,system,norm_name)
         self.make_connection(out,inp_node_name,norm_name)
     return norm_name
Exemple #9
0
 def __call__(self, obj, out, system, parent_name):
     norm_name = print_dot(obj.norm, out, system, parent_name)
     for i in obj.inputs:
         inp_node_name = print_dot(i, out, system, norm_name)
         self.make_connection(out, inp_node_name, norm_name)
     return norm_name
Exemple #10
0
 def __call__(self, obj, out, system, parent_name):
     #out.write("{rank=min;\n")
     input_name = print_dot(obj.adjective, out, system, parent_name)
     #out.write("}\n")
     return input_name