Exemple #1
0
        /// <summary>
        /// Charger le graphe1
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void chargeDuGraphe1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.pictureBoxGraphe1.Image != null)
            {
                pictureBoxGraphe1.Image.Dispose();
            }
            string nomFichier = GraphLibManager.ChoisirDirectory();

            this.isoLP.Graph1 = GraphLibManager.LoadGraph(nomFichier, this.comboBoxGraphe.SelectedIndex);
            if (this.isoLP.Graph1 != null)
            {
                GraphLibManager.DisplayGraph(this.isoLP.Graph1, this.pictureBoxGraphe1, "./Graph1.jpg", toolStripStatusLabel1);
                this.isoLP.Graph1.Name = "Graph1";
                if (!this.isoLP.Graph1.IsDirected)
                {
                    this.isoLP.DirectedGraph1 = GraphLibManager.LoadGraph(nomFichier, this.comboBoxGraphe.SelectedIndex);
                    GraphLibManager.transToDirectedGraph(this.isoLP.DirectedGraph1, false);
                    this.isoLP.DirectedGraph1.Name = "Graph1";
                }
                else
                {
                    this.isoLP.DirectedGraph1 = this.isoLP.Graph1;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// charger le graphe2
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void chargeDuGraphe2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.pictureBoxGraphe2.Image != null)
            {
                pictureBoxGraphe2.Image.Dispose();
            }
            // this.isoLP.Graph2 = GraphLibManager.LoadGraph(this.richTextBoxAppariement, this.toolStripStatusLabel1);
            string nomFichier = GraphLibManager.ChoisirDirectory();

            this.isoLP.Graph2 = GraphLibManager.LoadGraph(nomFichier, comboBoxGraphe.SelectedIndex);
            if (this.isoLP.Graph2 != null)
            {
                GraphLibManager.DisplayGraph(this.isoLP.Graph2, this.pictureBoxGraphe2, "./Graph2.jpg", toolStripStatusLabel1);
                this.isoLP.Graph2.Name = "Graph2";
                if (!this.isoLP.Graph2.IsDirected)
                {
                    this.isoLP.DirectedGraph2 = GraphLibManager.LoadGraph(nomFichier, comboBoxGraphe.SelectedIndex);
                    GraphLibManager.transToDirectedGraph(this.isoLP.DirectedGraph2, false);
                    this.isoLP.DirectedGraph2.Name = "Graph2";
                }
                else
                {
                    this.isoLP.DirectedGraph2 = this.isoLP.Graph2;
                }
            }
        }
        private static void manycomparison(string[] args)
        {
            //CxlNNodes cxlNNNodes = new CxlNNodes(noOfNodes, this.graphType, this.dbDirecttory, this.trainingFile, this.readTrainingCXLFile);
            string          dbDirecttory = "D:\\recherche\\data\\GREC\\GREC\\data";
            List <string[]> classMap     = GraphLibManager.loadGraphClass("D:\\recherche\\data\\GREC\\GREC\\data\\cplex.cxl", dbDirecttory);


            System.IO.StreamWriter monStream = null;
            for (int i = 0; i < classMap.Count; i++)
            {
                for (int j = 0; j < classMap.Count; j++)
                {
                    try
                    {
                        Graph  g1     = new Graph();
                        Graph  g2     = new Graph();
                        string g1file = classMap[i][0];
                        string g2file = classMap[j][0];
                        string res    = onecomparisonwithres(g1file, g2file);

                        System.IO.FileStream fs = new System.IO.FileStream("res.csv", System.IO.FileMode.Append, System.IO.FileAccess.Write);
                        monStream = new System.IO.StreamWriter(fs);
                        monStream.WriteLine(res);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                    finally
                    {
                        if (monStream != null)
                        {
                            monStream.Close();
                        }
                    }
                }
            }
        }
Exemple #4
0
        private void buttonTester_Click(object sender, EventArgs e)
        {
            if (int.TryParse(this.textBoxDebut.Text, out nodeDebut))
            {
                if (nodeDebut < 2)
                {
                    MessageBox.Show("il faut la valeur de  \"debut\" supérieur ou égale à 5");
                    return;
                }
                if (int.TryParse(this.textBoxFin.Text, out nodeFin))
                {
                    if (nodeFin < nodeDebut)
                    {
                        MessageBox.Show("la valeur de \"fin\" pas valide ");
                        return;
                    }
                    else if (int.TryParse(this.textBoxinterval.Text, out interval))
                    {
                        if (interval < 0)
                        {
                            MessageBox.Show("la valeur d'interval pas valide ");
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("la valeur d'interval pas valide ");
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("la valeur de  \"fin\" pas valide ");
                    return;
                }
            }
            else
            {
                MessageBox.Show("la valeur de  \"debut\" pas valide ");
                return;
            }


            //Integer.partextBox1.Text

            double.TryParse(this.textBox1.Text, out Program.MAXTIME_SIMPLEX);
            Program.MAXTIME_SECOND = Program.MAXTIME_SIMPLEX / 1000.0;

            double.TryParse(this.textBox2.Text, out Program.MAXMEMORY_MB);

            graphType = this.comboBoxGraphe.SelectedIndex;
            if (graphType == Program.noGrec)
            {
                graphTypeStr        = "Grec";
                this.MaxNumberNodes = 20;
            }

            if (graphType == Program.noLetter)
            {
                graphTypeStr        = "Letter";
                this.MaxNumberNodes = 10;
            }

            if (graphType == Program.noAlkane)
            {
                graphTypeStr        = "Alkane";
                this.MaxNumberNodes = 30;
            }

            if (graphType == Program.noMuta)
            {
                graphTypeStr        = "Mutagen";
                this.MaxNumberNodes = 85;
            }


            if (graphType == Program.noPRO)
            {
                graphTypeStr        = "Protein";
                this.MaxNumberNodes = 85;
            }

            if (graphType == Program.noIlpiso)
            {
                graphTypeStr        = "ILPISO";
                this.MaxNumberNodes = 50;
            }



            if (graphType == Program.noLOW)
            {
                graphTypeStr = "LOW";
            }

            if (nodeDebut < 1)
            {
                this.nodeDebut = 1;
            }
            if (nodeFin > this.MaxNumberNodes)
            {
                this.nodeFin = this.MaxNumberNodes;
            }
            //if (interval == 0) interval = 1;
            if (allFiles == null)
            {
                MessageBox.Show("Choisissez un dossier de graphes, svp");
            }
            else if (allFiles.Length < 1)
            {
                MessageBox.Show("Le dossier choisit n'est pas valide");
            }
            else
            {
                this.toolStripStatusTestLabel.Text = "test en cours";

                /**
                 * Generer les fichiers cxl regrouper par noeud
                 **/
                for (int noOfNodes = this.nodeDebut; noOfNodes <= this.nodeFin; noOfNodes += this.interval)
                {
                    if (dbDirecttory != null)
                    {
                        readTrainingCXLFile = this.dbDirecttory + "\\cplex.cxl";


                        //donc pas de découpe en sous base
                        if (interval == 0)
                        {
                            this.trainingFile = this.dbDirecttory + "\\cplex.cxl";
                            interval          = 0;
                            nodeFin           = 0;
                            noOfNodes         = 10000;
                        }
                        else
                        {
                            this.trainingFile = this.dbDirecttory + "\\train" + noOfNodes + ".cxl";
                            //this.trainingFile = this.dbDirecttory + "\\mixed-graphs.cxl";
                            CxlNNodes cxlNNNodes = new CxlNNodes(noOfNodes, this.graphType, this.dbDirecttory, this.trainingFile, this.readTrainingCXLFile);
                        }
                        classMap = GraphLibManager.loadGraphClass(this.trainingFile, this.dbDirecttory);
                        try
                        {
                            if (!this.checkBox7.Checked)
                            {
                                this.toolStripStatusTestLabel.Text = "";
                                fs = new FileStream(csvPath + "\\result" + this.graphTypeStr + noOfNodes + "nodes.csv", System.IO.FileMode.Create, System.IO.FileAccess.Write);
                                //monStream = new StreamWriter(fs, System.Text.UnicodeEncoding.UTF8);
                                monStream = new StreamWriter(fs, outputEncoding);
                                monStream.WriteLine("Method;Param;Graph1 Name;Graph2 Name;Graph1 nb nodes;" +
                                                    "Graph2 nb nodes;Graph1 nb edges;Graph2 nb edges; distance;" +
                                                    "explored nodes;max open size;time;feasible solution found;" +
                                                    "optimal solution found;memory overflow;time overflow;class Graph1;class Graph2;Node Matching");
                                monStream.WriteLine(classMap.Count + ";;;;;;;;;;;;;;;;;;");
                            }
                        }
                        catch (Exception OpenFileException)
                        {
                            MessageBox.Show("Impossible à écrir dans le fichier csv : " + OpenFileException.ToString());
                            return;
                        }
                        finally
                        {
                            if (monStream != null)
                            {
                                monStream.Close();
                            }
                        }

                        //  continue;
                        try
                        {
                            this.toolStripStatusTestLabel.Text = "";
                            this.toolStripStatusTestLabel.Text = "en cours...";
                            if (this.checkBox7.Checked)
                            {
                                this.toolStripStatusTestLabel.Text = "branch and bound";


                                //Create process
                                System.Diagnostics.Process pProcess = new System.Diagnostics.Process();
                                double time = (Program.MAXTIME_SECOND * 1000);
                                pProcess.StartInfo.FileName = "java";
                                // pProcess.StartInfo.Arguments = "-Xmx1024m -jar " + binPath + "\\ressource\\EditPath.jar " +
                                //      this.dbDirecttory + " " + csvPath + "\\result" + this.graphTypeStr + noOfNodes + "nodes.csv" + " 0 " + this.graphType + " "+time+" 5 " + noOfNodes;
                                pProcess.StartInfo.Arguments = "-Xmx1024m -jar " + binPath + "\\ressource\\grapheditdistance.jar " +
                                                               this.dbDirecttory + " " + csvPath + "\\result" + this.graphTypeStr + noOfNodes + "nodes.csv" + " 13 0 60000 2,6,3,100,1,3,5,3";

                                pProcess.StartInfo.UseShellExecute        = false;
                                pProcess.StartInfo.RedirectStandardOutput = true;
                                pProcess.StartInfo.RedirectStandardError  = true;
                                pProcess.StartInfo.CreateNoWindow         = true;

                                //Start the process
                                pProcess.Start();
                                string strOutput = pProcess.StandardOutput.ReadToEnd();
                                string strError  = pProcess.StandardError.ReadToEnd();

                                pProcess.WaitForExit();
                                Console.Out.WriteLine(strOutput);
                                Console.Out.WriteLine(strError);
                            }
                            if (this.checkBox1.Checked)
                            {
                                this.toolStripStatusTestLabel.Text = "F1b cplex avec un seul coeur";
                                if (!this.runTestByMethode(graphType, 1, noOfNodes))
                                {
                                    return;
                                }
                            }
                            if (this.checkBox2.Checked)
                            {
                                this.toolStripStatusTestLabel.Text = "F1b cplex avec plusieurs coeurs";
                                if (!this.runTestByMethode(graphType, 2, noOfNodes))
                                {
                                    return;
                                }
                            }
                            if (this.checkBox3.Checked)
                            {
                                this.toolStripStatusTestLabel.Text = "F2b cplex avec un seul coeur";
                                if (!this.runTestByMethode(graphType, 3, noOfNodes))
                                {
                                    return;
                                }
                            }
                            if (this.checkBox4.Checked)
                            {
                                this.toolStripStatusTestLabel.Text = "F2b cplex avec plusieurs coeurs";
                                if (!this.runTestByMethode(graphType, 4, noOfNodes))
                                {
                                    return;
                                }
                            }
                            if (this.checkBox5.Checked)
                            {
                                this.toolStripStatusTestLabel.Text = "F1b glpk avec un seul coeur";
                                if (!this.runTestByMethode(graphType, 5, noOfNodes))
                                {
                                    return;
                                }
                            }
                            if (this.checkBox6.Checked)
                            {
                                this.toolStripStatusTestLabel.Text = "F2b glpk avec un seul coeur";
                                if (!this.runTestByMethode(graphType, 6, noOfNodes))
                                {
                                    return;
                                }
                            }

                            if (this.checkBox10.Checked)
                            {
                                this.toolStripStatusTestLabel.Text = "BLPjusticehero cplex avec un seul coeur";
                                if (!this.runTestByMethode(graphType, 10, noOfNodes))
                                {
                                    return;
                                }
                            }

                            if (this.checkBox11.Checked)
                            {
                                this.toolStripStatusTestLabel.Text = "BLPjusticehero Quadratic cplex avec un seul coeur";
                                if (!this.runTestByMethode(graphType, 11, noOfNodes))
                                {
                                    return;
                                }
                            }

                            if (this.checkBox12.Checked)
                            {
                                this.toolStripStatusTestLabel.Text = "QAPGMGED cplex avec un seul coeur";
                                if (!this.runTestByMethode(graphType, 12, noOfNodes))
                                {
                                    return;
                                }
                            }
                        }
                        catch (Exception exce)
                        {
                            Console.Out.WriteLine("Exception : " + exce.ToString());
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                this.toolStripStatusTestLabel.Text = "Fini";
                Console.SetOut(System.IO.TextWriter.Null);
                return;
            }
        }
Exemple #5
0
        private bool runTestByMethode(int graphType, int methode, int noOfNodes)
        {
            string methodeName = "", solverType = "", formulaType = "";
            int    mode = 0;

            switch (methode)
            {
            case 1:
                methodeName = "F1bCplexUnCoeur";
                solverType  = "CPLEX";
                formulaType = "IsoGraphInexactF1b";
                mode        = 0;
                break;

            case 2:
                methodeName = "F1bCplexPlusieursCoeurs";
                solverType  = "CPLEX";
                formulaType = "IsoGraphInexactF1b";
                mode        = 1;
                break;

            case 3:
                methodeName = "F2bCPLEXUnCoeur";
                solverType  = "CPLEX";
                formulaType = "IsoGraphInexactF2b";
                mode        = 0;
                break;

            case 4:
                methodeName = "F2bCplexPlusieursCoeurs";
                solverType  = "CPLEX";
                formulaType = "IsoGraphInexactF2b";
                mode        = 1;
                break;

            case 5:
                methodeName = "F1bGlpkUnCoeur";
                solverType  = "GLPK";
                formulaType = "IsoGraphInexactF1b";
                mode        = 0;
                break;

            case 6:
                methodeName = "F2bGlpkUnCoeur";
                solverType  = "GLPK";
                formulaType = "IsoGraphInexactF2b";
                mode        = 0;
                break;

            case 7:
                methodeName = "BranchAndBound";
                solverType  = "GLPK";
                formulaType = "EditPath";
                mode        = 0;
                break;

            case 10:
                methodeName = "GEDBLPjusticehero";
                solverType  = "CPLEX";
                formulaType = "BLPjusticehero";
                mode        = 0;
                break;

            case 11:
                methodeName = "BLPjusticeheroQuadratic";
                solverType  = "CPLEX";
                formulaType = "BLPjusticeheroQuadratic";
                mode        = 0;
                break;

            case 12:
                methodeName = "QAPGMGED";
                solverType  = "CPLEX";
                formulaType = "QAPGMGED";
                mode        = 0;
                break;
            }

            string strToWrite = "";

            for (int i = 0; i < classMap.Count; i++)
            {
                for (int j = 0; j < classMap.Count; j++)
                {
                    try
                    {
                        this.graph1 = GraphLibManager.LoadGraph((classMap[i][0]), graphType);    //LoadGraph(this.richTextGraph, this.toolStripStatusTestLabel);
                        this.graph2 = GraphLibManager.LoadGraph(classMap[j][0], graphType);
                        Console.Out.WriteLine("i:" + i + "---> j : " + j);
                        Console.Out.WriteLine(graph1.Id + "--->" + graph2.Id);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Ne peut pas charger les graphes." + e);
                        return(false);
                    }

                    if ((graph1 == null) || (graph2 == null))
                    {
                        j++;                                          //jump the wrong .gxl if exist
                    }
                    else if (this.graph1.IsDirected ^ this.graph2.IsDirected)
                    {
                        j++;
                    }
                    else
                    {
                        /* if (!(this.graph1.IsDirected) && !(this.graph2.IsDirected))
                         * {
                         *   GraphLibManager.transToDirectedGraph(this.graph1,false);
                         *   GraphLibManager.transToDirectedGraph(this.graph2,false);
                         *   this.flagTransform = true;
                         * }*/
                        this.flagTransform = false;
                        this.iso           = new IsomorphismLP();

                        iso.Graph1 = this.graph1;
                        iso.Graph2 = this.graph2;

                        iso.DirectedGraph1 = this.graph1;
                        iso.DirectedGraph2 = this.graph2;

                        this.iso.SolverType  = solverType;   //this.comboBoxSolveur2.SelectedIndex == 0 ? "CPLEX" : "GLPK";
                        this.iso.FormulaType = formulaType;  // Program.formulas[formulaTypeIndice];//Program.formulas[this.comboBoxProblem2.SelectedIndex];

                        this.iso.initial();
                        Program.nbCoeursCplex = int.Parse(textBoxnbthread.Text);
                        this.iso.Solver.setThreadNumber(Program.nbCoeursCplex);

                        /*if (mode == 0)
                         *  this.iso.Solver.setThreadNumber(1);
                         * else if (mode == 1)
                         *  this.iso.Solver.setThreadNumber(Program.nbCoeursCplex);*/

                        iso.run();
                        try
                        {
                            fs         = new FileStream(csvPath + "\\result" + this.graphTypeStr + noOfNodes + "nodes.csv", System.IO.FileMode.Append, System.IO.FileAccess.Write);
                            monStream  = new StreamWriter(fs, this.outputEncoding);
                            strToWrite = methodeName + ";rien;" + classMap[i][0] + ";" + classMap[j][0] + ";";
                            // strToWrite = methodeName + ";rien;" + graph1.Id + ";" + graph2.Id + ";";
                            strToWrite += iso.Graph1.ListNodes.Count + ";" + iso.Graph2.ListNodes.Count + ";";
                            if (this.flagTransform)
                            {
                                strToWrite += iso.Graph1.ListEdges.Count / 2 + ";" + iso.Graph2.ListEdges.Count / 2 + ";";
                            }
                            else
                            {
                                strToWrite += iso.Graph1.ListEdges.Count + ";" + iso.Graph2.ListEdges.Count + ";";
                            }
                            this.flagTransform = false;
                            //strToWrite += (iso.MatchingResult.Distance.ToString()).Replace(',','.') + ";";
                            strToWrite += iso.MatchingResult.Distance + ";";
                            strToWrite += iso.MatchingResult.NbNodes + ";";
                            strToWrite += "-1;";
                            strToWrite += iso.MatchingResult.TimeUse + ";";
                            if (iso.MatchingResult.Feasible)
                            {
                                strToWrite += "true;";
                            }
                            else
                            {
                                strToWrite += "false;";
                            }
                            if (iso.MatchingResult.Optimal)
                            {
                                strToWrite += "true;";
                            }
                            else
                            {
                                strToWrite += "false;";
                            }
                            if (iso.MatchingResult.MemoryOverFlow)
                            {
                                strToWrite += "true;";
                            }
                            else
                            {
                                strToWrite += "false;";
                            }
                            if (iso.MatchingResult.TimeOverFlow)
                            {
                                strToWrite += "true;";
                            }
                            else
                            {
                                strToWrite += "false;";
                            }
                            strToWrite += classMap[i][1] + ";";
                            strToWrite += classMap[j][1] + ";";
                            strToWrite += MakeMatchingToString(iso.MatchingResult.NodeMatchingDictionary);
                            monStream.WriteLine(strToWrite);
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                        finally
                        {
                            if (monStream != null)
                            {
                                monStream.Close();
                            }
                            iso.Solver.closeSolver();
                        }
                    }
                }
            }
            return(true);
        }