Example #1
0
    def _extract_parameters(self, settings, structure, parameters,
                            **kwargs) -> None:
        bpmn, process_graph = structure
        p_extractor = spm.StructureParametersMiner(self.log_train, bpmn,
                                                   process_graph, settings)
        num_inst = len(self.log_valdn.caseid.unique())
        # Get minimum date
        start_time = (self.log_valdn.start_timestamp.min().strftime(
            "%Y-%m-%dT%H:%M:%S.%f+00:00"))
        p_extractor.extract_parameters(num_inst, start_time,
                                       parameters['resource_pool'])
        if p_extractor.is_safe:
            parameters = {**parameters, **p_extractor.parameters}
            # print parameters in xml bimp format
            xml.print_parameters(
                os.path.join(settings['output'],
                             settings['file'].split('.')[0] + '.bpmn'),
                os.path.join(settings['output'],
                             settings['file'].split('.')[0] + '.bpmn'),
                parameters)

            self.log_valdn.rename(columns={'user': '******'}, inplace=True)
            self.log_valdn['source'] = 'log'
            self.log_valdn['run_num'] = 0
            self.log_valdn['role'] = 'SYSTEM'
            self.log_valdn = self.log_valdn[~self.log_valdn.task.
                                            isin(['Start', 'End'])]
        else:
            raise RuntimeError('Parameters extraction error')
Example #2
0
 def extract_parameters(self) -> None:
     print("-- Mining Simulation Parameters --")
     p_extractor = par.ParameterMiner(self.log, self.bpmn,
                                      self.process_graph, self.settings)
     p_extractor.extract_parameters()
     self.process_stats = p_extractor.process_stats
     # print parameters in xml bimp format
     xml.print_parameters(
         os.path.join(self.settings['output'],
                      self.settings['file'].split('.')[0] + '.bpmn'),
         os.path.join(self.settings['output'],
                      self.settings['file'].split('.')[0] + '.bpmn'),
         p_extractor.parameters)
     self.process_stats = pd.DataFrame.from_records(self.process_stats)
Example #3
0
File: simod.py Project: dtdi/Simod
 def extract_parameters(self, **kwargs) -> None:
     print("-- Mining Simulation Parameters --")
     p_extractor = par.ParameterMiner(self.log_train, self.bpmn,
                                      self.process_graph, self.settings)
     num_inst = len(pd.DataFrame(self.log_test).caseid.unique())
     p_extractor.extract_parameters(num_inst)
     self.process_stats = self.process_stats.merge(
         p_extractor.resource_table[['resource', 'role']],
         on='resource',
         how='left')
     # print parameters in xml bimp format
     xml.print_parameters(
         os.path.join(self.settings['output'],
                      self.settings['file'].split('.')[0] + '.bpmn'),
         os.path.join(self.settings['output'],
                      self.settings['file'].split('.')[0] + '.bpmn'),
         p_extractor.parameters)
Example #4
0
def single_exec(settings):
    """Main aplication method"""
    # Read settings from config file
    settings = read_settings(settings)
    # Output folder creation
    if not os.path.exists(settings['output']):
        os.makedirs(settings['output'])
        os.makedirs(os.path.join(settings['output'], 'sim_data'))
    # Copy event-log to output folder
    copyfile(os.path.join(settings['input'], settings['file']),
             os.path.join(settings['output'], settings['file']))
    # Event log reading
    log = lr.LogReader(os.path.join(settings['output'], settings['file']),
                       settings['timeformat'])
    # Execution steps
    mining_structure(settings, settings['epsilon'], settings['eta'])
    bpmn = br.BpmnReader(os.path.join(settings['output'],
                                      settings['file'].split('.')[0]+'.bpmn'))
    process_graph = gph.create_process_structure(bpmn)

    # Evaluate alignment
    chk.evaluate_alignment(process_graph, log, settings)

    print("-- Mining Simulation Parameters --")
    parameters, process_stats = par.extract_parameters(log, bpmn, process_graph)
    xml.print_parameters(os.path.join(settings['output'],
                                      settings['file'].split('.')[0]+'.bpmn'),
                         os.path.join(settings['output'],
                                      settings['file'].split('.')[0]+'.bpmn'),
                         parameters)
    response = list()
    status = 'ok'
    sim_values = list()
    if settings['simulation']:
#        if settings['analysis']:
        process_stats = pd.DataFrame.from_records(process_stats)
        for rep in range(settings['repetitions']):
            print("Experiment #" + str(rep + 1))
            try:
                simulate(settings, rep)
                process_stats = process_stats.append(measure_stats(settings,
                                                                   bpmn, rep),
                                                     ignore_index=True,
                                                     sort=False)
                sim_values.append(gen.mesurement(process_stats, settings, rep))
            except:
                status = 'fail'
                break
    data = {'alg_manag': settings['alg_manag'],
            'epsilon': settings['epsilon'],
            'eta': settings['eta'],
            'output': settings['output']
            }

    if status == 'ok':
        loss = (1 - np.mean([x['act_norm'] for x in sim_values]))
        if loss < 0:
            response.append({**{'loss': loss, 'status': 'fail'}, **data})
        else:
            response.append({**{'loss': loss, 'status': status}, **data})
    else:
        response.append({**{'loss': 1, 'status': status}, **data})

    return response
Example #5
0
# -*- coding: utf-8 -*-
from extraction import parameter_extraction as par
from support_modules.readers import readers as rd
from support_modules.writers import xml_writer as xml_bimp
from sys import argv

log_file_name = argv[1]
bpmn_file_name = argv[2]
output_file_bimp = argv[3]

print("-- Mining Simulation Parameters --")
timeformat = "%Y-%m-%dT%H:%M:%S"
log_columns_numbers = "[0]"
log, bpmn = rd.read_inputs(timeformat, log_columns_numbers, log_file_name, bpmn_file_name, False)
print("-- Successfully read log and model --")
parameters,_ = par.extract_parameters(log, bpmn)
xml_bimp.print_parameters(bpmn_file_name, output_file_bimp, parameters)