public QpReport(double[] x, int iterations, TerminationType type, long time) { this.x = x; this.iterations = iterations; this.type = type; this.time = time; }
public CycleSplitFail(DateTime firstGreenEvent, DateTime redEvent, DateTime yellowEvent, DateTime lastGreenEvent, TerminationType terminationType, int firstSecondsOfRed) : base(firstGreenEvent, redEvent, yellowEvent, lastGreenEvent) { FirstSecondsOfRed = firstSecondsOfRed; TerminationEvent = terminationType; }
public Offer(OfferId offerid, OfferKind kind, uint typeid, uint amount, uint pieceprice, string character, TerminationType terminationtype) { this.OfferId = offerid; this.Kind = kind; this.TypeId = typeid; this.Amount = amount; this.PiecePrice = pieceprice; this.Character = character; this.TerminationType = terminationtype; }
private void DrawTerminatorSection(ComponentGenerator gen) { gen.TerminatorType = (TerminationType)EditorGUILayout.EnumPopup("TerminatorType", gen.TerminatorType); ClearPreviousTerminators(gen, PrevTerminationType); switch (gen.TerminatorType) { case TerminationType.Internal: gen.Terminator = null; break; case TerminationType.External: gen.Terminator = (GeneratorTerminatorComponent)EditorGUILayout.ObjectField("Terminator", gen.Terminator, typeof(GeneratorTerminatorComponent), true); EditorGUILayout.Space(); if (gen.Terminator != null) { try { CreateEditor(gen.Terminator).DrawDefaultInspector(); } catch (NullReferenceException) { //is ok. just don't draw it. } } break; case TerminationType.Duration: DurationTerminator TimedTermnator = gen.gameObject.GetComponent <DurationTerminator>() ?? gen.gameObject.AddComponent <DurationTerminator>(); TimedTermnator.Duration = EditorGUILayout.FloatField("Duration", TimedTermnator.Duration); gen.Terminator = TimedTermnator; break; case TerminationType.Counter: CountTerminator CountTerminator = gen.gameObject.GetComponent <CountTerminator>() ?? gen.gameObject.AddComponent <CountTerminator>(); CountTerminator.MaxGeneration = EditorGUILayout.IntField("Max Count", CountTerminator.MaxGeneration); gen.Terminator = CountTerminator; break; case TerminationType.OnSkip: SkippedTerminator SkipTerminator = gen.gameObject.GetComponent <SkippedTerminator>() ?? gen.gameObject.AddComponent <SkippedTerminator>(); gen.Terminator = SkipTerminator; break; } PrevTerminationType = gen.TerminatorType; }
public override bool OnJobTerminated(string id, string jobMetadata, TerminationType type) { string failedMessage = string.Empty; if (type == TerminationType.DidNotRespond) { failedMessage = string.Format("Job {0} was terminated because it did not respond.", id); } else { failedMessage = string.Format("Job {0} experienced an unhandled exception and exited. See log info.", id); } SetFailureStatus(id, 0, failedMessage, string.Empty); return(true); }
protected override void FitModel() { //Add a fitting variable alglib.minlmreport mla = GeneralLMFitting(); TerminationType term = (TerminationType)Enum.ToObject(typeof(TerminationType), mla.terminationtype); ReasonMarquadtEnded = term; //bad fit if (term == TerminationType.MaxIterations || term == TerminationType.WrongParams) { SuccessfulFit = false; pParameters = null; } else { SuccessfulFit = true; makeYHAT(); } }
private void ClearPreviousTerminators(ComponentGenerator gen, TerminationType prev) { if (prev == gen.TerminatorType || prev == TerminationType.Internal) { return; } gen.Terminator = null; switch (prev) { case TerminationType.Duration: DestroyImmediate(gen.gameObject.GetComponent <DurationTerminator>()); break; case TerminationType.Counter: DestroyImmediate(gen.gameObject.GetComponent <CountTerminator>()); break; case TerminationType.OnSkip: DestroyImmediate(gen.gameObject.GetComponent <SkippedTerminator>()); break; } }
protected override void OnTerminate(string contentInfo, TerminationType type) { base.OnTerminate(contentInfo, type); }
/// <summary> /// Starts the execution of the defined workspace /// 1) Parses the commandline parameters /// 2) Creates CT2 model and execution engine /// 3) Starts execution /// 4) Gives data as defined by user to the model /// 5) Retrieves results for output and outputs these /// 6) [terminates] /// </summary> /// <param name="args"></param> public void Start(string[] args) { _startTime = DateTime.Now; //Step 0: Set locale to English var cultureInfo = new CultureInfo("en-us", false); CultureInfo.CurrentCulture = cultureInfo; CultureInfo.CurrentUICulture = cultureInfo; CultureInfo.DefaultThreadCurrentCulture = cultureInfo; //Step 1: Check, if Help needed if (ArgsHelper.GetShowHelp(args)) { Environment.Exit(0); } //Step 2: Get cwm_file to open string cwm_file = ArgsHelper.GetCWMFileName(args); if (cwm_file == null) { Console.WriteLine("Please specify a cwm file using -cwm=filename"); Environment.Exit(-1); } if (!File.Exists(cwm_file)) { Console.WriteLine("Specified cwm file \"{0}\" does not exist", cwm_file); Environment.Exit(-2); } //Step 3: Get additional parameters _verbose = ArgsHelper.CheckVerboseMode(args); try { _timeout = ArgsHelper.GetTimeout(args); } catch (Exception ex) { Console.WriteLine(ex.Message); Environment.Exit(-2); } try { _loglevel = ArgsHelper.GetLoglevel(args); } catch (Exception ex) { Console.WriteLine(ex.Message); Environment.Exit(-2); } try { _terminationType = ArgsHelper.GetTerminationType(args); } catch (Exception ex) { Console.WriteLine(ex.Message); Environment.Exit(-2); } try { _jsonoutput = ArgsHelper.CheckJsonOutput(args); } catch (Exception ex) { Console.WriteLine(ex.Message); Environment.Exit(-2); } //Step 4: Check, if discover mode was selected if (ArgsHelper.CheckDiscoverMode(args)) { DiscoverCWMFile(cwm_file); Environment.Exit(0); } //Step 5: Get input parameters List <Parameter> inputParameters = null; try { inputParameters = ArgsHelper.GetInputParameters(args); if (_verbose) { foreach (var param in inputParameters) { Console.WriteLine("Input parameter given: " + param); } } } catch (InvalidParameterException ipex) { Console.WriteLine(ipex.Message); Environment.Exit(-3); } catch (Exception ex) { Console.WriteLine("Exception occured while parsing parameters: {0}", ex.Message); Environment.Exit(-3); } //Step 6: Get output parameters List <Parameter> outputParameters = null; try { outputParameters = ArgsHelper.GetOutputParameters(args); if (_verbose) { foreach (var param in inputParameters) { Console.WriteLine("Output parameter given: " + param); } } } catch (InvalidParameterException ipex) { Console.WriteLine(ipex.Message); Environment.Exit(-3); } catch (Exception ex) { Console.WriteLine("Exception occured while parsing parameters: {0}", ex.Message); Environment.Exit(-3); } //Step 7: Update application domain. This allows loading additional .net assemblies try { UpdateAppDomain(); } catch (Exception ex) { Console.WriteLine("Exception occured while updating AppDomain: {0}", ex.Message); Environment.Exit(-4); } //Step 8: Load cwm file and create model try { ModelPersistance modelPersistance = new ModelPersistance(); _workspaceModel = modelPersistance.loadModel(cwm_file, true); foreach (var pluginModel in _workspaceModel.GetAllPluginModels()) { pluginModel.Plugin.OnGuiLogNotificationOccured += OnGuiLogNotificationOccured; } } catch (Exception ex) { Console.WriteLine("Exception occured while loading model from cwm file: {0}", ex.Message); Environment.Exit(-5); } //Step 9: Set input parameters foreach (var param in inputParameters) { string name = param.Name; bool found = false; foreach (var component in _workspaceModel.GetAllPluginModels()) { //we also memorize here the name of each plugin if (!_pluginNames.ContainsKey(component.Plugin)) { _pluginNames.Add(component.Plugin, component.GetName()); } if (component.GetName().ToLower().Equals(param.Name.ToLower())) { if (component.PluginType.FullName.Equals("CrypTool.TextInput.TextInput")) { var settings = component.Plugin.Settings; var textProperty = settings.GetType().GetProperty("Text"); if (param.ParameterType == ParameterType.Text || param.ParameterType == ParameterType.Number) { textProperty.SetValue(settings, param.Value); } else if (param.ParameterType == ParameterType.File) { try { if (!File.Exists(param.Value)) { Console.WriteLine("Input file does not exist: {0}", param.Value); Environment.Exit(-7); } var value = File.ReadAllText(param.Value); textProperty.SetValue(settings, value); } catch (Exception ex) { Console.WriteLine("Exception occured while reading file {0}: {0}", param.Value, ex.Message); Environment.Exit(-7); } } //we need to call initialize to get the new text to the ui of the TextInput component //otherwise, it will output the value retrieved by deserialization component.Plugin.Initialize(); found = true; } } } if (!found) { Console.WriteLine("Component for setting input parameter not found: {0}", param); Environment.Exit(-7); } } //Step 10: Set output parameters foreach (var param in outputParameters) { string name = param.Name; bool found = false; foreach (var component in _workspaceModel.GetAllPluginModels()) { if (component.GetName().ToLower().Equals(param.Name.ToLower())) { if (component.PluginType.FullName.Equals("TextOutput.TextOutput")) { component.Plugin.PropertyChanged += Plugin_PropertyChanged; found = true; } } } if (!found) { Console.WriteLine("TextOutput for setting output parameter not found: {0}", param); Environment.Exit(-7); } } //Step 11: add OnPluginProgressChanged handlers foreach (var plugin in _workspaceModel.GetAllPluginModels()) { plugin.Plugin.OnPluginProgressChanged += OnPluginProgressChanged; } //Step 12: Create execution engine try { _engine = new ExecutionEngine(null); _engine.OnGuiLogNotificationOccured += OnGuiLogNotificationOccured; _engine.Execute(_workspaceModel, false); } catch (Exception ex) { Console.WriteLine("Exception occured while executing model: {0}", ex.Message); Environment.Exit(-7); } //Step 13: Start execution in a dedicated thread DateTime endTime = DateTime.Now.AddSeconds(_timeout); Thread t = new Thread(() => { CultureInfo.CurrentCulture = new CultureInfo("en-Us", false); while (_engine.IsRunning()) { Thread.Sleep(100); if (_engine.IsRunning() && _timeout < int.MaxValue && DateTime.Now >= endTime) { Console.WriteLine("Timeout ({0} seconds) reached. Kill process hard now", _timeout); Environment.Exit(-8); } } if (_verbose) { Console.WriteLine("Execution engine stopped. Terminate now"); Console.WriteLine("Total execution took: {0}", DateTime.Now - _startTime); } Environment.Exit(0); }); t.Start(); }