I'm working on building a travelling salesman model for a game I play in a Google Spreadsheet. I'm currently working on a portion of the script to calculate the "travel time" for each arc based on a formula from the game that determines travel time. When I run the script, it fills the formulas properly, but they all show parsing errors until I double click them to edit and hit enter, then they run just fine.
Is there a command in Apps Script to refresh formulas or is there something I can change to prevent this issue?
function nodeSetup() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Node Listing");
var calc = ss.getSheetByName("Distance Calculations");
var numNodes = sheet.getLastRow()-1;
var i = 1;
var j = 1;
while (i<numNodes+1){
calc.getRange(1,i+1).setValue(i);
i++
}
while (j<numNodes+1){
calc.getRange(j+1,1).setValue(j);
j++
}
var i = 1;
var j = 1;
while (i<numNodes+1){
var j = 1;
while (j<numNodes+1){
calc.getRange(i+1,j+1).setFormula("=Max(ABS(index('Node Listing'!$B$2:$C$6,"+(j)+",1)-index('Node Listing'!$B$2:$C$6,"+(i)+",1)),ABS(index('Node Listing'!$B$2:$C$6,"+(j)+",2)-index('Node Listing'!$B$2:$C$6,"+(i)+",2))*2/HyperVal*(1+0.05*PilotSkill)");
j++
}
i++
}
}