Skip to content

Commit 02fd882

Browse files
committed
added first version of long run rewards
1 parent 9f6c2b8 commit 02fd882

File tree

8 files changed

+1106
-13
lines changed

8 files changed

+1106
-13
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ SRCDIR = src
105105
BINDIR = bin
106106
LIBDIR = lib
107107
INCLUDEDIR = include
108-
LIBOBJ = read_file.o read_file_imc.o sparse.o unbounded.o expected_time.o expected_reward.o bounded_reward.o sccs.o sccs2.o long_run_average.o debug.o bounded.o
108+
LIBOBJ = read_file.o read_file_imc.o sparse.o unbounded.o expected_time.o expected_reward.o bounded_reward.o sccs.o sccs2.o long_run_average.o debug.o bounded.o long_run_reward.o
109109
BINOBJ = main.o
110110

111111
NAME = imca

imca/imca.xcodeproj/project.pbxproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
B96D6AE61664FDFB00B9A9BE /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
3939
B98752501704446800F35D50 /* sccs2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sccs2.h; sourceTree = "<group>"; };
4040
B9B5298916CBA3E100E6A0DD /* sccs2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sccs2.cpp; sourceTree = "<group>"; };
41+
B9CFFDFD1861DD1100A58492 /* long_run_reward.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = long_run_reward.cpp; sourceTree = "<group>"; };
42+
B9CFFDFE1861DD1900A58492 /* long_run_reward.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = long_run_reward.h; sourceTree = "<group>"; };
4143
/* End PBXFileReference section */
4244

4345
/* Begin PBXGroup section */
@@ -55,6 +57,7 @@
5557
B96D6ACC1664FDDC00B9A9BE /* src */ = {
5658
isa = PBXGroup;
5759
children = (
60+
B9CFFDFD1861DD1100A58492 /* long_run_reward.cpp */,
5861
B9B5298916CBA3E100E6A0DD /* sccs2.cpp */,
5962
B96D6ACD1664FDDC00B9A9BE /* .kdev_include_paths */,
6063
B96D6ACE1664FDDC00B9A9BE /* bcg2imca.c */,
@@ -78,6 +81,7 @@
7881
B96D6AD91664FDE200B9A9BE /* include */ = {
7982
isa = PBXGroup;
8083
children = (
84+
B9CFFDFE1861DD1900A58492 /* long_run_reward.h */,
8185
B98752501704446800F35D50 /* sccs2.h */,
8286
B96D6ADA1664FDE200B9A9BE /* bcg2imca.h */,
8387
B96D6ADB1664FDE200B9A9BE /* bounded.h */,
@@ -118,7 +122,7 @@
118122
B96D6AC11664FCFB00B9A9BE /* Project object */ = {
119123
isa = PBXProject;
120124
attributes = {
121-
LastUpgradeCheck = 0460;
125+
LastUpgradeCheck = 0500;
122126
ORGANIZATIONNAME = "Dennis Guck";
123127
};
124128
buildConfigurationList = B96D6AC41664FCFB00B9A9BE /* Build configuration list for PBXProject "imca" */;
@@ -161,7 +165,7 @@
161165
GCC_WARN_ABOUT_RETURN_TYPE = YES;
162166
GCC_WARN_UNINITIALIZED_AUTOS = YES;
163167
GCC_WARN_UNUSED_VARIABLE = YES;
164-
MACOSX_DEPLOYMENT_TARGET = 10.8;
168+
MACOSX_DEPLOYMENT_TARGET = 10.9;
165169
ONLY_ACTIVE_ARCH = YES;
166170
SDKROOT = macosx;
167171
};
@@ -184,7 +188,7 @@
184188
GCC_WARN_ABOUT_RETURN_TYPE = YES;
185189
GCC_WARN_UNINITIALIZED_AUTOS = YES;
186190
GCC_WARN_UNUSED_VARIABLE = YES;
187-
MACOSX_DEPLOYMENT_TARGET = 10.8;
191+
MACOSX_DEPLOYMENT_TARGET = 10.9;
188192
SDKROOT = macosx;
189193
};
190194
name = Release;

include/long_run_average.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
*
2222
* @file long_run_average.cpp
23-
* @brief Compute the expected time for an MA
23+
* @brief Compute the long-run average for an MA
2424
* @author Dennis Guck
2525
* @version 1.0
2626
*
@@ -43,7 +43,7 @@ using namespace soplex;
4343
*
4444
* @param ma file to read MA from
4545
* @param max identifier for min or max
46-
* @return expected time
46+
* @return long-run average
4747
*/
4848
extern Real compute_long_run_average(SparseMatrix*, bool);
4949

include/long_run_reward.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* IMCA is a analyzing tool for unbounded reachability probabilities, expected-
3+
* time, and long-run averages for Interactive Markov Chains and Markov Automata.
4+
* Copyright (C) RWTH Aachen, 2012
5+
* UTwente, 2013
6+
* Author: Dennis Guck
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*
22+
* @file long_run_reward.cpp
23+
* @brief Compute the long-run reward for an MA
24+
* @author Dennis Guck
25+
* @version 1.0
26+
*
27+
*/
28+
29+
#ifndef LONG_RUN_REWARD_H
30+
#define LONG_RUN_REWARD_H
31+
32+
33+
#include "sparse.h"
34+
35+
#ifdef __SOPLEX__
36+
#include "soplex.h"
37+
#endif
38+
39+
using namespace soplex;
40+
41+
/**
42+
* Computes long-run reward for MA.
43+
*
44+
* @param ma file to read MA from
45+
* @param max identifier for min or max
46+
* @return long-run reward
47+
*/
48+
extern Real compute_long_run_reward(SparseMatrix*, bool);
49+
50+
51+
#endif

src/bounded.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ Real compute_time_bounded_reachability(SparseMatrix* ma, bool max, Real epsilon,
435435
// value iteration
436436
cout << "iterations: " << (unsigned long) ceil((tb - ta) / tau) + (unsigned long) ceil(ta / tau) << endl;
437437
printf("step duration for interval [%g,%g]: %g\n", ta, tb, current_tau);
438+
cout << "iterations: " << (unsigned long) ceil((tb - ta) / tau) << endl;
438439

439440
for(unsigned long i=0; i < steps; i++){
440441
// compute v for Markovian states: from b dwon to a, we make discrete model absorbing
@@ -482,7 +483,7 @@ Real compute_time_bounded_reachability(SparseMatrix* ma, bool max, Real epsilon,
482483
SparseMatrix_free(discrete_ma);
483484

484485
steps = (unsigned long) ceil( (ta + current_tau) / tau); // calculating the number of steps for interval [0,a]
485-
current_tau = (ta + current_tau) / steps; // recalculate tau based on the number of steps
486+
current_tau = (ta + current_tau) / steps; // recalculate tau based on the number of steps
486487

487488
// discretize model with respect to the current value of tau 'current_tau'
488489
dbg_printf("discretize model for interval [0,%g] ... \n", ta);
@@ -491,8 +492,9 @@ Real compute_time_bounded_reachability(SparseMatrix* ma, bool max, Real epsilon,
491492
//print_model(discrete_ma);
492493

493494
printf("step duration for interval [0,%g]: %g\n", ta, current_tau);
495+
cout << "iterations: " << (unsigned long) ceil( (ta + current_tau) / tau) << endl;
494496

495-
for(unsigned long i=0; i < steps; i++){
497+
for(unsigned long i=0; i < steps; ++i){
496498
// compute v for Markovian states: shift up to a, we don't make discrete model absorbing
497499
compute_markovian_vector(discrete_ma,v,u, false);
498500
// compute u for Probabilistic states
@@ -615,8 +617,10 @@ Real compute_time_bounded_reachability(SparseMatrix* ma, bool max, Real epsilon,
615617
else
616618
prob=1;
617619
bool *initials = ma->initials;
620+
printf("vector(%d) [",num_states);
618621
for (unsigned long state_nr = 0; state_nr < num_states; state_nr++) {
619622
//cout << (ma->states_nr.find(state_nr)->second).c_str() << ": " << u[state_nr] << endl;
623+
printf(" %lf,",u[state_nr]);
620624
if(initials[state_nr]){
621625
if(max){
622626
if(prob<u[state_nr])
@@ -627,6 +631,7 @@ Real compute_time_bounded_reachability(SparseMatrix* ma, bool max, Real epsilon,
627631
}
628632
}
629633
}
634+
printf(" ]\n");
630635

631636

632637
return prob;

0 commit comments

Comments
 (0)