from utils import * from bigraph2xmi.models import Entity from bigraph2xmi.parser import parser from bigraph2xmi.xml_writer import make_xmi if __name__ == '__main__': cur_time = int((datetime.datetime.now() - datetime.datetime(1970, 1, 1)).total_seconds() * 1000) path = 'state/{0}'.format(cur_time) os.mkdir(path) random.seed(20161726) instance = generate_instance(config) random.seed(cur_time) assign_state(instance, state_config) with open('{0}/instance.json'.format(path), 'w') as f: json.dump(instance, f, indent=2) bigraph = dict_to_bigraph(instance) with open('{0}/instance.bi'.format(path), 'w') as f: f.write(bigraph) with open('{0}/instance.xmi'.format(path), 'w') as f: parser.parse(bigraph) f.write(make_xmi(Entity.instances)) gm = generate_goals(instance, goal_model, goal_config) assign_weight(gm) with open('{0}/goal.json'.format(path), 'w') as f: parser.parse(dict_to_bigraph(instance)) json.dump(gm, f, indent=2)
# coding: utf-8 import os import sys from bigraph2xmi.models import Entity from bigraph2xmi.parser import parser from bigraph2xmi.xml_writer import make_xmi if __name__ == '__main__': if not os.path.exists('output'): os.mkdir('output') input_file_name = sys.argv[1] if not os.path.exists(input_file_name): print("{} do not exist!".format(input_file_name)) sys.exit() with open(input_file_name, 'r') as input_file, \ open('output/input.xmi', 'w') as output_file: parser.parse(input_file.read()) output_file.write(str((make_xmi(Entity.instances)), encoding="utf8"))