Skip to main content

SolveResult

Struct SolveResult 

Source
pub struct SolveResult {
    pub status: SolveStatus,
    pub proof: SolveProof,
    pub stats: SolveStats,
}
Expand description

Complete result from a solve operation.

Combines the solve status, proof artifact, and statistics into a single comprehensive result structure.

§Construction

Use the constructor methods for common result types:

use xlog_solve::{SolveResult, SolveStats};

// Satisfiable result
let sat = SolveResult::satisfiable(vec![true, false, true]);
assert!(sat.is_sat());

// Unsatisfiable result
let unsat = SolveResult::unsatisfiable();
assert!(unsat.is_unsat());

// Unknown result (e.g., timeout)
let unknown = SolveResult::unknown(1000);
assert!(!unknown.is_sat());

// With custom statistics
let stats = SolveStats::new(100, 5000, 1024);
let result = SolveResult::satisfiable(vec![true]).with_stats(stats);

§Example

use xlog_solve::SolveResult;

let result = SolveResult::satisfiable(vec![true, false]);

if result.is_sat() {
    if let Some(assignment) = result.assignment() {
        println!("Found assignment: {:?}", assignment);
    }
}

Fields§

§status: SolveStatus

The solve status (SAT, UNSAT, Unknown, Optimal).

§proof: SolveProof

The proof artifact from solving.

§stats: SolveStats

Statistics from the solve operation.

Implementations§

Source§

impl SolveResult

Source

pub fn satisfiable(assignment: Vec<bool>) -> Self

Creates a satisfiable result with the given assignment.

Automatically computes a checksum for the assignment.

§Arguments
  • assignment - The satisfying assignment
§Example
use xlog_solve::SolveResult;

let result = SolveResult::satisfiable(vec![true, false, true]);
assert!(result.is_sat());
Source

pub fn unsatisfiable() -> Self

Creates an unsatisfiable result.

§Example
use xlog_solve::SolveResult;

let result = SolveResult::unsatisfiable();
assert!(result.is_unsat());
Source

pub fn unknown(iterations: u32) -> Self

Creates an unknown result (e.g., timeout).

§Arguments
  • iterations - Number of iterations performed before giving up
§Example
use xlog_solve::SolveResult;

let result = SolveResult::unknown(1000);
assert!(!result.is_sat());
assert!(!result.is_unsat());
Source

pub fn optimal(assignment: Vec<bool>, optimal_value: u64) -> Self

Creates an optimal result (for MaxSAT).

§Arguments
  • assignment - The optimal assignment
  • optimal_value - The optimal objective value
§Example
use xlog_solve::{SolveResult, SolveStatus};

let result = SolveResult::optimal(vec![true, false], 42);
assert!(matches!(result.status, SolveStatus::Optimal(42)));
Source

pub fn approximate( assignment: Vec<bool>, satisfied_clauses: u32, total_clauses: u32, iterations: u32, ) -> Self

Creates an approximate result from an incomplete solver.

§Arguments
  • assignment - The best assignment found
  • satisfied_clauses - Number of satisfied clauses
  • total_clauses - Total number of clauses
  • iterations - Number of solver iterations
§Example
use xlog_solve::SolveResult;

let result = SolveResult::approximate(vec![true, false], 8, 10, 1000);
assert!(!result.is_sat());  // Not definitively SAT
Source

pub fn with_stats(self, stats: SolveStats) -> Self

Updates the statistics, consuming and returning self.

§Arguments
  • stats - The new statistics
§Example
use xlog_solve::{SolveResult, SolveStats};

let stats = SolveStats::new(100, 5000, 1024);
let result = SolveResult::satisfiable(vec![true]).with_stats(stats);
assert_eq!(result.stats.iterations, 100);
Source

pub fn is_sat(&self) -> bool

Returns true if the result is satisfiable.

§Example
use xlog_solve::SolveResult;

assert!(SolveResult::satisfiable(vec![true]).is_sat());
assert!(!SolveResult::unsatisfiable().is_sat());
Source

pub fn is_unsat(&self) -> bool

Returns true if the result is unsatisfiable.

§Example
use xlog_solve::SolveResult;

assert!(SolveResult::unsatisfiable().is_unsat());
assert!(!SolveResult::satisfiable(vec![true]).is_unsat());
Source

pub fn assignment(&self) -> Option<&[bool]>

Returns the assignment if one is available.

§Example
use xlog_solve::SolveResult;

let result = SolveResult::satisfiable(vec![true, false]);
assert_eq!(result.assignment(), Some(&[true, false][..]));
Source

pub fn optimal_value(&self) -> Option<u64>

Returns the optimal value if this is a MaxSAT result.

§Example
use xlog_solve::SolveResult;

let result = SolveResult::optimal(vec![true], 42);
assert_eq!(result.optimal_value(), Some(42));
Source

pub fn verify_proof(&self) -> Option<bool>

Verifies the integrity of the proof checksum.

Returns Some(true) if the checksum is valid, Some(false) if corrupted, or None if verification is not applicable.

§Example
use xlog_solve::SolveResult;

let result = SolveResult::satisfiable(vec![true, false]);
assert_eq!(result.verify_proof(), Some(true));

Trait Implementations§

Source§

impl Clone for SolveResult

Source§

fn clone(&self) -> SolveResult

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SolveResult

Source§

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

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

impl Default for SolveResult

Source§

fn default() -> Self

Returns the “default value” for a 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,