Skip to main content

ResolvedGenericConstraintBounds

Struct ResolvedGenericConstraintBounds 

Source
pub struct ResolvedGenericConstraintBounds { /* private fields */ }
Expand description

Pre-resolved RHS bound table for user-defined generic linear constraints.

Sparse (constraint_index, stage_id) index with O(1) lookup. Absent pairs report is_active false and bounds_for_stage empty — no panic.

§Examples

use cobre_core::ResolvedGenericConstraintBounds;

let empty = ResolvedGenericConstraintBounds::empty();
assert!(!empty.is_active(0, 0));
assert!(empty.bounds_for_stage(0, 0).is_empty());

Implementations§

Source§

impl ResolvedGenericConstraintBounds

Source

pub fn empty() -> Self

Return an empty table with no constraints and no bounds.

The default value in System when no generic constraints are loaded; all queries return false / empty slices.

§Examples
use cobre_core::ResolvedGenericConstraintBounds;

let t = ResolvedGenericConstraintBounds::empty();
assert!(!t.is_active(0, 0));
assert!(t.bounds_for_stage(99, 5).is_empty());
Source

pub fn new<I>(constraint_id_to_idx: &HashMap<i32, usize>, raw_bounds: I) -> Self
where I: Iterator<Item = (i32, i32, Option<i32>, Option<f64>, Option<f64>)>,

Build a resolved table from sorted bound rows.

constraint_id_to_idx maps domain constraint_id: i32 to positional index; rows with an absent constraint_id are silently skipped (caught upstream by referential validation). raw_bounds must be sorted by (constraint_id, stage_id, block_id) ascending — the grouping into contiguous ranges relies on it.

§Examples
use std::collections::HashMap;
use cobre_core::ResolvedGenericConstraintBounds;

// Two constraints with IDs 10 and 20, mapped to positions 0 and 1.
let id_map: HashMap<i32, usize> = [(10, 0), (20, 1)].into_iter().collect();

// One bound row: constraint 10 at stage 3, block_id = None, bound_lower = 500.0,
// bound_upper = None.
let rows = vec![(10i32, 3i32, None::<i32>, Some(500.0f64), None::<f64>)];

let table = ResolvedGenericConstraintBounds::new(
    &id_map,
    rows.iter().map(|(cid, sid, bid, bl, bu)| (*cid, *sid, *bid, *bl, *bu)),
);

assert!(table.is_active(0, 3));
assert!(!table.is_active(1, 3));

let slice = table.bounds_for_stage(0, 3);
assert_eq!(slice.len(), 1);
assert_eq!(slice[0].block_id, None);
assert_eq!(slice[0].bound_lower, Some(500.0));
assert_eq!(slice[0].bound_upper, None);
Source

pub fn is_active(&self, constraint_idx: usize, stage_id: i32) -> bool

Return true if at least one bound entry exists for this constraint at the given stage.

Returns false for any unknown (constraint_idx, stage_id) pair.

§Examples
use cobre_core::ResolvedGenericConstraintBounds;

let empty = ResolvedGenericConstraintBounds::empty();
assert!(!empty.is_active(0, 0));
Source

pub fn bounds_for_stage( &self, constraint_idx: usize, stage_id: i32, ) -> &[GenericConstraintBoundEntry]

Return the bound entries for a constraint at the given stage.

Returns an empty slice when no bounds exist for the (constraint_idx, stage_id) pair.

§Examples
use cobre_core::ResolvedGenericConstraintBounds;

let empty = ResolvedGenericConstraintBounds::empty();
assert!(empty.bounds_for_stage(0, 0).is_empty());

Trait Implementations§

Source§

impl Clone for ResolvedGenericConstraintBounds

Source§

fn clone(&self) -> ResolvedGenericConstraintBounds

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 ResolvedGenericConstraintBounds

Source§

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

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

impl PartialEq for ResolvedGenericConstraintBounds

Source§

fn eq(&self, other: &ResolvedGenericConstraintBounds) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ResolvedGenericConstraintBounds

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.