Struct z3::Optimize

source ·
pub struct Optimize<'ctx> { /* private fields */ }
Expand description

Context for solving optimization queries.

Implementations§

source§

impl<'ctx> Optimize<'ctx>

source

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

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) -> &'ctx Context

Get this optimizers ’s context.

source

pub fn assert(&self, ast: &impl Ast<'ctx>)

Assert hard constraint to the optimization context.

See also:
source

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

pub fn maximize(&self, ast: &impl Ast<'ctx>)

Add a maximization constraint.

See also:
source

pub fn minimize(&self, ast: &impl Ast<'ctx>)

Add a minimization constraint.

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<'ctx>]) -> SatResult

Check consistency and produce optimal values.

See also:
source

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.

source

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.

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 get_statistics(&self) -> Statistics<'ctx>

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

Trait Implementations§

source§

impl<'ctx> Debug for Optimize<'ctx>

source§

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

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

impl<'ctx> Display for Optimize<'ctx>

source§

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

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

impl<'ctx> Drop for Optimize<'ctx>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'ctx> RefUnwindSafe for Optimize<'ctx>

§

impl<'ctx> !Send for Optimize<'ctx>

§

impl<'ctx> !Sync for Optimize<'ctx>

§

impl<'ctx> Unpin for Optimize<'ctx>

§

impl<'ctx> UnwindSafe for Optimize<'ctx>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

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 Twhere U: TryFrom<T>,

§

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.