Browse Source

Fix export of intermediate adversaries in value-iteration based multi-objective.

master
Dave Parker 7 years ago
parent
commit
ce4fd3d3a4
  1. 18
      prism/src/sparse/PS_NondetMultiObj.cc

18
prism/src/sparse/PS_NondetMultiObj.cc

@ -411,6 +411,7 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet
}
// see if the combined reward value is the min/max so far
bool pickThis = first || (min&&(d2<d1)) || (!min&&(d2>d1));
// if it equals the min/max do far for the combined reward value,
// but it is better for some individual reward, we choose it.
// not sure why
@ -430,22 +431,31 @@ JNIEXPORT jdoubleArray __jlongpointer JNICALL Java_sparse_PrismSparse_PS_1Nondet
for (int it = 0; it < lenRew + lenProb; it++)
if (it != ignoredWeight)
pd1[it] = pd2[it];
// if adversary generation is enabled, remember optimal choice
// if adversary generation is enabled, store optimal choice
if (export_adv_enabled != EXPORT_ADV_NONE) {
// if this is the first choice to be picked, always store it
if (adv[i] == -1) {
adv[i] = j;
} else {
// otherwise it depends whether we're doing min or max
// (but sometimes min is max with negative rewards)
bool minAdv = min ? d1>0 : d1<0;
// for max, only remember strictly better choices
// (this resolves problems with end components)
if (!min) {
if (adv[i] == -1 || (d1>soln[i])) {
// (note use of absolute values because values may be negative)
if (!minAdv) {
if (fabs(d1)>fabs(soln[i])) {
adv[i] = j;
}
}
// for min, this is straightforward
// for min, always store the value
// (in fact, could do it at the end of value iteration, but we don't)
else {
adv[i] = j;
}
}
}
}
first = false;
}

Loading…
Cancel
Save