From 6e783399b5f11648874edca7d72b1cea0351eb69 Mon Sep 17 00:00:00 2001 From: James Gaboardi Date: Tue, 3 Oct 2023 14:58:00 -0400 Subject: [PATCH 1/3] update pre-commit --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd6a78f2..f580b27c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ -files: 'spopt\/' +files: "spopt\/" repos: - repo: https://github.com/psf/black - rev: 23.9.1 + rev: "23.9.1" hooks: - id: black language_version: python3 From 035d27ab60d245757dba41d7bf74a8f1b767afdd Mon Sep 17 00:00:00 2001 From: James Gaboardi Date: Tue, 3 Oct 2023 14:59:25 -0400 Subject: [PATCH 2/3] add KPMP to API and docs --- docs/api.rst | 9 +++++---- spopt/locate/__init__.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 2ff3b29f..6af3ec0f 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -32,11 +32,12 @@ Exact solution approaches to facility location modeling problems. .. autosummary:: :toctree: generated/ - locate.coverage.LSCP - locate.coverage.LSCPB - locate.coverage.MCLP - locate.PCenter + locate.LSCP + locate.LSCPB + locate.MCLP locate.PMedian + locate.KNearestPMedian + locate.PCenter locate.PDispersion diff --git a/spopt/locate/__init__.py b/spopt/locate/__init__.py index d18e9654..6cd17eda 100644 --- a/spopt/locate/__init__.py +++ b/spopt/locate/__init__.py @@ -2,5 +2,5 @@ from .coverage import LSCP, LSCPB, MCLP from .p_center import PCenter from .p_dispersion import PDispersion -from .p_median import PMedian +from .p_median import KNearestPMedian, PMedian from .util import simulated_geo_points From e24bc25d4f713ee860010d7a69596982f414b8a9 Mon Sep 17 00:00:00 2001 From: James Gaboardi Date: Tue, 3 Oct 2023 15:35:27 -0400 Subject: [PATCH 3/3] lint p_median.py --- spopt/locate/p_median.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spopt/locate/p_median.py b/spopt/locate/p_median.py index 516e053b..984d4ec7 100644 --- a/spopt/locate/p_median.py +++ b/spopt/locate/p_median.py @@ -552,9 +552,9 @@ class KNearestPMedian(PMedian): \begin{array}{lllll} \displaystyle \textbf{Minimize} & \displaystyle \sum_{i \in I}\sum_{k \in k_{i}}{a_i d_{ik} X_{ik}} + \sum_{i \in I}{g_i (d_{i{k_i}} + 1)} && & (1) \\ - \displaystyle \textbf{Subject To} & \sum_{k \in k_{i}}{X_{ik} + g_i = 1} && \forall i \in I & (2) \\ + \displaystyle \textbf{Subject To} & \sum_{k \in k_{i}}{X_{ik} + g_i = 1} && \forall i \in I & (2) \\ & \sum_{j \in J}{Y_j} = p && & (3) \\ - & \sum_{i \in I}{a_i X_{ik}} \leq {Y_{k} c_{k}} && \forall k \in k_{i} & (4) \\ + & \sum_{i \in I}{a_i X_{ik}} \leq {Y_{k} c_{k}} && \forall k \in k_{i} & (4) \\ & X_{ij} \leq Y_{j} && \forall i \in I \quad \forall j \in J & (5) \\ & X_{ij} \in \{0, 1\} && \forall i \in I \quad \forall j \in J & (6) \\ & Y_j \in \{0, 1\} && \forall j \in J & (7) \\ @@ -807,7 +807,7 @@ def _from_sparse_matrix(self) -> None: # Client assignment integer decision variables row_indices, col_indices, values = find(self.aij) cli_assgn_vars = pulp.LpVariable.dicts( - "z", [(i, j) for i, j in zip(row_indices, col_indices)], 0, 1, pulp.LpBinary + "z", list(zip(row_indices, col_indices, strict=True)), 0, 1, pulp.LpBinary ) setattr(self, "cli_assgn_vars", cli_assgn_vars)