Clingo
Loading...
Searching...
No Matches
Clingo::ProgramBackend Class Reference

Program backend to add atoms and statements. More...

#include <backend.hh>

Inheritance diagram for Clingo::ProgramBackend:
Clingo::TheoryBackend

Public Member Functions

 ProgramBackend (clingo_backend_t *backend)
 Create a program atom from its C representation.
 
void close ()
 Finalize the backend.
 
auto atom (std::optional< Symbol > symbol) const -> ProgramAtom
 Create a fresh program atom.
 
void rule (ProgramAtomSpan head, ProgramLiteralSpan body={}, bool choice=false) const
 Add a choice or disjunctive ground rule.
 
void weight_rule (ProgramAtomSpan head, Weight lower, WeightedLiteralSpan body, bool choice=false) const
 Add a ground weight rule to the program.
 
void minimize (WeightedLiteralSpan literals, Weight priority=0) const
 Add a minimize constraint to the program.
 
void project (ProgramAtomSpan atoms) const
 Add a project directive to the program.
 
void external (ProgramAtom atom, ExternalType type) const
 Add an external directive to the program.
 
void assume (ProgramLiteralSpan literals) const
 Add assumptions to the program.
 
void heuristic (ProgramAtom atom, HeuristicType type, int bias, unsigned priority=0, ProgramLiteralSpan condition={}) const
 Add a heuristic directive to the program.
 
void edge (int node_u, int node_v, ProgramLiteralSpan condition) const
 Add an edge directive.
 
auto theory () const -> TheoryBackend const &
 Get the associated theory backend.
 

Detailed Description

Program backend to add atoms and statements.

The program backend must not be stored. Its destructor finalizes the added statements.

Constructor & Destructor Documentation

◆ ProgramBackend()

Clingo::ProgramBackend::ProgramBackend ( clingo_backend_t backend)
inlineexplicit

Create a program atom from its C representation.

For internal use.

Parameters
backendthe C backend

Member Function Documentation

◆ assume()

void Clingo::ProgramBackend::assume ( ProgramLiteralSpan  literals) const
inline

Add assumptions to the program.

Parameters
literalsthe literals to assume

◆ atom()

auto Clingo::ProgramBackend::atom ( std::optional< Symbol symbol) const -> ProgramAtom
inline

Create a fresh program atom.

If a symbol is given, the corresponding atom is returned or a fresh one created. If no symbol is given, a fresh program atom is returned.

Parameters
symbolthe symbol of the program atom
Returns
the program atom

◆ close()

void Clingo::ProgramBackend::close ( )
inline

Finalize the backend.

After closing the backend, it must no longer be used. If this function is called, the destructor is guaranteed to not throw.

◆ edge()

void Clingo::ProgramBackend::edge ( int  node_u,
int  node_v,
ProgramLiteralSpan  condition 
) const
inline

Add an edge directive.

Parameters
node_uthe start vertex of the edge
node_vthe end vertex of the edge
conditionthe condition under which the edge is part of the graph

◆ external()

void Clingo::ProgramBackend::external ( ProgramAtom  atom,
ExternalType  type 
) const
inline

Add an external directive to the program.

Parameters
atomthe external atom
typethe type of the external atom

◆ heuristic()

void Clingo::ProgramBackend::heuristic ( ProgramAtom  atom,
HeuristicType  type,
int  bias,
unsigned  priority = 0,
ProgramLiteralSpan  condition = {} 
) const
inline

Add a heuristic directive to the program.

Parameters
atomthe target atom
typethe type of the heuristic modification
biasthe heuristic bias
prioritythe heuristic priority
conditionthe condition under which to apply the heuristic modification

◆ minimize()

void Clingo::ProgramBackend::minimize ( WeightedLiteralSpan  literals,
Weight  priority = 0 
) const
inline

Add a minimize constraint to the program.

Parameters
literalsthe weighted literals
prioritythe priority of the constraint

◆ project()

void Clingo::ProgramBackend::project ( ProgramAtomSpan  atoms) const
inline

Add a project directive to the program.

Parameters
atomsthe atoms to project

◆ rule()

void Clingo::ProgramBackend::rule ( ProgramAtomSpan  head,
ProgramLiteralSpan  body = {},
bool  choice = false 
) const
inline

Add a choice or disjunctive ground rule.

Parameters
headthe head atoms
bodythe body literals
choicewhether the head is a choice or disjunction

◆ theory()

auto Clingo::ProgramBackend::theory ( ) const -> TheoryBackend const &
inline

Get the associated theory backend.

Returns
the backend

◆ weight_rule()

void Clingo::ProgramBackend::weight_rule ( ProgramAtomSpan  head,
Weight  lower,
WeightedLiteralSpan  body,
bool  choice = false 
) const
inline

Add a ground weight rule to the program.

Parameters
headthe head atoms
lowerthe lower bound
bodythe weighted body literals
choicewhether the head is a choice or disjunction

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