From 69236fd9ee48467f882808683a4d69f85a435f04 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Sat, 24 Aug 2024 02:21:07 -0400 Subject: [PATCH 1/4] Commented out associate_binary_var --- gdplib/ex1_linan_2023/ex1_linan_2023.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gdplib/ex1_linan_2023/ex1_linan_2023.py b/gdplib/ex1_linan_2023/ex1_linan_2023.py index ad0e439..8fd3ef0 100644 --- a/gdplib/ex1_linan_2023/ex1_linan_2023.py +++ b/gdplib/ex1_linan_2023/ex1_linan_2023.py @@ -130,9 +130,9 @@ def Disjunction1(m): # Disjunction for first Boolean variable m.Disjunction1 = Disjunction(rule=Disjunction1, xor=False) - # Associate boolean variables to disjuncts - for n1 in m.set1: - m.Y1[n1].associate_binary_var(m.Y1_disjunct[n1].indicator_var) + # # Associate boolean variables to disjuncts + # for n1 in m.set1: + # m.Y1[n1].associate_binary_var(m.Y1_disjunct[n1].indicator_var) # Second disjunction def build_disjuncts2(m, set2): # Disjuncts for second Boolean variable @@ -188,9 +188,9 @@ def Disjunction2(m): # Disjunction for first Boolean variable m.Disjunction2 = Disjunction(rule=Disjunction2, xor=False) - # Associate boolean variables to disjuncts - for n2 in m.set2: - m.Y2[n2].associate_binary_var(m.Y2_disjunct[n2].indicator_var) + # # Associate boolean variables to disjuncts + # for n2 in m.set2: + # m.Y2[n2].associate_binary_var(m.Y2_disjunct[n2].indicator_var) # Logical constraints From ff0de95043b2f22eb5421d6f5ab19e48eae07311 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Sat, 24 Aug 2024 02:23:23 -0400 Subject: [PATCH 2/4] Remove m.Y1 and m.Y2 --- gdplib/ex1_linan_2023/ex1_linan_2023.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gdplib/ex1_linan_2023/ex1_linan_2023.py b/gdplib/ex1_linan_2023/ex1_linan_2023.py index 8fd3ef0..4fd9114 100644 --- a/gdplib/ex1_linan_2023/ex1_linan_2023.py +++ b/gdplib/ex1_linan_2023/ex1_linan_2023.py @@ -40,9 +40,6 @@ def build_model(): m.sub1 = pyo.Set(initialize=[3], within=m.set1) # Variables - m.Y1 = pyo.BooleanVar(m.set1, doc="Boolean variable associated to set 1") - m.Y2 = pyo.BooleanVar(m.set2, doc="Boolean variable associated to set 2") - m.alpha = pyo.Var( within=pyo.Reals, bounds=(-0.1, 0.4), doc="continuous variable alpha" ) @@ -209,7 +206,7 @@ def select_one_Y1(m): Pyomo.LogicalConstraint Logical constraint that make Y1 to be true for only one element """ - return pyo.exactly(1, m.Y1) + return pyo.exactly(1, [m.Y1_disjunct[n].indicator_var for n in m.set1]) m.oneY1 = pyo.LogicalConstraint(rule=select_one_Y1) @@ -228,7 +225,7 @@ def select_one_Y2(m): Pyomo.LogicalConstraint Logical constraint that make Y2 to be true for only one element """ - return pyo.exactly(1, m.Y2) + return pyo.exactly(1,[m.Y2_disjunct[n].indicator_var for n in m.set2]) m.oneY2 = pyo.LogicalConstraint(rule=select_one_Y2) @@ -248,7 +245,7 @@ def infeasR_rule(m): Pyomo.LogicalConstraint Logical constraint that defines an infeasible region on Y1[3] """ - return pyo.land([pyo.lnot(m.Y1[j]) for j in m.sub1]) + return pyo.land([pyo.lnot(m.Y1_disjunct[j].indicator_var) for j in m.sub1]) m.infeasR = pyo.LogicalConstraint(rule=infeasR_rule) From dcdbce47c66a97ff6e4d48a86fbb9e9afb43cbbb Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Sat, 24 Aug 2024 02:24:03 -0400 Subject: [PATCH 3/4] Remove associate --- gdplib/ex1_linan_2023/ex1_linan_2023.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/gdplib/ex1_linan_2023/ex1_linan_2023.py b/gdplib/ex1_linan_2023/ex1_linan_2023.py index 4fd9114..92faa4d 100644 --- a/gdplib/ex1_linan_2023/ex1_linan_2023.py +++ b/gdplib/ex1_linan_2023/ex1_linan_2023.py @@ -127,10 +127,6 @@ def Disjunction1(m): # Disjunction for first Boolean variable m.Disjunction1 = Disjunction(rule=Disjunction1, xor=False) - # # Associate boolean variables to disjuncts - # for n1 in m.set1: - # m.Y1[n1].associate_binary_var(m.Y1_disjunct[n1].indicator_var) - # Second disjunction def build_disjuncts2(m, set2): # Disjuncts for second Boolean variable """ @@ -185,10 +181,6 @@ def Disjunction2(m): # Disjunction for first Boolean variable m.Disjunction2 = Disjunction(rule=Disjunction2, xor=False) - # # Associate boolean variables to disjuncts - # for n2 in m.set2: - # m.Y2[n2].associate_binary_var(m.Y2_disjunct[n2].indicator_var) - # Logical constraints # Constraint that allow to apply the reformulation over Y1 From 6349c63f71b523cd2cac3c21e563b0d7647ab7ac Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Sat, 24 Aug 2024 02:30:49 -0400 Subject: [PATCH 4/4] black formatting --- gdplib/ex1_linan_2023/ex1_linan_2023.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdplib/ex1_linan_2023/ex1_linan_2023.py b/gdplib/ex1_linan_2023/ex1_linan_2023.py index 92faa4d..a069d95 100644 --- a/gdplib/ex1_linan_2023/ex1_linan_2023.py +++ b/gdplib/ex1_linan_2023/ex1_linan_2023.py @@ -217,7 +217,7 @@ def select_one_Y2(m): Pyomo.LogicalConstraint Logical constraint that make Y2 to be true for only one element """ - return pyo.exactly(1,[m.Y2_disjunct[n].indicator_var for n in m.set2]) + return pyo.exactly(1, [m.Y2_disjunct[n].indicator_var for n in m.set2]) m.oneY2 = pyo.LogicalConstraint(rule=select_one_Y2)