public MainWindow() { InitializeComponent(); _plotBuilder = new PlotBuilder(); _integralSolver = new IntegralSolver(); _functionDataValidator = new FunctionDataValidator(); }
private void DrawOperationProperty(int index, Color color, PlotBuilder graph) { int[] indices = new int[100]; int[] numIterations = new int[100]; for (int i = 0; i < 100; i++) { indices[i] = i; } Cursor = Cursors.WaitCursor; for (int i = 0; i < 100; i++) { Problem problem = new Problem(); problem.Left = new double[] { 0.0, 0.0 }; problem.Right = new double[] { 1.0, 1.0 }; problem.Constraints = new List <FunctionDelegate>(); GrishaginFunction targetFunction = new GrishaginFunction(i + 1); problem.TargetFunction = delegate(double[] args) { return(-targetFunction.CalculateFunction(args)); }; method = (Method)Activator.CreateInstance(methods[experiments[index].MethodName]); method.SetProblem(problem); method.SetOptions(experiments[index].MethodOptions); method.IsOperationProperty = true; method.MaximumPoint = targetFunction.MaximumPoint; method.Solve(); Text = "Выполнено: " + i + "%"; numIterations[i] = method.GetTrials().Count; } Cursor = Cursors.Default; Text = "OptimLab"; Array.Sort(numIterations, indices); PointF[] points = new PointF[100]; for (int i = 0; i < 100; i++) { points[i] = new PointF(numIterations[i], i + 1); } Plot plotPoints = Triangulator.PointsVertexArray(points); plotPoints.Information.Name = "Points" + index; plotPoints.Color = color; graph.AddPlot(plotPoints); Plot plotLines = Triangulator.CurveStripVertexArray(points); plotLines.Information.Name = "Lines" + index; plotLines.Color = color; graph.AddPlot(plotLines); }
public void TestUsingSetting() { double[][] data = sampleData2D; PlotBuilder builder = Plot.Data(data); builder.Using(new int[] { 1, 2 }); PlotRender render = builder.Plot(); Assert.IsNotNull(render); Assert.IsNull(render.Exception); Assert.IsTrue(render.Output.Exists); }
public void TestTitleSetting() { double[][] data = sampleData2D; PlotBuilder builder = Plot.Data(data); builder.Title("Plot lines"); PlotRender render = builder.Plot(); Assert.IsNotNull(render); Assert.IsNull(render.Exception); Assert.IsTrue(render.Output.Exists); }
public void TestWithSetting() { double[][] data = sampleData2D; PlotBuilder builder = Plot.Data(data); builder.With(PlotType.lines); PlotRender render = builder.Plot(); Assert.IsNotNull(render); Assert.IsNull(render.Exception); Assert.IsTrue(render.Output.Exists); }
public void TestVectorPlot() { double[][] data = new double[][] { new double[] { 1, 1, 0.5, 0.5 }, new double[] { 3, 3, -0.5, -0.5 } }; PlotBuilder builder = Plot.Data(data); builder.With(PlotType.vectors); PlotRender render = builder.Plot(); Assert.IsNotNull(render); Assert.IsNull(render.Exception); Assert.IsTrue(render.Output.Exists); }
private void toolStripMenuItemOperationProperty_Click(object sender, EventArgs e) { List <int> indices = new List <int>(); FormExperiments dialogExperiments = new FormExperiments(); dialogExperiments.Initialize(experiments); if (dialogExperiments.ShowDialog() != DialogResult.OK) { dialogExperiments.Dispose(); return; } indices = dialogExperiments.GetIndices(); if (indices.Count == 0) { MessageBox.Show("Не выбрано ни одного эксперимента", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } dialogExperiments.Dispose(); FormOperationProperties dialogGraph = new FormOperationProperties(); PlotBuilder graph = new PlotBuilder(); graph.ShowPicture = false; graph.Width = 600; graph.Height = 432; graph.Location = new Point(10, 10); dialogGraph.Controls.Add(graph); for (int i = 0; i < indices.Count; i++) { Color color = StandardColors[i % StandardColors.Length]; DrawOperationProperty(indices[i], color, graph); dialogGraph.AddLegendRecord(experiments[indices[i]], color); } Plot plotStub = Triangulator.PointsVertexArray(new PointF[] { new PointF(-5.0f, -8.0f) }); plotStub.Information.Name = "Stub"; plotStub.Color = Color.White; graph.AddPlot(plotStub); dialogGraph.ShowDialog(); dialogGraph.Dispose(); }
public FormMain() { InitializeComponent(); MinimumSize = new Size(640, 480); methods = new Dictionary <string, Type>(); experiments = new List <Experiment>(); FileInfo[] files = new DirectoryInfo(Application.StartupPath).GetFiles(); foreach (FileInfo file in files) { try { Assembly assembly = Assembly.LoadFile(file.FullName); Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (type.IsSubclassOf(typeof(Method)) && !methods.ContainsKey(type.Name)) { methods.Add(type.Name, type); } } } catch (BadImageFormatException ex) { } } Dictionary <string, ToolStripMenuItem> menuItemGroups = new Dictionary <string, ToolStripMenuItem>(); foreach (Type type in methods.Values) { string groupName = ((Method)Activator.CreateInstance(type)).GetGroupName(); if (!menuItemGroups.ContainsKey(groupName)) { ToolStripMenuItem menuItemGroup = new ToolStripMenuItem(); menuItemGroup.Name = "toolStripMenuItemGroup" + groupName; menuItemGroup.Text = groupName; menuItemGroups.Add(groupName, menuItemGroup); } } bool isFirstMethod = true; foreach (String methodName in methods.Keys) { ToolStripMenuItem menuItem = new ToolStripMenuItem(); menuItem.Name = "toolStripMenuItem" + methodName; menuItem.Text = ((Method)Activator.CreateInstance(methods[methodName])).GetMethodName(); menuItem.Click += new EventHandler(toolStripMenuItemAnyMethod_Click); if (isFirstMethod) { menuItemCurrentMethod = menuItem; menuItemCurrentMethod.PerformClick(); isFirstMethod = false; } string groupName = ((Method)Activator.CreateInstance(methods[methodName])).GetGroupName(); menuItemGroups[groupName].DropDownItems.Add(menuItem); } int currentPosition = 0; foreach (ToolStripMenuItem menuItem in menuItemGroups.Values) { toolStripMenuItemMethod.DropDownItems.Insert(currentPosition, menuItem); currentPosition++; } targetFunction = new GrishaginFunction(1); constraints = new List <Constraint>(); plotBuilder = new PlotBuilder(); plotBuilder.ShowAxises = false; plotBuilder.ShowNumbers = false; SetSizesAndLocations(); Controls.Add(plotBuilder); ResetControls(); }