コード例 #1
0
ファイル: Program.cs プロジェクト: vslab/Energon
        private static void TestGeneral()
        {
            TextWriter tout = new NullWriter();


            LPProblem p = new LPProblem();

            tout.WriteLine(p.AddRows(4));
            tout.WriteLine(p.AddCols(5));


            p.Name = "yoyoyo";
            tout.WriteLine(p.Name);
            p.ObjectiveName = "monobj";
            tout.WriteLine(p.ObjectiveName);
            p.ObjectiveDirection = OptimisationDirection.MINIMISE;
            tout.WriteLine(p.ObjectiveDirection);
            p.ObjectiveDirection = OptimisationDirection.MAXIMISE;
            tout.WriteLine(p.ObjectiveDirection);


            p.SetRowName(1, "ert");
            tout.WriteLine(p.GetRowName(1));
            tout.WriteLine(p.GetRowName(2));
            p.SetRowName(1, null);
            tout.WriteLine(p.GetRowName(1));

            p.SetColName(1, "colk");
            tout.WriteLine(p.GetColName(1));
            p.SetColName(1, null);
            tout.WriteLine(p.GetColName(1));
            tout.WriteLine(p.GetColName(2));

            p.SetRowBounds(1, BOUNDSTYPE.Upper, 4, 6);
            p.SetColBounds(2, BOUNDSTYPE.Upper, 3, 7);
            p.SetMatRow(1, new int[] { 0, 1, 2, 4 }, new double[] { 0, 2.2, 3.3, 4.4 });
            int[]    ind;
            double[] val;
            p.GetMatRow(1, out ind, out val);
            tout.WriteLine(ind.Length + " " + ind[1]);
            tout.WriteLine(val.Length + " " + val[1]);

            p.SetObjCoef(2, 3.6);
            tout.WriteLine(p.GetObjCoef(2));

            tout.WriteLine(p.GetNonZeroCount());
            tout.WriteLine(p.GetColBoundType(2));
            tout.WriteLine(p.GetColLb(2));
            tout.WriteLine(p.GetColUb(2));
            p.SetColKind(1, COLKIND.Integer);

            tout.WriteLine(p.GetColsCount());
            tout.WriteLine(p.GetRowsCount());
            Console.Out.WriteLine(p.GetVersion());
            p.TermHook(new TermHookDelegate(Hook));
            p.ModelClass = MODELCLASS.MIP;
            BnCCallback.SetCallback(p,
                                    new BranchAndCutDelegate(
                                        delegate(BranchTree t, Object o)
            {
                Console.WriteLine(t.GetReason().ToString());
            }
                                        ));
            p.SolveSimplex();
            p.SolveInteger();
            p.WriteSol("c:\\sol.txt");
            KKT    kkt = p.CheckKKT(0);
            int    count;
            int    cpeak;
            double total;
            double tpeak;

            p.GetMemoryUsage(out count, out cpeak, out total, out tpeak);
            Console.Out.WriteLine(count);
            Console.Out.WriteLine(cpeak);
            Console.Out.WriteLine(total);
            Console.Out.WriteLine(tpeak);

            LPProblem copy = p.Clone(true);

            p.Clear();

            Console.Out.WriteLine("tapez une touche.");
            Console.In.ReadLine();
            //Console.In.Read();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: vslab/Energon
        private static void TestGeneral()
        {
            TextWriter tout = new NullWriter();

            LPProblem p = new LPProblem();

            tout.WriteLine(p.AddRows(4));
            tout.WriteLine(p.AddCols(5));

            p.Name = "yoyoyo";
            tout.WriteLine(p.Name);
            p.ObjectiveName = "monobj";
            tout.WriteLine(p.ObjectiveName);
            p.ObjectiveDirection = OptimisationDirection.MINIMISE;
            tout.WriteLine(p.ObjectiveDirection);
            p.ObjectiveDirection = OptimisationDirection.MAXIMISE;
            tout.WriteLine(p.ObjectiveDirection);

            p.SetRowName(1, "ert");
            tout.WriteLine(p.GetRowName(1));
            tout.WriteLine(p.GetRowName(2));
            p.SetRowName(1, null);
            tout.WriteLine(p.GetRowName(1));

            p.SetColName(1, "colk");
            tout.WriteLine(p.GetColName(1));
            p.SetColName(1, null);
            tout.WriteLine(p.GetColName(1));
            tout.WriteLine(p.GetColName(2));

            p.SetRowBounds(1, BOUNDSTYPE.Upper, 4, 6);
            p.SetColBounds(2, BOUNDSTYPE.Upper, 3, 7);
            p.SetMatRow(1, new int[] { 0, 1, 2, 4 }, new double[] { 0, 2.2, 3.3, 4.4 });
            int[] ind;
            double[] val;
            p.GetMatRow(1, out ind, out val);
            tout.WriteLine(ind.Length + " " + ind[1]);
            tout.WriteLine(val.Length + " " + val[1]);

            p.SetObjCoef(2, 3.6);
            tout.WriteLine(p.GetObjCoef(2));

            tout.WriteLine(p.GetNonZeroCount());
            tout.WriteLine(p.GetColBoundType(2));
            tout.WriteLine(p.GetColLb(2));
            tout.WriteLine(p.GetColUb(2));
            p.SetColKind(1, COLKIND.Integer);

            tout.WriteLine(p.GetColsCount());
            tout.WriteLine(p.GetRowsCount());
            Console.Out.WriteLine(p.GetVersion());
            p.TermHook(new TermHookDelegate(Hook));
            p.ModelClass = MODELCLASS.MIP;
            BnCCallback.SetCallback(p,
                new BranchAndCutDelegate(
                    delegate(BranchTree t, Object o)
                    {
                        Console.WriteLine(t.GetReason().ToString());
                    }
                    ));
            p.SolveSimplex();
            p.SolveInteger();
            p.WriteSol("c:\\sol.txt");
            KKT kkt = p.CheckKKT(0);
            int count;
            int cpeak;
            double total;
            double tpeak;
            p.GetMemoryUsage(out count, out cpeak, out total, out tpeak);
            Console.Out.WriteLine(count);
            Console.Out.WriteLine(cpeak);
            Console.Out.WriteLine(total);
            Console.Out.WriteLine(tpeak);

            LPProblem copy = p.Clone(true);
            p.Clear();

            Console.Out.WriteLine("tapez une touche.");
            Console.In.ReadLine();
            //Console.In.Read();
        }