Skip to content

Commit

Permalink
Update/fix output of parsed model info.
Browse files Browse the repository at this point in the history
Rewards included if unmamed, e.g.: "r1" 2 "r3".

So, for consistency, labels/observations displayed in quotes too.
  • Loading branch information
davexparker committed Sep 26, 2024
1 parent b5e6021 commit 1f86cc2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
6 changes: 3 additions & 3 deletions prism/src/prism/Prism.java
Original file line number Diff line number Diff line change
Expand Up @@ -1814,13 +1814,13 @@ private void printModelInfo(ModelInfo modelInfo, RewardGenerator<?> rewardInfo)
}
mainLog.println("Variables: " + String.join(" ", modelInfo.getVarNames()));
if (modelInfo.getModelType().partiallyObservable()) {
mainLog.println("Observables: " + String.join(" ", modelInfo.getObservableNames()));
mainLog.println("Observables: " + "\"" + String.join("\" \"", modelInfo.getObservableNames()) + "\"");
}
if (modelInfo.getNumLabels() > 0) {
mainLog.println("Labels: " + String.join(" ", modelInfo.getLabelNames()));
mainLog.println("Labels: " + "\"" + String.join("\" \"", modelInfo.getLabelNames()) + "\"");
}
if (rewardInfo.getNumRewardStructs() > 0) {
mainLog.println("Rewards: " + String.join(" ", rewardInfo.getRewardStructNames()));
mainLog.println("Rewards: " + String.join(" ", rewardInfo.getRewardStructReferences()));
}
}

Expand Down
22 changes: 21 additions & 1 deletion prism/src/prism/RewardGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

package prism;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -80,7 +81,26 @@ public default List<String> getRewardStructNames()
// No reward structures by default
return Collections.emptyList();
}


/**
* Get a list of the strings needed to reference the reward structures,
* i.e., "r" for named ones and k for unnamed ones.
*/
public default List<String> getRewardStructReferences()
{
List<String> refs = new ArrayList<>();
int numRewards = getNumRewardStructs();
for (int r = 0; r < numRewards; r++) {
String name = getRewardStructName(r);
if ("".equals(name) || name == null) {
refs.add(Integer.toString(r + 1));
} else {
refs.add("\"" + name + "\"");
}
}
return refs;
}

/**
* Get the number of reward structures.
*/
Expand Down

0 comments on commit 1f86cc2

Please # to comment.