Skip to content

Commit 7382c45

Browse files
authored
Merge pull request #93 from hdavid16/abstract-model
2 parents 08878e3 + 1e6dbe2 commit 7382c45

26 files changed

+1345
-798
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Logical variables are JuMP `AbstractVariable`s with two fields: `fix_value` and
5959

6060
Two types of logical constraints are supported:
6161

62-
1. `Selector` or cardinality constraints: A subset of Logical variables is passed and `Exactly`, `AtMost`, or `AtLeast` `n` of these is allowed to be `True`. These constraints are specified with the `func` $\in$ `set` notation in `MathOptInterface` in a `@constraint` JuMP macro. It is not assumed that disjunctions have an `Exactly(1)` constraint enforced on their disjuncts upon creation. This constraint must be explicitly specified.
62+
1. `Selector` or cardinality constraints: A subset of Logical variables is passed and `Exactly`, `AtMost`, or `AtLeast` `n` of these is allowed to be `true`. These constraints are specified with the `func` $\in$ `set` notation in `MathOptInterface` in a `@constraint` JuMP macro. It is not assumed that disjunctions have an `Exactly(1)` constraint enforced on their disjuncts upon creation. This constraint must be explicitly specified.
6363

6464
```julia
6565
@constraint(model, [Y[1], Y[2]] in Exactly(1))
@@ -117,12 +117,10 @@ The following reformulation methods are currently supported:
117117

118118
- `value`: Big-M value to use. Default: `1e9`. Big-M values are currently global to the model. Constraint specific Big-M values can be supported in future releases.
119119
- `tighten`: Boolean indicating if tightening the Big-M value should be attempted (currently supported only for linear disjunct constraints when variable bounds have been set or specified in the `variable_bounds` field). Default: `true`.
120-
- `variable_bounds`: Dictionary specifying the lower and upper bounds for each `VariableRef` (e.g., `Dict(x => (lb, ub))`). Default: populate when calling the reformulation method.
121120

122121
2. [Hull](https://optimization.cbe.cornell.edu/index.php?title=Disjunctive_inequalities#Convex-Hull_Reformulation[1][2]): The `Hull` struct is created with the following optional arguments:
123122

124123
- `value`: `ϵ` value to use when reformulating quadratic or nonlinear constraints via the perspective function proposed by [Furman, et al. [2020]](https://link.springer.com/article/10.1007/s10589-020-00176-0). Default: `1e-6`. `ϵ` values are currently global to the model. Constraint specific tolerances can be supported in future releases.
125-
- `variable_bounds`: Dictionary specifying the lower and upper bounds for each `VariableRef` (e.g., `Dict(x => (lb, ub))`). Default: populate when calling the reformulation method.
126124

127125
3. [Indicator](https://jump.dev/JuMP.jl/stable/manual/constraints/#Indicator-constraints): This method reformulates each disjunct constraint into an indicator constraint with the Boolean reformulation counterpart of the Logical variable used to define the disjunct constraint.
128126

@@ -154,7 +152,7 @@ print(m)
154152
# x[2] ≤ 20
155153
156154
##
157-
optimize!(m, method = BigM(100, false)) #specify M value and disable M-tightening
155+
optimize!(m, gdp_method = BigM(100, false)) #specify M value and disable M-tightening
158156
print(m)
159157
# Max x[1] + x[2]
160158
# Subject to
@@ -175,7 +173,7 @@ print(m)
175173
# Y[2] binary
176174
177175
##
178-
optimize!(m, method = Hull())
176+
optimize!(m, gdp_method = Hull())
179177
print(m)
180178
# Max x[1] + x[2]
181179
# Subject to

docs/src/index.md

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pkg.add("DisjunctiveProgramming")
1616

1717
## Model
1818

19-
A generalized disjunctive programming (GDP) model is created using `GDPModel()`, where the optimizer can be passed at model creation, along with other keyword arguments supported by JuMP Models.
19+
A generalized disjunctive programming (GDP) model is created using [`GDPModel`](@ref), where the optimizer can be passed at model creation, along with other keyword arguments supported by JuMP Models.
2020

2121
```julia
2222
using DisjunctiveProgramming
@@ -25,13 +25,13 @@ using HiGHS
2525
model = GDPModel(HiGHS.Optimizer)
2626
```
2727

28-
A `GDPModel` is a `JuMP Model` with a `GDPData` field in the model's `.ext` dictionary, which stores the following:
28+
A [`GDPModel`](@ref) is a `JuMP Model` with a [`GDPData`](@ref) field in the model's `.ext` dictionary, which stores the following:
2929

3030
- `Logical Variables`: Indicator variables used for the various disjuncts involved in the model's disjunctions.
3131
- `Logical Constraints`: Selector (cardinality) or proposition (Boolean) constraints describing the relationships between the logical variables.
3232
- `Disjunct Constraints`: Constraints associated with each disjunct in the model.
3333
- `Disjunctions`: Disjunction constraints.
34-
- `Solution Method`: The reformulation technique or solution method. Currently supported methods include Big-M, Hull, and Indicator Constraints.
34+
- `Solution Method`: The reformulation technique or solution method. Currently, supported methods include Big-M, Hull, and Indicator Constraints.
3535
- `Reformulation Variables`: List of JuMP variables created when reformulating a GDP model into a MIP model.
3636
- `Reformulation Constraints`: List of constraints created when reformulating a GDP model into a MIP model.
3737
- `Ready to Optimize`: Flag indicating if the model can be optimized.
@@ -49,7 +49,7 @@ data = gdp_data(model)
4949

5050
## Logical Variables
5151

52-
Logical variables are JuMP `AbstractVariable`s with two fields: `fix_value` and `start_value`. These can be optionally specified at variable creation. Logical variables are created with the `@variable` JuMP macro by adding the tag `Logical` as the last keyword argument. As with the regular `@variable` macro, variables can be named and indexed:
52+
Logical variables are JuMP `AbstractVariable`s with two fields: `fix_value` and `start_value`. These can be optionally specified at variable creation. Logical variables are created with the `@variable` JuMP macro by adding the tag [`Logical`](@ref) as the last keyword argument. As with the regular `@variable` macro, variables can be named and indexed:
5353

5454
```julia
5555
@variable(model, Y[1:3], Logical)
@@ -59,7 +59,7 @@ Logical variables are JuMP `AbstractVariable`s with two fields: `fix_value` and
5959

6060
Two types of logical constraints are supported:
6161

62-
1. `Selector` or cardinality constraints: A subset of Logical variables is passed and `Exactly`, `AtMost`, or `AtLeast` `n` of these is allowed to be `True`. These constraints are specified with the `func` $\in$ `set` notation in `MathOptInterface` in a `@constraint` JuMP macro. It is not assumed that disjunctions have an `Exactly(1)` constraint enforced on their disjuncts upon creation. This constraint must be explicitly specified.
62+
1. `Selector` or cardinality constraints: A subset of Logical variables is passed and [`Exactly`](@ref), [`AtMost`](@ref), or [`AtLeast`](@ref) `n` of these is allowed to be `true`. These constraints are specified with the `func` $\in$ `set` notation in `MathOptInterface` in a `@constraint` JuMP macro. It is not assumed that disjunctions have an `Exactly(1)` constraint enforced on their disjuncts upon creation. This constraint must be explicitly specified.
6363

6464
```julia
6565
@constraint(model, [Y[1], Y[2]] in Exactly(1))
@@ -73,33 +73,33 @@ Two types of logical constraints are supported:
7373
- `` of `implies` (Implication, typed with `\Longrightarrow + tab`).
7474
- `` or `iff` or `==` (double implication or equivalence, typed with `\Leftrightarrow + tab`).
7575

76-
The `@constraint` JuMP macro is used to create these constraints with `:=`:
76+
The `@constraint` JuMP macro is used to create these constraints with `:=`:
7777

78-
```julia
79-
@constraint(model, Y[1] ⟹ Y[2] := true)
80-
```
78+
```julia
79+
@constraint(model, Y[1] ⟹ Y[2] := true)
80+
```
8181

82-
_Note_: The parenthesis in the example above around the implication clause are only required when the parent logical operator is `` or `` to avoid parsing errors.
82+
_Note_: The parenthesis in the example above around the implication clause are only required when the parent logical operator is `` or `` to avoid parsing errors.
8383

84-
Logical propositions can be reformulated to IP constraints by automatic reformulation to [Conjunctive Normal Form](https://en.wikipedia.org/wiki/Conjunctive_normal_form).
84+
Logical propositions can be reformulated to IP constraints by automatic reformulation to [Conjunctive Normal Form](https://en.wikipedia.org/wiki/Conjunctive_normal_form).
8585

8686
## Disjunctions
8787

88-
Disjunctions are built by first defining the constraints associated with each disjunct. This is done via the `@constraint` JuMP macro with the extra `Disjunct` tag specifying the Logical variable associated with the constraint:
88+
Disjunctions are built by first defining the constraints associated with each disjunct. This is done via the `@constraint` JuMP macro with the extra [`Disjunct`](@ref) tag specifying the Logical variable associated with the constraint:
8989

9090
```julia
9191
@variable(model, x)
9292
@constraint(model, x ≤ 100, Disjunct(Y[1]))
9393
@constraint(model, x ≥ 200, Disjunct(Y[2]))
9494
```
9595

96-
After all disjunct constraints associated with a disjunction have been defined, the disjunction is created with the `@disjunction` macro, where the disjunction is defined as a `Vector` of Logical variables associated with each disjunct:
96+
After all disjunct constraints associated with a disjunction have been defined, the disjunction is created with the [`@disjunction`](@ref) macro, where the disjunction is defined as a `Vector` of Logical variables associated with each disjunct:
9797

9898
```julia
9999
@disjunction(model, [Y[1], Y[2]])
100100
```
101101

102-
Disjunctions can be nested by passing an additional `Disjunct` tag. The Logical variable in the `Disjunct` tag specifies which disjunct, the nested disjunction belongs to:
102+
Disjunctions can be nested by passing an additional [`Disjunct`](@ref) tag. The Logical variable in the `Disjunct` tag specifies which disjunct, the nested disjunction belongs to:
103103

104104
```julia
105105
@disjunction(model, Y[1:2], Disjunct(Y[3]))
@@ -113,18 +113,11 @@ For convenience, the `Exactly(1)` selector constraint is added by default when a
113113

114114
The following reformulation methods are currently supported:
115115

116-
1. [Big-M](https://optimization.cbe.cornell.edu/index.php?title=Disjunctive_inequalities#Big-M_Reformulation[1][2]): The `BigM` struct is created with the following optional arguments:
117-
118-
- `value`: Big-M value to use. Default: `1e9`. Big-M values are currently global to the model. Constraint specific Big-M values can be supported in future releases.
119-
- `tighten`: Boolean indicating if tightening the Big-M value should be attempted (currently supported only for linear disjunct constraints when variable bounds have been set or specified in the `variable_bounds` field). Default: `true`.
120-
- `variable_bounds`: Dictionary specifying the lower and upper bounds for each `VariableRef` (e.g., `Dict(x => (lb, ub))`). Default: populate when calling the reformulation method.
121-
122-
2. [Hull](https://optimization.cbe.cornell.edu/index.php?title=Disjunctive_inequalities#Convex-Hull_Reformulation[1][2]): The `Hull` struct is created with the following optional arguments:
116+
1. [Big-M](https://optimization.cbe.cornell.edu/index.php?title=Disjunctive_inequalities#Big-M_Reformulation[1][2]): The [`BigM`](@ref) struct is used.
123117

124-
- `value`: `ϵ` value to use when reformulating quadratic or nonlinear constraints via the perspective function proposed by [Furman, et al. [2020]](https://link.springer.com/article/10.1007/s10589-020-00176-0). Default: `1e-6`. `ϵ` values are currently global to the model. Constraint specific tolerances can be supported in future releases.
125-
- `variable_bounds`: Dictionary specifying the lower and upper bounds for each `VariableRef` (e.g., `Dict(x => (lb, ub))`). Default: populate when calling the reformulation method.
118+
2. [Hull](https://optimization.cbe.cornell.edu/index.php?title=Disjunctive_inequalities#Convex-Hull_Reformulation[1][2]): The [`Hull`](@ref) struct is used.
126119

127-
3. [Indicator](https://jump.dev/JuMP.jl/stable/manual/constraints/#Indicator-constraints): This method reformulates each disjunct constraint into an indicator constraint with the Boolean reformulation counterpart of the Logical variable used to define the disjunct constraint.
120+
3. [Indicator](https://jump.dev/JuMP.jl/stable/manual/constraints/#Indicator-constraints): This method reformulates each disjunct constraint into an indicator constraint with the Boolean reformulation counterpart of the Logical variable used to define the disjunct constraint. This is invoked with [`Indicator`](@ref).
128121

129122
## Release Notes
130123

@@ -154,7 +147,7 @@ print(m)
154147
# x[2] ≤ 20
155148
156149
##
157-
optimize!(m, method = BigM(100, false)) #specify M value and disable M-tightening
150+
optimize!(m, gdp_method = BigM(100, false)) #specify M value and disable M-tightening
158151
print(m)
159152
# Max x[1] + x[2]
160153
# Subject to
@@ -175,7 +168,7 @@ print(m)
175168
# Y[2] binary
176169
177170
##
178-
optimize!(m, method = Hull())
171+
optimize!(m, gdp_method = Hull())
179172
print(m)
180173
# Max x[1] + x[2]
181174
# Subject to

examples/ex1.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ print(m)
3636

3737
## BigM reformulation
3838
set_optimizer(m, HiGHS.Optimizer)
39-
optimize!(m, method = BigM())
39+
optimize!(m, gdp_method = BigM())
4040
print(m)
4141
# Max x
4242
# Subject to
@@ -51,7 +51,7 @@ print(m)
5151
# Y[2] binary
5252

5353
## Hull reformulation
54-
optimize!(m, method = Hull())
54+
optimize!(m, gdp_method = Hull())
5555
print(m)
5656
# Max x
5757
# Subject to

examples/ex2.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ print(m)
1818
# x[2] ≤ 20
1919

2020
##
21-
optimize!(m, method = BigM(100, false)) #specify M value and disable M-tightening
21+
optimize!(m, gdp_method = BigM(100, false)) #specify M value and disable M-tightening
2222
print(m)
2323
# Max x[1] + x[2]
2424
# Subject to
@@ -39,7 +39,7 @@ print(m)
3939
# Y[2] binary
4040

4141
##
42-
optimize!(m, method = Hull())
42+
optimize!(m, gdp_method = Hull())
4343
print(m)
4444
# Max x[1] + x[2]
4545
# Subject to

0 commit comments

Comments
 (0)