Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KNearestPMP to API and documentation #399

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 5 additions & 4 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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


2 changes: 1 addition & 1 deletion spopt/locate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions spopt/locate/p_median.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) \\
Expand Down Expand Up @@ -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)

Expand Down