Exemplo n.º 1
0
        private void computeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ComputeForm cf = new ComputeForm();

            if (cf.ShowDialog() == DialogResult.OK)
            {
                this.UseWaitCursor = true;
                pm.SetSolutions(cf.NSol);
                pm.Seed          = cf.SeedVal;
                pm.ProblemType   = cf.ProblemType;
                pm.MaxIterSecond = cf.MaxIterSec;
                pm.Verbose       = cf.Verbose;

                ConsoleAppendText("\r\nStarting computation...");
                ConsoleAppendText("\r\nNumber of solution          : " + pm.Nsolution);
                ConsoleAppendText("\r\nCompute As Parallel         : " + cf.AsParSol.ToString());
                ConsoleAppendText("\r\nRefine Clusters As Parallel : " + cf.AsParClu.ToString());
                ConsoleAppendText("\r\nVerbose                     : " + pm.Verbose.ToString() + "\r\n");

                backgroundWorkerParameter param = new backgroundWorkerParameter();
                param.Parallel = cf.AsParSol;
                param.Clusters = cf.AsParClu;
                computeToolStripMenuItem.Enabled = false;
                openToolStripMenuItem.Enabled    = false;
                viewToolStripMenuItem.Enabled    = false;
                toolStripProgressBar1.Maximum    = (int)pm.Nsolution;
                toolStripProgressBar1.Value      = 0;
                SolutionViewer.Nodes.Clear();
                ClusterTextBox.Text           = "";
                SolutionViewer.Enabled        = false;
                SolutionViewer.Visible        = false;
                toolStripStatusLabel1.Enabled = false;
                backgroundWorker1.RunWorkerAsync(param);
            }
        }
Exemplo n.º 2
0
        private bool GetSolution(int n, ref uint WrapSol, ref List <uint>[] WrapSolClu)
        {
            bool ret = false;

            WrapSol    = 0;
            WrapSolClu = null;

            if (!isloaded)
            {
                return(false);
            }
            pm.SetSolutions((uint)n);


            ret = pm.ComputeSolutions(parsol, parclu);
            //tolto il parallelo...
            //ret = pm.ComputeSolutions(false, false);

            if (ret)
            {
                WrapSol    = pm.WrapperSolution;
                WrapSolClu = pm.WrapperSolutionClusters;
            }

            return(ret);
        }
Exemplo n.º 3
0
        private static bool ComputeBestof3Sol(string nomep)
        {
            //int i_sol = 3;
            int      i_sol = 1;
            int      i, j;
            TimeSpan timeelapsed = new TimeSpan();

            //uint[] setN = {1000, 3000, 5000};
            uint[] setN = { 1000 };
            //uint[] setN = { 100, 500, 1000, 3000, 5000, 10000, 15000, 20000 };
            uint setpofsol;
            //double MaxIterSec = 60 * 5; // 5 min;
            double MaxIterSec = 0.0;

            pmed.Seed          = 1657;
            pmed.MaxIterSecond = MaxIterSec;

            swBatchOut.WriteLine("\r\nSeed = {0}", pmed.Seed);
            uint bestsol    = int.MaxValue;
            bool isbestwrap = false;

            for (j = 0; j < setN.Length; j++)
            {
                Console.WriteLine("preparing computation {0} ...", setN[j]);
                pmed.SetSolutions(setN[j]);
                setpofsol = 0;

                //swBatchOut.WriteLine("Computing with {0} sols", setN[j]);
                bestsol     = int.MaxValue;
                isbestwrap  = false;
                timeelapsed = new TimeSpan();
                for (i = 0; i < i_sol; i++)
                {
                    Console.WriteLine("Computing SOl..");
                    if (!pmed.ComputeSolutions(true, true))
                    {
                        swBatchOut.WriteLine("Cannot Compute Wrapper Solution!!! error!!!");
                    }
                    /*else*/ if (bestsol > pmed.WrapperSolution)
                    {
                        if (pmed.WrapperSolution > 0)
                        {
                            if (pmed.WrapperSolution < pmed.Solutions[pmed.BestSolutionIndex])
                            {
                                isbestwrap = true;
                            }
                            else
                            {
                                isbestwrap = false;
                            }

                            bestsol = pmed.WrapperSolution;

                            //Console.WriteLine("\r\nChecking Solutions Set of p ...");
                            //setpofsol = pmed.CheckPofSolutions(false);
                            timeelapsed = pmed.GetTotalElapsedTime();
                        }
                        else
                        {
                            swBatchOut.WriteLine("{0} : No Wrapper Computed!!!!", nomep);
                            if (bestsol > pmed.Solutions[pmed.BestSolutionIndex])
                            {
                                Console.WriteLine("\r\nChecking Solutions Set of p ...");
                                //setpofsol = pmed.CheckPofSolutions(false);
                                timeelapsed = pmed.GetTotalElapsedTime();
                                bestsol     = pmed.Solutions[pmed.BestSolutionIndex];
                            }
                        }

                        //timeelapsed = pmed.GetTotalElapsedTime();

                        //setpofsol = pmed.CheckPofSolutions(false);
                    }
                }
                //salvo i risultati del meglio
                Console.Write("\r\nSalvo i risultati...");
                swBatchOut.WriteLine("{4} : Solution = {0} --- Wrapper = {1} --- TotTime = {2} --- N = {3} CheckSetP = {5}", bestsol, isbestwrap, timeelapsed, setN[j], nomep, setpofsol);
                swBatchOut.Flush();
                Console.WriteLine("ok");
            }
            return(true);
        }