Added cost code to match compromise branch.
Includes some refactoring in cost.c.
This commit is contained in:
parent
e23c79f59d
commit
8ec1908306
37
src/cost.c
37
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;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#ifndef COST
|
||||
#define COST
|
||||
|
||||
int computeAttackCost (const System sys);
|
||||
int attackCost (const System sys);
|
||||
|
||||
#endif
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user