pub struct SampleSet {
pub metadata: Option<ProcessMetadata>,
pub annotations: HashMap<String, String>,
/* private fields */
}Expand description
Multiple sample solution results with deduplication
§Invariants
Self::decision_variablesowns aSampledDecisionVariableTable; table keys ownVariableIDand sampled decision-variable rows do not carry IDs.- The decision-variable table rejects modeling labels for unknown variable IDs.
Self::named_functionsis keyed by the table-ownedNamedFunctionID; sampled named-function rows do not carry IDs.- All
Self::decision_variables,Self::objectives, sampled constraint collections, andSelf::named_functionshave the same sample ID set. Self::decision_variablescontains all variable IDs referenced inused_decision_variable_idsof each sampled constraint and sampled named function.- Sampled special-constraint structural variables are defined in
Self::decision_variables. Indicator variables and one-hot variables must be binary; one-hot and SOS1 variable sets must be non-empty, andactive_variablevalues must belong to their structural variable set. - Sampled special-constraint stage fields are consistent with
Self::decision_variables:indicator_activereflects the indicator variable values, and one-hot/SOS1active_variableplusfeasiblereflect the structural variable values underfeasibility_atol. Self::feasibleandSelf::feasible_relaxedare computed from all sampled constraint collections:feasible: true if all constraints are satisfied for that sample.feasible_relaxed: true if all non-removed constraints are satisfied.
feasibility_atolis the absolute tolerance used to validate serialized per-constraint feasibility columns and to interpret per-sampleSolutionvalues extracted from this sample set.
Fields§
§metadata: Option<ProcessMetadata>OMMX-defined provenance metadata.
annotations: HashMap<String, String>User-defined or third-party extension annotations.
Implementations§
Source§impl SampleSet
impl SampleSet
Sourcepub fn decision_variable_names(&self) -> BTreeSet<String>
pub fn decision_variable_names(&self) -> BTreeSet<String>
Get all unique decision variable names in this sample set
Returns a set of all unique variable names that have at least one named variable. Variables without names are not included.
Sourcepub fn named_function_names(&self) -> BTreeSet<String>
pub fn named_function_names(&self) -> BTreeSet<String>
Get all unique named function names in this sample set
Returns a set of all unique named function names that have at least one named function.
Sourcepub fn extract_decision_variables(
&self,
name: &str,
sample_id: SampleID,
) -> Result<BTreeMap<Vec<i64>, f64>, SampleSetError>
pub fn extract_decision_variables( &self, name: &str, sample_id: SampleID, ) -> Result<BTreeMap<Vec<i64>, f64>, SampleSetError>
Extract decision variable values for a given name and sample ID
Returns a map from subscripts to values for the specified sample.
Note: Parameters in decision variable labels are ignored. Only subscripts are used as keys.
§Errors
Returns an error if:
- No decision variables with the given name are found
- The same subscript is found multiple times (which can happen when parameters differ)
- The sample ID is not found
Sourcepub fn extract_all_decision_variables(
&self,
sample_id: SampleID,
) -> Result<BTreeMap<String, BTreeMap<Vec<i64>, f64>>, SampleSetError>
pub fn extract_all_decision_variables( &self, sample_id: SampleID, ) -> Result<BTreeMap<String, BTreeMap<Vec<i64>, f64>>, SampleSetError>
Extract all decision variables grouped by name for a given sample ID
Returns a mapping from variable name to a mapping from subscripts to values. This is useful for extracting all variables at once in a structured format. Variables without names are not included in the result.
Note: Parameters in decision variable labels are ignored. Only subscripts are used as keys.
§Errors
Returns an error if:
- The same name and subscript combination is found multiple times (which can happen when parameters differ)
- The sample ID is invalid
Sourcepub fn extract_constraints(
&self,
name: &str,
sample_id: SampleID,
) -> Result<BTreeMap<Vec<i64>, f64>, SampleSetError>
pub fn extract_constraints( &self, name: &str, sample_id: SampleID, ) -> Result<BTreeMap<Vec<i64>, f64>, SampleSetError>
Extract constraint values for a given name and sample ID
Returns a map from subscripts to values for the specified sample
Sourcepub fn extract_all_named_functions(
&self,
sample_id: SampleID,
) -> Result<BTreeMap<String, BTreeMap<Vec<i64>, f64>>, SampleSetError>
pub fn extract_all_named_functions( &self, sample_id: SampleID, ) -> Result<BTreeMap<String, BTreeMap<Vec<i64>, f64>>, SampleSetError>
Extract all named functions grouped by name for a given sample ID
Returns a mapping from function name to a mapping from subscripts to values. This is useful for extracting all functions at once in a structured format. Functions without names are not included in the result.
Note: Parameters in named function are ignored. Only subscripts are used as keys.
§Errors
Returns an error if:
- The same name and subscript combination is found multiple times
- The sample ID is invalid
Sourcepub fn extract_named_functions(
&self,
name: &str,
sample_id: SampleID,
) -> Result<BTreeMap<Vec<i64>, f64>, SampleSetError>
pub fn extract_named_functions( &self, name: &str, sample_id: SampleID, ) -> Result<BTreeMap<Vec<i64>, f64>, SampleSetError>
Extract named function values for a given name and sample ID
Returns a map from subscripts to values for the specified sample.
Note: Parameters in named function are ignored. Only subscripts are used as keys.
§Errors
Returns an error if:
- The same name and subscript combination is found multiple times
- The sample ID is invalid
- No named function with the given name is found
Source§impl SampleSet
impl SampleSet
pub fn to_v1_bytes(&self) -> Vec<u8> ⓘ
pub fn to_v2_bytes(&self) -> Vec<u8> ⓘ
pub fn from_v1_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_v2_bytes(bytes: &[u8]) -> Result<Self>
Source§impl SampleSet
impl SampleSet
pub fn objectives(&self) -> &Sampled<f64>
pub fn constraints(&self) -> &SampledCollection<Constraint>
pub fn indicator_constraints(&self) -> &SampledCollection<IndicatorConstraint>
pub fn one_hot_constraints(&self) -> &SampledCollection<OneHotConstraint>
pub fn sos1_constraints(&self) -> &SampledCollection<Sos1Constraint>
pub fn sense(&self) -> &Sense
pub fn feasible(&self) -> &BTreeMap<SampleID, bool>
pub fn feasible_relaxed(&self) -> &BTreeMap<SampleID, bool>
Source§impl SampleSet
impl SampleSet
Sourcepub fn new(
decision_variables: BTreeMap<VariableID, SampledDecisionVariable>,
objectives: Sampled<f64>,
constraints: BTreeMap<ConstraintID, SampledConstraint>,
sense: Sense,
) -> Result<Self, SampleSetError>
👎Deprecated since 2.5.0: Use SampleSet::builder().build() for construction with named_functions support
pub fn new( decision_variables: BTreeMap<VariableID, SampledDecisionVariable>, objectives: Sampled<f64>, constraints: BTreeMap<ConstraintID, SampledConstraint>, sense: Sense, ) -> Result<Self, SampleSetError>
Use SampleSet::builder().build() for construction with named_functions support
Create a new SampleSet
§Deprecated
This constructor does not support named functions.
Use SampleSetBuilder::build for full functionality.
Sourcepub fn named_function_table(&self) -> &NamedFunctionTable<SampledNamedFunction>
pub fn named_function_table(&self) -> &NamedFunctionTable<SampledNamedFunction>
Access sampled named-function rows plus their modeling labels.
Sourcepub fn named_functions(
&self,
) -> &BTreeMap<NamedFunctionID, SampledNamedFunction>
pub fn named_functions( &self, ) -> &BTreeMap<NamedFunctionID, SampledNamedFunction>
Access sampled named-function row payloads keyed by table-owned IDs.
Sourcepub fn named_function_labels(&self) -> &NamedFunctionLabelStore
pub fn named_function_labels(&self) -> &NamedFunctionLabelStore
Access the per-named-function modeling-label store.
Sourcepub fn decision_variable_table(&self) -> &SampledDecisionVariableTable
pub fn decision_variable_table(&self) -> &SampledDecisionVariableTable
Access sampled decision-variable rows plus their modeling labels.
Sourcepub fn decision_variables(
&self,
) -> &BTreeMap<VariableID, SampledDecisionVariable>
pub fn decision_variables( &self, ) -> &BTreeMap<VariableID, SampledDecisionVariable>
Access sampled decision-variable rows keyed by table-owned IDs.
Sourcepub fn variable_labels(&self) -> &VariableLabelStore
pub fn variable_labels(&self) -> &VariableLabelStore
Access the per-variable modeling-label store.
Sourcepub fn sample_ids(&self) -> SampleIDSet
pub fn sample_ids(&self) -> SampleIDSet
Get sample IDs available in this sample set
pub fn feasible_ids(&self) -> SampleIDSet
pub fn feasible_relaxed_ids(&self) -> SampleIDSet
pub fn feasible_unrelaxed_ids(&self) -> SampleIDSet
Sourcepub fn is_sample_feasible(&self, sample_id: SampleID) -> Option<bool>
pub fn is_sample_feasible(&self, sample_id: SampleID) -> Option<bool>
Check if a specific sample is feasible.
Returns None if sample_id is not in this sample set.
Sourcepub fn is_sample_feasible_relaxed(&self, sample_id: SampleID) -> Option<bool>
pub fn is_sample_feasible_relaxed(&self, sample_id: SampleID) -> Option<bool>
Check if a specific sample is feasible in the relaxed problem.
Returns None if sample_id is not in this sample set.
Sourcepub fn get(&self, sample_id: SampleID) -> Option<Solution>
pub fn get(&self, sample_id: SampleID) -> Option<Solution>
Get a specific solution by sample ID.
Returns None if sample_id is not in this sample set.
pub fn best_feasible_id(&self) -> Result<SampleID, SampleSetError>
pub fn best_feasible_relaxed_id(&self) -> Result<SampleID, SampleSetError>
Sourcepub fn best_feasible(&self) -> Result<Solution, SampleSetError>
pub fn best_feasible(&self) -> Result<Solution, SampleSetError>
Get the best feasible solution
pub fn best_feasible_relaxed(&self) -> Result<Solution, SampleSetError>
Sourcepub fn builder() -> SampleSetBuilder
pub fn builder() -> SampleSetBuilder
Creates a new SampleSetBuilder.
Trait Implementations§
Source§impl FlatAnnotations for SampleSet
impl FlatAnnotations for SampleSet
Source§impl From<SampleSet> for SampleSet
Lossy: v1::SampleSet only has a constraints field for regular
sampled constraints — it has no fields for indicator / one-hot / sos1
sampled constraints, so any data the in-memory SampleSet holds in
those collections is dropped on serialization. This is a wire-format
limitation that pre-dates the label/context SoA refactor; the matching
Parse impl above initializes those collections to
Default::default() for symmetry. Round-trip through to_v1_bytes /
from_v1_bytes preserves variable labels and regular-constraint context.
impl From<SampleSet> for SampleSet
Lossy: v1::SampleSet only has a constraints field for regular
sampled constraints — it has no fields for indicator / one-hot / sos1
sampled constraints, so any data the in-memory SampleSet holds in
those collections is dropped on serialization. This is a wire-format
limitation that pre-dates the label/context SoA refactor; the matching
Parse impl above initializes those collections to
Default::default() for symmetry. Round-trip through to_v1_bytes /
from_v1_bytes preserves variable labels and regular-constraint context.
Auto Trait Implementations§
impl Freeze for SampleSet
impl RefUnwindSafe for SampleSet
impl Send for SampleSet
impl Sync for SampleSet
impl Unpin for SampleSet
impl UnsafeUnpin for SampleSet
impl UnwindSafe for SampleSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more