|
80 | 80 | import parser.type.TypeDouble; |
81 | 81 | import parser.visitor.ASTTraverseModify; |
82 | 82 | import parser.visitor.ReplaceLabels; |
83 | | -import prism.Accuracy; |
84 | | -import prism.Evaluator; |
85 | | -import prism.Filter; |
86 | | -import prism.ModelInfo; |
87 | | -import prism.ModelType; |
88 | | -import prism.Pair; |
89 | | -import prism.Prism; |
90 | | -import prism.PrismComponent; |
91 | | -import prism.PrismException; |
92 | | -import prism.PrismFileLog; |
93 | | -import prism.PrismLangException; |
94 | | -import prism.PrismLog; |
95 | | -import prism.PrismNotSupportedException; |
96 | | -import prism.PrismSettings; |
97 | | -import prism.Result; |
98 | | -import prism.RewardGenerator; |
| 83 | +import prism.*; |
99 | 84 |
|
100 | 85 | /** |
101 | 86 | * Super class for explicit-state model checkers. |
@@ -1473,6 +1458,25 @@ private Object replaceWithLabel(Expression e) throws PrismLangException |
1473 | 1458 | } |
1474 | 1459 | } |
1475 | 1460 |
|
| 1461 | + /** |
| 1462 | + * Get a {@link ModelInfo} object for the provided model, |
| 1463 | + * containing info about model type, variables and labels. |
| 1464 | + * If this is already stored locally in {@link #modelInfo}, use that. |
| 1465 | + * If not construct one from data attached to the model. |
| 1466 | + */ |
| 1467 | + protected <Value> ModelInfo getModelInfo(Model<Value> model) throws PrismException |
| 1468 | + { |
| 1469 | + if (modelInfo != null) { |
| 1470 | + return modelInfo; |
| 1471 | + } |
| 1472 | + BasicModelInfo modelInfo = new BasicModelInfo(model.getModelType()); |
| 1473 | + if (model.getVarList() != null) { |
| 1474 | + modelInfo.setVarList(model.getVarList()); |
| 1475 | + } |
| 1476 | + model.getLabels().forEach(label -> modelInfo.getLabelNameList().add(label)); |
| 1477 | + return modelInfo; |
| 1478 | + } |
| 1479 | + |
1476 | 1480 | /** |
1477 | 1481 | * Construct rewards for the reward structure with index r of the reward generator and a model. |
1478 | 1482 | * Ensures non-negative rewards. |
@@ -1594,9 +1598,9 @@ protected <Value> Pair<List<Rewards<Value>>, List<String>> getAllRewards(Model<V |
1594 | 1598 | * (always present) stored model info, plus any additional labels attached directly |
1595 | 1599 | * to the model that are not already included. |
1596 | 1600 | */ |
1597 | | - protected List<String> getAllLabelNames(Model<?> model) |
| 1601 | + protected List<String> getAllLabelNames(Model<?> model) throws PrismException |
1598 | 1602 | { |
1599 | | - List<String> labelNames = new ArrayList<>(modelInfo.getLabelNames()); |
| 1603 | + List<String> labelNames = new ArrayList<>(getModelInfo(model).getLabelNames()); |
1600 | 1604 | for (String name : model.getLabels()) { |
1601 | 1605 | if (!labelNames.contains(name)) { |
1602 | 1606 | labelNames.add(name); |
@@ -1646,7 +1650,7 @@ public <Value> void exportModel(Model<Value> model, ModelExportTask exportTask) |
1646 | 1650 | default: |
1647 | 1651 | throw new PrismNotSupportedException("Export " + exportOptions.getFormat().description() + " not supported by explicit engine"); |
1648 | 1652 | } |
1649 | | - exporter.setModelInfo(modelInfo); |
| 1653 | + exporter.setModelInfo(getModelInfo(model)); |
1650 | 1654 | File file = exportTask.getFile(); |
1651 | 1655 | // Disallow stdout export for binary formats |
1652 | 1656 | if (exportOptions.getFormat().isBinary() && !exportOptions.getBinaryAsText() && file == null) { |
|
0 commit comments