diff --git a/prism/src/sparse/PS_NondetReachReward.cc b/prism/src/sparse/PS_NondetReachReward.cc index a21d098d..0d3df77a 100644 --- a/prism/src/sparse/PS_NondetReachReward.cc +++ b/prism/src/sparse/PS_NondetReachReward.cc @@ -183,7 +183,12 @@ jboolean min // min or max probabilities (true = min, false = max) // open file to store adversary (if required) if (adv) { fp_adv = fopen("adv.tra", "w"); - fprintf(fp_adv, "%d ?\n", n); + if (fp_adv) { + fprintf(fp_adv, "%d ?\n", n); + } else { + PS_PrintToMainLog(env, "\nWarning: Adversary generation cancelled (could not open file \"%s\").\n", "adv.tra"); + adv = false; + } } while ((!done && iters < max_iters) || adv_loop) { @@ -305,6 +310,7 @@ jboolean min // min or max probabilities (true = min, false = max) // close file to store adversary (if required) if (adv) { fclose(fp_adv); + PS_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", "adv.tra"); } // catch exceptions: register error, free memory diff --git a/prism/src/sparse/PS_NondetUntil.cc b/prism/src/sparse/PS_NondetUntil.cc index fc17f557..90f6cc32 100644 --- a/prism/src/sparse/PS_NondetUntil.cc +++ b/prism/src/sparse/PS_NondetUntil.cc @@ -82,7 +82,7 @@ jboolean min // min or max probabilities (true = min, false = max) long start1, start2, start3, stop; double time_taken, time_for_setup, time_for_iters; // adversary stuff - bool adv = false, adv_loop = false; + bool adv = true, adv_loop = false; FILE *fp_adv = NULL; int adv_l, adv_h; int *actions; @@ -176,7 +176,12 @@ jboolean min // min or max probabilities (true = min, false = max) // open file to store adversary (if required) if (adv) { fp_adv = fopen("adv.tra", "w"); - fprintf(fp_adv, "%d ?\n", n); + if (fp_adv) { + fprintf(fp_adv, "%d ?\n", n); + } else { + PS_PrintToMainLog(env, "\nWarning: Adversary generation cancelled (could not open file \"%s\").\n", "adv.tra"); + adv = false; + } } while ((!done && iters < max_iters) || adv_loop) { @@ -277,6 +282,7 @@ jboolean min // min or max probabilities (true = min, false = max) // close file to store adversary (if required) if (adv) { fclose(fp_adv); + PS_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", "adv.tra"); } // catch exceptions: register error, free memory