Topic
1 reply Latest Post - ‏2013-01-06T17:33:50Z by SystemAdmin
SystemAdmin
SystemAdmin
1883 Posts
ACCEPTED ANSWER

Pinned topic How to extract 3-D arrays (CPLEX + C++)

‏2013-01-01T15:34:58Z |
Hello,

I have one 2D and one 3D boolean arrays that I defined as:


typedef IloArray<IloBoolVarArray> ArrayVar2D; typedef IloArray<IloArray<IloBoolVarArray> > ArrayVar3D;


and


IloEnv env; IloModel model(env); IloCplex cplex(env);


and


ArrayVar2D yir (env, 10); ArrayVar3D wijr (env, 10); 

for (

int a=0; a<10; a++) 
{ xij[a] = IloBoolVarArray(env, 10); yir[a] = IloBoolVarArray(env, 10); wijr[a] = ArrayVar2D(env, 10); 

for (

int b=0; b<10; b++) 
{ wijr[a][b] = IloBoolVarArray(env, 10); 
} 
}


It compiles, and CPLEX solves the model. My Problem: when I try to get the values. The code:




for (

int b=0; b<10; b++) 
{ 

for (

int a=0; a<10; a++) 
{ cout << 
"\t" << cplex.getValue(yir[b][a]); 
} cout << endl; 
}


Works fine. But I couldn't get the results from the 3D matrix. The code:




for (

int c=0; c<10; c++) 
{ cout << 
"c="<<c<<endl; 

for (

int b=0; b<10; b++) 
{ cout << 
" "<<b; 

for (

int a=0; a<10; a++) 
{ cout << 
"\t" << cplex.getValue(wijr[b][a][c]); 
} cout << endl; 
} 
}


Gives me:


Error: IloExtractable 11 IloNumVarI has not been extracted by IloAlgorithm 0x9848ab0


Does anyone have any idea?

Thanks!!!
Updated on 2013-01-06T17:33:50Z at 2013-01-06T17:33:50Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1883 Posts
    ACCEPTED ANSWER

    Re: How to extract 3-D arrays (CPLEX + C++)

    ‏2013-01-06T17:33:50Z  in response to SystemAdmin
    This error occurs if you attempt to query the value of a variable that is not part of the model, i.e., the variable does not appear in the objective function or any constraint.
    You should double-check that all variables in the 3D array actually appear somewhere in the model.
    You can explicitly add the variables to the model:
    for (int c=0; c<10; c++) {
      for (int b=0; b<10; b++) {
        for (int a=0; a<10; a++) {
          model.add(wijr[b][a][b]);
        }
      }
    }
    

    When you do that you can query any of the variables in the 3D array and should no longer get that error.
    Updated on 2014-03-26T05:51:25Z at 2014-03-26T05:51:25Z by iron-man