From df63c6e9a1b455e76b01e8858a5d3a70fde67c73 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Fri, 17 Jul 2015 09:39:03 +0000 Subject: [PATCH] Refactoring: StateRewardsArray extends StateRewards. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@10353 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- .../explicit/rewards/StateRewardsArray.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/prism/src/explicit/rewards/StateRewardsArray.java b/prism/src/explicit/rewards/StateRewardsArray.java index 65ee7b4c..66388468 100644 --- a/prism/src/explicit/rewards/StateRewardsArray.java +++ b/prism/src/explicit/rewards/StateRewardsArray.java @@ -26,10 +26,12 @@ package explicit.rewards; +import explicit.Model; + /** * Explicit-state storage of just state rewards (as an array). */ -public class StateRewardsArray implements MCRewards, MDPRewards +public class StateRewardsArray extends StateRewards { /** Array of state rewards **/ protected double stateRewards[] = null; @@ -41,10 +43,24 @@ public class StateRewardsArray implements MCRewards, MDPRewards public StateRewardsArray(int numStates) { stateRewards = new double[numStates]; - for (int i = 0; i < numStates; i++) + for (int i = 0; i < numStates; i++) { stateRewards[i] = 0.0; + } } + /** + * Copy constructor + * @param rews Rewards to copy + */ + public StateRewardsArray(StateRewardsArray rews) + { + int numStates= rews.stateRewards.length; + stateRewards = new double[numStates]; + for (int i = 0; i < numStates; i++) { + stateRewards[i] = rews.stateRewards[i]; + } + } + // Mutators /** @@ -71,9 +87,11 @@ public class StateRewardsArray implements MCRewards, MDPRewards return stateRewards[s]; } + // Other + @Override - public double getTransitionReward(int s, int i) + public StateRewardsArray deepCopy() { - return 0.0; + return new StateRewardsArray(this); } }