Beispiel #1
0
    public static void Main(string[] args)
    {
        if (args.Length != 1)
        {
            System.Console.WriteLine("Usage: Goalex3 filename");
            System.Console.WriteLine("   where filename is a file with extension ");
            System.Console.WriteLine("      MPS, SAV, or LP (lower case is allowed)");
            System.Console.WriteLine(" Exiting...");
            System.Environment.Exit(-1);
        }

        try {
            Cplex cplex = new Cplex();

            cplex.ImportModel(args[0]);

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

            ILPMatrix lp = (ILPMatrix)matrixEnum.Current;

            Cplex.Goal iiSumGoal = cplex.Apply(new MyBranchGoal(lp.NumVars),
                                               new MyIISEvaluator());
            Cplex.Goal depthGoal = cplex.Apply(iiSumGoal,
                                               new MyDepthEvaluator());

            cplex.SetParam(Cplex.Param.MIP.Strategy.Search, Cplex.MIPSearch.Traditional);
            if (cplex.Solve(depthGoal))
            {
                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)
    {
        if ( args.Length != 1 ) {
         System.Console.WriteLine("Usage: Goalex3 filename");
         System.Console.WriteLine("   where filename is a file with extension ");
         System.Console.WriteLine("      MPS, SAV, or LP (lower case is allowed)");
         System.Console.WriteLine(" Exiting...");
         System.Environment.Exit(-1);
          }

          try {
         Cplex cplex = new Cplex();

         cplex.ImportModel(args[0]);

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

         ILPMatrix lp = (ILPMatrix)matrixEnum.Current;

         Cplex.Goal iiSumGoal = cplex.Apply(new MyBranchGoal(lp.NumVars),
                                            new MyIISEvaluator());
         Cplex.Goal depthGoal = cplex.Apply(iiSumGoal,
                                            new MyDepthEvaluator());

         cplex.SetParam(Cplex.Param.MIP.Strategy.Search, Cplex.MIPSearch.Traditional);
         if ( cplex.Solve(depthGoal) ) {
            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);
          }
    }