Struct clingo::Control
[−]
[src]
pub struct Control { /* fields omitted */ }
Control object holding grounding and solving state.
Methods
impl Control
[src]
pub fn new(arguments: Vec<String>) -> Result<Control, Error>
[src]
Create a new control object.
Note: Only gringo options (without --output
) and clasp's options are supported as
arguments, except basic options such as --help
.
Furthermore, a control object is blocked while a search call is active;
you must not call any member function during search.
Messages are printed to stderr.
Arguments
arguments
- string array of command line arguments
Errors
NulError
- if an argument contains a nul byteErrorType::BadAlloc
ErrorType::Runtime
if argument parsing failsWrapperError
pub fn new_with_logger<L: Logger>(
arguments: Vec<String>,
logger: &mut L,
message_limit: u32
) -> Result<Control, Error>
[src]
arguments: Vec<String>,
logger: &mut L,
message_limit: u32
) -> Result<Control, Error>
Create a new control object.
Note: Only gringo options (without --output
) and clasp's options are supported as
arguments,
except basic options such as --help
.
Furthermore, a control object is blocked while a search call is active;
you must not call any member function during search.
Arguments
arguments
- string array of command line argumentslogger
- callback functions for warnings and info messagesmessage_limit
- maximum number of times the logger callback is called
Errors
NulError
- if an argument contains a nul byteErrorType::BadAlloc
ErrorType::Runtime
if argument parsing fails
pub fn add(
&mut self,
name: &str,
parameters: &[&str],
program: &str
) -> Result<(), Error>
[src]
&mut self,
name: &str,
parameters: &[&str],
program: &str
) -> Result<(), Error>
Extend the logic program with the given non-ground logic program in string form.
This function puts the given program into a block of form: #program name(parameters).
After extending the logic program, the corresponding program parts are typically grounded
with ground()
.
Arguments
name
- name of the program blockparameters
- string array of parameters of the program blockprogram
- string representation of the program
Errors
NulError
- if a any argument contains a nul byteErrorType::BadAlloc
ErrorType::Runtime
if parsing fails
pub fn ground(&mut self, parts: &[Part]) -> Result<(), ClingoError>
[src]
Ground the selected parts of the current (non-ground) logic program.
After grounding, logic programs can be solved with solve()
.
Note: Parts of a logic program without an explicit #program
specification are by default put into a program called base
- without
arguments.
Arguments
parts
- array of parts to ground
Errors
pub fn ground_with_event_handler<T: ExternalFunctionHandler>(
&mut self,
parts: &[Part],
handler: &mut T
) -> Result<(), ClingoError>
[src]
&mut self,
parts: &[Part],
handler: &mut T
) -> Result<(), ClingoError>
Ground the selected parts of the current (non-ground) logic program.
After grounding, logic programs can be solved with solve()
.
Note: Parts of a logic program without an explicit #program
specification are by default put into a program called base
- without
arguments.
Arguments
parts
- array of parts to groundhandler
- implementing the traitExternalFunctionHandler
to evaluate external functions
Errors
pub fn solve(
&mut self,
mode: &SolveMode,
assumptions: &[SymbolicLiteral]
) -> Result<SolveHandle, Error>
[src]
&mut self,
mode: &SolveMode,
assumptions: &[SymbolicLiteral]
) -> Result<SolveHandle, Error>
Solve the currently grounded logic program enumerating its models.
Arguments
mode
- configures the search modeassumptions
- array of assumptions to solve under
Errors
ErrorType::BadAlloc
ErrorType::Runtime
if solving could not be startedWrapperError
pub fn solve_with_event_handler<T: SolveEventHandler>(
&mut self,
mode: &SolveMode,
assumptions: &[SymbolicLiteral],
handler: &mut T
) -> Result<SolveHandle, Error>
[src]
&mut self,
mode: &SolveMode,
assumptions: &[SymbolicLiteral],
handler: &mut T
) -> Result<SolveHandle, Error>
Solve the currently grounded logic program enumerating its models.
Arguments
mode
- configures the search modeassumptions
- array of assumptions to solve underhandler
- implementing the traitSolveEventHandler
Errors
WrapperError
ErrorType::BadAlloc
ErrorType::Runtime
if solving could not be started
pub fn cleanup(&mut self) -> Result<(), ClingoError>
[src]
Clean up the domains of clingo's grounding component using the solving component's top level assignment.
This function removes atoms from domains that are false and marks atoms as facts that are true. With multi-shot solving, this can result in smaller groundings because less rules have to be instantiated and more simplifications can be applied.
Errors
pub fn assign_external(
&mut self,
symbol: &Symbol,
value: TruthValue
) -> Result<(), ClingoError>
[src]
&mut self,
symbol: &Symbol,
value: TruthValue
) -> Result<(), ClingoError>
Assign a truth value to an external atom.
If the atom does not exist or is not external, this is a noop.
Arguments
atom
- atom to assignvalue
- the truth value
Errors
pub fn release_external(&mut self, Symbol: Symbol) -> Result<(), ClingoError>
[src]
Release an external atom.
After this call, an external atom is no longer external and subject to program simplifications. If the atom does not exist or is not external, this is a noop.
Arguments
atom
- atom to release
Errors
pub fn register_propagator<T: Propagator>(
&mut self,
propagator: &mut T,
sequential: bool
) -> Result<(), ClingoError>
[src]
&mut self,
propagator: &mut T,
sequential: bool
) -> Result<(), ClingoError>
Register a custom propagator with the control object.
If the sequential flag is set to true, the propagator is called sequentially when solving with multiple threads.
Arguments
propagator
- implementing the traitPropagator
sequential
- whether the propagator should be called sequentially
Errors
pub fn statistics(&self) -> Result<&Statistics, Error>
[src]
Get a statistics object to inspect solver statistics.
Statistics are updated after a solve call.
Attention:
The level of detail of the statistics depends on the stats option
(which can be set using Configuration
or passed as an
option when creating the control object).
The default level zero only provides basic statistics,
level one provides extended and accumulated statistics,
and level two provides per-thread statistics.
Errors
pub fn interrupt(&mut self)
[src]
Interrupt the active solve call (or the following solve call right at the beginning).
pub fn configuration_mut(&mut self) -> Option<&mut Configuration>
[src]
Get a configuration object to change the solver configuration.
pub fn configuration(&self) -> Option<&Configuration>
[src]
Get a configuration object to change the solver configuration.
pub fn use_enumeration_assumption(&mut self, enable: bool) -> Option<()>
[src]
Configure how learnt constraints are handled during enumeration.
If the enumeration assumption is enabled, then all information learnt from the solver's various enumeration modes is removed after a solve call. This includes enumeration of cautious or brave consequences, enumeration of answer sets with or without projection, or finding optimal models, as well as clauses added with clingo_solve_control_add_clause().
Attention: For practical purposes, this option is only interesting for single-shot solving or before the last solve call to squeeze out a tiny bit of performance. Initially, the enumeration assumption is enabled.
Arguments
enable
- whether to enable the assumption
pub fn get_const(&self, name: &str) -> Option<Symbol>
[src]
Return the symbol for a constant definition of form: #const name = symbol
.
Arguments
name
- the name of the constant if it exists
pub fn has_const(&self, name: &str) -> bool
[src]
Check if there is a constant definition for the given constant.
Arguments
name
- the name of the constant
See: Part::get_const()
pub fn symbolic_atoms(&self) -> Option<&SymbolicAtoms>
[src]
Get an object to inspect symbolic atoms (the relevant Herbrand base) used for grounding.
pub fn theory_atoms(&self) -> Option<&TheoryAtoms>
[src]
Get an object to inspect theory atoms that occur in the grounding.
pub fn register_observer<T: GroundProgramObserver>(
&mut self,
observer: &mut T,
replace: bool
) -> bool
[src]
&mut self,
observer: &mut T,
replace: bool
) -> bool
Register a program observer with the control object.
Arguments
observer
- the observer to registerreplace
- just pass the grounding to the observer but not the solver
Returns whether the call was successful
pub fn backend(&mut self) -> Option<&mut Backend>
[src]
pub fn program_builder(&mut self) -> Result<ProgramBuilder, WrapperError>
[src]
Get an object to add non-ground directives to the program.
Trait Implementations
impl Debug for Control
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more