Substitute runtimeException with a warning if no guard in a branchtransition evaluates to true
In case of no guarded branch transition evaluates to true, the simulation is stopped by a RuntimeException.
In the case of a Probabilistic Branch the Probabilities are automatically normalized if they do not sum up to 1.
For guarded branches this is not possible however it might be very helpfull to continue the simulation including a Warning in the Logging instead of stopping the complete simulation run.
I already implemented this in my local version of the transformation templates.
in m2t_transforms::sim::java_core.xpt the following line have to be added starting at line 37
private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(de.uka.ipd.sdq.simucomframework.model.SimuComModel.class.getName());
It is not possible to use the origial class name for logger registration, as the generated package name depends on the repository's name.
In m2t_transforms::sim::seff.xpt, line 74
throw new RuntimeException("No branch condition evaluated to true :-(");
should be substituted with:
logger.warn("No branch condition evaluated to true in «this.entityName» :-(");
Operating System: All
I also opt against this patch (while issuing an error is a decent trade-off). However, the arguments:
1.) You cannot compare it to the normalisation feature for PDFs. This has been introduced to deal with the issue that summing up double numbers is imprecise and sometimes it failed when not normalised according to a predefined epsilon. Using it for other cases is possible but not recommended.
2.) Forcing valid models to cover every branch is necessary for the Dependency Solver. SimuCom also only checks the semantic constraint incomplete. The branches of valid models are also not allowed to overlap which is not checked.
The only correct solution would be to include these checks in the validation of the model. There we already differentiate between validation warnings and validation errors....
I guess it also should be added to the guarded branch transition metamodel documentation, as we usually say that SimuCom somewhat defines the semantics?
I discussed this topic with Klaus and Micha.
The behaviour is comparable to the automated adaptation of probabilistic branches.
If they do not sum up to 1, the values are adapted automatically and an error is logged.
Additionally, I documented the changes within the change log as requested by Klaus.
I changed Warning to Error. That was a good point.
As Warnings and Errors are shown in red they are quite obvious.
I am not sure whether that is a good idea. Such a model is invalid in my understanding. Such an issue is most likely caused by some forgotten aspect. Warnings by the simulation are easily overlooked, so an error is maybe more appropriate.
You are proposing to add a new implicit empty else branch. If we want to do that, that should probably also be documented for the metamodel itself.