コード例 #1
0
 def perform_tbr_net_variants(self, net, im, fm, var_list=None, parameters=None):
     if parameters is None:
         parameters = {}
     if var_list is None:
         variants = self.get_variants(parameters=parameters)
         var_list = [[x, y] for x,y in variants.items()]
     petri_string = pnml_exporter.export_petri_as_string(net, im, fm, parameters=parameters)
     return slave.perform_token_replay(petri_string, var_list, parameters=parameters)
コード例 #2
0
def perform_tbr():
    try:
        from pm4pydistr.slave import slave

        process = request.args.get('process', type=str)
        keyphrase = request.args.get('keyphrase', type=str)
        session = request.args.get('session', type=str)
        use_transition = request.args.get(PARAMETER_USE_TRANSITION,
                                          type=str,
                                          default=str(DEFAULT_USE_TRANSITION))
        no_samples = request.args.get(PARAMETER_NO_SAMPLES,
                                      type=int,
                                      default=DEFAULT_MAX_NO_SAMPLES)

        try:
            content = json.loads(request.data)
        except:
            content = json.loads(request.data.decode('utf-8'))

        petri_string = content["petri_string"]
        var_list = content["var_list"]
        enable_parameters_precision = content["enable_parameters_precision"]
        consider_remaining_in_fitness = content[
            "consider_remaining_in_fitness"]

        if keyphrase == configuration.KEYPHRASE:
            parameters = {
                "enable_parameters_precision": enable_parameters_precision,
                "consider_remaining_in_fitness": consider_remaining_in_fitness
            }

            return jsonify({
                "tbr":
                slave.perform_token_replay(petri_string,
                                           var_list,
                                           parameters=parameters)
            })

        return jsonify({})
    except:
        return traceback.format_exc()