cplex_rs/parameters/barrier/
mod.rs1pub mod limits;
2
3use ffi::{
4 CPXPARAM_Barrier_Algorithm, CPXPARAM_Barrier_ColNonzeros, CPXPARAM_Barrier_ConvergeTol,
5 CPXPARAM_Barrier_Crossover, CPXPARAM_Barrier_Display, CPXPARAM_Barrier_QCPConvergeTol,
6 CPXPARAM_Barrier_StartAlg,
7};
8
9use crate::errors::{self, Result};
10use crate::parameters::{private, Parameter, ParameterValue};
11
12impl private::Parameter for Algorithm {}
13impl private::Parameter for ColNonzeros {}
14impl private::Parameter for Crossover {}
15impl private::Parameter for Display {}
16impl private::Parameter for ConvergeTol {}
17impl private::Parameter for QCPConvergeTol {}
18impl private::Parameter for StartAlg {}
19
20#[derive(Copy, Clone, Debug)]
23pub enum Algorithm {
24 Default,
25 InfeasibilityEstimateStart,
26 InfeasibilityConstantStart,
27 StandardBarrier,
28}
29
30impl Parameter for Algorithm {
31 fn value(&self) -> ParameterValue {
32 ParameterValue::Integer(match self {
33 Self::Default => 0,
34 Self::InfeasibilityEstimateStart => 1,
35 Self::InfeasibilityConstantStart => 2,
36 Self::StandardBarrier => 3,
37 })
38 }
39
40 fn id(&self) -> u32 {
41 CPXPARAM_Barrier_Algorithm
42 }
43}
44
45#[derive(Copy, Clone, Debug)]
48pub struct ColNonzeros(u32);
49
50impl Parameter for ColNonzeros {
51 fn value(&self) -> ParameterValue {
52 ParameterValue::Integer(self.0 as i32)
53 }
54
55 fn id(&self) -> u32 {
56 CPXPARAM_Barrier_ColNonzeros
57 }
58}
59
60#[derive(Copy, Clone, Debug)]
63pub enum Crossover {
64 Automatic,
65 PrimalCrossover,
66 DualCrossover,
67}
68
69impl Parameter for Crossover {
70 fn value(&self) -> ParameterValue {
71 ParameterValue::Integer(match self {
72 Self::Automatic => 0,
73 Self::PrimalCrossover => 1,
74 Self::DualCrossover => 2,
75 })
76 }
77
78 fn id(&self) -> u32 {
79 CPXPARAM_Barrier_Crossover
80 }
81}
82
83#[derive(Copy, Clone, Debug)]
86pub enum Display {
87 None,
88 NormalSetupAndIteration,
89 Diagnostic,
90}
91
92impl Parameter for Display {
93 fn value(&self) -> ParameterValue {
94 ParameterValue::Integer(match self {
95 Self::None => 0,
96 Self::NormalSetupAndIteration => 1,
97 Self::Diagnostic => 2,
98 })
99 }
100
101 fn id(&self) -> u32 {
102 CPXPARAM_Barrier_Display
103 }
104}
105
106#[derive(Copy, Clone, Debug)]
109pub struct ConvergeTol(f64);
110
111impl ConvergeTol {
112 pub fn new(value: f64) -> Result<Self> {
113 if value < 0.0 {
114 return Err(errors::Input::from_message(
115 "CPXPARAM_Barrier_ConvergeTol cannot be < 0.0".to_string(),
116 )
117 .into());
118 }
119 Ok(Self(value))
120 }
121}
122
123impl Parameter for ConvergeTol {
124 fn value(&self) -> ParameterValue {
125 ParameterValue::Double(self.0)
126 }
127
128 fn id(&self) -> u32 {
129 CPXPARAM_Barrier_ConvergeTol
130 }
131}
132
133#[derive(Copy, Clone, Debug)]
136pub struct QCPConvergeTol(f64);
137
138impl QCPConvergeTol {
139 pub fn new(value: f64) -> Result<Self> {
140 if value < 0.0 {
141 return Err(errors::Input::from_message(
142 "CPXPARAM_Barrier_QCPConvergeTol cannot be < 0.0".to_string(),
143 )
144 .into());
145 }
146 Ok(Self(value))
147 }
148}
149
150impl Parameter for QCPConvergeTol {
151 fn value(&self) -> ParameterValue {
152 ParameterValue::Double(self.0)
153 }
154
155 fn id(&self) -> u32 {
156 CPXPARAM_Barrier_QCPConvergeTol
157 }
158}
159
160#[derive(Copy, Clone, Debug)]
163pub enum StartAlg {
164 DualIs0,
165 EstimateDual,
166 AverageOfPrimalEstimateDualIs0,
167 AverageOfPrimalEstimateEstimateDual,
168}
169
170impl Parameter for StartAlg {
171 fn value(&self) -> ParameterValue {
172 ParameterValue::Integer(match self {
173 Self::DualIs0 => 1,
174 Self::EstimateDual => 2,
175 Self::AverageOfPrimalEstimateDualIs0 => 3,
176 Self::AverageOfPrimalEstimateEstimateDual => 4,
177 })
178 }
179
180 fn id(&self) -> u32 {
181 CPXPARAM_Barrier_StartAlg
182 }
183}