Clingo
Loading...
Searching...
No Matches
CppClingo::ProgramBackend Class Referenceabstract

Abstract class connecting grounder and solver. More...

#include <backend.hh>

Public Member Functions

virtual ~ProgramBackend ()=default
 Destroy the backend.
 
void preamble (unsigned major, unsigned minor, unsigned revision, bool incremental)
 Initialize the backend.
 
void end ()
 Finalize the current grounding step.
 
auto next_lit () -> prg_lit_t
 Return a fresh (positive) literal.
 
auto fact_lit () -> std::optional< prg_lit_t >
 Get a factual literal if one existis.
 
void bd_aggr (PrgLitSpan head, WeightedPrgLitSpan body, int32_t bound, bool choice)
 Define a weight constraint.
 
void rule (PrgLitSpan head, PrgLitSpan body, bool choice)
 Add a disjunctive or choice rule.
 
void show_term (Symbol sym, PrgLitSpan body)
 Show the given symbol if the given condition is true.
 
void show_term (Symbol sym, prg_id_t id)
 Associate the given symbol with an id.
 
void show_term (prg_id_t id, PrgLitSpan body)
 Show the symbol with the given id if the given condition is true.
 
void show_atom (Symbol sym, prg_lit_t lit)
 Show the atom with the given symbol and program literal.
 
void edge (prg_id_t u, prg_id_t v, PrgLitSpan body)
 Add an edge for acyclicity checking.
 
void heuristic (prg_lit_t atom, int32_t weight, int32_t prio, HeuristicType type, PrgLitSpan body)
 Add a heuristic directive.
 
void external (prg_lit_t atom, ExternalType type)
 Declare the given atom as external.
 
void project (PrgLitSpan atoms)
 Project the given atoms.
 
void assume (PrgLitSpan literals)
 Assume the given literals.
 
void minimize (prg_weight_t priority, WeightedPrgLitSpan body)
 Minimize the given weighted literals.
 

Detailed Description

Abstract class connecting grounder and solver.

The backend is responsible for passing grounded statements to the solver (or other forms of backends).

Member Function Documentation

◆ assume()

void CppClingo::ProgramBackend::assume ( PrgLitSpan  literals)
inline

Assume the given literals.

Parameters
literalsthe literals to assume

◆ bd_aggr()

void CppClingo::ProgramBackend::bd_aggr ( PrgLitSpan  head,
WeightedPrgLitSpan  body,
int32_t  bound,
bool  choice 
)
inline

Define a weight constraint.

Precondition
Literals in the head must be positive.
Parameters
headthe literal that is derived
bodythe weighted body literals
boundthe lower bound of the constraint
choicewhether the rule has a choice head

◆ edge()

void CppClingo::ProgramBackend::edge ( prg_id_t  u,
prg_id_t  v,
PrgLitSpan  body 
)
inline

Add an edge for acyclicity checking.

Parameters
uthe source vertex
vthe target vertex
bodythe body of the statement

◆ external()

void CppClingo::ProgramBackend::external ( prg_lit_t  atom,
ExternalType  type 
)
inline

Declare the given atom as external.

Precondition
The atom must be positive.
Parameters
atomthe atom to declare external
typethe truth value of the atom

◆ fact_lit()

auto CppClingo::ProgramBackend::fact_lit ( ) -> std::optional<prg_lit_t>
inline

Get a factual literal if one existis.

Returns
the literal

◆ heuristic()

void CppClingo::ProgramBackend::heuristic ( prg_lit_t  atom,
int32_t  weight,
int32_t  prio,
HeuristicType  type,
PrgLitSpan  body 
)
inline

Add a heuristic directive.

Precondition
The atom must be positive.
Parameters
atomthe atom to modify heuristically
weightthe weight of the modification
priothe priority of the modification
typethe type of the modification
bodythe body of the directive.

◆ minimize()

void CppClingo::ProgramBackend::minimize ( prg_weight_t  priority,
WeightedPrgLitSpan  body 
)
inline

Minimize the given weighted literals.

Parameters
prioritythe priority of the literal
bodythe weighted literals of the minimize constraint

◆ next_lit()

auto CppClingo::ProgramBackend::next_lit ( ) -> prg_lit_t
inline

Return a fresh (positive) literal.

All literals should be created using this function.

Returns
the fresh literal

◆ preamble()

void CppClingo::ProgramBackend::preamble ( unsigned  major,
unsigned  minor,
unsigned  revision,
bool  incremental 
)
inline

Initialize the backend.

Parameters
majorthe major version component
minorthe major version component
revisionthe major version component
incrementalwhether program updates have to be enabled

◆ project()

void CppClingo::ProgramBackend::project ( PrgLitSpan  atoms)
inline

Project the given atoms.

Precondition
The literals atoms must be positive.
Parameters
atomsthe atoms to project

◆ rule()

void CppClingo::ProgramBackend::rule ( PrgLitSpan  head,
PrgLitSpan  body,
bool  choice 
)
inline

Add a disjunctive or choice rule.

Precondition
Literals in the head must be positive.
Parameters
headthe literals forming the head
bodythe literals forming the body
choicewhether the rule is a choice or disjunctive rule

◆ show_atom()

void CppClingo::ProgramBackend::show_atom ( Symbol  sym,
prg_lit_t  lit 
)
inline

Show the atom with the given symbol and program literal.

Precondition
The literal must be positive.
Parameters
symthe symbol to show
litthe literal when to show the symbol

◆ show_term() [1/3]

void CppClingo::ProgramBackend::show_term ( prg_id_t  id,
PrgLitSpan  body 
)
inline

Show the symbol with the given id if the given condition is true.

Parameters
idthe symbol to show
bodythe condition when to show the symbol

◆ show_term() [2/3]

void CppClingo::ProgramBackend::show_term ( Symbol  sym,
prg_id_t  id 
)
inline

Associate the given symbol with an id.

Note
Raises an exception if the given symbol already has an id.
Parameters
symthe symbol
idthe id

◆ show_term() [3/3]

void CppClingo::ProgramBackend::show_term ( Symbol  sym,
PrgLitSpan  body 
)
inline

Show the given symbol if the given condition is true.

Parameters
symthe symbol to show
bodythe condition when to show the symbol

The documentation for this class was generated from the following file: