-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstant.py
51 lines (40 loc) · 1.19 KB
/
constant.py
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
"""
the Constant Variables.
"""
class ConstantSet(object):
"""
The class of constant number.
It doesn't follow the Pascal format since its speciality.
"""
class ConstError(TypeError):
pass
class ConstCaseError(ConstError):
pass
def __setattr__(self, key, value):
if key in self.__dict__:
raise self.ConstError("Can't change const.{0}".format(key))
if not key.isupper():
raise self.ConstCaseError("Const name {0} is not all uppercase".format(key))
self.__dict__[key] = value
const = ConstantSet()
# the category of decision variables
const.CAT_BINARY = "Binary"
const.CAT_CONTINUOUS = "Continuous"
const.CAT_INTEGER = "Integer"
# sense for a constrain
const.SENSE_LEQ = "<="
const.SENSE_EQ = "="
const.SENSE_GEQ = ">="
# sense for a model
const.SENSE_MAX = "Max"
const.SENSE_MIN = "Min"
# the lower and upper bound type of a variable
const.BOUND_TWO_OPEN = 0
const.BOUND_LEFT_OPEN = 1
const.BOUND_RIGHT_OPEN = 2
const.BOUND_TWO_CLOSED = 3
# the status of the model
const.STATUS_UNSOLVED = "Unsolved"
const.STATUS_OPTIMAL = "Optimal"
const.STATUS_NO_SOLUTION = "No feasible solution"
const.STATUS_UNBOUNDED = "Unbounded"