pub struct HighsOptions {
pub universal: UniversalOptions,
pub mip_gap: Option<f64>,
pub presolve: Option<HighsPresolve>,
pub method: Option<HighsMethod>,
pub parallel: Option<bool>,
}Available on crate feature
highs only.Expand description
HiGHS-specific solver options.
Fields§
§universal: UniversalOptions§mip_gap: Option<f64>§presolve: Option<HighsPresolve>§method: Option<HighsMethod>§parallel: Option<bool>Implementations§
Source§impl HighsOptions
impl HighsOptions
Sourcepub fn mip_gap(self, gap: f64) -> HighsOptions
pub fn mip_gap(self, gap: f64) -> HighsOptions
Examples found in repository?
examples/lot_sizing.rs (line 98)
55fn main() -> Result<(), Box<dyn std::error::Error>> {
56 const T: usize = 12;
57
58 let demand: [f64; T] =
59 [120.0, 90.0, 80.0, 140.0, 160.0, 200.0, 220.0, 190.0, 150.0, 130.0, 100.0, 170.0];
60 let prod_cost: [f64; T] = [5.0, 5.0, 5.0, 5.5, 6.0, 6.5, 6.5, 6.0, 5.5, 5.0, 5.0, 5.5];
61 let setup_cost = 500.0;
62 let hold_cost = 2.0;
63 let capacity = 300.0;
64 let initial_inventory = 50.0;
65 let safety_stock = 30.0;
66
67 let m = Model::new("lot_sizing");
68 let periods = Set::range(0..T);
69
70 variable!(m, 0.0 <= x[t in periods] <= capacity);
71 variable!(m, h[t in periods] >= 0.0);
72 variable!(m, s[t in periods], Bin);
73
74 constraint!(m, inv_bal0, h[0] - x[0] == initial_inventory - demand[0]);
75 constraint!(m, inv_bal[t in 1..T], h[t] - h[t - 1] - x[t] == -demand[t]);
76 constraint!(m, setup[t in periods], x[t] <= capacity * s[t]);
77 constraint!(m, safety_stock, h[T - 1] >= safety_stock);
78
79 objective!(
80 m,
81 Min,
82 sum!(prod_cost[t] * x[t] + setup_cost * s[t] + hold_cost * h[t] for t in periods)
83 );
84
85 #[cfg(feature = "gurobi")]
86 let result = {
87 let opts = GurobiOptions::default()
88 .time_limit(std::time::Duration::from_secs(60))
89 .mip_gap(1e-4)
90 .verbose(true);
91 Gurobi.solve(&m, &opts)?
92 };
93
94 #[cfg(all(feature = "highs", not(feature = "gurobi")))]
95 let result = {
96 let opts = HighsOptions::default()
97 .time_limit(std::time::Duration::from_secs(60))
98 .mip_gap(1e-4)
99 .verbose(true);
100 Highs.solve(&m, &opts)?
101 };
102
103 println!("\nLot-Sizing Result");
104 println!("Status : {:?}", result.termination);
105 if let Some(obj) = result.objective() {
106 println!("Total cost: {obj:.2}");
107 }
108
109 println!(
110 "\n{:<8} {:>10} {:>10} {:>8} {:>12}",
111 "Period", "Produce", "Inventory", "Active", "Period cost"
112 );
113 println!("{}", "-".repeat(55));
114
115 let mut total_check = 0.0;
116 for t in 0..T {
117 let xt = result.value_of(x[t]).unwrap_or(0.0);
118 let ht = result.value_of(h[t]).unwrap_or(0.0);
119 let st = result.value_of(s[t]).unwrap_or(0.0);
120 let period_cost = prod_cost[t] * xt + setup_cost * st + hold_cost * ht;
121 total_check += period_cost;
122 println!(
123 "{:<8} {:>10.1} {:>10.1} {:>8} {:>12.2}",
124 t + 1,
125 xt,
126 ht,
127 if (st - 1.0).abs() < 1e-6 { "Yes" } else { "No" },
128 period_cost
129 );
130 }
131 println!("{}", "-".repeat(55));
132 println!("{:<8} {:>10} {:>10} {:>8} {:>12.2}", "TOTAL", "", "", "", total_check);
133
134 Ok(())
135}pub fn presolve(self, p: HighsPresolve) -> HighsOptions
pub fn method(self, m: HighsMethod) -> HighsOptions
pub fn parallel(self, on: bool) -> HighsOptions
Trait Implementations§
Source§impl Clone for HighsOptions
impl Clone for HighsOptions
Source§fn clone(&self) -> HighsOptions
fn clone(&self) -> HighsOptions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HighsOptions
impl Debug for HighsOptions
Source§impl Default for HighsOptions
impl Default for HighsOptions
Source§fn default() -> HighsOptions
fn default() -> HighsOptions
Returns the “default value” for a type. Read more
Source§impl HasUniversal for HighsOptions
impl HasUniversal for HighsOptions
fn universal(&self) -> &UniversalOptions
fn universal_mut(&mut self) -> &mut UniversalOptions
Auto Trait Implementations§
impl Freeze for HighsOptions
impl RefUnwindSafe for HighsOptions
impl Send for HighsOptions
impl Sync for HighsOptions
impl Unpin for HighsOptions
impl UnsafeUnpin for HighsOptions
impl UnwindSafe for HighsOptions
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
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>
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 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>
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