0
votes

I try to create a set of decision variables which is not using the integer values from the for-Loop but instead gets the value from an array.

The reason is that I want the indices to be the same like the numbers in the arrays. The numbering of Array could look like:

int [] Array = {12,11,10,15,16,17};

I get a arrayoutofboundsexception error when I run it.

Here the part of the code:

 x = new IloNumVar[inputData.Array().length][inputData.Array().length][inputData.Arraytwo().length];
    for (int i=0; i< inputData.Array().length;i++){
        this.x[inputData.Array()[i]]= new IloNumVar[inputData.Array().length][]; 
            for (int j=0; j< inputData.Array().length;j++){
            this.x[inputData.Array()[[i][j] = new IloNumVar[inputData.Arraytwo().length];
            for (int k=0; k<inputData.get_sub_K_set().length;k++){
                this.xx[inputData.Array()[i]][inputData.Array()[j]][inputData.Arraytwo()[k]]= this.boolVar("x:i_"+inputData.Array()[i]+"-j_"+inputData.Array()[j]+"-k_"+inputData.Arraytwo()[k]);
            }
        }
    }

I appreciate any help. Thank you guys!

1

1 Answers

0
votes

You are declaring Array as:

int [] Array = {12,11,10,15,16,17};

and then iterating in:

for (int i=0; i< inputData.Array().length;i++){

this means that the values of i are {0,1,2,3,4,5}

and x is defined like IloNumVar[6][6][6]

when you do:

this.x[inputData.Array()[i]]

is and error because you dont have indexes {12,11,10,15,16,17} in the x variable.