Browse Source

explicit.DTMC: mvMultRewGS for Gauss-Seidel style reward computations

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@12098 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Joachim Klein 9 years ago
parent
commit
1dd339ede5
  1. 22
      prism/src/explicit/DTMC.java

22
prism/src/explicit/DTMC.java

@ -392,6 +392,28 @@ public interface DTMC extends Model
}
}
/**
* Do a matrix-vector multiplication and sum of action reward (Gauss-Seidel).
* @param vect Vector to multiply by and store result in
* @param mcRewards The rewards
* @param states Do multiplication for these rows, in the specified order
* @param absolute If true, compute absolute, rather than relative, difference
* @return The maximum difference between old/new elements of {@code vect}
*/
public default double mvMultRewGS(double vect[], MCRewards mcRewards, PrimitiveIterator.OfInt states, boolean absolute)
{
double d, diff, maxDiff = 0.0;
while (states.hasNext()) {
int s = states.nextInt();
d = mvMultRewJacSingle(s, vect, mcRewards);
diff = absolute ? (Math.abs(d - vect[s])) : (Math.abs(d - vect[s]) / d);
maxDiff = diff > maxDiff ? diff : maxDiff;
vect[s] = d;
}
return maxDiff;
}
/**
* Do a single row of matrix-vector multiplication and sum of action reward.
* @param s Row index

Loading…
Cancel
Save