1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use crate::num::traits::{One, Zero};
use crate::*;
pub trait Number:
Clone
+ Send
+ Sync
+ One
+ Zero
+ std::str::FromStr
+ std::ops::Neg<Output = Self>
+ std::ops::Add<Output = Self>
+ std::ops::Sub<Output = Self>
+ std::ops::Mul<Output = Self>
+ std::ops::Div<Output = Self>
+ std::ops::AddAssign
+ std::ops::SubAssign
+ std::ops::MulAssign
+ std::ops::DivAssign
+ std::cmp::PartialOrd
+ std::fmt::Debug
+ std::fmt::Display
{
fn floor(&self) -> Self;
fn ceil(&self) -> Self;
fn is_integer(&self) -> bool;
}
impl Number for f32 {
fn floor(&self) -> Self {
f32::floor(*self)
}
fn ceil(&self) -> Self {
f32::ceil(*self)
}
fn is_integer(&self) -> bool {
self.fract().abs() <= std::f32::EPSILON
}
}
impl Number for f64 {
fn floor(&self) -> Self {
f64::floor(*self)
}
fn ceil(&self) -> Self {
f64::ceil(*self)
}
fn is_integer(&self) -> bool {
self.fract().abs() <= std::f64::EPSILON
}
}
impl Number for Rational32 {
fn floor(&self) -> Self {
Rational32::floor(self)
}
fn ceil(&self) -> Self {
Rational32::ceil(self)
}
fn is_integer(&self) -> bool {
Rational32::is_integer(self)
}
}
impl Number for Rational64 {
fn floor(&self) -> Self {
Rational64::floor(self)
}
fn ceil(&self) -> Self {
Rational64::ceil(self)
}
fn is_integer(&self) -> bool {
Rational64::is_integer(self)
}
}
impl Number for Rational {
fn floor(&self) -> Self {
Rational::floor(self)
}
fn ceil(&self) -> Self {
Rational::ceil(self)
}
fn is_integer(&self) -> bool {
Rational::is_integer(self)
}
}
impl Number for Ratio<BigInt> {
fn floor(&self) -> Self {
Self::floor(self)
}
fn ceil(&self) -> Self {
Self::ceil(self)
}
fn is_integer(&self) -> bool {
Self::is_integer(self)
}
}
#[derive(Debug, PartialEq)]
pub enum Solution<T> {
Infeasible,
Unbounded,
Optimal(T, Vec<T>),
}
pub enum SolverSettings {
EnableDataParallelism,
}
pub(crate) struct SolverOptions {
pub parallel: bool,
}