Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

compmod Struct Reference

#include <compmod.h>

List of all members.

Public Types

enum  strategy { STRATEGY_RANDOM = 1, STRATEGY_FIRST, STRATEGY_LAST }

Public Member Functions

 compmod (c_rule *rule)
void finalise ()
void report_answer (const c_term *ans_head) const
void deep_delete ()
bool extend_set ()
void set_pick_strategy (const string &s)
void set_ans_a_pick_strategy (const strategy &s)
void set_ans_b_pick_strategy (const strategy &s)
void set_calls_pick_strategy (const strategy &s)
void set_possibles_strategy (const strategy &s)
void set_local_ebc_percentage (size_t p)

Static Public Member Functions

strategy get_strategy (const string &name)

Private Member Functions

entry get_next_entry (const set< entry > &s, compmod::strategy pick_strategy) const
entry get_next_call () const
entry get_next_answer_alternative () const
entry get_next_answer_bound () const
void extend_by_call ()
void extend_by_answer_alternative ()
void extend_by_answer_bound ()
pair< const c_rule *, unifier * > add_to_set (c_rule *rule)
void extend_by_first_answer (const c_rule *rule, const con_type &answer, const unifier *mgu)
void change_constraint_disjunction_call (const c_rule *original, const con_type &addition)
void change_constraint_disjunction_answer (const c_rule *original, const con_type &addition)
void change_constraint_disjunction (const c_rule *original, const con_type &addition)
void change_constraint_conjunction_call (const c_rule *original, const con_type &addition)
void change_constraint_conjunction_answer (const c_rule *original, const con_type &addition)
void change_constraint_conjunction (const c_rule *original, const con_type &addition)
bool get_answer (const c_term *t, con_type &answer, unifier &mgu) const
void get_calls (const c_term *t, vector< const c_rule * > &calls) const
void fatal_error () const

Private Attributes

set< entrycalls
set< entryob_calls
set< entryans_a
set< entryans_b
set< entryob_ans_a
set< entryob_ans_b
strategy calls_pick_strategy
strategy ans_a_pick_strategy
strategy ans_b_pick_strategy
strategy possibles_strategy
string pick_strategy
size_t percent_local_extensions
map< const c_rule *, pair<
const c_rule *, unifier * > > 
answer_extension
set< const c_rule * > used_ebc
vector< c_rule * > all_rules

Friends

ostream & operator<< (ostream &os, const compmod &c)


Detailed Description

This class represents the computation model and encapsulates all operations that can be performed on such a model. This is the main class used in the calculation.


Member Enumeration Documentation

enum compmod::strategy
 

The values possible for the picking strategy.

Enumeration values:
STRATEGY_RANDOM 
STRATEGY_FIRST 
STRATEGY_LAST 


Constructor & Destructor Documentation

compmod::compmod c_rule rule  ) 
 

Constructor that initialises the random number generator, inserts the query in the model and sets the pick strategies.

Parameters:
rule the query to solve.


Member Function Documentation

pair< const c_rule *, unifier * > compmod::add_to_set c_rule rule  )  [private]
 

Adds a new entry to the model. If the entry already exists in the model, the old and the new con_type merge and replace the existing one.

void compmod::change_constraint_conjunction const c_rule original,
const con_type addition
[private]
 

Change the constraint C of this rule into the conjunction of C and another constraint. It will call the appropriate specialised method. This is part of the update mechanism.

Parameters:
original the rule whose constraint to update.
addition the constraint to incorporate.

void compmod::change_constraint_conjunction_answer const c_rule original,
const con_type addition
[private]
 

Change the constraint C of this answer into the conjunction of C and another constraint. This will add to the unused accumulated answer alternative if it exists, otherwise add a new unused answer alternative. This is part of the update mechanism.

Parameters:
original the rule whose constraint to update.
addition the constraint to incorporate.

void compmod::change_constraint_conjunction_call const c_rule original,
const con_type addition
[private]
 

Change the constraint C of this call into the conjunction of C and another constraint. The change will be duefully propagated to all answer extensions of this call, as to preserve consistency. This is part of the update mechanism.

Parameters:
original the rule whose constraint to update.
addition the constraint to incorporate.

void compmod::change_constraint_disjunction const c_rule original,
const con_type addition
[private]
 

Change the constraint C of this rule into the disjunction of C and another constraint. It will call the appropriate specialised method. This is part of the update mechanism.

Parameters:
original the rule whose constraint to update.
addition the constraint to incorporate.

void compmod::change_constraint_disjunction_answer const c_rule original,
const con_type addition
[private]
 

Change the constraint C of this answer into the disjunction of C and another constraint. This will add to the unused accumulated answer alternative if it exists, otherwise add a new unused answer alternative. This is part of the update mechanism.

Parameters:
original the rule whose constraint to update.
addition the constraint to incorporate.

void compmod::change_constraint_disjunction_call const c_rule original,
const con_type addition
[private]
 

Change the constraint C of this call into the disjunction of C and another constraint. The change will be duefully propagated to all answer extensions of this call, as to preserve consistency. This is part of the update mechanism.

Parameters:
original the rule whose constraint to update.
addition the constraint to incorporate.

void compmod::deep_delete  ) 
 

Clears all remaining dynamic memory allocated by this model.

void compmod::extend_by_answer_alternative  )  [private]
 

Extends the model by EBAA.

void compmod::extend_by_answer_bound  )  [private]
 

Extends the model by EBAB.

void compmod::extend_by_call  )  [private]
 

Extends the model by EBC or EBCWA.

void compmod::extend_by_first_answer const c_rule rule,
const con_type answer,
const unifier mgu
[private]
 

Extends the model by applying an answer to the first body literal of the given rule for the first time. This will not be called if the answer is not the first one used on this rule.

Parameters:
rule the rule whose first body literal unifies with the answer's head.
answer the answer to apply to the first body literal.
mgu the unifier used when unifying the stored away answer with the first body literal of this rule. The structure changing bindings (the ones which are not variable renamings) of this unifier will be applied to the derived rule.

bool compmod::extend_set  ) 
 

Extends the model by picking an entry (answer alternative or bound or call), depending on the choosing strategy and using the appropriate extension operation.

Returns:
False if we have reached a fixpoint. True if an extension was tried.

void compmod::fatal_error  )  const [private]
 

This method is called if a serious error occurs. This should not happen, because it means that the model is inconsistent and cannot be trusted. This also throws an compmod_error exception, which aborts the computation.

void compmod::finalise  ) 
 

Finalise the computation model. This clears all used dynamic memory.

bool compmod::get_answer const c_term t,
con_type answer,
unifier mgu
const [private]
 

Gets the answer (conjunction of alternative and bound) that has been applied to the model for a given head, if one has been applied.

Parameters:
t the head for which to search for an applied answer.
answer the answer (conjunction of alternative and bound) that has been applied for this rule. The variables used are consistent with those in the given head.
mgu the unifier used when translating from the stored answer into the variables used in the returned answer.
Returns:
Truth value denoting if an answer was found or not. If the value returned is false, neither the returned answer or unifier can be used.

void compmod::get_calls const c_term t,
vector< const c_rule * > &  calls
const [private]
 

Gets at least the calls (both active and obsolete) whose first body literal unifies with the given literal. Both negated and non-negated literals are returned.

Parameters:
t the literal to search for.
calls the vector that will contain the matching calls.

compmod::entry compmod::get_next_answer_alternative  )  const [private]
 

Uses the answer alternative picking strategy to find an unused answer alternative.

Returns:
The answer alternative.

compmod::entry compmod::get_next_answer_bound  )  const [private]
 

Uses the answer bound picking strategy to find an unused answer bound.

Returns:
The answer bound.

compmod::entry compmod::get_next_call  )  const [private]
 

Uses the call picking strategy to find a call that can be used.

Returns:
The call.

compmod::entry compmod::get_next_entry const set< entry > &  s,
compmod::strategy  pick_strategy
const [private]
 

Gets an entry from the given set, using a given pick strategy.

Parameters:
s the set to pick from.
pick_strategy the strategy used.

compmod::strategy compmod::get_strategy const string &  name  )  [static]
 

Translates a strategy name into a strategy token.

Parameters:
name the strategy name.
Returns:
The corresponding strategy.

void compmod::report_answer const c_term ans_head  )  const
 

Reports the answer for the given head (usually the given query).

Parameters:
ans_head the head of the answer.

void compmod::set_ans_a_pick_strategy const strategy s  ) 
 

Sets the strategy for choosing which answer alternative to use if several exist.

Parameters:
s one of STRATEGY_FIRST, STRATEGY_LAST and STRATEGY_RANDOM.

void compmod::set_ans_b_pick_strategy const strategy s  ) 
 

Sets the strategy for choosing which answer bound to use if several exist.

Parameters:
s one of STRATEGY_FIRST, STRATEGY_LAST and STRATEGY_RANDOM.

void compmod::set_calls_pick_strategy const strategy s  ) 
 

Sets the strategy for choosing which call to use if several exist.

Parameters:
s one of STRATEGY_FIRST, STRATEGY_LAST and STRATEGY_RANDOM.

void compmod::set_local_ebc_percentage size_t  p  ) 
 

Sets the percentage that local EBC is used.

void compmod::set_pick_strategy const string &  s  ) 
 

Sets the global strategy for choosing whether to use an answer alternative, answer bound or a call when extending the model.

Parameters:
s either "weighted", in which case a weighted random choice is made, or a permutation of the letters "ABC", in which case answer alternatives (A), answer bounds (B) or calls (C) will be preferred first. "ABC" means that we pick answer alternatives if they exist, otherwise answer bounds if they exist and lastly calls.

void compmod::set_possibles_strategy const strategy s  ) 
 

Sets the strategy for choosing which clause in the program to use for EBC if several exist.

Parameters:
s one of STRATEGY_FIRST, STRATEGY_LAST and STRATEGY_RANDOM.


Friends And Related Function Documentation

ostream& operator<< ostream &  os,
const compmod c
[friend]
 

Write a text representation of a computation model's state to an ostream.

Parameters:
os the ostream to write to.
c the model, whose state to write.


Member Data Documentation

vector<c_rule*> compmod::all_rules [private]
 

A vector of all the c_rule*:s used in the model, so that final garbage collection can be used.

set<entry> compmod::ans_a [private]
 

The set of disjunctions of answer alternatives not yet used. There can be only one element per head variant.

strategy compmod::ans_a_pick_strategy [private]
 

The strategy used for choosing which answer alternative to use.

set<entry> compmod::ans_b [private]
 

The set of conjunctions of answer bounds not yet used. There can be only one element per head variant.

strategy compmod::ans_b_pick_strategy [private]
 

The strategy used for choosing which answer bound to use.

map<const c_rule*, pair<const c_rule*, unifier*> > compmod::answer_extension [private]
 

The answer extension of call entries, when they exist. This is a function "Call(origin) -> Call(target) x Unifier", where the unifier gives the unifier that unifies the origin and the target.

set<entry> compmod::calls [private]
 

The set of "active" calls, the calls which still has possibilities for EBC or EBCWA.

strategy compmod::calls_pick_strategy [private]
 

The strategy used for choosing which call to use.

set<entry> compmod::ob_ans_a [private]
 

The set of disjunctions of answer alternatives already used. There can be only one element per head variant.

set<entry> compmod::ob_ans_b [private]
 

The set of conjunctions of answer bounds already used. There can be only one element per head variant.

set<entry> compmod::ob_calls [private]
 

The set of obsolete calls, those that definitely can no longer be used for EBC or EBCWA.

size_t compmod::percent_local_extensions [private]
 

The percent of EBC that should be done locally (derive the constraint from the call ancestor). The rest is done globally (the derived call is not influenced by the parent call).

string compmod::pick_strategy [private]
 

The global strategy used for choosing which entry type (answer alternative/bound or call) to use to extend the model.

strategy compmod::possibles_strategy [private]
 

The strategy used for choosing which clause in the program to use for EBC.

set<const c_rule*> compmod::used_ebc [private]
 

A set of all calls that has been the origin of a EBC.


The documentation for this struct was generated from the following files:
Generated on Sun Jan 16 16:10:49 2005 for Fixpoint Engine by  doxygen 1.3.9.1