NeverOnTimeSdnBhd / Delivery-Instances

2 stars 6 forks source link

Question with MCTS #14

Open Afiq1j opened 3 years ago

Afiq1j commented 3 years ago

1) 3d array initialization My code is almost the same with Issue #11 (Sir said it was correct), but we got a ArrayIndexOutOfBoundsException error. I have checked and tried for many times and the error shown always the same. Without solving this problem we cannot continue debugging other line. Do sir meet this error b4 and have any idea on why this is happening? Please provide us aid as we are stuck on debugging this particular issue for a long time

private double[][][]policy=new double[level][N][N]; //level = 3, N = 5 private double[][]globalPolicy=new double[N][N];

function search{ //something if{ //something }else{ policy[level]=globalPolicy; //line with error for{ //something } }}

2) line 69 : find every possible successor that is not yet checked for currentStop What it means by not yet checked here? What is the difference of checked and visited? We have followed exactly the code from the pseudocode, but there seems to be no mention what is the field checked (where and when was it initialised).
From our understanding, unchecked is a field we initialised it as a linkedlist storing all possible customers for a particular customer (capacity enough).

line 71: currentroute is completed. From our understanding, current route here is the new_tour last route right? So we should depot behind Ex: newTour.get(newTour.size()-1).addNode(head);

3) line 54 & 57: the int stop and move This refer to the id of these nodes, or the index of the for loop since both stop and move are inside two nested for loops Ex: for (int k = 0; k < allStops.length ; k++){ if (currentStop.testNode(allStops[k]) && !allStops[k].visited){ z+= Math.exp(globalPolicy[j][k]); fyi: testnode function is to check validity (Capacity enough)

4) line 52 55 are they the same? Can i combine line 53 54 56 57 in a single for loop For every possible move that can be made by stop: Currently we are using all the nodes (including depot) no matter they are visited or not since will be evaluated a line after that, is our concept correct?

5) In issue 2, sir mentioned that we need to clear all the checked conditions since they have not yet been added to any route. May we know where to add this function? If it helps to answer our questions, we can share our code here for you to check.

We have really go through the logic and pseudocode provided countless time but still don't understand. Thank you for taking your time to answer our questions, it's a bit too much, these problems are either not in issues or we still don't get it even Sir have replied.

NeverOnTimeSdnBhd commented 3 years ago

Hi

  1. Consider thinking if I have 3 level of search, what is the highest level id if lowest id start from 0 ? Is it 2? or 3? Please remember that your array initialization is always start from 0 (double [3][N][N] only create double [0], double [1] and double [2] N x N array...).

  2. Consider reading https://github.com/NeverOnTimeSdnBhd/Delivery-Instances/issues/2#issuecomment-842096290 , I explained the meaning of checked and visited...

    line 71: currentroute is completed. From our understanding, current route here is the new_tour last route right? So we should depot behind Ex: newTour.get(newTour.size()-1).addNode(head);

    yes ...

  3. ID of stop / move

    For every possible move that can be made by stop: Currently we are using all the nodes (including depot) no matter they are visited or not since will be evaluated a line after that, is our concept correct?

    correct

  4. What about z? If you are not familiar with exp try replace it with something simple like just sum value of globalPolicy[stop][move] for z, do you think combine those two loop will give same result as one loop?

  5. In the rollout function after you add new route to your tour and starting searching nodes for the new route