Debian Codegraph @

Source/Test/CCacheTestReader.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CCacheTestReader.h"
22
23
24 namespace Konclude {
25
26 namespace Test {
27
28
29
30 CCacheTestReader::CCacheTestReader(COccurrenceUnsatisfiableCacheReader *occUnsatCacheReader) {
31 reader = occUnsatCacheReader;
32 testCount = 0;
33 unsatCount = 0;
34
35 }
36
37
38 CCacheTestReader::~CCacheTestReader() {
39 quit();
40 wait();
41 }
42
43
44 void CCacheTestReader::startReader() {
45 start();
46 moveToThread(this);
47 }
48
49
50 qint64 CCacheTestReader::getCacheReads() {
51 return testCount;
52 }
53
54
55 void CCacheTestReader::run() {
56 if (reader) {
57
58 qint64 maxOntTag = 1;
59 qint64 maxConTag = 100;
60 qint64 maxCount = 20;
61
62 while (true) {
63 qint64 randOntTagNumber = rand() % maxOntTag;
64 qint64 randCount = rand() % maxCount;
65 QVector<qint64> conTags(randCount,0);
66 for (qint64 i = 0; i < randCount; ++i) {
67 qint64 randConTagNumber = rand() % maxConTag;
68 conTags[i] = randConTagNumber;
69 }
70 qSort(conTags);
71 QVector<CCacheValue> values;
72 for (qint64 i = 0; i < randCount; ++i) {
73 values.append(CCacheValue(conTags[i],randOntTagNumber,CCacheValue::CACHEVALCONCEPTONTOLOGYTAG));
74 }
75 values.append(CCacheValue(0,0,CCacheValue::CACHEVALUETERMINATOR));
76
77 testCount++;
78 if (reader->isUnsatisfiable(values,values.count())) {
79 unsatCount++;
80 }
81 }
82 }
83 }
84
85
86
87
88 }; // end namespace Test
89
90 }; // end namespace Konclude