|
|
|
@ -1,6 +1,5 @@ |
|
|
|
package explicit; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.BitSet; |
|
|
|
import java.util.Vector; |
|
|
|
|
|
|
|
@ -170,58 +169,6 @@ public class AccumulationProductCounting<M extends Model> extends AccumulationPr |
|
|
|
protected Integer getInitialComponent() { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
protected AccumulationState<Integer> updateAccumulationState(final int modelFromStateId, |
|
|
|
final AccumulationState<Integer> accstate, final ExpressionAccumulation accexp, |
|
|
|
final double[] weights, final ProbModelChecker mc) throws PrismException { |
|
|
|
// We have the current accumulation state, the current model id and the accumulation expression. |
|
|
|
|
|
|
|
// Get the old tracker and tracks. |
|
|
|
AccumulationTracker<Integer> oldTracker = accstate.getTracker(trackers); |
|
|
|
ArrayList<AccumulationTrack<Integer>> oldTracks = oldTracker.getTracks(); |
|
|
|
|
|
|
|
BitSet oldGoodTracks = accstate.getGoodTracks(); |
|
|
|
BitSet newGoodTracks = (BitSet) oldGoodTracks.clone(); |
|
|
|
|
|
|
|
// This restart will be... |
|
|
|
int newLastRestartNr = accstate.getNextRestartNr(); |
|
|
|
//mc.getLog().print(newLastRestartNr); |
|
|
|
|
|
|
|
// Build the new tracks. |
|
|
|
ArrayList<AccumulationTrack<Integer>> newTracks = new ArrayList<>(); |
|
|
|
|
|
|
|
int trackNr = 0; |
|
|
|
for(AccumulationTrack<Integer> oldTrack : oldTracks) { |
|
|
|
AccumulationTrack<Integer> newTrack; |
|
|
|
|
|
|
|
// restart or advance |
|
|
|
if(trackNr == newLastRestartNr) { |
|
|
|
//assert oldTrack == null : "Track " + newLastRestartNr + " is not null!"; |
|
|
|
newTrack = new AccumulationTrack<Integer>(numberOfWeights, 0); //TODO: off-by-one? |
|
|
|
newGoodTracks.clear(trackNr); |
|
|
|
} else if (oldTrack == null) { |
|
|
|
newTrack = null; |
|
|
|
} else { |
|
|
|
assert oldTrack != null; |
|
|
|
newTrack = updateTrack(modelFromStateId, oldTrack, accexp, weights, mc); |
|
|
|
} |
|
|
|
|
|
|
|
// check whether the track is good |
|
|
|
if(!newGoodTracks.get(trackNr)) { |
|
|
|
newGoodTracks.set(trackNr, isGoodTrack(newTrack, accexp, mc)); |
|
|
|
} |
|
|
|
|
|
|
|
newTracks.add(newTrack); |
|
|
|
trackNr++; |
|
|
|
} |
|
|
|
|
|
|
|
AccumulationTracker<Integer> newTracker = new AccumulationTracker<>(newTracks); |
|
|
|
|
|
|
|
|
|
|
|
int newTrackerId = trackers.findOrAdd(newTracker); |
|
|
|
|
|
|
|
return new AccumulationState<>(newTrackerId, newLastRestartNr, numberOfTracks, newGoodTracks); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected AccumulationTrack<Integer> updateTrack(Integer modelFromStateId, final AccumulationTrack<Integer> track, |
|
|
|
@ -246,23 +193,10 @@ public class AccumulationProductCounting<M extends Model> extends AccumulationPr |
|
|
|
return new AccumulationTrack<Integer>(newweights, currentStep+1); |
|
|
|
} |
|
|
|
|
|
|
|
protected int createInitialStateId(final int numberOfRewards) { |
|
|
|
// The initial active track is the first one, all tracks are non-good by default |
|
|
|
int initialActiveTrack = 0; |
|
|
|
BitSet initialGoodTracks = new BitSet(); |
|
|
|
|
|
|
|
// Generate the initial tracker and product state |
|
|
|
AccumulationTracker<Integer> initialTracker = new AccumulationTracker<>(numberOfTracks, numberOfRewards, 0); |
|
|
|
int initialTrackerId = trackers.findOrAdd(initialTracker); |
|
|
|
AccumulationState<Integer> initialAccState = new AccumulationState<>(initialTrackerId, initialActiveTrack, numberOfTracks, initialGoodTracks); |
|
|
|
int initialAccStateId = accStates.findOrAdd(initialAccState); |
|
|
|
|
|
|
|
return initialAccStateId; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Populates fields: |
|
|
|
* - numberOfTracks |
|
|
|
* - numberOfTracks with the highest relevant integer plus one, and |
|
|
|
* - numberOfWeights with the size of the reward vector. |
|
|
|
* @param graph |
|
|
|
* @param accexp |
|
|
|
* @param rewards |
|
|
|
|