1use ffi::{CPX_BINARY, CPX_CONTINUOUS, CPX_INTEGER, CPX_SEMICONT, CPX_SEMIINT};
2
3#[derive(Copy, Clone, Debug)]
4pub enum VariableType {
5 Continuous,
6 Binary,
7 Integer,
8 SemiContinuous,
9 SemiInteger,
10}
11
12impl VariableType {
13 pub(crate) fn into_raw(self) -> u8 {
14 match self {
15 VariableType::Continuous => CPX_CONTINUOUS,
16 VariableType::Binary => CPX_BINARY,
17 VariableType::Integer => CPX_INTEGER,
18 VariableType::SemiContinuous => CPX_SEMICONT,
19 VariableType::SemiInteger => CPX_SEMIINT,
20 }
21 }
22}
23
24#[derive(Clone, Debug)]
25pub struct Variable {
26 type_: VariableType,
27 weight: f64,
28 lower_bound: f64,
29 upper_bound: f64,
30 name: String,
31}
32
33impl Variable {
34 pub fn new<S>(ty: VariableType, obj: f64, lb: f64, ub: f64, name: S) -> Variable
35 where
36 String: From<S>,
37 {
38 let name = name.into();
39 Variable {
40 type_: ty,
41 weight: obj,
42 lower_bound: lb,
43 upper_bound: ub,
44 name,
45 }
46 }
47
48 pub fn name(&self) -> &str {
49 &self.name
50 }
51
52 pub fn upper_bound(&self) -> f64 {
53 self.upper_bound
54 }
55
56 pub fn lower_bound(&self) -> f64 {
57 self.lower_bound
58 }
59
60 pub fn weight(&self) -> f64 {
61 self.weight
62 }
63
64 pub fn type_(&self) -> VariableType {
65 self.type_
66 }
67}