Skip to main content

PresolveOptions

Struct PresolveOptions 

Source
pub struct PresolveOptions {
Show 20 fields pub enabled: bool, pub bound_tightening: bool, pub redundant_constraint_removal: bool, pub linear_eq_reduction: bool, pub licq_check: bool, pub print_level: Index, pub max_passes: Index, pub licq_action: LicqAction, pub warm_z_bounds: bool, pub bound_mult_init_val: Number, pub auxiliary: bool, pub auxiliary_tol: Number, pub auxiliary_max_block_dim: Index, pub auxiliary_wall_time_fraction: Number, pub auxiliary_coupling: AuxiliaryCouplingPolicy, pub auxiliary_diagnostics: bool, pub fbbt: bool, pub fbbt_tol: Number, pub fbbt_max_iter: Index, pub fbbt_max_constraints: Index,
}
Expand description

Resolved presolve options, materialised from an OptionsList.

Keeping this as a plain Copy struct makes Phase 0’s no-op path branch-free; later phases that grow more state can promote it to a Clone struct without API churn.

Fields§

§enabled: bool

Master switch (presolve). When false, the wrapper is a no-op and wrap_with_presolve returns the inner TNLP.

§bound_tightening: bool

presolve_bound_tightening — Phase 1.

§redundant_constraint_removal: bool

presolve_redundant_constraint_removal — Phase 2.

§linear_eq_reduction: bool

presolve_linear_eq_reduction — Phase ≥2, off by default.

§licq_check: bool

presolve_licq_check — Phase 3.

§print_level: Index

presolve_print_level — 0 silent, 5 per-pass, 8 per-xform.

§max_passes: Index

presolve_max_passes — fixed-point iteration cap.

§licq_action: LicqAction

presolve_licq_action — what to do on degenerate equality rows. Phase 3 honours auto_l1; Phase 0 just stores it.

§warm_z_bounds: bool

presolve_warm_z_bounds — Phase 4: hint bound-multiplier warm starts for variables whose bounds were tightened.

§bound_mult_init_val: Number

presolve_bound_mult_init_val — value used for those hints.

§auxiliary: bool

presolve_auxiliary — master switch for the Phase-0 auxiliary-equality preprocessing pass (issue #53). When false (the default), Phase 0 is a no-op even if the outer enabled master switch is on.

§auxiliary_tol: Number

presolve_auxiliary_tol — residual tolerance for accepting a candidate block solve (full-space KKT residual after the reduction must stay within this).

§auxiliary_max_block_dim: Index

presolve_auxiliary_max_block_dim — the lightweight Newton solver only handles blocks up to this dimension. PR 11 lifts this by injecting an IPM-backed fallback.

§auxiliary_wall_time_fraction: Number

presolve_auxiliary_wall_time_fraction — fraction of the solver’s overall wall-time budget Phase 0 is allowed to spend.

§auxiliary_coupling: AuxiliaryCouplingPolicy

presolve_auxiliary_coupling — which coupling classes are eligible for elimination.

§auxiliary_diagnostics: bool

presolve_auxiliary_diagnostics — emit the diagnostics struct via the journalist.

§fbbt: bool

presolve_fbbt — Feasibility-Based Bound Tightening over nonlinear constraint expression DAGs (issue #62). Off by default until benchmark evidence justifies a flip.

§fbbt_tol: Number

fbbt_tol — minimum bound improvement to keep iterating.

§fbbt_max_iter: Index

fbbt_max_iter — outer sweep cap.

§fbbt_max_constraints: Index

fbbt_max_constraints — cap on constraints examined per sweep; 0 means unlimited.

Implementations§

Source§

impl PresolveOptions

Source

pub fn defaults() -> Self

All-default settings, matching the registered defaults.

Examples found in repository?
examples/auxiliary_noop.rs (line 84)
78fn main() {
79    let opts = PresolveOptions {
80        enabled: true,
81        auxiliary: true,
82        auxiliary_coupling: AuxiliaryCouplingPolicy::Safe,
83        auxiliary_diagnostics: true,
84        ..PresolveOptions::defaults()
85    };
86    let inner: Rc<RefCell<dyn TNLP>> = Rc::new(RefCell::new(Mini));
87    let wrapped = wrap_with_presolve(inner, opts).expect("wrap ok");
88
89    // Trigger lazy init through any TNLP method.
90    let info = wrapped.borrow_mut().get_nlp_info().expect("get_nlp_info");
91
92    // Force one Jacobian-values call so the example exercises the
93    // forwarding path (the wrapper does not change anything in PR 1).
94    let mut values = vec![0.0; info.nnz_jac_g as usize];
95    let ok = wrapped.borrow_mut().eval_jac_g(
96        Some(&[0.5, 0.5]),
97        true,
98        SparsityRequest::Values {
99            values: &mut values,
100        },
101    );
102    assert!(ok, "eval_jac_g(Values) must succeed");
103
104    // Downcast back to PresolveTnlp via a typed handle would require
105    // a different constructor; instead, build a second wrapper using
106    // PresolveTnlp::new so we can read the diagnostics.
107    let inner2: Rc<RefCell<dyn TNLP>> = Rc::new(RefCell::new(Mini));
108    let mut typed = PresolveTnlp::new(inner2, opts);
109    let _ = typed.get_nlp_info();
110    let d = typed.auxiliary_diagnostics();
111
112    println!("auxiliary_noop example — PR 1 of pounce#53");
113    println!(
114        "inner shape: n={}, m={}, nnz_jac_g={}",
115        info.n, info.m, info.nnz_jac_g
116    );
117    println!("jac values at (0.5, 0.5): {:?}", values);
118    println!(
119        "diagnostics: blocks_eliminated={}, vars_eliminated={}, rows_eliminated={}, total_time_ms={}",
120        d.blocks_eliminated, d.vars_eliminated, d.rows_eliminated, d.total_time_ms,
121    );
122    println!("rejection_reasons: {:?}", d.rejection_reasons);
123}
More examples
Hide additional examples
examples/phase0_via_tnlp.rs (line 128)
121fn main() {
122    let opts = PresolveOptions {
123        enabled: true,
124        auxiliary: true,
125        // Aggressive lets us eliminate even when grad_f is non-zero
126        // at the block variables at the probe (ObjectiveCoupled).
127        auxiliary_coupling: AuxiliaryCouplingPolicy::Aggressive,
128        ..PresolveOptions::defaults()
129    };
130    let inner: Rc<RefCell<dyn TNLP>> = Rc::new(RefCell::new(Mini));
131    let wrapped = wrap_with_presolve(inner, opts).expect("wrap ok");
132
133    let info = wrapped.borrow_mut().get_nlp_info().expect("init");
134    println!("phase0_via_tnlp — PR 8 of pounce#53");
135    println!("====================================");
136    println!("Inner TNLP: n=2, m=2 (two equalities).");
137    println!("After PresolveTnlp wrapping with presolve_auxiliary=yes:");
138    println!("   outer n = {}", info.n);
139    println!("   outer m = {}", info.m);
140    println!("   outer nnz_jac_g = {}", info.nnz_jac_g);
141
142    // Read the clamped bounds.
143    let mut x_l = vec![0.0; info.n as usize];
144    let mut x_u = vec![0.0; info.n as usize];
145    let mut g_l = vec![0.0; info.m as usize];
146    let mut g_u = vec![0.0; info.m as usize];
147    wrapped.borrow_mut().get_bounds_info(BoundsInfo {
148        x_l: &mut x_l,
149        x_u: &mut x_u,
150        g_l: &mut g_l,
151        g_u: &mut g_u,
152    });
153    println!("\nClamped bounds (from PresolveTnlp):");
154    println!("   x_l = {:?}", x_l);
155    println!("   x_u = {:?}", x_u);
156    println!("   g_l = {:?}", g_l);
157
158    // Simulate the IPM handing back a solution: the eliminated vars
159    // are pinned to their clamps; outer lambda is empty (no rows).
160    let sol_x = [x_l[0], x_l[1]];
161    let sol_z_l = vec![0.0; info.n as usize];
162    let sol_z_u = vec![0.0; info.n as usize];
163    let sol_lambda: Vec<Number> = Vec::new(); // outer m == 0
164    let sol_g: Vec<Number> = Vec::new();
165    let ip_data = IpoptData::default();
166    let ip_cq = IpoptCq::default();
167    wrapped.borrow_mut().finalize_solution(
168        Solution {
169            status: SolverReturn::Success,
170            x: &sol_x,
171            z_l: &sol_z_l,
172            z_u: &sol_z_u,
173            g: &sol_g,
174            lambda: &sol_lambda,
175            obj_value: 0.0,
176        },
177        &ip_data,
178        &ip_cq,
179    );
180
181    println!("\n✓ End-to-end orchestrator path exercised.");
182}
Source

pub fn from_options_list(opts: &OptionsList) -> Result<Self, SolverException>

Read every presolve_* key out of an OptionsList, falling back to registered defaults where unset.

Trait Implementations§

Source§

impl Clone for PresolveOptions

Source§

fn clone(&self) -> PresolveOptions

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 PresolveOptions

Source§

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

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

impl Copy for PresolveOptions

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> 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<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