-
Notifications
You must be signed in to change notification settings - Fork 6
/
func.jl
65 lines (48 loc) · 1.26 KB
/
func.jl
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
function value_vec(vec_x::Union{Array{VariableRef,1}, VariableRef})
if isa(vec_x, VariableRef)
vec_value = value(vec_x)
else
vec_value = [value(vec_x[i]) for i = 1:length(vec_x)]
end
return vec_value
end
function dual_vec(vec_cons)
return [dual(vec_cons[i]) for i = 1:length(vec_cons)]
end
@enum ColRow begin
row = 1
col = 2
end
function checkColVec(vec::Array{Int64,2}, str_name::String)
if size(vec)[Int(col)] != 1
throw("$str_name is not a column vector")
end
end
function checkMatrixMatch(
len::Float64, array::Array{Int64,2}, whi::ColRow,
str_len::String, str_array::String
)
if size(array)[Int(whi)] != len
throw("The $(str(whi)) of $str_array doesn't match the $str_len.")
end
end
function checkListMatch(
len::Float64, list::Array{Int64,1}, str_len::String, str_list::String,
)
if length(list_1) != length(list_2)
throw("The length of list $str_list doesn't match the $str_len.")
end
end
"""
Solution for Model
"""
mutable struct Sol
obj::Float64
vec_result_x::Array{Float64,2}
vec_result_u::Array{Float64,2}
end
mutable struct SolMix
obj::Float64
vec_result_x::Array{Float64,2}
vec_result_y::Array{Float64,2}
end