Struct Optimize

Source
pub struct Optimize { /* private fields */ }
Expand description

Context for solving optimization queries.

Implementations§

Source§

impl Optimize

Source

pub fn new(ctx: &Context) -> Optimize

Create a new optimize context.

Source

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.

Source

pub fn get_context(&self) -> &Context

Get this optimizers ’s context.

Source

pub fn assert(&self, ast: &impl Ast)

Assert hard constraint to the optimization context.

§See also:
Source

pub fn assert_and_track(&self, ast: &Bool, p: &Bool)

Assert a constraint a into the solver, and track it (in the unsat) core using the Boolean constant p.

This API is an alternative to Optimize::check() for extracting unsat cores. Both APIs can be used in the same solver. The unsat core will contain a combination of the Boolean variables provided using Optimize::assert_and_track() and the Boolean literals provided using Optimize::check().

§See also:
Source

pub fn assert_soft( &self, ast: &impl Ast, 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:
Source

pub fn maximize(&self, ast: &impl Ast)

Add a maximization constraint.

§See also:
Source

pub fn minimize(&self, ast: &impl Ast)

Add a minimization constraint.

§See also:
Source

pub fn get_unsat_core(&self) -> Vec<Bool>

Return a subset of the assumptions provided to either the last

These are the assumptions Z3 used in the unsatisfiability proof. Assumptions are available in Z3. They are used to extract unsatisfiable cores. They may be also used to “retract” assumptions. Note that, assumptions are not really “soft constraints”, but they can be used to implement them.

By default, the unsat core will not be minimized. Generation of a minimized unsat core can be enabled via the "sat.core.minimize" and "smt.core.minimize" settings for SAT and SMT cores respectively. Generation of minimized unsat cores will be more expensive.

§See also:
Source

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:
Source

pub fn pop(&self)

Backtrack one level.

§Preconditions:
§See also:
Source

pub fn check(&self, assumptions: &[Bool]) -> SatResult

Check consistency and produce optimal values.

§See also:
Source

pub fn get_model(&self) -> Option<Model>

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.

Source

pub fn get_objectives(&self) -> Vec<Dynamic>

Retrieve the objectives for the last Optimize::check().

This contains maximize/minimize objectives and grouped soft constraints.

Source

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.

Source

pub fn set_params(&self, params: &Params)

Configure the parameters for this Optimize.

Source

pub fn get_statistics(&self) -> Statistics

Retrieve the statistics for the last Optimize::check().

Trait Implementations§

Source§

impl Debug for Optimize

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Optimize

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Drop for Optimize

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.