A,OR,10,3,B,C,D,20,40,OPTIONAL,0,1,10,15,20,20,15,10 B,NULL,0,0,10,15,OPTIONAL,0,0 C,NULL,0,0,20,30,FIXED,1,0,5,5,5,5,5,10,5,5,5,5,5 D,NULL,0,0,10,100,OPTIONAL,1,0,2,3,4,5,6,7,6,5,4,3,2 When read will be: Nodes[1].Name = A Nodes[1].Operand = OR Nodes[1].GoalPriority = 10 Nodes[1].ChildCount = 3 Nodes[1].Child[1] = B Nodes[1].Child[2] = C Nodes[1].Child[3] = D Nodes[1].MinRange = 20 Nodes[1].MaxRange = 40 Nodes[1]. GivenDistributionStatus = OPTIONAL Nodes[1].GivenFlag = 0 Nodes[1].GoalFlag = 1 Nodes[1].GivenDistribution = EMPTY Nodes[1].GoalDistribution = {10,15,20,20,15,10} Nodes[2].Name = B Nodes[2].Operand = NULL Nodes[2].GoalPriority = 0 Nodes[2].ChildCount = 0 Nodes[2].MinRange = 10 Nodes[2].MaxRange = 15 Nodes[2]. GivenDistributionStatus = OPTIONAL Nodes[2].GivenFlag = 0 Nodes[2].GoalFlag = 0 Nodes[2].GivenDistribution = EMPTY Nodes[2].GoalDistribution = EMPTY Nodes[3].Name = C Nodes[3].Operand = NULL Nodes[3].GoalPriority = 0 Nodes[3].ChildCount = 0 Nodes[3].MinRange = 20 Nodes[3].MaxRange = 30 Nodes[3]. GivenDistributionStatus = FIXED Nodes[3].GivenFlag = 1 Nodes[3].GoalFlag = 0 Nodes[3].GivenDistribution = {5,5,5,5,5,10,5,5,5,5,5} Nodes[3].GoalDistribution = EMPTY Nodes[4].Name = D Nodes[4].Operand = NULL Nodes[4].GoalPriority = 0 Nodes[4].ChildCount = 0 Nodes[4].MinRange = 10 Nodes[4].MaxRange = 100 Nodes[4].GivenDistributionStatus = OPTIONAL Nodes[4].GivenFlag = 1 Nodes[4].GoalFlag = 0 Nodes[4].GivenDistribution = {2,3,4,5,6,7,6,5,4,3,2} Nodes[4].GoalDistribution = EMPTY #INPUT: CSV lines containing the node's name, operand, goal priority, number of child node(s), child node(s) if any, distribution range, given distribution optional flag, given distribution flag, goal distribution flag, given distribution (if flag set), goal distribution (if flag set) #OUTPUT: a distribution for each node MaxDistort = 2 Runs = 100 Bins = 20 for bin in Bins initialize minError[bin] for node in Nodes read and store node's information if (no priority given OR highest priority == root.priority) goalNode = root else goalNode = node with maximum priority for run in Runs { for node in Nodes initialize node.PredictedDistribution #PROCESS LEAF NODES for node in leaf nodes { if (node.GivenDistributionStatus == fixed AND node.GivenFlag == 1) for each bin in Bins node.PredictedDistribution[bin] = node.GivenDistribution[bin] else if (run > 1) for each bin in Bins value1 = a random number between 0 and goalNode.GoalDistribution[bin]*MaxDistort value2 = best.distribution[node,bin] node.PredictedDistribution[bin] = selectRandomly(value1,value2) else for each bin in Bins value1 = a random number between 0 and goalNode.GoalDistribution[bin]*MaxDistort node.PredictedDistribution[bin] = value1 } #PROCESS ALL OTHER NODES for node in non-leaf nodes node.PredictedDistribution = apply node.Operand on all its child nodes #SCORING for bin in Bins initialize error[bin] for node in Nodes if (node.GoalFlag == 1) for bin in Bins error[bin] = error[bin] + abs(node.PredictedDistribution[bin] - node.GoalDistribution[bin]) #FINDING THE BEST for bin in Bins if (error[bin] < minError[bin]) minError[bin] = error[bin] for (node in leaf nodes) best.distribution[node,bin] = node.PredictedDistribution[bin]; } }}