Browse Source

Update sparse engine adversary generation to include number of transitions in the tra file.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@10092 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 11 years ago
parent
commit
1eb73ab127
  1. 14
      prism/src/sparse/PS_NondetReachReward.cc
  2. 18
      prism/src/sparse/PS_NondetUntil.cc

14
prism/src/sparse/PS_NondetReachReward.cc

@ -347,6 +347,13 @@ jboolean min // min or max probabilities (true = min, false = max)
// Traverse matrix to extract adversary
if (export_adv_enabled != EXPORT_ADV_NONE) {
// Do two passes: first to compute the number of transitions,
// the second to actually do the export
int num_trans = 0;
for (int pass = 1; pass <= 2; pass++) {
if (pass == 2) {
fprintf(fp_adv, "%d %d\n", n, num_trans);
}
h1 = h2 = 0;
for (i = 0; i < n; i++) {
if (!use_counts) { l1 = row_starts[i]; h1 = row_starts[i+1]; }
@ -357,6 +364,11 @@ jboolean min // min or max probabilities (true = min, false = max)
else { l2 = h2; h2 += choice_counts[j]; }
// But only output a choice if it is in the adversary
if (j == adv[i]) {
switch (pass) {
case 1:
num_trans += (h2-l2);
break;
case 2:
for (k = l2; k < h2; k++) {
switch (export_adv_enabled) {
case EXPORT_ADV_DTMC:
@ -371,6 +383,8 @@ jboolean min // min or max probabilities (true = min, false = max)
}
}
}
}
}
// stop clocks
stop = util_cpu_time();

18
prism/src/sparse/PS_NondetUntil.cc

@ -215,9 +215,7 @@ jlong _strat // strategy storage
// open file to store adversary (if required)
if (export_adv_enabled != EXPORT_ADV_NONE) {
fp_adv = fopen(export_adv_filename, "w");
if (fp_adv) {
fprintf(fp_adv, "%d ?\n", n);
} else {
if (!fp_adv) {
PS_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").", export_adv_filename);
export_adv_enabled = EXPORT_ADV_NONE;
}
@ -304,6 +302,13 @@ jlong _strat // strategy storage
// Traverse matrix to extract adversary
if (export_adv_enabled != EXPORT_ADV_NONE) {
// Do two passes: first to compute the number of transitions,
// the second to actually do the export
int num_trans = 0;
for (int pass = 1; pass <= 2; pass++) {
if (pass == 2) {
fprintf(fp_adv, "%d %d\n", n, num_trans);
}
h1 = h2 = 0;
for (i = 0; i < n; i++) {
if (!use_counts) { l1 = row_starts[i]; h1 = row_starts[i+1]; }
@ -314,6 +319,11 @@ jlong _strat // strategy storage
else { l2 = h2; h2 += choice_counts[j]; }
// But only output a choice if it is in the adversary
if (j == adv[i]) {
switch (pass) {
case 1:
num_trans += (h2-l2);
break;
case 2:
for (k = l2; k < h2; k++) {
switch (export_adv_enabled) {
case EXPORT_ADV_DTMC:
@ -328,6 +338,8 @@ jlong _strat // strategy storage
}
}
}
}
}
// stop clocks
stop = util_cpu_time();

Loading…
Cancel
Save