Example #1
0
        private void ResetControls()
        {
            labelIterations.Text   = OptimLab.Properties.Resources.LabelIterationsText + ": 0";
            labelPoint.Text        = OptimLab.Properties.Resources.LabelPointText + ":";
            labelValue.Text        = OptimLab.Properties.Resources.LabelValueText + ":";
            labelErrorInPoint.Text = OptimLab.Properties.Resources.LabelErrorInPointText + ":";
            labelErrorInValue.Text = OptimLab.Properties.Resources.LabelErrorInValueText + ":";
            labelEvalsTarget.Text  = OptimLab.Properties.Resources.LabelEvalsTargetText + ":";
            labelEvalsConst1.Text  = OptimLab.Properties.Resources.LabelEvalsConst1Text + ":";
            labelEvalsConst2.Text  = OptimLab.Properties.Resources.LabelEvalsConst2Text + ":";
            labelEvalsConst3.Text  = OptimLab.Properties.Resources.LabelEvalsConst3Text + ":";

            Color[] constraintColors = new Color[] { Color.DarkGray, Color.Pink, Color.Cyan };

            plotBuilder.RemoveAllPlots();
            plotBuilder.RemoveAllConstraints();

            Plot plot = Triangulator.SurfaceLevelLines(
                delegate(double x, double y)
            {
                return(targetFunction.CalculateFunction(new double[] { x, y }));
            },
                0.0, 1.0, 0.0, 1.0, 100, 100, 10);

            plot.Information.Name = "Target function";
            plot.Color            = Color.Black;
            plotBuilder.AddPlot(plot);

            for (int i = 0; i < constraints.Count; i++)
            {
                plotBuilder.ConstraintColor = constraintColors[i];
                plotBuilder.AddConstraint("Constraint " + (i + 1).ToString(),
                                          delegate(double x, double y)
                {
                    return(constraints[i].A * constraints[i].F.CalculateFunction(new double[] { x, y }) +
                           constraints[i].B);
                }
                                          );
            }

            plotBuilder.PictureLocation = new PointF((float)targetFunction.MaximumPoint[0],
                                                     (float)targetFunction.MaximumPoint[1]);
        }