Originally posted by: SystemAdmin
[prubin said:]
For future reference, please avoid using subscript i -- the forum software thinks an i inside square brackets means "commence italics".
[quote author=nfan link=topic=1417.msg3991#msg3991 date=1255961765]
I used following codes in C++ to define high dimensional integer and continuous variables. However, I always got the error
"Segmentation fault".
But when I change all variables into binary integer form, there is no such error.
what is wrong with my definition of variables? I want to define x[h][j] to be binary and y[h][j][k] to be continuous variables.
Thanks,
[i]typedef IloArray<IloNumVarArray> IloNumArray2;
typedef IloArray<IloNumArray2> IloNumArray3;
typedef IloArray<IloBoolVarArray> IloBoolArray2;
//define binary integers x[h][j] with dimension N*N
IloBoolArray2 x(env,N+1);
for(h=1;h<=N;h++){<br /> x[h]=IloBoolVarArray(env,K+1);}
//define continuous variables y[h][j][k] with dimension N*N*K
IloNumArray3 y(env,N+1);
for(h=1;h<=N;h++){<br /> y[h]=IloNumArray2(env,N+1);
for(j=1;j<=N;j++){<br /> y[h][j]=IloNumVarArray(env,K+1);}}[/i]
Do you get the seg fault in this block of code, or when you go to use y? I note that you are leaving y[0] and y[h][0] undefined; I wonder if the seg fault is actually the result of a null pointer being used later?
/Paul
#CPLEXOptimizers#DecisionOptimization