Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  CPXbinvarow and corresponding variable

    Posted 05/06/10 03:49 AM

    Originally posted by: agelos


    Hi all,

    When I obtain a row of the tableau using CPXbinvarow, is there a way to know which basic variable does it (the row) correspond to?

    Does Cplex keep the rows of the tableau ordered according to the initial order of variables (first the original problem variables, then the slacks)?

    Thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: CPXbinvarow and corresponding variable

    Posted 05/06/10 04:21 AM

    Originally posted by: SystemAdmin


    You need to call CPXgetbhead() to get information about which variables and slacks are currently in the basis. In the basis array that it returns, negative values indicate rows (i.e., basic slacks) while non-negative values indicate structural basic variables.

    Something like this:
    int processbinva(CPXENVptr env, CPXLPptr lp)
    {
       int cols = CPXgetnumcols(env, lp);
       int rows = CPXgetnumrows(env, lp);
       int *bhead = NULL;
       double *coefs = NULL;
       int status = 0;
       int i;
     
       bhead = malloc(rows * sizeof(int));
       coefs = malloc(cols * sizeof(double));
       if ( bhead == NULL || coefs == NULL ) {
          status = CPXERR_NO_MEMORY;
          goto TERMINATE;
       }
     
       status = CPXgetbhead(env, lp, bind, NULL);
       if ( status ) goto TERMINATE;
     
       for ( i = 0; i < rows; i++ ) {
          /* get tableau row for basis entry 'i' */
          status = CPXbinvarow(env, lp, i, coefs);
          if ( status ) goto TERMINATE;
     
          if ( bind[i] >= 0 ) {
             /* tableau row 'i' corresponds to basic variable 'c' */
             int c = bind[i];
          }
          else {
             /* tableau row 'i' corresponds to basic row 'r' */
             int r = -bind[i]-1;
         }
       }
     
    TERMINATE:
     
       if ( bhead != NULL )
          free(bhead);
       if ( coefs != NULL )
          free(coefs);
     
       return status;
    }
    


    I did not test this code, but still hope that there are no syntax errors. Hope this helps...

    Tobias
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: CPXbinvarow and corresponding variable

    Posted 05/06/10 10:07 AM

    Originally posted by: agelos


    Thanks
    #CPLEXOptimizers
    #DecisionOptimization