This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 1433-Add-CLI-options-to-docs
- Loading branch information
Showing
5 changed files
with
110 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...r/src/main/java/com/scottlogic/deg/generator/walker/decisionbased/RandomOptionPicker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...ator/src/main/java/com/scottlogic/deg/generator/walker/rowspec/PotentialRowSpecCount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2019 Scott Logic Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.scottlogic.deg.generator.walker.rowspec; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.name.Named; | ||
import com.scottlogic.deg.generator.decisiontree.ConstraintNode; | ||
import com.scottlogic.deg.generator.decisiontree.DecisionNode; | ||
import com.scottlogic.deg.generator.decisiontree.DecisionTree; | ||
|
||
public class PotentialRowSpecCount { | ||
private final int max; | ||
|
||
@Inject | ||
public PotentialRowSpecCount(@Named("config:internalRandomRowSpecStorage") int max) { | ||
this.max = max; | ||
} | ||
|
||
/** | ||
* recursively traverses the tree counting the maximum potential number of | ||
* decisions that could result. Breaks early if count goes over given max value | ||
* @param decisionTree tree to count | ||
* @return whether the tree has less than the max number of decisions | ||
*/ | ||
boolean lessThanMax(DecisionTree decisionTree){ | ||
Integer total = countConstraintNode(decisionTree.rootNode); | ||
return total != null; | ||
} | ||
|
||
private Integer countConstraintNode(ConstraintNode constraintNode){ | ||
int total = 1; | ||
for (DecisionNode decision : constraintNode.getDecisions()) { | ||
Integer count = countDecisionNode(decision); | ||
if (count == null) return null; | ||
|
||
total *= count; | ||
if (total > max) return null; | ||
} | ||
return total; | ||
} | ||
|
||
private Integer countDecisionNode(DecisionNode decision) { | ||
int total = 0; | ||
for (ConstraintNode option : decision.getOptions()) { | ||
Integer count = countConstraintNode(option); | ||
if (count == null) return null; | ||
|
||
total += count; | ||
if (total > max) return null; | ||
} | ||
return total; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters