Skip to content

Commit 91ea54e

Browse files
committed
update example in readme for review
1 parent 24a997e commit 91ea54e

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

README.md

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,28 @@ The example below is from the [Cornell University Computational Optimization Ope
134134

135135
```julia
136136
using DisjunctiveProgramming
137+
using HiGHS
137138
138-
m = GDPModel()
139+
m = GDPModel(HiGHS.Optimizer)
139140
@variable(m, 0 ≤ x[1:2] ≤ 20)
140141
@variable(m, Y[1:2], Logical)
141142
@constraint(m, [i = 1:2], [2,5][i] ≤ x[i] ≤ [6,9][i], DisjunctConstraint(Y[1]))
142143
@constraint(m, [i = 1:2], [8,10][i] ≤ x[i] ≤ [11,15][i], DisjunctConstraint(Y[2]))
143144
@disjunction(m, Y)
144145
@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
145154
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
148157
print(m)
149-
# Feasibility
158+
# Max x[1] + x[2]
150159
# Subject to
151160
# Y[1] + Y[2] = 1
152161
# x[1] - 100 Y[1] ≥ -98
@@ -164,10 +173,10 @@ print(m)
164173
# Y[1] binary
165174
# Y[2] binary
166175
167-
## Hull
168-
reformulate_model(m, Hull())
176+
##
177+
optimize!(m, method = Hull())
169178
print(m)
170-
# Feasibility
179+
# Max x[1] + x[2]
171180
# Subject to
172181
# -x[2] + x[2]_Y[1] + x[2]_Y[2] = 0
173182
# -x[1] + x[1]_Y[1] + x[1]_Y[2] = 0
@@ -202,21 +211,4 @@ print(m)
202211
# x[1]_Y[2] ≤ 20
203212
# Y[1] binary
204213
# 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]}
222214
```

0 commit comments

Comments
 (0)