Skip to content

Commit

Permalink
[PExplicit] Minor improvement to stateful backtracking
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-goel committed Apr 19, 2024
1 parent c021b78 commit 5c76a2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ protected void runStep() throws TimeoutException {
return;
}

if (PExplicitGlobal.getConfig().isStatefulBacktrackEnabled()) {
if (PExplicitGlobal.getConfig().isStatefulBacktrackEnabled()
&& stepState.getStepNumber() != 0) {
stepState.storeMachinesState();
schedule.setStepBeginState(stepState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class StepState implements Serializable {
private SortedSet<PMachine> machineSet = new TreeSet<>();

/**
* Local state of each machine in machineSet in order
* Local state of each machine (null if not in machineSet)
*/
@Getter
private List<MachineLocalState> machineLocalStates = new ArrayList<>();
Expand Down Expand Up @@ -76,20 +76,23 @@ public void setTo(StepState input) {
machineLocalStates = input.machineLocalStates;

int i = 0;
for (PMachine machine : machineSet) {
machine.setMachineState(machineLocalStates.get(i++));
}
for (PMachine machine: PExplicitGlobal.getMachineSet()) {
if (!machineSet.contains(machine)) {
MachineLocalState ms = machineLocalStates.get(i++);
if (ms == null) {
machine.reset();
} else {
machine.setMachineState(ms);
}
}
}

public void storeMachinesState() {
machineLocalStates.clear();
for (PMachine machine : machineSet) {
MachineLocalState ms = machine.copyMachineState();
for (PMachine machine : PExplicitGlobal.getMachineSet()) {
MachineLocalState ms = null;
if (machineSet.contains(machine)) {
ms = machine.copyMachineState();
}
machineLocalStates.add(ms);
}
}
Expand Down

0 comments on commit 5c76a2d

Please sign in to comment.