[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
|
var current = if(it.hasNext) Some(it.next) else None
|
||||||
while(!current.isEmpty) {
|
while(!current.isEmpty) {
|
||||||
val next = if(it.hasNext) Some(it.next) else None
|
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
|
timeVector(time) = current.get._2
|
||||||
}
|
}
|
||||||
current = next
|
current = next
|
||||||
@@ -212,13 +212,17 @@ class SimulationConfigParser(input: Map[String, Any], simulationBehaviours: Simu
|
|||||||
} else {
|
} else {
|
||||||
debugf(DebugType.WARNING, "Duplicate Ground Truth in Group [%s]. Ignoring Ground Truth: %s", groupString, groundTruthMap.toString())
|
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(groundTruthMap.contains("truth")){
|
||||||
if(groundTruthValues.contains(kv._1)) {
|
parseTruth(groundTruthMap("truth").asInstanceOf[Vector[Any]]).map(kv => {
|
||||||
groundTruthValues(kv._1)(group) = kv._2
|
if(groundTruthValues.contains(kv._1)) {
|
||||||
} else {
|
groundTruthValues(kv._1)(group) = kv._2
|
||||||
groundTruthValues(kv._1) = mutable.Map[Group, Truth](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 {
|
} 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())
|
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()
|
val groupDone: mutable.HashSet[Group] = mutable.HashSet()
|
||||||
|
|
||||||
def groupMapper(group: Group, count: SensorCount): List[(Group, Sensor, Option[GroundTruth])] = {
|
def groupMapper(group: Group, count: SensorCount): List[(Group, Sensor, Option[GroundTruth])] = {
|
||||||
if(!behaviourListSensor.contains(group)) {
|
if(groupDone.contains(group)) {
|
||||||
debugf(DebugType.WARNING, "Group [%s] does not have a behaviour, using default", group.toString())
|
// if we've already seen the group, get the list so we can add a depended group
|
||||||
behaviourListSensor(group) = Behaviour(BehaviourVector(Vector.tabulate(config.duration)(_ => None)))
|
val root = getParentRoot(group, this.groups.toMap) // get root if already added
|
||||||
}
|
if(!root.isEmpty) {
|
||||||
if(group.parent.isEmpty) {
|
groupMap(root.get)
|
||||||
groupDone.add(group)
|
} else { List() } // circular dependency, just return empty list
|
||||||
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 {
|
} else {
|
||||||
if(groupDone.contains(group)) {
|
if(!behaviourListSensor.contains(group)) {
|
||||||
debugf(DebugType.WARNING, "Circular dependency of groups: [%s]", groupDone.toString())
|
debugf(DebugType.WARNING, "Group [%s] does not have a behaviour, using default", group.toString())
|
||||||
List()
|
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 {
|
} else {
|
||||||
groupDone.add(group)
|
groupDone.add(group)
|
||||||
val parentGroup = this.groups(group.parent.get) // this should really exist at this point
|
val parentGroup = this.groups(group.parent.get) // this should really exist at this point
|
||||||
|
|||||||
Reference in New Issue
Block a user