예제 #1
0
        private static IList<PointPairList> FindNthThickSegments(int i, AutoResult result, IList<double[]> series)
        {
            var oThickSegments = new List<PointPairList>();

            int nLast = 0;
            int nLastDir = -1;
            for (int j = 0; j < result.Positions.Count; j++)
            {
                IntPair oPos = result.Positions[j];
                int nCurrentSliceLength = oPos.Key - 1 - nLast;
                var oXSlice = new double[nCurrentSliceLength];
                var oYSlice = new double[nCurrentSliceLength];

                Array.Copy(series[0], nLast, oXSlice, 0, nCurrentSliceLength);
                Array.Copy(series[i + 1], nLast, oYSlice, 0, nCurrentSliceLength);
                nLastDir = oPos.Value;

                if (nLastDir > 0)
                {
                    oThickSegments.Add(new PointPairList(oXSlice, oYSlice));
                }

                nLast = oPos.Key;
            }

            if (nLast < series[0].Length)
            {
                int nLastSliceLength = series[0].Length - nLast;

                var oXSlice = new double[nLastSliceLength];
                var oYSlice = new double[nLastSliceLength];

                Array.Copy(series[0], nLast, oXSlice, 0, nLastSliceLength);
                Array.Copy(series[i + 1], nLast, oYSlice, 0, nLastSliceLength);

                if (nLastDir*-1 > 0)
                {
                    oThickSegments.Add(new PointPairList(oXSlice, oYSlice));
                }
            }
            return oThickSegments;
        }
예제 #2
0
        private void RunContinuationForTripple(IntTripple tripple)
        {
            try
            {
                if (SBML == null || SBML.Length == 0)
                    return;

                string fort8 = AutoResult.NewFort8; //.Replace(" 7 ", " 12 ");
                //string fort7 = AutoResult.NewFort7;

                ResetAuto();

                setupControl1.RunContinuation = true;
                setupControl1.Label = tripple.Value1;

                string originalConfig = setupControl1.CurrentConfig.ToInputString();

                //setupControl1.CurrentConfig.IPS = 2;
                setupControl1.CurrentConfig.IRS = tripple.Value1;
                //setupControl1.CurrentConfig.ILP = 1;

                setupControl1.CurrentConfig.NICP = 2;
                setupControl1.CurrentConfig.ICP.Clear();
                setupControl1.CurrentConfig.ICP.Add(0);
                setupControl1.CurrentConfig.ICP.Add(10);

                //setupControl1.CurrentConfig.NCOL = 4;
                //setupControl1.CurrentConfig.IAD = 3;
                //setupControl1.CurrentConfig.ISP = 1;
                //setupControl1.CurrentConfig.ISW = 1;

                setupControl1.CurrentConfig.MXBF = 10;

                setupControl1.CurrentConfig.NTHL = 1;
                setupControl1.CurrentConfig.THL.Add(new IntDoublePair(10, 0));

                txtConfig.Text = setupControl1.Configuration;

                SetupAuto();

                AutoInterface.setFort2File(txtConfig.Text, txtConfig.Text.Length);

                AutoInterface.setFort3File(fort8, fort8.Length);

                if (setupControl1.CurrentConfig.IPS != 1)
                {
                    if (
                        MessageBox.Show(
                            "Currently only IPS = 1 is supported, any other value will make the library unstable. It is recommendet that you Quit (yes).",
                            "Unsupported Values", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        return;
                    }
                }

                AutoInterface.CallAuto();
                string lastMessage = AutoInterface.GetLastMessage();

                //fort7 = fort7 + AutoResult.NewFort7;
                //AutoInterface.setFort7File(fort7, fort7.Length);

                fort8 = fort8 + AutoResult.NewFort8;
                AutoInterface.setFort8File(fort8, fort8.Length);

                CurrentResult = new AutoResult();
                txtResult.Text = CurrentResult.Fort7;

                RemoveWartermark();
                if (CurrentResult.ErrorOccured && CurrentResult.NumPoints < 10)
                {
                    AddWaterMark("Auto\ndid not\nreturn\nresults.");
                }
                else if (CurrentResult.NumPoints < 10)
                {
                    AddWaterMark("Not\nenough\npoints\nreturned.");
                }

                setupControl1.CurrentConfig = AutoInputConstants.FromContent(originalConfig);

                if (!string.IsNullOrEmpty(lastMessage))
                {
                    RemoveWartermark();
                    AddWaterMark(lastMessage);
                    return;
                }

                PlotResults(CurrentResult);

                if (setupControl1.ReloadAfterRun)
                {
                    try
                    {
                        //Simulator.loadSBML(SBML);
                        cmdSendToAuto_Click(this, EventArgs.Empty);
                    }
                    catch (Exception)
                    {
                        //
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "An Error occured while running Auto", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
예제 #3
0
        internal void RunAuto()
        {
            Cursor originalCursor = Cursor;
            try
            {
                Cursor = Cursors.WaitCursor;

                if (string.IsNullOrEmpty(SBML))
                    OpenSBML();

                ResetAuto();
                setupControl1.RunContinuation = false;
                SetupAuto();

                AutoInterface.setFort2File(txtConfig.Text, txtConfig.Text.Length);

                if (setupControl1.CurrentConfig.IPS != 1)
                {
                    if (
                        MessageBox.Show(
                            "Currently only IPS = 1 is supported, any other value will make the library unstable. It is recommendet that you Quit (yes).",
                            "Unsupported Values", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        return;
                    }
                }

                AutoInterface.CallAuto();

                CurrentResult = new AutoResult();
                txtResult.Text = CurrentResult.Fort7;

                RemoveWartermark();
                if (CurrentResult.ErrorOccured)
                {
                    AddWaterMark("Auto\ndid not\nreturn\nresults.");
                }
                else if (CurrentResult.NumPoints < 10)
                {
                    AddWaterMark("Not\nenough\npoints\nreturned.");
                }

                PlotResults(CurrentResult);

                //if (setupControl1.ReloadAfterRun)
                //{
                //    try
                //    {
                //        //Simulator.loadSBML(SBML);
                //        cmdSendToAuto_Click(this, EventArgs.Empty);
                //    }
                //    catch (Exception)
                //    {
                //        //
                //    }
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "An Error occured while running Auto", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            finally
            {
                Cursor = originalCursor;
            }
        }
예제 #4
0
        private void PlotResults(AutoResult oResult)
        {
            graphControl1.ZedControl.GraphPane.CurveList.Clear();
            var oRot = new ColorSymbolRotator();
            CurrentPlot = new List<PlotInfo>();

            foreach (AutoResultRun run in oResult.AllRuns)
            {
                var series = run.DataSeries;

                if (series.Count < 2) continue;

                if (series[0].Length < 10) continue;

                for (int i = 0; i < series.Count - 1; i++)
                {
                    var sLabel = GetNthName(i);
                    var oLineColor = oRot.NextColor;
                    var info = new PlotInfo {
                        Label = sLabel,
                        MainCurve = new PointPairList(series[0], series[i+1])
                    };

                    if (oResult.Positions.Count == 0)
                    {
                        AddNthCurveToGraph(i, series, sLabel, oLineColor);
                    }
                    else
                    {
                        var thickSegments = FindNthThickSegments(i, oResult, series);
                        AddNthSegmentedCurveToGraph(i, thickSegments, series, sLabel, oLineColor);
                        info.ThickSegments = thickSegments;
                    }
                    CurrentPlot.Add(info);
                }

                foreach (IntTripple tripple in oResult.Labels)
                {
                    for (int i = 0; i < series.Count - 1; i++)
                    {
                        int currentPos = UtilLib.FindClosestStablePoint(tripple.Key, oResult.Positions);

                        double x = series[0][currentPos];
                        double y = series[1 + i][currentPos];
                        var text = new TextObj(UtilLib.ConvertIntTypeToShortString(tripple.Value2), x, y);
                        text.Tag = new TagData {Series = 1 + i, Tripple = tripple, Label = GetNthName(i)};

                        graphControl1.ZedControl.GraphPane.GraphObjList.Add(text);
                    }
                }
            }

            graphControl1.ZedControl.GraphPane.XAxis.Scale.MaxGrace = 0f;
            graphControl1.ZedControl.GraphPane.XAxis.Scale.MinGrace = 0f;
            graphControl1.ZedControl.GraphPane.YAxis.Scale.MaxGrace = 0f;
            graphControl1.ZedControl.GraphPane.YAxis.Scale.MinGrace = 0f;

            SetParameterAxisTitle();

            graphControl1.ZedControl.AxisChange();
            tabControl1.Refresh();
        }