UPPAAL命令行跑SMC;命令行运行SMC;命令行SMC; :::success
- 本文基于uppaal-4.1.25版本,Win10 20H2。
- 如果不清楚如何写SMC性质语句,请阅读SMC问题总结。
:::
一、基本命令行语法
Win10利用power shell跑UPPAAL:
首先进入\uppaal\bin-Windows
目录,把要验证的.xml
模型拷贝到该目录,然后按下shift+鼠标右键
打开power shell(或者其他命令行),然后运行.\verifyta.exe [OPTION]... MODEL QUERY
, where MODEL is a model file and QUERY is a query file.
其中QUERY会验证写在xml文件中的所有验证语句。具体查看本文末的help文档。二、Example
这里提供最常用的两个例子,批量运行可以使用python调用系统命令行,并且可以利用多线程来加快运行速度。文档链接:python 多线程。 :::success 注意:在命令行中,UPPAAL会对所有语句进行验证,无法指定某个语句。 :::1. 运行simulate,并保存观测结果
写好验证性质以后,直接在命令行输入.\verifyta.exe .\模型名字 > 输出文件名
即可。
比如.\verifyta.exe .\NPN_Initial.xml > result.txt
即可将运行结果输出到result.txt
文件中。
提示1:使用
> result.txt
会让结果不再显示到命令行中,可以用cat result.txt
来输出结果。也可以用分号
;
将两个语句连起来:.\verifyta.exe .\NPN_Initial.xml > result.txt ; cat result.txt
提示2:可以通过加
-r [ --seed ] arg
来指定随机数帮助复现结果。否则默认是当前时间:.\verifyta.exe -r 0 .\NPN_Initial.xml > result.txt ; cat result.txt
输出结果分析
验证语句为
simulate [<=10000;1000] {Output.pass}
,为了节约篇幅,下面只贴了输出的一部分。 ```powershell Options for the verification: Generating no trace Search order is breadth first Using conservative space optimisation Seed is 0 State space representation uses minimal constraint systems [2K Verifying formula 1 at /nta/queries/query1/formula [2K — Formula is satisfied. Output.pass:
……
……
……
从运行的结果来看,每行的开头为验证次数,后面的二维数第0个元素为时刻横坐标,后面元素为对应的观测纵坐标。从结果中还可以注意到,虽然验证语句中限制了时间`<=10000`,但实际运行时仍会超出20%-50%的时间。
<a name="SzLk3"></a>
## 2. 运行simulate并保存所需trace
在运行`simulate [<=10000; 1000] {Output.pass}`时,有时候我们需要保存`Output.pass==1`的Trace。虽然这条语句模拟了1000次,但是在Get Trace的时候只能获取某一个Trace,而这个Trace不一定是我们需求的。
<a name="dmtRh"></a>
### 思路
多次运行`simulate [<=10000; 1] {Output.pass}`,当出现`Output.pass==1`的观测时,保存本次的Trace。
<a name="T7W4a"></a>
### 命令行
在写好性质以后,在命令行输入以下内容可以运行并保存模拟的Trace。为了判断模拟结果是否符合要求,进而判断我们是否需要保存该Trace,我们开发了一套python工具`uppaal-controller包`来辅助检测。
<a name="E8Mmp"></a>
## 3. 运行Pr[<=T] (<>psi),并显示观测结果
写好验证性质以后,直接在命令行输入`.\verifyta.exe .\模型名字`即可,如果需要保存输出请看[1](#JI9cT)。
:::danger
**注意:**在运行该语句时,不建议添加`-r`来指定随机数,因为多次验证结果为<br />`[0, 0.0981446]`(不可能)的情况下,仍有可能出现`[0.0169465, 0.116203]`(有可能)的结果。
:::
相关参数设置:
```powershell
SMC:
-r [ --seed ] arg Set seed for random number generator
(default is current time).
-p [ --lower-delta ] arg lower (delta) probabilistic uncertainty.
-P [ --upper-delta ] arg upper (delta) probabilistic uncertainty.
-a [ --alpha ] arg probability of false negatives (alpha).
-B [ --beta ] arg probability of false positives (beta).
-E [ --epsilon ] arg probability uncertainty (epsilon).
-i [ --u0 ] arg threshold u0 for comparing
probabilities.
-j [ --u1 ] arg threshold u1 for comparing
probabilities.
-w [ --histogram-bar-width ] arg width of buckets in histogram. Should
not be set in conjunction with
--histogram-bar-count
--histogram-bar-count arg number of buckets in histogram. Should
not be set in conjunction with
--histogram-bar-width
-c [ --parametric-comp ] arg <0|1>
activate (1) or not (0) the SMC
parametric comparison.
-V [ --smc-coverage ] activate SMC coverage.
-R [ --resolution ] arg simulation resolution (pixels).
-D [ --discretization ] arg discretization step size (time) for
hybrid systems.
-L [ --probability-log ] arg SMC-Log file.
-F [ --sampling-time ] arg outputs to a file a sampling of
simulations (when simulate is used).
三、官方Help文档
双击打开verifyta.exe
会告诉如何查看help。
Usage: D:\uppaal64-4.1.25-5\bin-Windows\verifyta.exe [OPTION]... MODEL QUERY
where MODEL is a model file and QUERY is a query file.
If QUERY is missing it will be guessed.
Options:
-h [ --help ] produce help message
General:
-H [ --hashtable-size ] arg Set hash table size for bit state
hashing to 2**n bits
(default = 27)
-n [ --extrapolation ] arg <0|1|2|3|4>
Select extrapolation operator.
0: Automatic
1: No extrapolation (use with care)
2: Difference extrapolation
3: Location based extrapolation
4: Lower/upper extrapolation
-t [ --diagnostic ] arg <0|1|2>
Generate diagnostic information on
stderr.
0: Some trace
1: Shortest trace (disables reuse)
2: Fastest trace (disables reuse)
-o [ --search-order ] arg <0|1|2|3|4>
Select search order. Only 0 and 1 for
TIGA properties.
0: Breadth first (short-hand -b)
1: Depth first (short-hand -d)
2: Random depth first
3: Optimal first (requires -t1 or -t2)
4: Random optimal depth first
(requires -t1 or -t2)
--state-representation arg <0|1|2|3>
Choose how discrete states should be
represented. (default 1)
0: Difference Bound Matrix. Has
short-hand -C
1: Compact DBM. Uses less space but
more time compared to pure DBM.
2: Bit-state hashing.
Under-approximates states. Has
short-hand -Z.
3: Convex-hull approximation.
Over-approximates states. Has
short-hand -A.
-S [ --statespace-consumption ] arg <0|1|2|3>
Optimize space consumption (0 = none,
1 = default, 2 = aggressive, 3 =
extreme)
-T [ --reuse-statespace ] Reuse state space when several
properties are examined.
-N [ --polyhedra ] Use polyhedra verification of
stopwatches over-approximation
-M [ --modest ] activate Modest semantics for updates.
Output:
-f [ --prefix ] arg Write symbolic traces to files
'prefix-n.xtr' rather than to stderr.
-W Disable warnings
-y [ --post-symbolic ] Display traces symbolically
(post-stable).
-Y [ --pre-symbolic ] Display traces symbolically (pre- and
post-stable).
-q [ --nosummary ] Do not display the option summary.
-x [ --save-system ] arg Save the (modified) system in XML
format, in specified file.
If the system has been modified, an
associated query file is created.
-X [ --save-trace ] arg Save the symbolic trace in file
'<arg>Propertynumber.xml'
-O [ --simulation-format ] arg write the filtered simulation
trajectories to:
std: one trajectory per line into
standard output (default)
csv: one trajectory per file in
comma-separated-values format.
Miscellaneous:
-s [ --silence-progress ] Do not display the progress indicator.
-u [ --summary ] Show verification summary at the end
(incorrect for liveness properties).
-v [ --version ] Show version number.
SMC:
-r [ --seed ] arg Set seed for random number generator
(default is current time).
-p [ --lower-delta ] arg lower (delta) probabilistic uncertainty.
-P [ --upper-delta ] arg upper (delta) probabilistic uncertainty.
-a [ --alpha ] arg probability of false negatives (alpha).
-B [ --beta ] arg probability of false positives (beta).
-E [ --epsilon ] arg probability uncertainty (epsilon).
-i [ --u0 ] arg threshold u0 for comparing
probabilities.
-j [ --u1 ] arg threshold u1 for comparing
probabilities.
-w [ --histogram-bar-width ] arg width of buckets in histogram. Should
not be set in conjunction with
--histogram-bar-count
--histogram-bar-count arg number of buckets in histogram. Should
not be set in conjunction with
--histogram-bar-width
-c [ --parametric-comp ] arg <0|1>
activate (1) or not (0) the SMC
parametric comparison.
-V [ --smc-coverage ] activate SMC coverage.
-R [ --resolution ] arg simulation resolution (pixels).
-D [ --discretization ] arg discretization step size (time) for
hybrid systems.
-L [ --probability-log ] arg SMC-Log file.
-F [ --sampling-time ] arg outputs to a file a sampling of
simulations (when simulate is used).
The ordering of options is significant.
Environment variables:
UPPAAL_DUMP_STATE output a state satisfying the property.
UPPAAL_DISABLE_SWEEPLINE disable sweepline method
UPPAAL_DISABLE_OPTIMISER disable peephole optimiser
UPPAAL_DISABLE_SYMMETRY disable symmetry reduction
UPPAAL_COMPILE_ONLY write compiled model to stdout and stop
UPPAAL_OLD_SYNTAX use UPPAAL 3.4 syntax
The value of these variables does not matter. Defining them is
enough to activate the feature in question.