[fix] fixed bugs in parser
- [fix] fixed out of bound error - [fix] fixed ground truth to not requiring "truth" key if parent exist - [fix] fixed group list overwriting itself in groupMapper function
This commit is contained in:
@@ -177,7 +177,7 @@ class SimulationConfigParser(input: Map[String, Any], simulationBehaviours: Simu
|
||||
var current = if(it.hasNext) Some(it.next) else None
|
||||
while(!current.isEmpty) {
|
||||
val next = if(it.hasNext) Some(it.next) else None
|
||||
for(time <- current.get._1 to (if(!next.isEmpty) next.get._1 else config.duration - 1)) {
|
||||
for(time <- current.get._1 to (if(!next.isEmpty && next.get._1 < config.duration) next.get._1 else config.duration - 1)) {
|
||||
timeVector(time) = current.get._2
|
||||
}
|
||||
current = next
|
||||
@@ -212,13 +212,17 @@ class SimulationConfigParser(input: Map[String, Any], simulationBehaviours: Simu
|
||||
} else {
|
||||
debugf(DebugType.WARNING, "Duplicate Ground Truth in Group [%s]. Ignoring Ground Truth: %s", groupString, groundTruthMap.toString())
|
||||
}
|
||||
parseTruth(groundTruthMap("truth").asInstanceOf[Vector[Any]]).map(kv => {
|
||||
if(groundTruthValues.contains(kv._1)) {
|
||||
groundTruthValues(kv._1)(group) = kv._2
|
||||
} else {
|
||||
groundTruthValues(kv._1) = mutable.Map[Group, Truth](group -> kv._2)
|
||||
}
|
||||
})
|
||||
if(groundTruthMap.contains("truth")){
|
||||
parseTruth(groundTruthMap("truth").asInstanceOf[Vector[Any]]).map(kv => {
|
||||
if(groundTruthValues.contains(kv._1)) {
|
||||
groundTruthValues(kv._1)(group) = kv._2
|
||||
} else {
|
||||
groundTruthValues(kv._1) = mutable.Map[Group, Truth](group -> kv._2)
|
||||
}
|
||||
})
|
||||
} else if(group.parent.isEmpty) {
|
||||
debugf(DebugType.WARNING, "Sensor Group [%s] has no parent and no ground truth values", groupString)
|
||||
}
|
||||
} else {
|
||||
debugf(DebugType.WARNING, "Unused Ground Truth in Group [%s] because the Sensor has Parent [%s]. Ignoring Ground Truth: %s", groupString, group.parent.get, groundTruthMap.toString())
|
||||
}
|
||||
@@ -281,18 +285,21 @@ class SimulationConfigParser(input: Map[String, Any], simulationBehaviours: Simu
|
||||
val groupDone: mutable.HashSet[Group] = mutable.HashSet()
|
||||
|
||||
def groupMapper(group: Group, count: SensorCount): List[(Group, Sensor, Option[GroundTruth])] = {
|
||||
if(!behaviourListSensor.contains(group)) {
|
||||
debugf(DebugType.WARNING, "Group [%s] does not have a behaviour, using default", group.toString())
|
||||
behaviourListSensor(group) = Behaviour(BehaviourVector(Vector.tabulate(config.duration)(_ => None)))
|
||||
}
|
||||
if(group.parent.isEmpty) {
|
||||
groupDone.add(group)
|
||||
List((group, Sensor(group, cell, count, behaviourListSensor(group), config.parSensor, config.sensorThreadPool),
|
||||
if(behaviourListGroundTruth.contains(group)) Some(GroundTruth(group, Some(behaviourListGroundTruth(group)))) else None))
|
||||
if(groupDone.contains(group)) {
|
||||
// if we've already seen the group, get the list so we can add a depended group
|
||||
val root = getParentRoot(group, this.groups.toMap) // get root if already added
|
||||
if(!root.isEmpty) {
|
||||
groupMap(root.get)
|
||||
} else { List() } // circular dependency, just return empty list
|
||||
} else {
|
||||
if(groupDone.contains(group)) {
|
||||
debugf(DebugType.WARNING, "Circular dependency of groups: [%s]", groupDone.toString())
|
||||
List()
|
||||
if(!behaviourListSensor.contains(group)) {
|
||||
debugf(DebugType.WARNING, "Group [%s] does not have a behaviour, using default", group.toString())
|
||||
behaviourListSensor(group) = Behaviour(BehaviourVector(Vector.tabulate(config.duration)(_ => None)))
|
||||
}
|
||||
if(group.parent.isEmpty) {
|
||||
groupDone.add(group)
|
||||
List((group, Sensor(group, cell, count, behaviourListSensor(group), config.parSensor, config.sensorThreadPool),
|
||||
if(behaviourListGroundTruth.contains(group)) Some(GroundTruth(group, Some(behaviourListGroundTruth(group)))) else None))
|
||||
} else {
|
||||
groupDone.add(group)
|
||||
val parentGroup = this.groups(group.parent.get) // this should really exist at this point
|
||||
|
||||
Reference in New Issue
Block a user