コード例 #1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("*** This is Monitor from KAOSTools. ***");
            Console.WriteLine("*** For more information on KAOSTools see <https://github.com/ancailliau/KAOSTools> ***");
            Console.WriteLine("*** Please report bugs to <https://github.com/ancailliau/KAOSTools/issues> ***");
            Console.WriteLine();
            Console.WriteLine("*** Copyright (c) 2017, Université catholique de Louvain ***");
            Console.WriteLine("");

            string rootname = "root";

            options.Add("roots=", "Specify the roots goal for which to compute the satisfaction rate. (Default: root)", v => rootname = v);

            string outfile = null;

            options.Add("outfile=", "Specify the output file for the satisfaction rates", v => outfile = v);

            Init(args);

            optimization_model = BuildModel();

            roots = rootname.Split(',').Select(x => model.Goal(x)).ToHashSet();
            if (roots.Count() == 0 || roots.Any(x => x == null))
            {
                PrintError("A root goal among '" + rootname + "' was not found");
            }

            try {
                modelMonitor = new ModelMonitor(model, roots);
                modelMonitor.SetOutputFile(outfile);

                _active_resolutions = new HashSet <Resolution>();
                _integrator_model   = new SoftResolutionIntegrator(model);

                //optimizer = new MOCECountermeasureSelectionOptimizer(optimization_model);
                //optimization_model.satisfactionRateRepository = modelMonitor._model_running.satisfactionRateRepository;

                var commands = new List <ICommand>();
                commands.Add(new GetSatisfactionRateCommand(model, roots, modelMonitor));
                commands.Add(new ExportModelCommand(model));
                commands.Add(new PrintDebugCommand(model, roots, modelMonitor));

                stop = false;

                Listen();
                Optimize();

                while (!stop)
                {
                    Console.Write("> ");
                    var input = Console.ReadLine();
                    if (input.Equals("quit") | input.Equals("exit"))
                    {
                        stop = true;
                        continue;
                    }

                    foreach (var command in commands)
                    {
                        command.Execute(input);
                    }
                }

                Console.WriteLine("Exiting...");
                modelMonitor.Stop();
            } catch (Exception e) {
                PrintError("An error occured during the computation. (" + e.Message + ").\n"
                           + "Please report this error to <https://github.com/ancailliau/KAOSTools/issues>.\n"
                           + "----------------------------\n"
                           + e.StackTrace
                           + "\n----------------------------\n");
            }
        }
コード例 #2
0
 public GetSatisfactionRateCommand(KAOSModel model, HashSet <Goal> root, ModelMonitor modelMonitor)
 {
     _modelMonitor = modelMonitor;
     _model        = model;
     _root         = root.Select(x => x.Identifier).ToHashSet();
 }
コード例 #3
0
 public PrintDebugCommand(KAOSModel model, HashSet <Goal> root, ModelMonitor modelMonitor)
 {
     _modelMonitor = modelMonitor;
     _model        = model;
     _root         = root.Select(x => x.Identifier).ToHashSet();
 }