diff --git a/prism/src/sparse/PS_NondetMultiObj.cc b/prism/src/sparse/PS_NondetMultiObj.cc index 196ff295..a5fe4d97 100644 --- a/prism/src/sparse/PS_NondetMultiObj.cc +++ b/prism/src/sparse/PS_NondetMultiObj.cc @@ -39,6 +39,7 @@ #include "PrismSparseGlob.h" #include "jnipointer.h" #include +#include //The following gives more output on stdout. In fact quite a lot of it, usable only for ~10 state examples //#define MORE_OUTPUT @@ -116,6 +117,8 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet jdoubleArray ret = 0; // local copy of max_iters, since we will change it int max_iters_local = max_iters; + // whether to export individual solution vectors (with adversaries) + bool export_vectors = false; // Extract some info about objectives bool has_rewards = _ndsm_r != 0; @@ -692,6 +695,25 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet fclose(fp_adv); PS_PrintToMainLog(env, "\nAdversary written to file \"%s\".\n", export_adv_filename); } + + // export individual solution vectors + if (export_adv_enabled != EXPORT_ADV_NONE && export_vectors) { + for (int it = 0; it < lenRew + lenProb; it++) { + if (it != ignoredWeight) { + std::string export_vect_filename(export_adv_filename); + export_vect_filename += ".vec"; + export_vect_filename += std::to_string(it); + FILE *fp_vect = fopen(export_vect_filename.c_str(), "w"); + if (fp_vect) { + PS_PrintWarningToMainLog(env, "Exporting solution vector %d to file %s.", it, export_vect_filename.c_str()); + for (i = 0; i < n; i++) { + fprintf(fp_vect, "%d %g\n", i, psoln[it][i]); + } + fclose(fp_vect); + } + } + } + } // catch exceptions: register error, free memory } catch (std::bad_alloc e) {