pub struct Optimize<'ctx> { /* private fields */ }
Expand description
Context for solving optimization queries.
Implementations§
source§impl<'ctx> Optimize<'ctx>
impl<'ctx> Optimize<'ctx>
sourcepub fn from_string<T: Into<Vec<u8>>>(&self, source_string: T)
pub fn from_string<T: Into<Vec<u8>>>(&self, source_string: T)
Parse an SMT-LIB2 string with assertions, soft constraints and optimization objectives. Add the parsed constraints and objectives to the optimizer.
sourcepub fn get_context(&self) -> &'ctx Context
pub fn get_context(&self) -> &'ctx Context
Get this optimizers ’s context.
sourcepub fn assert(&self, ast: &impl Ast<'ctx>)
pub fn assert(&self, ast: &impl Ast<'ctx>)
Assert hard constraint to the optimization context.
See also:
sourcepub fn assert_soft(
&self,
ast: &impl Ast<'ctx>,
weight: impl Weight,
group: Option<Symbol>
)
pub fn assert_soft( &self, ast: &impl Ast<'ctx>, weight: impl Weight, group: Option<Symbol> )
Assert soft constraint to the optimization context. Weight is a positive, rational penalty for violating the constraint. Group is an optional identifier to group soft constraints.
See also:
sourcepub fn push(&self)
pub fn push(&self)
Create a backtracking point.
The optimize solver contains a set of rules, added facts and assertions.
The set of rules, facts and assertions are restored upon calling
Optimize::pop()
.
See also:
sourcepub fn pop(&self)
pub fn pop(&self)
Backtrack one level.
Preconditions:
- The number of calls to
Optimize::pop
cannot exceed the number of calls toOptimize::push()
.
See also:
sourcepub fn get_model(&self) -> Option<Model<'ctx>>
pub fn get_model(&self) -> Option<Model<'ctx>>
Retrieve the model for the last Optimize::check()
.
The error handler is invoked if a model is not available because
the commands above were not invoked for the given optimization
solver, or if the result was SatResult::Unsat
.
sourcepub fn get_objectives(&self) -> Vec<Dynamic<'ctx>>
pub fn get_objectives(&self) -> Vec<Dynamic<'ctx>>
Retrieve the objectives for the last Optimize::check()
.
This contains maximize/minimize objectives and grouped soft constraints.
sourcepub fn get_reason_unknown(&self) -> Option<String>
pub fn get_reason_unknown(&self) -> Option<String>
Retrieve a string that describes the last status returned by Optimize::check()
.
Use this method when Optimize::check()
returns SatResult::Unknown
.
sourcepub fn get_statistics(&self) -> Statistics<'ctx>
pub fn get_statistics(&self) -> Statistics<'ctx>
Retrieve the statistics for the last Optimize::check()
.