diff --git a/src/cost.c b/src/cost.c index 5fd8136..5643ed8 100644 --- a/src/cost.c +++ b/src/cost.c @@ -48,6 +48,27 @@ * A lower value (closer to 0) is a more feasible attack. */ int +computeAttackCost (const System sys) +{ + // Use nice heuristic cf. work of Gijs Hollestelle. Hand-picked parameters. + int cost; + + cost = 0; + + //cost += get_semitrace_length (); + + cost += 10 * selfInitiators (sys); + cost += 7 * selfResponders (sys); + cost += 10 * sys->num_regular_runs; + cost += 3 * countInitiators (sys); + cost += 2 * countBindingsDone (); + cost += 1 * sys->num_intruder_runs; + + return cost; +} + +//! Compute attack cost in different pruning contexts. +int attackCost (const System sys) { if (switches.prune == 0) @@ -72,21 +93,7 @@ attackCost (const System sys) } if (switches.prune == 2) { - // Use nice heuristic cf. work of Gijs Hollestelle. Hand-picked parameters. - int cost; - - cost = 0; - - //cost += get_semitrace_length (); - - cost += 10 * selfInitiators (sys); - cost += 7 * selfResponders (sys); - cost += 10 * sys->num_regular_runs; - cost += 3 * countInitiators (sys); - cost += 2 * countBindingsDone (); - cost += 1 * sys->num_intruder_runs; - - return cost; + return computeAttackCost (sys); } error ("Unknown pruning method (cost function not found)"); return 0; diff --git a/src/cost.h b/src/cost.h index 3c66292..371fb1e 100644 --- a/src/cost.h +++ b/src/cost.h @@ -20,6 +20,7 @@ #ifndef COST #define COST +int computeAttackCost (const System sys); int attackCost (const System sys); #endif diff --git a/src/dotout.c b/src/dotout.c index 6de3fca..9bbca2d 100644 --- a/src/dotout.c +++ b/src/dotout.c @@ -28,6 +28,7 @@ #include "debug.h" #include "error.h" #include "specialterm.h" +#include "cost.h" extern Protocol INTRUDER; // Pointers, to be set by the Init of arachne.c extern Role I_M; // Same here. @@ -1658,6 +1659,8 @@ dotSemiState (const System mysys) termPrintRemap (sys->current_claim->rolename); eprintf (", claim type "); termPrintRemap (sys->current_claim->type); + // For debugging: + eprintf (", cost %i", computeAttackCost (sys)); eprintf ("\";\n"); // Needed for the bindings later on: create graph