Browse Source

Export of individual solution vectors during multi-objective model checking (currently disabled).

accumulation-v4.7
Dave Parker 7 years ago
parent
commit
6196501210
  1. 22
      prism/src/sparse/PS_NondetMultiObj.cc

22
prism/src/sparse/PS_NondetMultiObj.cc

@ -39,6 +39,7 @@
#include "PrismSparseGlob.h"
#include "jnipointer.h"
#include <new>
#include <string>
//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;
@ -693,6 +696,25 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet
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) {
PS_SetErrorMessage("Out of memory");

Loading…
Cancel
Save