From eeddcf903993a4a1a7e96c31ee90459c614365a1 Mon Sep 17 00:00:00 2001 From: Joachim Klein Date: Wed, 26 Aug 2015 10:19:24 +0000 Subject: [PATCH] Add hasTransitionRewards() method to explicit Reward interface. Currently, the main use is to determinie whether a MDPRewards has any transition rewards. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@10579 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/explicit/rewards/MCRewardsFromMDPRewards.java | 7 +++++++ prism/src/explicit/rewards/MDPRewards.java | 3 +++ prism/src/explicit/rewards/MDPRewardsSimple.java | 6 ++++++ prism/src/explicit/rewards/Rewards.java | 3 +++ prism/src/explicit/rewards/StateRewards.java | 7 +++++++ 5 files changed, 26 insertions(+) diff --git a/prism/src/explicit/rewards/MCRewardsFromMDPRewards.java b/prism/src/explicit/rewards/MCRewardsFromMDPRewards.java index 3ed4642c..4628de5c 100644 --- a/prism/src/explicit/rewards/MCRewardsFromMDPRewards.java +++ b/prism/src/explicit/rewards/MCRewardsFromMDPRewards.java @@ -64,4 +64,11 @@ public class MCRewardsFromMDPRewards implements MCRewards { throw new UnsupportedOperationException(); } + + @Override + public boolean hasTransitionRewards() + { + // only state rewards + return false; + } } diff --git a/prism/src/explicit/rewards/MDPRewards.java b/prism/src/explicit/rewards/MDPRewards.java index bf246c11..d32b0c5b 100644 --- a/prism/src/explicit/rewards/MDPRewards.java +++ b/prism/src/explicit/rewards/MDPRewards.java @@ -46,4 +46,7 @@ public interface MDPRewards extends Rewards @Override public MDPRewards liftFromModel(Product product); + + /** Returns true if this reward structure has transition rewards */ + public boolean hasTransitionRewards(); } diff --git a/prism/src/explicit/rewards/MDPRewardsSimple.java b/prism/src/explicit/rewards/MDPRewardsSimple.java index d5e8e6f1..3c4752c9 100644 --- a/prism/src/explicit/rewards/MDPRewardsSimple.java +++ b/prism/src/explicit/rewards/MDPRewardsSimple.java @@ -216,4 +216,10 @@ public class MDPRewardsSimple implements MDPRewards { return "st: " + this.stateRewards + "; tr:" + this.transRewards; } + + @Override + public boolean hasTransitionRewards() + { + return transRewards != null; + } } diff --git a/prism/src/explicit/rewards/Rewards.java b/prism/src/explicit/rewards/Rewards.java index 06c35a05..f8d07ae4 100644 --- a/prism/src/explicit/rewards/Rewards.java +++ b/prism/src/explicit/rewards/Rewards.java @@ -40,4 +40,7 @@ public interface Rewards * model that is a product of the one that this reward structure is defined over. */ public Rewards liftFromModel(Product product); + + /** Returns true if this reward structure has transition rewards */ + public boolean hasTransitionRewards(); } diff --git a/prism/src/explicit/rewards/StateRewards.java b/prism/src/explicit/rewards/StateRewards.java index 8f10aa9b..03fc59a9 100644 --- a/prism/src/explicit/rewards/StateRewards.java +++ b/prism/src/explicit/rewards/StateRewards.java @@ -64,4 +64,11 @@ public abstract class StateRewards implements MCRewards, MDPRewards, STPGRewards * Perform a deep copy. */ public abstract StateRewards deepCopy(); + + @Override + public boolean hasTransitionRewards() + { + // only state rewards + return false; + } }