STAMINA/STORM 0.1
Infinite state-space truncator which generates a probability within a window
StaminaArgParse.h
1
6#ifndef STAMINA_STAMINAARGPARSE_H
7#define STAMINA_STAMINAARGPARSE_H
8
9#include <iostream>
10#include <fstream>
11#include <string>
12#include <argp.h>
13#include <stdlib.h>
14
15enum STAMINA_METHODS {
16 ITERATIVE_METHOD = 0 // STAMINA 2.5
17 , PRIORITY_METHOD = 1 // STAMINA 3.0
18 , RE_EXPLORING_METHOD = 2 // STAMINA 2.0
19};
20
21
22
23static char doc[] = "STAMINA -- truncates infinite CTMC state space and passes into STORM";
24
25static char args_doc[] = "MODEL_FILE PROPERTIES_FILE";
26
30static struct argp_option options[] = {
31 {"kappa", 'k', "double", 0,
32 "Reachability threshold for the first iteration (default: 1.0)"}
33 , {"reduceKappa", 'r', "double", 0,
34 "Reduction factor for Reachability Threshold (kappa) during the refinement step (default 2.0)"}
35 , {"approxFactor", 'f', "double", 0,
36 "Factor to estimate how far off our reachability predictions will be (default: 2.0)"}
37 , {"probWin", 'w', "double", 0,
38 "Probability window between lower and upperbound for termination (default: 1.0e-3)"}
39 , {"maxApproxCount", 'n', "int", 0,
40 "Maximum number of iterations in the approximation (default 10)"}
41 , {"noPropRefine", 'R', 0, 0,
42 "Do not use property based refinement. If given, the model exploration method will reduce kappa and do property independent definement (default: off)"}
43 , {"cuddMaxMem", 'C', "memory", 0,
44 "Maximum CUDD memory, in the same format as PRISM (default: 1g)"}
45 , {"export", 'e', "filename", 0,
46 "Export model to a (text) file"}
47 , {"exportPerimeterStates", 'S', "filename", 0,
48 "Export perimeter states to a file. Please provide a filename. This will append to the file if it is existing"}
49 , {"import", 'i', "filename", 0,
50 "Import model to a (text) file"}
51 , {"property", 'p', "propname", 0,
52 "Specify a certain property to check in a model file that contains many"}
53 , {"const", 'c', "\"C1=VAL,C2=VAL,C3=VAL\"", 0,
54 "Comma separated values for constants"}
55 , {"exportTrans", 't', "filename", 0,
56 "Export the list of transitions and actions to a specified file name, or to trans.txt if no file name is specified.\nTransitions are exported in the format <Source State Index> <Destination State Index> <Action Label>"}
57 /* Additional options. GNU argp shows args alphabetically */
58 , {"rankTransitions", 'T', 0, 0,
59 "Rank transitions before expanding (default: false)"}
60 , {"maxIterations", 'M', "int", 0,
61 "Maximum iteration for solution (default: 10000)"}
62 , {"maxStates", 'V', "integer", 0,
63 "The maximum number of states to explore in an iteration (default 2000000)"}
64 , {"iterative", 'I', 0, 0,
65 "Use the STAMINA 2.5 method (iterative)"}
66 , {"priority", 'P', 0, 0,
67 "Use the STAMINA 3.0 method (priority)"}
68 , {"reExploring", 'J', 0, 0,
69 "Use the STAMINA 2.0 method (the method in STAMINA/PRISM)"}
70 , {"threads", 'j', "int", 0,
71 "Number of threads to use for state exploration (default 1)"}
72 , { 0 }
73};
74
78struct arguments {
79 std::string model_file;
80 std::string properties_file;
81 double kappa;
82 double reduce_kappa;
83 double approx_factor; // Analagous to "misprediction factor" in the Java version
84 double prob_win;
85 uint64_t max_approx_count;
86 bool no_prop_refine;
87 std::string cudd_max_mem;
88 std::string export_filename;
89 std::string export_perimeter_states;
90 std::string import_filename;
91 std::string property;
92 std::string consts;
93 std::string export_trans;
94 bool rank_transitions;
95 uint64_t max_iterations;
96 uint64_t max_states;
97 uint8_t method;
98 uint8_t threads;
99};
100
104static error_t
105parse_opt(int key, char * arg, struct argp_state * state) {
106
107 struct arguments * arguments = static_cast<struct arguments*>(state->input);
108 switch (key) {
109 // kappa value
110 case 'k':
111 arguments->kappa = (double) atof(arg);
112 break;
113 // kappa reduction factor
114 case 'r':
115 arguments->reduce_kappa = (double) atof(arg);
116 break;
117 // approx factor
118 case 'f':
119 arguments->approx_factor = (double) atof(arg);
120 break;
121 // probability window (difference between Pmin and Pmax)
122 case 'w':
123 arguments->prob_win = (double) atof(arg);
124 break;
125 // max number of iterations in approximation
126 case 'n':
127 arguments->max_approx_count = (uint64_t) atoi(arg);
128 break;
129 // whether or not to use property based refinement
130 case 'R':
131 arguments->no_prop_refine = true;
132 break;
133 // cudd max memory limit
134 case 'C':
135 arguments->cudd_max_mem = std::string(arg);
136 break;
137 // filename to export to
138 case 'e':
139 arguments->export_filename = std::string(arg);
140 break;
141 // whether or not to export the perimeter states
142 case 'S':
143 arguments->export_perimeter_states = true;
144 break;
145 // import model filename
146 case 'i':
147 arguments->import_filename = std::string(arg);
148 break;
149 // specific property to check
150 case 'p':
151 arguments->property = std::string(arg);
152 break;
153 // constants to specify
154 case 'c':
155 arguments->consts = std::string(arg);
156 break;
157 // export transitions
158 case 't':
159 arguments->export_trans = std::string(arg);
160 break;
161 // use rank transitions before expanding
162 case 'T':
163 arguments->rank_transitions = true;
164 break;
165 // max number of iterations
166 case 'M':
167 arguments->max_iterations = (uint64_t) atoi(arg);
168 break;
169 case 'V':
170 arguments->max_states = (uint64_t) atoi(arg);
171 break;
172 case 'I':
173 arguments->method = STAMINA_METHODS::ITERATIVE_METHOD;
174 break;
175 case 'P':
176 arguments->method = STAMINA_METHODS::PRIORITY_METHOD;
177 break;
178 case 'J':
179 arguments->method = STAMINA_METHODS::RE_EXPLORING_METHOD;
180 break;
181 // model and properties file
182 case ARGP_KEY_ARG:
183 // get model file
184 if (state->arg_num == 0) {
185 arguments->model_file = std::string(arg);
186 }
187 // get properties file
188 else if (state->arg_num == 1) {
189 arguments->properties_file = std::string(arg);
190 }
191 // we have too many arguments
192 else {
193 argp_usage(state);
194 }
195 break;
196 case ARGP_KEY_END:
197 if (state->arg_num < 2) {
198 /* Require at least 2 arguments */
199 argp_usage(state);
200 }
201 break;
202 default:
203 return ARGP_ERR_UNKNOWN;
204 }
205
206 return 0;
207}
208
212static struct argp argp = {options, parse_opt, args_doc, doc};
213
214void set_default_values(struct arguments * arguments);
215
216#endif // STAMINA_STAMINAARGPARSE_H
Definition: StaminaArgParse.h:78