Skip to content

Commit

Permalink
Change order of if-statements, EQUAL first
Browse files Browse the repository at this point in the history
  • Loading branch information
AniekMarkus committed Jun 29, 2024
1 parent 4346965 commit 62775d6
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions src/C++/Explore/rule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,11 @@ void RULE::CreateFeatureOperators() {
FeatureOperators.push_back(LessCondition);
FOperator++;
} else {
if ((*Features)[i].GetOperator()==EQUAL) {
CONDITION EqualCondition(i, (*Features)[i].GetName(), (*Features)[i].GetCutoffs(), EQUAL, FOperator);
EqualCondition.NoOperators=1;
FeatureOperators.push_back(EqualCondition);
}
if ((*Features)[i].GetOperator()==GREATER) {
CONDITION GreaterCondition(i, (*Features)[i].GetName(), (*Features)[i].GetCutoffs(), GREATER, FOperator);
GreaterCondition.NoOperators=1;
Expand All @@ -1478,11 +1483,6 @@ void RULE::CreateFeatureOperators() {
LessCondition.NoOperators=1;
FeatureOperators.push_back(LessCondition);
}
if ((*Features)[i].GetOperator()==EQUAL) {
CONDITION EqualCondition(i, (*Features)[i].GetName(), (*Features)[i].GetCutoffs(), EQUAL, FOperator);
EqualCondition.NoOperators=1;
FeatureOperators.push_back(EqualCondition);
}

FOperator++;
}
Expand Down Expand Up @@ -2043,23 +2043,7 @@ bool RULE::NextCutoffSet() {
MaxCutoff = CurrentCondition->Cutoffs.size();

if (CurrentConjunction->Size==1 && Conjunctions.size()>1) { // More than one conjunction and current conjunction size = 1
if (CurrentCondition->Operator==LESS) {
MaxCutoff = GetMinCutoff(CurrentCondition->FeatureOperator);
if (CurrentCondition->CutoffNumber+1 < MaxCutoff) {
CurrentCondition->CutoffNumber++;
Incremented = true;
} else {
ConditionNr--;
}
} else if (CurrentCondition-> Operator==GREATER){
MaxCutoff = GetMaxCutoff(CurrentCondition->FeatureOperator);
if (CurrentCondition->CutoffNumber+1 > MaxCutoff && CurrentCondition->CutoffNumber+1<CurrentCondition->Cutoffs.size()) {
CurrentCondition->CutoffNumber++;
Incremented = true;
} else {
ConditionNr--;
}
} else if (CurrentCondition-> Operator==EQUAL){
if (CurrentCondition-> Operator==EQUAL){
if (CurrentCondition->CutoffNumber+1 < MaxCutoff) {
CurrentCondition->CutoffNumber++;
Incremented = true;
Expand Down Expand Up @@ -2128,6 +2112,22 @@ bool RULE::NextCutoffSet() {
} else {
ConditionNr--;
}
} else if (CurrentCondition->Operator==LESS) {
MaxCutoff = GetMinCutoff(CurrentCondition->FeatureOperator);
if (CurrentCondition->CutoffNumber+1 < MaxCutoff) {
CurrentCondition->CutoffNumber++;
Incremented = true;
} else {
ConditionNr--;
}
} else if (CurrentCondition-> Operator==GREATER){
MaxCutoff = GetMaxCutoff(CurrentCondition->FeatureOperator);
if (CurrentCondition->CutoffNumber+1 > MaxCutoff && CurrentCondition->CutoffNumber+1<CurrentCondition->Cutoffs.size()) {
CurrentCondition->CutoffNumber++;
Incremented = true;
} else {
ConditionNr--;
}
}
} else {
if (CurrentFeatureOperator->IsSolo && CurrentFeatureOperator->NonSoloIncluded && CurrentConjunction->Size>1) { // && !(CurrentFeatureOperator->Operator == LESS)
Expand Down Expand Up @@ -2169,17 +2169,7 @@ bool RULE::NextCutoffSet() {
CurrentFeatureOperator = &FeatureOperators[CurrentCondition->FeatureOperator];

if (CurrentConjunction->Size==1 && Conjunctions.size()>1) { // More than one conjunction and current conjunction size = 1
if (CurrentCondition->Operator==LESS) {
CurrentCondition->CutoffNumber = 0;
} else if (CurrentCondition->Operator==GREATER) {
// Reset to next cutoff
CurrentCondition->CutoffNumber = GetMinCutoff(CurrentCondition->FeatureOperator)+1;

// Or first if maximum reached
if (CurrentCondition->CutoffNumber > CurrentCondition->Cutoffs.size()-1) {
CurrentCondition->CutoffNumber = 0;
}
} else if (CurrentCondition->Operator==EQUAL) {
if (CurrentCondition->Operator==EQUAL) {
// If the previous FOP is the same nominal FOP, increase the condition
if ((ConjunctionNr > 0) && ((&Conjunctions[ConjunctionNr-1])->Size==1)
&& (PreviousCondition->FeatureNumber == CurrentCondition->FeatureNumber)
Expand Down Expand Up @@ -2210,6 +2200,16 @@ bool RULE::NextCutoffSet() {
}
}
}
} else if (CurrentCondition->Operator==LESS) {
CurrentCondition->CutoffNumber = 0;
} else if (CurrentCondition->Operator==GREATER) {
// Reset to next cutoff
CurrentCondition->CutoffNumber = GetMinCutoff(CurrentCondition->FeatureOperator)+1;

// Or first if maximum reached
if (CurrentCondition->CutoffNumber > CurrentCondition->Cutoffs.size()-1) {
CurrentCondition->CutoffNumber = 0;
}
}
} else {
if (CurrentCondition->PreviousSame) { // Increase cutoff for the same features within a conjunction
Expand Down

0 comments on commit 62775d6

Please sign in to comment.