Skip to content

Commit b60b7eb

Browse files
author
shiv-666
committed
2 parents 01afcae + cee5c22 commit b60b7eb

File tree

2 files changed

+318
-78
lines changed

2 files changed

+318
-78
lines changed

src/macro.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
macro disjunction(args...)
2+
pos_args, kw_args, _ = Containers._extract_kw_args(args)
3+
4+
#get kw_args
5+
reformulation = filter(i -> i.args[1] == :reformulation, kw_args)
6+
if !isempty(reformulation)
7+
reformulation = reformulation[1].args[2]
8+
if length(pos_args[2:end]) < 2
9+
throw(DomainError(args, "At least 2 constraints expected"))
10+
end
11+
else
12+
throw(UndefKeywordError(:reformulation))
13+
end
14+
M = filter(i -> i.args[1] == :M, kw_args)
15+
M = !isempty(M) ? esc(M[1].args[2]) : :(missing)
16+
eps = filter(i -> i.args[1] == :eps, kw_args)
17+
eps = !isempty(eps) ? esc(eps[1].args[2]) : :(1e-6)
18+
name = filter(i -> i.args[1] == :name, kw_args)
19+
name = !isempty(name) ? esc(name[1].args[2]) : :(missing)
20+
21+
#get args
22+
m = esc(pos_args[1])
23+
disj = [esc(a) for a in pos_args[2:end]]
24+
25+
#build disjunction
26+
:(add_disjunction($m, $(disj...), reformulation = $reformulation, M = $M, eps = $eps, name = $name))
27+
end

0 commit comments

Comments
 (0)