- Improved cost function: now also avoids using initiators when

possible.
This commit is contained in:
ccremers 2006-04-02 12:07:25 +00:00
parent 52708d09b4
commit e1890ddc9f
3 changed files with 20 additions and 0 deletions

View File

@ -35,6 +35,7 @@ attackCost (const System sys)
cost += get_semitrace_length ();
cost += 8 * selfInitiators (sys);
cost += 4 * selfResponders (sys);
cost += 2 * countInitiators (sys);
return cost;
}

View File

@ -1399,6 +1399,24 @@ eventRoledef (const System sys, const int run, const int ev)
return roledef_shift (sys->runs[run].start, ev);
}
//! count the number of initiators
int
countInitiators (const System sys)
{
int run;
int count;
count = 0;
for (run = 0; run < sys->maxruns; run++)
{
if (sys->runs[run].role->initiator)
{
count++;
}
}
return count;
}
//! determine whether a run talks to itself
int
selfSession (const System sys, const int run)

View File

@ -201,6 +201,7 @@ int iterateLocalToOther (const System sys, const int myrun,
int (*callback) (Term t));
int firstOccurrence (const System sys, const int r, Term t, int evtype);
Roledef eventRoledef (const System sys, const int run, const int ev);
int countInitiators (const System sys);
int selfResponder (const System sys, const int run);
int selfResponders (const System sys);
int selfInitiator (const System sys, const int run);