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: SolveStatusThe solve status (SAT, UNSAT, Unknown, Optimal).
proof: SolveProofThe proof artifact from solving.
stats: SolveStatsStatistics from the solve operation.
Implementations§
Source§impl SolveResult
impl SolveResult
Sourcepub fn satisfiable(assignment: Vec<bool>) -> Self
pub fn satisfiable(assignment: Vec<bool>) -> Self
Sourcepub fn unsatisfiable() -> Self
pub fn unsatisfiable() -> Self
Creates an unsatisfiable result.
§Example
use xlog_solve::SolveResult;
let result = SolveResult::unsatisfiable();
assert!(result.is_unsat());Sourcepub fn optimal(assignment: Vec<bool>, optimal_value: u64) -> Self
pub fn optimal(assignment: Vec<bool>, optimal_value: u64) -> Self
Creates an optimal result (for MaxSAT).
§Arguments
assignment- The optimal assignmentoptimal_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)));Sourcepub fn approximate(
assignment: Vec<bool>,
satisfied_clauses: u32,
total_clauses: u32,
iterations: u32,
) -> Self
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 foundsatisfied_clauses- Number of satisfied clausestotal_clauses- Total number of clausesiterations- 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 SATSourcepub fn with_stats(self, stats: SolveStats) -> Self
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);Sourcepub fn is_sat(&self) -> bool
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());Sourcepub fn is_unsat(&self) -> bool
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());Sourcepub fn assignment(&self) -> Option<&[bool]>
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][..]));Sourcepub fn optimal_value(&self) -> Option<u64>
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));Sourcepub fn verify_proof(&self) -> Option<bool>
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
impl Clone for SolveResult
Source§fn clone(&self) -> SolveResult
fn clone(&self) -> SolveResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more