/// <summary> /// This is the event handler for SFS Solving Event. /// It prints out the detailed information on the IPM solve process. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void SolvingEventHandler(object sender, SolvingEventArgs e) { if (e[SolverProperties.SolveState].ToString() == "Init") return; StringBuilder sb = new StringBuilder(); if ((Int32)e[SolverProperties.IterationCount] == 1) { // print the header sb.AppendLine("Iteration PrimalObjective DualObjective AbsoluteGap"); // Gap is null for the iteration 1 sb.AppendFormat("{0,-9:G2} {1,15:F5} {2,15:F5}{3}", (Int32)e[SolverProperties.IterationCount], (double)e[InteriorPointProperties.PrimalObjectiveValue], (double)e[InteriorPointProperties.DualObjectiveValue], Environment.NewLine); } else sb.AppendFormat("{0,-9:G2} {1,15:F5} {2,15:F5} {3,15:F9}{4}", (Int32)e[SolverProperties.IterationCount], (double)e[InteriorPointProperties.PrimalObjectiveValue], (double)e[InteriorPointProperties.DualObjectiveValue], (double)e[InteriorPointProperties.AbsoluteGap], Environment.NewLine); // append the new solve log to the textbox OnSolveLogUpdated(new SolveLogUpdatedEventArgs(sb.ToString())); // this is added for demo purpose Thread.Sleep(50); }
/// <summary> /// Raises the <see cref="E:Progress" /> event. /// </summary> /// <param name="e">The <see cref="SolvingEventArgs"/> instance containing the event data.</param> protected virtual void OnEngineStatus(SolvingEventArgs e) { this.Progress?.Invoke(this, e); }
public void SolvingEventHandler(object sender, SolvingEventArgs e) { try { if (e[SolverProperties.SolveState].ToString() == "Init") return; StringBuilder sb = new StringBuilder(); if ((Int32) e[SolverProperties.IterationCount] == 1) { // print the header sb.AppendLine("Iteration PrimalObjective DualObjective AbsoluteGap"); // Gap is null for the iteration 1 sb.AppendFormat("{0,-9:G2} {1,15:F5} {2,15:F5}{3}", (Int32) e[SolverProperties.IterationCount], (double) e[InteriorPointProperties.PrimalObjectiveValue], (double) e[InteriorPointProperties.DualObjectiveValue], Environment.NewLine); } else sb.AppendFormat("{0,-9:G2} {1,15:F5} {2,15:F5} {3,15:F9}{4}", (Int32) e[SolverProperties.IterationCount], (double) e[InteriorPointProperties.PrimalObjectiveValue], (double) e[InteriorPointProperties.DualObjectiveValue], (double) e[InteriorPointProperties.AbsoluteGap], Environment.NewLine); Logger.Debug(sb.ToString(), typeof (RvolSolver)); } catch { } }
/// <summary> /// Called when progress event is raised. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="SolvingEventArgs"/> instance containing the event data.</param> private void OnProgress(object sender, SolvingEventArgs e) { this.ProgressTextBlock.Text = e.ProgressState == StateValue.OnTheWay ? $"Moving to X:{e.Position.X} Y:{e.Position.Y}" : $"Target reached at X:{e.Position.X} Y:{e.Position.Y}"; this.MovesTextBlock.Text = e.Moves.ToString(); }