Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Solving LP with just bound constraints using callable library

    Posted 05/27/13 01:28 AM

    Originally posted by: youngdae


    Hello,

    I would like to solve LP using callable library which has just bound constraints. For example, when I write down the problem using CPXwriteprob() before calling CPXlpopt(), it generates the following output.

    Minimize

     obj: 0 x1 + 0 x2

    Bounds

     0 <= x1 <= 1

              x2 Free

    End

    However, when I call CPXlpopt(), it failed with an error code 1017. Error code 1017 is CPXERR_NOT_FOR_MIP: The requested operation can not be performed for mixed integer programs. Change the problem type.

    Could anyone help with this? Should I add at least one constraint with just 0 coefficients?


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Solving LP with just bound constraints using callable library

    Posted 05/27/13 03:07 PM

    Originally posted by: T_O


    For some reason, your problem has become a MIP. You have several opportunities:

    • Find out why you created a MIP. (Where there integer variables that you removed?) (recommended)
    • Change the problem type to lp (CPXchgprobtype).
    • Call CPXmipopt instead of CPXlpopt (your problem should be solved at the root node).

    Best regards,
    Thomas

    BTW: An LP with just bound constraints is trivial. You can "see" the solution.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Solving LP with just bound constraints using callable library

    Posted 05/29/13 02:31 AM

    I guess you used a non-NULL ctype argument for function CPXnewcols. The below program works just fine. It creates your model and solves it without issue.

    #include <stdio.h>
    #include <stdlib.h>
    #include <ilcplex/cplexx.h>

    static double const obj[] = { 0.0, 0.0 };
    static double const lb[] = { 0, -CPX_INFBOUND };
    static double const ub[] = { 1, CPX_INFBOUND };
    static char const *const name[] = { "x1", "x2" };
    #ifdef PRODUCE_MIP
    static char const ctype[] = { 'C', 'C' };
    #else
    static char const *ctype = NULL;
    #endif

    int
    main(void)
    {
       CPXENVptr env;
       CPXLPptr lp;
       int status;

       if ( (env = CPXXopenCPLEX(&status)) == NULL || status != 0 ) {
          fprintf (stderr, "CPXXopenCPLEX: %d\n", status);
          abort();
       }
       if ( (lp = CPXXcreateprob(env, &status, "model")) == NULL || status != 0 ) {
          fprintf (stderr, "CPXXcreateprob: %d\n", status);
          abort ();
       }

       status = CPXXnewcols (env, lp, 2, obj, lb, ub, ctype, name);
       if ( status != 0 ) {
          fprintf (stderr, "CPXXnewcols: %d\n", status);
          abort ();
       }
       status = CPXXwriteprob (env, lp, "model.lp", NULL);
       if ( status != 0 ) {
          fprintf (stderr, "CPXXwriteprob: %d\n", status);
          abort ();
       }
       status = CPXXlpopt (env, lp);
       if ( status != 0 ) {
          fprintf (stderr, "CPXXlpopt: %d\n", status);
          abort ();
       }

       CPXXfreeprob (env, &lp);
       CPXXcloseCPLEX (&env);
       printf ("Success\n");
       return 0;
    }

    Note that I pass a NULL pointer as ctype to CPXnewcols. When I pass a non-NULL pointer as ctype (define PRODUCE_MIP) then CPLEX will always consider the problem as a MIP, even if all entries in ctype are 'C'.

    This is expected behavior and is specified in the reference documentation for CPXnewcols.


    #CPLEXOptimizers
    #DecisionOptimization