Exemplo n.º 1
0
    def OperationDataGenerator(self, operation):
        myFile = open(
            'performance_testing/performance_datasets/' + self.operation_type +
            '_data_performance.csv', 'w')
        writer = csv.writer(myFile)
        writer.writerows([["Features", "Seconds", "Percent_cons"]])
        for cons in self.percent_cons:
            for feat in self.features:
                path = "models/synthetic/simple_betty_gen_models/" + str(
                    feat) + "/" + str(cons) + "-9.xml"
                parser = XMLTransformation(path)
                fm = parser.transform()

                if self.operation_type in ("vc", "f"):
                    configuration = self.get_config(fm)
                    operation.set_configuration(configuration)

                transform = FmToPysat(fm)
                transform.transform()

                if self.operation_type == "vp":
                    product = self.get_product(fm, transform)
                    operation.set_configuration(product)

                t0 = time.time()
                operation.execute(transform.destination_model)
                t1 = time.time() - t0

                writer.writerows([[feat, t1, cons]])

        print(
            "Generated data!\nNow you can see it with Seaborn Visualizer file")
Exemplo n.º 2
0
    def get_results(self, fm_model, case_results) -> tuple[Any, Any]:
        transform = FmToPysat(fm_model)
        transform.transform()
        pysat_model = transform.destination_model

        if self.operation_type == "p":
            operation = Glucose3Products()
        elif self.operation_type == "pn":
            operation = Glucose3ProductsNumber()
            case_results = len(case_results)
        elif self.operation_type == "cf":
            operation = Glucose3CoreFeatures()
            if case_results:
                cores = list(pysat_model.features.values())
            else:
                cores = []
            for product in case_results:
                cores = [feature for feature in product if feature in cores]
            case_results = cores
        elif self.operation_type == "df":
            operation = Glucose3DeadFeatures()
            deads = list(pysat_model.features.values())
            for product in case_results:
                deads = [
                    feature for feature in deads if feature not in product
                ]
            case_results = deads
        elif self.operation_type == "v":
            operation = Glucose3Valid()
            if case_results:
                case_results = True
            else:
                case_results = False
        elif self.operation_type == "fof":
            operation = Glucose3FalseOptionalFeatures()
            falses = []
            if case_results:
                cores = list(pysat_model.features.values())
            else:
                cores = []
            for product in case_results:
                cores = [feature for feature in product if feature in cores]
            for relation in fm_model.relations:
                names = [feat.name for feat in relation.children]
                for core in cores:
                    relation_check = relation.is_optional() or relation.is_or(
                    ) or relation.is_alternative()
                    if core in names and relation_check:
                        falses.append(core)

            case_results = falses
        else:
            raise Exception("The operation type is not defined")

        operation.execute(pysat_model)
        operation_results = operation.get_result()

        return operation_results, case_results
Exemplo n.º 3
0
    def setUp(self):
        xmlreader = XMLTransformation(
            "models/fama_test_suite/relationships/allrelationships/allrelationships.xml"
        )
        fm = xmlreader.transform()

        transform = FmToPysat(fm)
        return fm, transform.transform()
Exemplo n.º 4
0
    def setUp(self, model_path):
        xmlreader = XMLTransformation(model_path)
        fm = xmlreader.transform()

        transform = FmToPysat(fm)
        return transform.transform()
Exemplo n.º 5
0
from famapy.metamodels.pysat_metamodel.operations.glucose3_valid import Glucose3Valid
from famapy.metamodels.pysat_metamodel.transformations.fm_to_pysat import FmToPysat

# Parse a file
xmlreader = XMLTransformation("example.fama")
fm = xmlreader.transform()

# print the model
print(fm)

# Create a detination metamodel (Pysat for the record)
sat = PySATModel()

# Transform the first onto the second
transform = FmToPysat(fm, sat)
transform.transform()

# Create the operation
valid = Glucose3Valid()

# Execute the operation . TODO Investigate how t avoid that sat parameter
valid.execute(sat)

# Print the result
print("Is the model valid: " + str(valid.isValid()))

# Create the operation
products = Glucose3Products()

# Execute the operation . TODO Investigate how t avoid that sat parameter
products.execute(sat)