24 for(
int i=1; i <= scnt; ++i) {
29 std::map<int, Idx> map_evidx;
30 for(
int i=0; i < evcnt; ++i) {
38 for(
int i = 0; i < tc; ++i) {
52 std::cout <<
"perfloop: " << message << std::endl;
53 std::cout <<
"" << std::endl;
56 std::cout <<
"perfloop: version " <<
VersionString() << std::endl;
57 std::cout <<
"" << std::endl;
58 std::cout <<
"perfloop: usage: " << std::endl;
59 std::cout <<
" perfloop [-q][-cs <nnn>][-ce <nnn>][-ct <nn>] [-n <nn>] " << std::endl;
60 std::cout <<
"where " << std::endl;
61 std::cout <<
" -q: less console output " << std::endl;
62 std::cout <<
" -cs <nnn>: number of states <nnn> " << std::endl;
63 std::cout <<
" -ce <nnn>: number of events <nnn> " << std::endl;
64 std::cout <<
" -ct <nnn>: number of transitions <nnn> per state" << std::endl;
65 std::cout <<
" -n <nnn>: repetition of test" << std::endl;
66 std::cout <<
" -s: use zero seed for random number generator" << std::endl;
67 std::cout <<
"" << std::endl;
68 std::cout <<
"" << std::endl;
74 int main(
int argc,
char* argv[]){
85 for(
int i=1; i<argc; i++) {
86 std::string option(argv[i]);
88 if((option==
"-q") || (option==
"--quiet")) {
93 if((option==
"-cs") || (option==
"--states")) {
95 param_cs=
ToIdx(argv[i]);
96 if(param_cs <=0)
usage_exit(
"positive state count required");
100 if((option==
"-ce") || (option==
"--events")) {
102 param_ce=
ToIdx(argv[i]);
103 if(param_ce <=0)
usage_exit(
"positive event count required");
107 if((option==
"-ct") || (option==
"--transition-density")) {
109 param_ct=
ToIdx(argv[i]);
110 if(param_ct <=0)
usage_exit(
"positive transition count required");
114 if((option==
"-n") || (option==
"--loop-count")) {
116 param_n=
ToIdx(argv[i]);
117 if(param_ce <=0)
usage_exit(
"positive loop count");
121 if((option==
"-s") || (option==
"--seed0")) {
126 if((option==
"-?") || (option==
"--help")) {
131 if(option.c_str()[0]==
'-') {
143 faudes_systime_t now;
144 faudes_gettimeofday(&now);
151 faudes_systime_t lastprint;
152 faudes_gettimeofday(&lastprint);
155 faudes_mstime_t overall_duration = 0;
158 long int overall_reduction = 0;
161 for(
int i=0; i<param_n; ++i) {
168 faudes_systime_t start;
169 faudes_gettimeofday(&start);
172 std::map<faudes::Idx, faudes::Idx> pmap;
174 calcBisimulation(grand,pmap, gbisim);
177 faudes_systime_t stop;
178 faudes_gettimeofday(&stop);
179 faudes_mstime_t delta;
181 overall_duration += delta;
184 long int reduction = grand.
Size()-gbisim.
Size();
185 overall_reduction += reduction;
189 faudes_mstime_t deltaprint;
191 if((deltaprint>2000) && param_q==0) {
192 std::cout <<
"perfloop: state set reduction #" << reduction <<
" amounts to " <<
193 ((
long int)(10.0 * 100.0 * reduction/grand.
Size())) / 10.0 <<
"%" << std::endl;
194 std::cout <<
"perfloop: time elapse " << ((delta + 50) / 100) / 10.0 <<
"sec." << std::endl;
202 std::cout <<
"perfloop: average state set reduction " <<
203 ((
long int)(10.0 * 100.0 * overall_reduction / param_cs / param_n)) / 10.0 <<
"%" << std::endl;
204 long int average_duration = ((double) overall_duration) / (param_n*100.0) + 0.5;
205 std::cout <<
"perfloop: average duration per loop " << ((double) average_duration) / 10.0 <<
"sec." << std::endl;
Base class of all FAUDES generators.
StateSet::Iterator StatesBegin(void) const
Iterator to Begin() of state set.
bool SetTransition(Idx x1, Idx ev, Idx x2)
Add a transition to generator by indices.
void SetInitState(Idx index)
Set an existing state as initial state by index.
StateSet::Iterator StatesEnd(void) const
Iterator to End() of state set.
Idx InsState(void)
Add new anonymous state to generator.
bool InsEvent(Idx index)
Add an existing event to alphabet by index.
Idx Size(void) const
Get generator size (number of states)
virtual void Clear(void)
Clear generator data.
long ran_uniform_int(long a, long b)
Sample a discrete random variable uniformly on interval [a;b) Distribution: p(n) = 1/(b-a-1)
void ran_init(long seed)
Initialize random generator.
Includes all libFAUDES headers, incl plugings
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
std::string VersionString()
Return FAUDES_VERSION as std::string.
Idx ToIdx(const std::string &rString)
Convert a string to Idx.
std::string ToStringInteger(Int number)
integer to string
int main(int argc, char *argv[])
void RandomGenerator(int scnt, int evcnt, int tcnt, Generator &rRes)
void usage_exit(const std::string &message="")