Skip to main content

SampleSet

Struct SampleSet 

Source
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_variables owns a SampledDecisionVariableTable; table keys own VariableID and sampled decision-variable rows do not carry IDs.
  • The decision-variable table rejects modeling labels for unknown variable IDs.
  • Self::named_functions is keyed by the table-owned NamedFunctionID; sampled named-function rows do not carry IDs.
  • All Self::decision_variables, Self::objectives, sampled constraint collections, and Self::named_functions have the same sample ID set.
  • Self::decision_variables contains all variable IDs referenced in used_decision_variable_ids of 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, and active_variable values must belong to their structural variable set.
  • Sampled special-constraint stage fields are consistent with Self::decision_variables: indicator_active reflects the indicator variable values, and one-hot/SOS1 active_variable plus feasible reflect the structural variable values under feasibility_atol.
  • Self::feasible and Self::feasible_relaxed are 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_atol is the absolute tolerance used to validate serialized per-constraint feasibility columns and to interpret per-sample Solution values 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

Source

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.

Source

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.

Source

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
Source

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
Source

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

Source

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
Source

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

Source

pub fn to_v1_bytes(&self) -> Vec<u8>

Source

pub fn to_v2_bytes(&self) -> Vec<u8>

Source

pub fn from_v1_bytes(bytes: &[u8]) -> Result<Self>

Source

pub fn from_v2_bytes(bytes: &[u8]) -> Result<Self>

Source§

impl SampleSet

Source§

impl SampleSet

Source

pub 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

Create a new SampleSet

§Deprecated

This constructor does not support named functions. Use SampleSetBuilder::build for full functionality.

Source

pub fn named_function_table(&self) -> &NamedFunctionTable<SampledNamedFunction>

Access sampled named-function rows plus their modeling labels.

Source

pub fn named_functions( &self, ) -> &BTreeMap<NamedFunctionID, SampledNamedFunction>

Access sampled named-function row payloads keyed by table-owned IDs.

Source

pub fn named_function_labels(&self) -> &NamedFunctionLabelStore

Access the per-named-function modeling-label store.

Source

pub fn decision_variable_table(&self) -> &SampledDecisionVariableTable

Access sampled decision-variable rows plus their modeling labels.

Source

pub fn decision_variables( &self, ) -> &BTreeMap<VariableID, SampledDecisionVariable>

Access sampled decision-variable rows keyed by table-owned IDs.

Source

pub fn variable_labels(&self) -> &VariableLabelStore

Access the per-variable modeling-label store.

Source

pub fn sample_ids(&self) -> SampleIDSet

Get sample IDs available in this sample set

Source

pub fn feasible_ids(&self) -> SampleIDSet

Source

pub fn feasible_relaxed_ids(&self) -> SampleIDSet

Source

pub fn feasible_unrelaxed_ids(&self) -> SampleIDSet

Source

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.

Source

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.

Source

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.

Source

pub fn best_feasible_id(&self) -> Result<SampleID, SampleSetError>

Source

pub fn best_feasible_relaxed_id(&self) -> Result<SampleID, SampleSetError>

Source

pub fn best_feasible(&self) -> Result<Solution, SampleSetError>

Get the best feasible solution

Source

pub fn best_feasible_relaxed(&self) -> Result<Solution, SampleSetError>

Source

pub fn builder() -> SampleSetBuilder

Creates a new SampleSetBuilder.

Trait Implementations§

Source§

impl Clone for SampleSet

Source§

fn clone(&self) -> SampleSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SampleSet

Source§

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

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

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.

Source§

fn from(sample_set: SampleSet) -> Self

Converts to this type from the input type.
Source§

impl From<SampleSet> for SampleSet

Source§

fn from(value: SampleSet) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<SampleSet> for SampleSet

Source§

type Error = ParseError

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

fn try_from(value: SampleSet) -> Result<Self, Self::Error>

Performs the conversion.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more