Skip to content

Commit 6024050

Browse files
committed
fixed wrong handling of bindings in copy
1 parent 9dc19bd commit 6024050

3 files changed

Lines changed: 30 additions & 22 deletions

File tree

core/src/main/kotlin/org/evomaster/core/problem/util/BindingBuilder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ object BindingBuilder {
115115
p.second.addBindingGene(p.first)
116116
}
117117

118-
val first = ParamUtil.getValueGene(p.first)
119-
val second = ParamUtil.getValueGene(p.second)
118+
val first = p.first.getLeafGene()
119+
val second = p.second.getLeafGene()
120120
if(ok && !doBuildBindingGene && first is StringGene && TaintInputName.isTaintInput(first.value)){
121121
//do not use same tainted value in non-bound genes
122122
if(second is StringGene){

core/src/main/kotlin/org/evomaster/core/search/gene/Gene.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -911,19 +911,22 @@ abstract class Gene(
911911
* sync [bindingGenes] based on [this]
912912
*/
913913
fun syncBindingGenesBasedOnThis(all: MutableSet<Gene> = mutableSetOf()) {
914-
if (bindingGenes.isEmpty()) return
914+
if (bindingGenes.isEmpty()){
915+
return
916+
}
915917
all.add(this)
916918
bindingGenes.filterNot { all.contains(it) }.forEach { b ->
917919
all.add(b)
918-
if (!b.copyValueFrom(this))
919-
LoggingUtil.uniqueWarn(
920-
log,
921-
"fail to bind the gene (${b.name} with the type ${b::class.java.simpleName}) based on this gene (${this.name} with ${this::class.java.simpleName})"
922-
)
920+
if (!b.copyValueFrom(this)) {
921+
LoggingUtil.uniqueWarn(log, "fail to bind the gene (${b.name} with the type ${b::class.java.simpleName})" +
922+
" based on this gene (${this.name} with ${this::class.java.simpleName})")
923+
}
923924
b.syncBindingGenesBasedOnThis(all)
924925
}
925926

926-
children.filterNot { all.contains(it) }.forEach { it.syncBindingGenesBasedOnThis(all) }
927+
children.filterNot { all.contains(it) }.forEach {
928+
it.syncBindingGenesBasedOnThis(all)
929+
}
927930
}
928931

929932
/**

core/src/main/kotlin/org/evomaster/core/search/gene/string/StringGene.kt

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,10 @@ class StringGene(
985985

986986
override fun unsafeCopyValueFrom(other: Gene): Boolean {
987987

988+
/*
989+
TODO aren't we ignoring here if this gene is using a specialization?
990+
*/
991+
988992
//TODO should this be handled with phenotype or wrapper? need to double-check
989993
if(other is ChoiceGene<*>){
990994
val x = other.activeGene()
@@ -1029,19 +1033,20 @@ class StringGene(
10291033
}
10301034
}
10311035

1032-
if(other is StringGene) {
1033-
this.selectedSpecialization = other.selectedSpecialization
1034-
1035-
this.specializations.clear()
1036-
this.specializations.addAll(other.specializations)
1037-
1038-
killAllChildren()
1039-
addChildren(other.specializationGenes.map { it.copy() })
1040-
1041-
this.tainted = other.tainted
1042-
this.bindingIds.clear()
1043-
this.bindingIds.addAll(other.bindingIds)
1044-
}
1036+
//TODO would need updating...
1037+
// if(other is StringGene) {
1038+
// this.selectedSpecialization = other.selectedSpecialization
1039+
//
1040+
// this.specializations.clear()
1041+
// this.specializations.addAll(other.specializations)
1042+
//
1043+
// killAllChildren()
1044+
// addChildren(other.specializationGenes.map { it.copy() })
1045+
//
1046+
// this.tainted = other.tainted
1047+
// this.bindingIds.clear()
1048+
// this.bindingIds.addAll(other.bindingIds)
1049+
// }
10451050

10461051
return true
10471052
}

0 commit comments

Comments
 (0)