@@ -134,19 +134,28 @@ The example below is from the [Cornell University Computational Optimization Ope
134
134
135
135
``` julia
136
136
using DisjunctiveProgramming
137
+ using HiGHS
137
138
138
- m = GDPModel()
139
+ m = GDPModel(HiGHS.Optimizer )
139
140
@variable(m, 0 ≤ x[1:2] ≤ 20)
140
141
@variable(m, Y[1:2], Logical)
141
142
@constraint(m, [i = 1:2], [2,5][i] ≤ x[i] ≤ [6,9][i], DisjunctConstraint(Y[1]))
142
143
@constraint(m, [i = 1:2], [8,10][i] ≤ x[i] ≤ [11,15][i], DisjunctConstraint(Y[2]))
143
144
@disjunction(m, Y)
144
145
@constraint(m, Y in Exactly(1)) #logical constraint
146
+ @objective(m, Max, sum(x))
147
+ print(m)
148
+ # Max x[1] + x[2]
149
+ # Subject to
150
+ # x[1] ≥ 0
151
+ # x[2] ≥ 0
152
+ # x[1] ≤ 20
153
+ # x[2] ≤ 20
145
154
146
- ## Big-M
147
- reformulate_model (m, BigM(100, false)) #specify M value and disable M-tightening
155
+ ##
156
+ optimize! (m, method = BigM(100, false)) #specify M value and disable M-tightening
148
157
print(m)
149
- # Feasibility
158
+ # Max x[1] + x[2]
150
159
# Subject to
151
160
# Y[1] + Y[2] = 1
152
161
# x[1] - 100 Y[1] ≥ -98
@@ -164,10 +173,10 @@ print(m)
164
173
# Y[1] binary
165
174
# Y[2] binary
166
175
167
- ## Hull
168
- reformulate_model (m, Hull())
176
+ ##
177
+ optimize! (m, method = Hull())
169
178
print(m)
170
- # Feasibility
179
+ # Max x[1] + x[2]
171
180
# Subject to
172
181
# -x[2] + x[2]_Y[1] + x[2]_Y[2] = 0
173
182
# -x[1] + x[1]_Y[1] + x[1]_Y[2] = 0
@@ -202,21 +211,4 @@ print(m)
202
211
# x[1]_Y[2] ≤ 20
203
212
# Y[1] binary
204
213
# Y[2] binary
205
-
206
- ## Indicator
207
- reformulate_model(m, Indicator())
208
- print(m)
209
- # Feasibility
210
- # Subject to
211
- # Y[1] + Y[2] = 1
212
- # x[1] ≥ 0
213
- # x[2] ≥ 0
214
- # x[1] ≤ 20
215
- # x[2] ≤ 20
216
- # Y[1] binary
217
- # Y[2] binary
218
- # Y[1] => {x[1] ∈ [2, 6]}
219
- # Y[1] => {x[2] ∈ [5, 9]}
220
- # Y[2] => {x[1] ∈ [8, 11]}
221
- # Y[2] => {x[2] ∈ [10, 15]}
222
214
```
0 commit comments