-
Notifications
You must be signed in to change notification settings - Fork 3
/
table.xml
191 lines (186 loc) · 6.96 KB
/
table.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.5//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_5.dtd'>
<nta>
<declaration>import "/tmp/uppaal-libs/libtable-dbg.so" {
int table_new_int(int rows, int cols, int value); // creates a new table and returns its id
int table_new_double(int rows, int cols, double value); // creates a new table and returns its id
int table_read_csv(const string& filename, int skip_lines); // reads table from csv file and returns id
int table_write_csv(int id, const string& filename); // writes table to csv file and returns number of rows
int table_copy(int id); // creates a new table copy and returns its id
int table_clear(int id); // releases resources associated with the table and returns id
int table_resize_int(int id, int rows, int cols, int value); // resizes the table with given dimensions
int table_rows(int id); // number of rows in the table
int table_cols(int id); // number of columns in the table
int read_int(int id, int row, int col); // read integer at row:col
double read_double(int id, int row, int col); // read double at row:col
// interpolated look up for key in key_column (sorted in ascending order) and returns value_column
double interpolate(int id, double key, int key_column, int value_column);
void write_int(int id, int row, int col, int value); // write integer at row:col
void write_double(int id, int row, int col, double value); // write double at row:col
void read_int_col(int id, int row, int col, int& items[4], int offset, int count); // read column
void read_int_row(int id, int row, int col, int& items[3], int offset, int count); // read row
};
const int id = table_read_csv("/tmp/uppaal-libs/table_input.csv", 0);
//const int id = table_new_double(3, 4, 3.14);
const int rows = table_rows(id);
const int cols = table_cols(id);
const int len = table_write_csv(id, "/tmp/uppaal-libs/table_output.csv");
int _id = id;
int _rows = rows;
int _cols = cols;
int _len = len;
/*
typedef int row_t[cols];
typedef row_t table_t[rows];
table_t table;
*/
int table[rows][cols];
void read_all()
{
if (rows>0 && cols>0) {
for (i : int[0,rows-1])
for (j : int[0,cols-1])
table[i][j] = read_int(_id, i, j);
}
}
void read_by_row()
{
// crash
// for (r : int[0,rows-1])
/*
const int r = 0;
//row_t row;
int row[3];
read_int_row(id, r, 0, row, 0, cols);
table[r] = row;
*/
}
</declaration>
<template>
<name x="5" y="5">Template</name>
<declaration>clock x;</declaration>
<location id="id0" x="-136" y="51">
<urgent/>
</location>
<location id="id1" x="144" y="93">
<label kind="invariant" x="127" y="102">x'==x</label>
</location>
<location id="id2" x="127" y="0">
<label kind="invariant" x="119" y="8">x'==x</label>
<label kind="comments" x="-17" y="34">ODE is needed to force
the small-step integration</label>
</location>
<location id="id3" x="-8" y="93">
<urgent/>
</location>
<location id="id4" x="-8" y="0">
<urgent/>
</location>
<init ref="id0"/>
<transition id="id5">
<source ref="id0"/>
<target ref="id3"/>
</transition>
<transition id="id6">
<source ref="id0"/>
<target ref="id4"/>
</transition>
<transition id="id7">
<source ref="id3"/>
<target ref="id1"/>
<label kind="assignment" x="8" y="93">read_by_row()</label>
</transition>
<transition id="id8">
<source ref="id4"/>
<target ref="id2"/>
<label kind="assignment" x="18" y="0">read_all()</label>
</transition>
</template>
<system>clock t;
// Place template instantiations here.
Process = Template();
// List one or more processes to be composed into a system.
system Process;
</system>
<queries>
<query>
<formula>simulate 1 [<=1] { id, rows, cols, len }</formula>
<comment/>
</query>
<query>
<formula>simulate 1 [<=10] { interpolate(id, t, 0, 1), interpolate(id, t, 0, 3) } </formula>
<comment/>
<result outcome="success" type="quality" timestamp="2021-01-19 11:37:19 +0100">
<option key="--extrapolation" value="0"/>
<option key="--split-ks" value="0.25"/>
<option key="--resolution" value="4000"/>
<option key="--max-iterations" value="30"/>
<option key="--runs-pr-state" value="100"/>
<option key="--filter" value="0"/>
<option key="--split-lower-t" value="0.15"/>
<option key="--split-filter-rate" value="0.02"/>
<option key="--good-runs" value="200"/>
<option key="--search-order" value="0"/>
<option key="--statespace-consumption" value="1"/>
<option key="--discount" value="0.99"/>
<option key="--qlearning-alpha" value="2"/>
<option key="--histogram-bar-count" value="0"/>
<option key="--truncation-time-error" value="0.01"/>
<option key="--backwards-order" value="1"/>
<option key="--split-filter-val" value="0.99"/>
<option key="--upper-delta" value="0.01"/>
<option key="--epsilon" value="0.05"/>
<option key="--priority-order" value="0"/>
<option key="--max-imitation" value="5"/>
<option key="--beta" value="0.05"/>
<option key="--discretization" value="0.01"/>
<option key="--learning-method" value="4"/>
<option key="--eval-runs" value="100"/>
<option key="--indifference-smoothing" value="10"/>
<option key="--u1" value="1.1"/>
<option key="--reset-no-better" value="10"/>
<option key="--diagnostic" value="-1"/>
<option key="--random-search-limit" value="0.5"/>
<option key="--histogram-bar-width" value="0.0"/>
<option key="--u0" value="0.9"/>
<option key="--truncation-error" value="0.01"/>
<option key="--split-upper-t" value="1.75"/>
<option key="--total-runs" value="500"/>
<option key="--lower-delta" value="0.01"/>
<option key="--deterministic-search-limit" value="0.5"/>
<option key="--alpha" value="0.05"/>
<option key="--hashtable-size" value="27"/>
<option key="--generate-strategy" value="2"/>
<option key="--indifference-scale" value="0.005"/>
<option key="--max-reset-learning" value="3"/>
<plot title="Simulations (1)" xaxis="time" yaxis="value">
<series title="interpolate(id, t, 0, 1)" type="l" color="0xff0000" encoding="csv">0.0,0.0
0.0,5.0
0.9414457301025632,5.0
1.0349100048926037,5.034910004892604
3.9656626646137303,7.96566266461373
4.06031870243298,8.0
10.0,8.0
</series>
<series title="interpolate(id, t, 0, 3)" type="l" color="0x00ffff" encoding="csv">0.0,0.0
0.0,1.0
0.9414457301025632,1.0
1.0349100048926037,1.1047299959958121
1.9780855313525585,3.934256580691863
2.072691053829776,4.3634551890810505
2.924455899968412,8.622279417106203
3.019109181427911,9.13376428914594
3.9656626646137303,15.75963853437155
4.06031870243298,16.0
10.0,16.0
</series>
<comment/>
</plot>
</result>
</query>
<query>
<formula>//simulate 1 [<=10] {table[0][0], table[0][1], table[0,2]}</formula>
<comment/>
</query>
</queries>
</nta>