Newer
Older
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
#pragma once
#include <vector>
#include <string>
#include <limits>
#include "generator.h"
#include "strings.h"
using namespace pictcore;
const int UNDEFINED_ORDER = std::numeric_limits<int>::max();
//
//
//
class CModelValue
{
public:
CModelValue
(
wstrings& names,
unsigned int weight,
bool positive
) : _names ( names ),
_weight ( weight ),
_positive ( positive ),
_currentNameIndex( 0 ) {}
wstrings& GetAllNames() { return( _names ); }
std::wstring GetPrimaryName() { return( _names[ 0 ] ); }
// type of the value and any other attribute is currently decided based on the primary name
wstrings GetNamesForComparisons();
// round-robin through names
std::wstring GetNextName();
bool IsPositive() { return( _positive ); }
unsigned int GetWeight() { return( _weight ); }
private:
wstrings _names;
bool _positive;
unsigned int _weight;
wstrings::size_type _currentNameIndex;
};
//
//
//
class CModelParameter
{
public:
std::wstring Name;
std::vector< CModelValue > Values;
unsigned int Order; // default order assigned when parameter is defined
bool IsResultParameter; // special parameter for results
Parameter* GcdPointer;
CModelParameter() :
IsResultParameter( false ),
GcdPointer( NULL ) {}
int GetValueOrdinal( IN std::wstring& name, IN bool caseSensitive );
bool ValueNamesUnique( IN bool CaseSensitive );
};
//
//
//
typedef std::vector< unsigned int > CParameters;
class CModelSubmodel
{
public:
int Order; // order at which a submodel should be combined
CParameters Parameters; // indexes to Parameters in CModelData
CModelSubmodel() : Order(UNDEFINED_ORDER) {}
};
//
//
//
typedef std::list< std::pair< std::wstring, std::wstring > > CModelRowSeed; // param_name, value_name
typedef std::vector< CModelRowSeed > CModelRowSeeds;
//
//
//
class CModelData
{
public:
int Order;
wchar_t ValuesDelim;
wchar_t NamesDelim;
wchar_t InvalidPrefix;
unsigned short RandSeed;
bool CaseSensitive;
bool Verbose; // prints out some additional info while generating
bool Statistics; // show the statistics only
pictcore::GenerationMode GenerationMode;
size_t MaxApproxTries; // for Approximate mode
std::wstring RowSeedsFile;
std::vector< CModelParameter > Parameters;
std::vector< CModelSubmodel > Submodels;
std::wstring ConstraintPredicates;
std::vector< CModelRowSeed > RowSeeds;
std::set< wchar_t > ProvidedArguments; // arguments defined by a user
// helpful to catch redefinitions
// ctor
CModelData() : Order(2),
ValuesDelim(L','),
NamesDelim(L'|'),
InvalidPrefix(L'~'),
RandSeed(0),
CaseSensitive(false),
Verbose(false),
Statistics(false),
RowSeedsFile(L""),
GenerationMode(Regular),
MaxApproxTries(1000),
ConstraintPredicates(L""),
m_hasNegativeValues(false),
m_encoding(ANSI),
m_totalCombinations(0),
m_remainingCombinations(0) {}
bool ReadModel( std::wstring& filePath );
bool ReadRowSeedFile( std::wstring& filePath );
size_t TotalParameterCount() { return(Parameters.size()); }
size_t ResultParameterCount();
std::vector< CModelParameter >::iterator FindParameterByName( std::wstring& Name );
std::vector< CModelParameter >::iterator FindParameterByGcdPointer( Parameter* Pointer );
std::wstring GetConstraintText( unsigned int index );
bool HasNegativeValues() { return( m_hasNegativeValues ); }
EncodingType GetEncoding() { return( m_encoding ); }
void AddToTotalCombinationsCount ( size_t n ) { m_totalCombinations += n; }
void AddToRemainingCombinationsCount( size_t n ) { m_remainingCombinations += n; }
void RemoveNegativeValues();
bool ValidateParams();
bool ValidateRowSeeds();
void PrintModelContents( std::wstring title );
void PrintStatistics();
private:
bool m_hasNegativeValues;
EncodingType m_encoding; // io encoding determined based on input file
long m_totalCombinations; // number of combinations PICT dealt with in this run
long m_remainingCombinations; // number of uncovered combinations (Preview and Approximate)
std::wifstream openFile( std::wstring& filePath );
bool readModel ( std::wstring& filePath );
bool readParameter ( std::wstring& line );
bool readParamSet ( std::wstring& line );
void getUnmatchedParameterNames( wstrings& paramsOfSubmodel, wstrings& unmatchedParams );
};