| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef PRIORITYMATRIX_H |
| 21 |
#define PRIORITYMATRIX_H |
| 22 |
|
| 23 |
#include "eFaCTPlusPlus.h" |
| 24 |
#include "dlVertex.h" |
| 25 |
#include "logging.h" |
| 26 |
|
| 27 |
typedef unsigned short int ToDoListIndex; |
| 28 |
|
| 29 |
|
| 30 |
constexpr ToDoListIndex nRegularOps = 7; |
| 31 |
|
| 32 |
constexpr ToDoListIndex iId = nRegularOps+1; |
| 33 |
|
| 34 |
constexpr ToDoListIndex iNN = nRegularOps+2; |
| 35 |
|
| 36 |
|
| 37 |
class ToDoPriorMatrix |
| 38 |
{ |
| 39 |
protected: |
| 40 |
|
| 41 |
ToDoListIndex iAnd = nRegularOps, |
| 42 |
iOr = nRegularOps, |
| 43 |
iExists = nRegularOps, |
| 44 |
iForall = nRegularOps, |
| 45 |
iLE = nRegularOps, |
| 46 |
iGE = nRegularOps; |
| 47 |
|
| 48 |
public: |
| 49 |
|
| 50 |
void initPriorities ( const std::string& options, const char* optionName ); |
| 51 |
|
| 52 |
ToDoListIndex getIndex ( DagTag Op, bool Sign, bool NominalNode ) const; |
| 53 |
}; |
| 54 |
|
| 55 |
inline void ToDoPriorMatrix :: initPriorities ( const std::string& options, const char* optionName ) |
| 56 |
{ |
| 57 |
|
| 58 |
if ( options.size () != 7 ) |
| 59 |
throw EFaCTPlusPlus ( "ToDo List option string should have length 7" ); |
| 60 |
|
| 61 |
|
| 62 |
auto char2int = [] (const char c) { return static_cast<ToDoListIndex>(c - '0'); }; |
| 63 |
|
| 64 |
|
| 65 |
iAnd = char2int(options[1]); |
| 66 |
iOr = char2int(options[2]); |
| 67 |
iExists = char2int(options[3]); |
| 68 |
iForall = char2int(options[4]); |
| 69 |
iLE = char2int(options[5]); |
| 70 |
iGE = char2int(options[6]); |
| 71 |
|
| 72 |
|
| 73 |
if ( iAnd >= nRegularOps || |
| 74 |
iOr >= nRegularOps || |
| 75 |
iExists >= nRegularOps || |
| 76 |
iForall >= nRegularOps || |
| 77 |
iGE >= nRegularOps || |
| 78 |
iLE >= nRegularOps ) |
| 79 |
throw EFaCTPlusPlus ( "ToDo List option out of range" ); |
| 80 |
|
| 81 |
|
| 82 |
if ( LLM.isWritable(llAlways) ) |
| 83 |
LL << "\nInit " << optionName << " = " << iAnd << iOr << iExists << iForall << iLE << iGE; |
| 84 |
} |
| 85 |
|
| 86 |
inline ToDoListIndex ToDoPriorMatrix :: getIndex ( DagTag Op, bool Sign, bool NominalNode ) const |
| 87 |
{ |
| 88 |
switch ( Op ) |
| 89 |
{ |
| 90 |
case dtAnd: |
| 91 |
return (Sign?iAnd:iOr); |
| 92 |
|
| 93 |
case dtForall: |
| 94 |
case dtIrr: |
| 95 |
return (Sign?iForall:iExists); |
| 96 |
|
| 97 |
case dtProj: |
| 98 |
case dtChoose: |
| 99 |
return iOr; |
| 100 |
|
| 101 |
case dtLE: |
| 102 |
return (Sign?(NominalNode?iNN:iLE):iGE); |
| 103 |
|
| 104 |
case dtDataType: |
| 105 |
case dtDataValue: |
| 106 |
case dtDataExpr: |
| 107 |
case dtNN: |
| 108 |
case dtTop: |
| 109 |
return nRegularOps; |
| 110 |
|
| 111 |
case dtPSingleton: |
| 112 |
case dtPConcept: |
| 113 |
return (Sign?iId:nRegularOps); |
| 114 |
|
| 115 |
case dtNSingleton: |
| 116 |
case dtNConcept: |
| 117 |
return iId; |
| 118 |
|
| 119 |
default: |
| 120 |
fpp_unreachable(); |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
#endif |