Beispiel #1
0
    public static void Main(string[] args)
    {
        try {
            Cplex cplex = new Cplex();

            string filename = "../../../../examples/data/noswot.mps";
            if (args.Length > 0)
            {
                filename = args[0];
                if (filename.IndexOf("noswot") < 0)
                {
                    System.Console.WriteLine("Error: noswot model is required.");
                    return;
                }
            }
            cplex.ImportModel(filename);

            IEnumerator matrixEnum = cplex.GetLPMatrixEnumerator();
            matrixEnum.MoveNext();

            ILPMatrix lp = (ILPMatrix)matrixEnum.Current;

            // Use AddUserCuts when the added constraints strengthen the
            // formulation.  Use AddLazyConstraints when the added constraints
            // remove part of the feasible region.  Use AddCuts when you are
            // not certain.

            cplex.AddUserCuts(MakeCuts(cplex, lp));

            cplex.SetParam(Cplex.Param.MIP.Interval, 1000);
            if (cplex.Solve())
            {
                System.Console.WriteLine("Solution status = " + cplex.GetStatus());
                System.Console.WriteLine("Solution value  = " + cplex.ObjValue);
            }
            cplex.End();
        }
        catch (ILOG.Concert.Exception e) {
            System.Console.WriteLine("Concert exception caught: " + e);
        }
    }
Beispiel #2
0
    public static void Main(string[] args)
    {
        try {
         Cplex cplex = new Cplex();

         string filename = "../../../../examples/data/noswot.mps";
         if ( args.Length > 0 ) {
            filename = args[0];
            if ( filename.IndexOf("noswot") < 0 ) {
               System.Console.WriteLine("Error: noswot model is required.");
               return;
            }
         }
         cplex.ImportModel(filename);

         IEnumerator matrixEnum = cplex.GetLPMatrixEnumerator();
         matrixEnum.MoveNext();

         ILPMatrix lp = (ILPMatrix)matrixEnum.Current;

         // Use AddUserCuts when the added constraints strengthen the
         // formulation.  Use AddLazyConstraints when the added constraints
         // remove part of the feasible region.  Use AddCuts when you are
         // not certain.

         cplex.AddUserCuts(MakeCuts(cplex, lp));

         cplex.SetParam(Cplex.Param.MIP.Interval, 1000);
         if ( cplex.Solve() ) {
            System.Console.WriteLine("Solution status = " + cplex.GetStatus());
            System.Console.WriteLine("Solution value  = " + cplex.ObjValue);
         }
         cplex.End();
          }
          catch (ILOG.Concert.Exception e) {
         System.Console.WriteLine("Concert exception caught: " + e);
          }
    }