pub struct GenericControl<C: ControlCtx> { /* private fields */ }Expand description
Control object holding grounding and solving state.
Implementations§
Source§impl<C: ControlCtx> GenericControl<C>
impl<C: ControlCtx> GenericControl<C>
Sourcepub fn ground(&mut self, parts: &[Part]) -> Result<(), ClingoError>
pub fn ground(&mut self, parts: &[Part]) -> Result<(), ClingoError>
Ground the selected parts Part of the current (non-ground) logic
program.
After grounding, logic programs can be solved with Control::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
Sourcepub fn register_control_context<T: ControlCtx>(
self,
context: T,
) -> GenericControl<T>
pub fn register_control_context<T: ControlCtx>( self, context: T, ) -> GenericControl<T>
Sourcepub fn solve(
self,
mode: SolveMode,
assumptions: &[SolverLiteral],
) -> Result<GenericSolveHandle<C, Non>, ClingoError>
pub fn solve( self, mode: SolveMode, assumptions: &[SolverLiteral], ) -> Result<GenericSolveHandle<C, Non>, ClingoError>
Solve the currently grounded (Control::ground()) logic program
enumerating its models.
§Arguments
mode- configures the search modeassumptions- array of assumptions to solve under
§Errors
ClingoError::InternalErrorwithErrorCode::BadAllocorErrorCode::Runtimeif solving could not be started
Sourcepub fn solve_with_event_handler<T: SolveEventHandler>(
self,
mode: SolveMode,
assumptions: &[SolverLiteral],
event_handler: T,
) -> Result<GenericSolveHandle<C, T>, ClingoError>
pub fn solve_with_event_handler<T: SolveEventHandler>( self, mode: SolveMode, assumptions: &[SolverLiteral], event_handler: T, ) -> Result<GenericSolveHandle<C, T>, ClingoError>
Solve the currently grounded (Control::ground()) logic program
enumerating its models.
§Arguments
mode- configures the search modeassumptions- array of assumptions to solve underhandler- implementing the traitSolveEventHandler
§Errors
ClingoError::InternalErrorwithErrorCode::BadAllocorErrorCode::Runtimeif solving could not be started
Sourcepub fn add(
&mut self,
name: &str,
parameters: &[&str],
program: &str,
) -> Result<(), ClingoError>
pub fn add( &mut self, name: &str, parameters: &[&str], program: &str, ) -> Result<(), ClingoError>
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
ClingoError::NulError- if a any argument contains a nul byteClingoError::InternalErrorwithErrorCode::BadAllocorErrorCode::Runtimeif parsing fails
Sourcepub fn cleanup(&mut self) -> Result<(), ClingoError>
pub fn cleanup(&mut self) -> Result<(), ClingoError>
Sourcepub fn assign_external(
&mut self,
literal: SolverLiteral,
value: TruthValue,
) -> Result<(), ClingoError>
pub fn assign_external( &mut self, literal: SolverLiteral, value: TruthValue, ) -> Result<(), ClingoError>
Sourcepub fn release_external(
&mut self,
SolverLiteral: SolverLiteral,
) -> Result<(), ClingoError>
pub fn release_external( &mut self, SolverLiteral: SolverLiteral, ) -> Result<(), ClingoError>
Release an external atom.
If a negative literal is passed, the corresponding atom is released.
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
literal- literal to release
§Errors
Sourcepub fn is_conflicting(&self) -> bool
pub fn is_conflicting(&self) -> bool
Check if the solver has determined that the internal program representation is conflicting.
If this function returns true, solve calls will return immediately with an unsatisfiable solve result. Note that conflicts first have to be detected, e.g. - initial unit propagation results in an empty clause, or later if an empty clause is resolved during solving. Hence, the function might return false even if the problem is unsatisfiable.
Sourcepub fn statistics(&self) -> Result<&Statistics, ClingoError>
pub fn statistics(&self) -> Result<&Statistics, ClingoError>
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 (control()).
The default level zero only provides basic statistics,
level one provides extended and accumulated statistics,
and level two provides per-thread statistics.
Furthermore, the statistics object is best accessed right after solving.
Otherwise, not all of its entries have valid values.
§Errors
Sourcepub fn interrupt(&mut self)
pub fn interrupt(&mut self)
Interrupt the active solve call (or the following solve call right at the beginning).
Sourcepub fn configuration_mut(&mut self) -> Result<&mut Configuration, ClingoError>
pub fn configuration_mut(&mut self) -> Result<&mut Configuration, ClingoError>
Get a configuration object to change the solver configuration.
Sourcepub fn configuration(&self) -> Result<&Configuration, ClingoError>
pub fn configuration(&self) -> Result<&Configuration, ClingoError>
Get a configuration object to change the solver configuration.
Sourcepub fn set_enable_enumeration_assumption(
&mut self,
enable: bool,
) -> Result<(), ClingoError>
pub fn set_enable_enumeration_assumption( &mut self, enable: bool, ) -> Result<(), ClingoError>
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 SolveControl::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
Sourcepub fn get_enable_enumeration_assumption(&self) -> bool
pub fn get_enable_enumeration_assumption(&self) -> bool
Check whether the enumeration assumption is enabled.
See Control::set_enable_enumeration_assumption()
Returns using the enumeration assumption is enabled
Sourcepub fn set_enable_cleanup(&mut self, enable: bool) -> bool
pub fn set_enable_cleanup(&mut self, enable: bool) -> bool
Enable automatic cleanup after solving.
Note: Cleanup is enabled by default.
§Arguments
enable- whether to enable cleanups
Returns whether the call was successful
Sourcepub fn get_enable_cleanup(&self) -> bool
pub fn get_enable_cleanup(&self) -> bool
Check whether automatic cleanup is enabled.
Sourcepub fn get_const(&self, name: &str) -> Result<Symbol, ClingoError>
pub fn get_const(&self, name: &str) -> Result<Symbol, ClingoError>
Return the symbol for a constant definition of form: #const name = symbol.
§Arguments
name- the name of the constant if it exists
§Errors
ClingoError::NulError- ifnamecontains a nul byteClingoError::InternalError
Sourcepub fn has_const(&self, name: &str) -> Result<bool, ClingoError>
pub fn has_const(&self, name: &str) -> Result<bool, ClingoError>
Check if there is a constant definition for the given constant.
§Arguments
name- the name of the constant
§Errors
ClingoError::NulError- ifnamecontains a nul byteClingoError::InternalError
See: Control::get_const()
Sourcepub fn symbolic_atoms<'a>(&self) -> Result<&'a SymbolicAtoms, ClingoError>
pub fn symbolic_atoms<'a>(&self) -> Result<&'a SymbolicAtoms, ClingoError>
Get an object to inspect symbolic atoms (the relevant Herbrand base) used
Sourcepub fn theory_atoms(&self) -> Result<&TheoryAtoms, ClingoError>
pub fn theory_atoms(&self) -> Result<&TheoryAtoms, ClingoError>
Get an object to inspect theory atoms that occur in the grounding.
Sourcepub fn backend(&mut self) -> Result<Backend<'_>, ClingoError>
pub fn backend(&mut self) -> Result<Backend<'_>, ClingoError>
Get an object to add ground directives to the program.
§Errors
pub fn add_facts(&mut self, facts: &FactBase) -> Result<(), ClingoError>
Sourcepub fn all_models(self) -> Result<AllModels<C, Non>, ClingoError>
pub fn all_models(self) -> Result<AllModels<C, Non>, ClingoError>
Covenience function that returns an iterator over the models.
Uses Control::solve() with SolveMode::YIELD and empty assumptions.
§Errors
ClingoError::InternalErrorwithErrorCode::BadAllocorErrorCode::Runtimeif solving could not be started
Sourcepub fn optimal_models(self) -> Result<OptimalModels<C, Non>, ClingoError>
pub fn optimal_models(self) -> Result<OptimalModels<C, Non>, ClingoError>
Covenience function that returns an iterator over the optimal models.
Uses Control::solve() with SolveMode::YIELD and empty assumptions.
§Errors
ClingoError::InternalErrorwithErrorCode::BadAllocorErrorCode::Runtimeif solving could not be started