该研究得到了 ECSEL JU 项目 H2020 826060 AI4DI - 数字化行业的人工智能的支持。 AI4DI 由奥地利联邦运输、创新和技术部 (BMVIT) 在“未来 ICT”计划下于 2019 年 5 月至 2022 年 4 月期间资助。更多信息可从 https://iktderzukunft.at/en/ 检索。
基于定理求解器 CLINGO 5.4.1 的 ASP 模型诊断工具。
“diagnose”是一个可执行文件,其中包括 CLINGO 5.4.1 所需的所有库。该文件只能在 MAC 操作系统上执行。 “diagnose_win.exe”是 Windows 系统的可执行文件,包括运行 CLINGO 5.4.1 的所有库。
要调用和使用Python(python 3.6.15)脚本,需要安装clingo(版本5.4.1),这可以通过基于环境目录中预定义提供的文件创建Conda环境来完成:
cd environment
conda env create -f environment.yml
conda activate diagnose
如果需要使用 python 导入该工具,可以使用diagnose.py 类导入相关的 python 脚本。此类的参数“设置”字典可以在 main_diagnose.py 中看到(请参阅可选参数)
| Argument | Argument | Description |
| ------ | ------ | ------ |
| --help | -h | show this help message and exit |
| --index | -i | index to identify actual call (E.g.: time, call counter, etc.) |
| --file | -f | load ASP model file |
| --path | -p | load ASP model directory path |
| --faultsize | -fault | size of faults to search |
| --hidediagoutput | -hidediag | hide diagnose output in terminal (no argument needed) |
| --output | -out | define output file name and path for CSV (overview result) and JSON (detailed results) / default path: actual directory and file name with date and time |
| --json | -j | JSON output file is written (no argument needed) |
| --csv | -c | CSV output file is written (no argument needed) |
| --answersets | -a | number of answer sets (0: all, 1: compute one answer set, 2: two answer sets, ... |
| --observation | -obs | add additional observation file to ground with ASP file (e.g.: example.pl) |
| --adapt | -adapt | adapt data (comment out all constraints ':- not no_ab(X)' |
| --strongfaults | -strongfaults | use argument to activate search for strong fault 'only' or 'without' constraints, if argument is not used strong faults constraints are not implemented. choices=["only", "without"] |
application/diagnose --index "0" --path data/asp_test_data --faultsize 3 --answersets 0 --output application/filename --json --csv --hidediagoutput --strongfaults "only"
python app/main_diagnose.py --index "*" --path data/asp_test_data --faultsize 3 --answersets 0 --output application/filename --json --csv --strongfaults "without"
python app/main_diagnose.py --index "1" --file testfile.pl --faultsize 3 --answersets 0 --output application/filename --json --csv
计算完成后,可以根据给定的输出(--output)文件名和路径将数据存储在 CSV(--csv)和 JSON(--json)文件中。如果在循环中使用相同的输出文件名调用该工具,那么它的文件将使用新数据进行扩展。例如,如果在依赖时间的系统上执行诊断并且对于每个时间步执行诊断,则这非常有用。要跟踪呼叫,请使用索引 (--index) 选项。例如,这允许添加相关的时间步长来识别数据。 (例如:时间:0.01 -> 索引=0.01,时间:0.02 -> 索引=0.02,...)
CSV 数据文件的标题:“索引、型号、时间 0、时间 1、时间 2、时间 3、NoD 0、NoD 1、NoD 2、NoD 3、ASPDiagTime”
例如:
Index,Model,Time 0,Time 1,NoD 0,NoD 1,ASPDiagTime
0,test_heater_circuit.pl,0.007652997970581055,0.009721755981445312,0,1,0.017589092254638672
1,test_heater_circuit.pl,0.007380962371826172,0.010998964309692383,0,0,0.018507003784179688
2,test_heater_circuit.pl,0.007673025131225586,0.0077838897705078125,0,0,0.015599727630615234
JSON 文件存储文件名和相关数据以及详细的诊断结果。
例如:
[
{
"0": {
"test_heater_circuit.pl": [
{
"diag time": 0.007652997970581055,
"fault size": 0,
"diag found": 0,
"diag": [],
"observation": [
"val(int(tm),between(t_low, null),0)."
]
},
{
"diag time": 0.009721755981445312,
"fault size": 1,
"diag found": 1,
"diag": [
[
"ab(sw)"
]
],
"observation": [
"val(int(tm),between(t_low, null),0)."
]
}
]
}
},
{
"1": {
"test_heater_circuit.pl": [
{
"diag time": 0.007380962371826172,
"fault size": 0,
"diag found": 0,
"diag": [],
"observation": [
"val(int(tm),between(t_low, null),0).",
"val(int(tm),between(t_low, null),1)."
]
},
{
"diag time": 0.010998964309692383,
"fault size": 1,
"diag found": 0,
"diag": [],
"observation": [
"val(int(tm),between(t_low, null),0).",
"val(int(tm),between(t_low, null),1)."
]
}
]
}
},
{
"2": {
"test_heater_circuit.pl": [
{
"diag time": 0.007673025131225586,
"fault size": 0,
"diag found": 0,
"diag": [],
"observation": [
"val(int(tm),between(t_low, null),0).",
"val(int(tm),between(t_low, null),1).",
"val(int(tm),between(t_low, null),2)."
]
},
{
"diag time": 0.0077838897705078125,
"fault size": 1,
"diag found": 0,
"diag": [],
"observation": [
"val(int(tm),between(t_low, null),0).",
"val(int(tm),between(t_low, null),1).",
"val(int(tm),between(t_low, null),2)."
]
}
]
}
}
]
使用 conda 环境通过以下命令构建相关操作系统的可执行文件。
pyinstaller --onefile app/main_diagnose.py --name diagnose --distpath application/ --specpath application/ --hidden-import cffi