Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix container inefficiency in HeuristicSearch.java #490

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/main/gov/nasa/jpf/search/heuristic/HeuristicSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@ public abstract class HeuristicSearch extends Search {
*/
protected boolean isBeamSearch;

/*
* allocate childStates on needed (useChildStates == true)
*/
protected boolean useChildStates;


public HeuristicSearch (Config config, VM vm) {
super(config, vm);

useAstar = config.getBoolean("search.heuristic.astar");
isBeamSearch = config.getBoolean("search.heuristic.beam_search");
useChildStates = config.getBoolean("search.heuristic.child_states");
}


Expand Down Expand Up @@ -104,8 +110,9 @@ void backtrackToParent () {
* explicit termination request
*/
protected boolean generateChildren () {

childStates = new ArrayList<HeuristicState>();
if (useChildStates) {
childStates = new ArrayList<HeuristicState>();
}

while (!done) {

Expand Down Expand Up @@ -146,7 +153,9 @@ protected boolean generateChildren () {

HeuristicState newHState = queueCurrentState();
if (newHState != null) {
childStates.add(newHState);
if (useChildStates) {
childStates.add(newHState);
}
notifyStateStored();
}
}
Expand Down
Loading