From adfb221b8b45189f832bc90b4ab5f88c6d1d56c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?T=C3=BAlio=20Toffolo?=
 <tuliotoffolo@users.noreply.github.com>
Date: Fri, 19 Jan 2024 13:15:09 -0800
Subject: [PATCH] Fix CI issues (#366)

Fix CI issues
---
 .github/workflows/github-ci.yml | 18 +++++++----------
 README.md                       |  2 +-
 examples/plant_location.py      | 35 +--------------------------------
 pyproject.toml                  | 17 +++++++++++++---
 4 files changed, 23 insertions(+), 49 deletions(-)

diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml
index a94c2885..b46f6533 100644
--- a/.github/workflows/github-ci.yml
+++ b/.github/workflows/github-ci.yml
@@ -39,18 +39,14 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        # temporarily downgraded to 3.7.9 and 3.8.10 due to a bug https://github.com/actions/setup-python/issues/402
-        python-version: ["3.8.10", "3.9.13", "3.10.9", "3.11.1", "3.12.0", "pypy3.9-v7.3.9"]
+        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9-v7.3.15"]
         os: [macos-11, macos-12, ubuntu-20.04, ubuntu-22.04, windows-2019, windows-2022]
         exclude:
           # temporarily exclude pypy3 on mac-os as there failing tests caused by bug on cbc side
           - os: macos-11
-            python-version: "pypy3.9-v7.3.9"
+            python-version: "pypy3.9-v7.3.15"
           - os: macos-12
-            python-version: "pypy3.9-v7.3.9"
-          # several version (3.7.9 and 3.8.10) at not available at ubuntu-22.04
-          - os: ubuntu-22.04
-            python-version: "3.8.10"
+            python-version: "pypy3.9-v7.3.15"
 
     steps:
 
@@ -70,22 +66,22 @@ jobs:
       run: python -m pip install --upgrade pip
 
     - name: Install mip for testing (PyPy)
-      if: ${{ matrix.python-version == 'pypy3.9-v7.3.9' }}
+      if: ${{ matrix.python-version == 'pypy3.9-v7.3.15' }}
       run: python -m pip install .[test,numpy]
 
     - name: Install mip for testing (CPython)
-      if: ${{ matrix.python-version != 'pypy3.9-v7.3.9' }}
+      if: ${{ matrix.python-version != 'pypy3.9-v7.3.15' }}
       run: python -m pip install .[test,numpy,gurobi]
 
     - name: list installed packages
       run: python -m pip list
 
     - name: Run tests PyPy
-      if: ${{ matrix.python-version == 'pypy3.9-v7.3.9'}}
+      if: ${{ matrix.python-version == 'pypy3.9-v7.3.15'}}
       run: |
         python -m pytest test --verbose --color=yes --doctest-modules --ignore="test/test_gurobi.py"
 
     - name: Run tests
-      if: ${{ matrix.python-version != 'pypy3.9-v7.3.9'}}
+      if: ${{ matrix.python-version != 'pypy3.9-v7.3.15'}}
       run: |
         python -m pytest test --verbose --color=yes --doctest-modules -Werror
diff --git a/README.md b/README.md
index ad55cbf7..44e80172 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ Some of the main features of MIP are:
   different solvers are handled by Python-MIP and you write only one
   solver independent code;
 
-* written in modern [typed](https://docs.python.org/3/library/typing.html) Python 3 (requires Python 3.6 or newer).
+* written in modern [typed](https://docs.python.org/3/library/typing.html) Python 3 (requires Python 3.8 or newer).
 
 ## Examples
 
diff --git a/examples/plant_location.py b/examples/plant_location.py
index b0d31ef8..734aff12 100644
--- a/examples/plant_location.py
+++ b/examples/plant_location.py
@@ -11,15 +11,6 @@
 
 import sys
 
-# Workaround for issues with python not being installed as a framework on mac
-# by using a different backend.
-if sys.platform == "darwin":  # OS X
-    import matplotlib as mpl
-
-    mpl.use("Agg")
-    del mpl
-
-import matplotlib.pyplot as plt
 from math import sqrt, log
 from itertools import product
 from mip import Model, xsum, minimize, OptimizationStatus
@@ -53,20 +44,6 @@
 # demands
 d = {1: 302, 2: 273, 3: 275, 4: 266, 5: 287, 6: 296, 7: 297, 8: 310, 9: 302, 10: 309}
 
-# plotting possible plant locations
-for i, p in pf.items():
-    plt.scatter((p[0]), (p[1]), marker="^", color="purple", s=50)
-    plt.text((p[0]), (p[1]), "$f_%d$" % i)
-
-# plotting location of clients
-for i, p in pc.items():
-    plt.scatter((p[0]), (p[1]), marker="o", color="black", s=15)
-    plt.text((p[0]), (p[1]), "$c_{%d}$" % i)
-
-plt.text((20), (78), "Region 1")
-plt.text((70), (78), "Region 2")
-plt.plot((50, 50), (0, 80))
-
 dist = {
     (f, c): round(sqrt((pf[f][0] - pc[c][0]) ** 2 + (pf[f][1] - pc[c][1]) ** 2), 1)
     for (f, c) in product(F, C)
@@ -116,21 +93,11 @@
 
 m.optimize()
 
-plt.savefig("location.pdf")
-
 if m.num_solutions:
     print("Solution with cost {} found.".format(m.objective_value))
     print("Facilities capacities: {} ".format([z[f].x for f in F]))
     print("Facilities cost: {}".format([y[f].x for f in F]))
 
-    # plotting allocations
-    for i, j in [(i, j) for (i, j) in product(F, C) if x[(i, j)].x >= 1e-6]:
-        plt.plot(
-            (pf[i][0], pc[j][0]), (pf[i][1], pc[j][1]), linestyle="--", color="darkgray"
-        )
-
-    plt.savefig("location-sol.pdf")
-
 # sanity checks
 opt = 99733.94905406
 if m.status == OptimizationStatus.OPTIMAL:
@@ -138,4 +105,4 @@
 elif m.status == OptimizationStatus.FEASIBLE:
     assert m.objective_value >= opt - 0.01
 else:
-    assert m.status not in [OptimizationStatus.INFEASIBLE, OptimizationStatus.UNBOUNDED]
+    assert m.status not in [OptimizationStatus.INFEASIBLE, OptimizationStatus.UNBOUNDED]
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 1ff50da5..abc240fe 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -32,12 +32,23 @@ classifiers = [
 ]
 dynamic = ["version"]
 
-dependencies = ["cffi==1.15.*"]
+dependencies = ["cffi>=1.15"]
 
 [project.optional-dependencies]
-numpy = ["numpy==1.24.*; python_version >= '3.8'", "numpy==1.21.6; python_version == '3.7'"]
+numpy = [
+    "numpy>=1.25; python_version>='3.9'",
+    "numpy==1.24.*; python_version=='3.8'",
+    "numpy==1.21.*; python_version=='3.7'"
+]
 gurobi = ["gurobipy>=8"]
-test = ["pytest==7.2.0", "networkx==2.8.8; python_version >= '3.8'", "networkx==2.6.3; python_version == '3.7'", "matplotlib==3.6.2; python_version >= '3.8'", "matplotlib==3.5.3; python_version == '3.7'"]
+test = [
+    "pytest>=7.4",
+    "networkx==2.8.8; python_version>='3.8'",
+    "networkx==2.6.3; python_version=='3.7'",
+    "matplotlib>=3.7; python_version>='3.9'",
+    "matplotlib==3.6.2; python_version=='3.8'",
+    "matplotlib==3.5.3; python_version=='3.7'"
+]
 
 [project.urls]
 "Homepage" = "https://www.python-mip.com"