Skip to content

Commit f736ccb

Browse files
authored
Merge pull request #1 from Robbybp/no-submodule
Stop using submodules
2 parents a16c2b6 + 9d8384f commit f736ccb

11 files changed

+118
-168
lines changed

docs/src/reference/get_equality.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# GetEquality
1+
# Identifying equality constraints
22

33
```@meta
44
CurrentModule = JuMPIn
55
```
66

77
```@docs
8-
GetEquality
9-
GetEquality.get_equality_constraints
10-
GetEquality.is_equality
11-
GetEquality.set_implies_equality
8+
get_equality_constraints
9+
is_equality
10+
set_implies_equality
1211
```
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# IdentifyVariables
1+
# Identifying variables in constraints
22

33
```@meta
44
CurrentModule = JuMPIn
55
```
66

77
```@docs
8-
IdentifyVariables
9-
IdentifyVariables.identify_unique_variables
10-
IdentifyVariables._get_variable_terms
8+
identify_unique_variables
9+
_get_variable_terms
1110
```
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
# IncidenceGraph
1+
# Incidence graph
22

33
```@meta
44
CurrentModule = JuMPIn
55
```
66

77
```@docs
8-
IncidenceGraph
9-
IncidenceGraph.get_bipartite_incidence_graph
8+
get_bipartite_incidence_graph
109
```

docs/src/reference/interface.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
# Interface
1+
# Algorithm interfaces
22

33
```@meta
44
CurrentModule = JuMPIn
55
```
66

77
```@docs
8-
Interface
9-
Interface.IncidenceGraphInterface
10-
Interface.get_adjacent
11-
Interface.maximum_matching
12-
Interface.dulmage_mendelsohn
8+
IncidenceGraphInterface
9+
get_adjacent
10+
maximum_matching
11+
dulmage_mendelsohn
1312
```

src/JuMPIn.jl

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,19 @@
1818
# ___________________________________________________________________________
1919

2020
module JuMPIn
21-
# TODO: Explicitly export functions?
22-
23-
# Methods to identify variables
24-
include("identify_variables.jl") # IdentifyVariables
25-
identify_unique_variables = IdentifyVariables.identify_unique_variables
2621

2722
# Methods to identify equality constraints
28-
include("get_equality.jl") # GetEquality
29-
get_equality_constraints = GetEquality.get_equality_constraints
23+
include("get_equality.jl")
24+
25+
# Methods to identify variables
26+
include("identify_variables.jl")
3027

3128
# Methods to get the incidence graph of constraints and variables
32-
include("incidence_graph.jl") # IncidenceGraph
33-
get_bipartite_incidence_graph = IncidenceGraph.get_bipartite_incidence_graph
29+
include("incidence_graph.jl")
3430

3531
# Methods to apply graph algorithms to JuMP models
36-
include("interface.jl") # Interface
37-
IncidenceGraphInterface = Interface.IncidenceGraphInterface
38-
get_adjacent = Interface.get_adjacent
39-
maximum_matching = Interface.maximum_matching
40-
dulmage_mendelsohn = Interface.dulmage_mendelsohn
32+
include("maximum_matching.jl")
33+
include("dulmage_mendelsohn.jl")
34+
include("interface.jl")
4135

4236
end

src/dulmage_mendelsohn.jl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
# This software is distributed under the 3-clause BSD license.
1818
# ___________________________________________________________________________
1919

20-
module DulmageMendelsohn
21-
2220
import Graphs as gjl
23-
include("maximum_matching.jl") # MaximumMatching
24-
using .MaximumMatching: _is_valid_bipartition, maximum_matching
21+
22+
import JuMPIn: maximum_matching, _is_valid_bipartition
2523

2624

2725
"""
@@ -155,5 +153,3 @@ function dulmage_mendelsohn(graph::gjl.Graph, set1::Set)
155153
other2,
156154
))
157155
end
158-
159-
end

src/get_equality.jl

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,50 +21,50 @@
2121
Utility functions for identifying JuMP constraints that define equalities.
2222
2323
"""
24-
module GetEquality
25-
import JuMP as jmp
26-
import MathOptInterface as moi
27-
28-
function get_set_of_constraint(
29-
model::jmp.Model,
30-
constraint::jmp.ConstraintRef,
31-
index::moi.ConstraintIndex,
24+
25+
import JuMP
26+
import MathOptInterface as MOI
27+
28+
function _get_set_of_constraint(
29+
model::JuMP.Model,
30+
constraint::JuMP.ConstraintRef,
31+
index::MOI.ConstraintIndex,
3232
)
33-
set = moi.get(model, moi.ConstraintSet(), constraint)
33+
set = MOI.get(model, MOI.ConstraintSet(), constraint)
3434
return set
3535
end
3636

37-
function get_set_of_constraint(
38-
model::jmp.Model,
39-
constraint::jmp.ConstraintRef,
40-
index::moi.Nonlinear.ConstraintIndex,
37+
function _get_set_of_constraint(
38+
model::JuMP.Model,
39+
constraint::JuMP.ConstraintRef,
40+
index::MOI.Nonlinear.ConstraintIndex,
4141
)
4242
nl_con = model.nlp_model.constraints[index]
4343
return nl_con.set
4444
end
4545

46-
function set_implies_equality(set::moi.EqualTo)::Bool
46+
function set_implies_equality(set::MOI.EqualTo)::Bool
4747
return true
4848
end
4949

5050
# Q: How does Julia determine if an argument has the right type.
5151
# I.e. why is this interpreted as "set must be a subtype of Union(...)"
5252
# rather than "set must be an 'instance' of Union()".
5353
#function set_implies_equality(
54-
# set::Union{moi.GreaterThan, moi.LessThan},
54+
# set::Union{MOI.GreaterThan, MOI.LessThan},
5555
# # Note that ^this works, but this doesn't
56-
# # set::Type{<:Union{moi.GreaterThan, moi.LessThan}},
56+
# # set::Type{<:Union{MOI.GreaterThan, MOI.LessThan}},
5757
#)::Bool
5858
# return false
5959
#end
6060

61-
function set_implies_equality(set::T)::Bool where T<:moi.AbstractVectorSet
62-
throw(TypeError(set, moi.AbstractScalarSet, typeof(set)))
61+
function set_implies_equality(set::T)::Bool where T<:MOI.AbstractVectorSet
62+
throw(TypeError(set, MOI.AbstractScalarSet, typeof(set)))
6363
end
6464

6565
# NOTE: Have not implemented tolerance arg in any calling function yet.
6666
function set_implies_equality(
67-
set::moi.Interval,
67+
set::MOI.Interval,
6868
tolerance::Float64=Float64(0)
6969
)::Bool
7070
return abs(set.upper - set.lower) <= tolerance
@@ -75,9 +75,9 @@ end
7575
#
7676
# I intend this to catch anything that is a subtype of ConstraintSet.
7777
# Is the "subtype syntax" necessary?
78-
# It appears, e.g., moi.GreaterThan is not a subtype of moi.ConstraintSet.
78+
# It appears, e.g., MOI.GreaterThan is not a subtype of MOI.ConstraintSet.
7979
# This is non-intuitive for me...
80-
# So this won't catch arbitrary moi Sets...
80+
# So this won't catch arbitrary MOI Sets...
8181
# The right type to use is actually AbstractSet?
8282
# Nope. This doesn't catch GreatherThan/LessThan
8383
# ^ Wrong. Actually it does, but my syntax was wrong. I guess providing
@@ -103,7 +103,7 @@ types of constraints in [`is_equality`](@ref) and
103103
"""
104104
function set_implies_equality(
105105
set::T
106-
)::Bool where T<:moi.AbstractSet
106+
)::Bool where T<:MOI.AbstractSet
107107
return false
108108
end
109109

@@ -113,17 +113,17 @@ end
113113
Detect whether a constraint is an equality constraint.
114114
115115
"""
116-
function is_equality(constraint::jmp.ConstraintRef)::Bool
116+
function is_equality(constraint::JuMP.ConstraintRef)::Bool
117117
model = constraint.model
118118
index = constraint.index
119-
set = get_set_of_constraint(model, constraint, index)
119+
set = _get_set_of_constraint(model, constraint, index)
120120
return set_implies_equality(set)
121121
end
122122

123123
function get_equality_constraints(
124-
constraints::Vector{jmp.ConstraintRef}
125-
)::Vector{jmp.ConstraintRef}
126-
eq_cons = Vector{jmp.ConstraintRef}()
124+
constraints::Vector{JuMP.ConstraintRef}
125+
)::Vector{JuMP.ConstraintRef}
126+
eq_cons = Vector{JuMP.ConstraintRef}()
127127
for con in constraints
128128
if is_equality(con)
129129
push!(eq_cons, con)
@@ -137,8 +137,6 @@ end
137137
138138
Return a vector of equality constraints in the provided model.
139139
140-
This function is also accessible via the `JuMPIn` module.
141-
142140
# Example
143141
```julia-repl
144142
julia> using JuMP
@@ -153,12 +151,10 @@ julia> display(eq_cons)
153151
```
154152
155153
"""
156-
function get_equality_constraints(model::jmp.Model)::Vector{jmp.ConstraintRef}
157-
constraints = jmp.all_constraints(
154+
function get_equality_constraints(model::JuMP.Model)::Vector{JuMP.ConstraintRef}
155+
constraints = JuMP.all_constraints(
158156
model,
159157
include_variable_in_set_constraints=false,
160158
)
161159
return get_equality_constraints(constraints)
162160
end
163-
164-
end # module get_equality

0 commit comments

Comments
 (0)