Skip to content

Commit

Permalink
Merge branch 'master' into xpress_py_github_actions
Browse files Browse the repository at this point in the history
  • Loading branch information
pchtsp committed Sep 30, 2023
2 parents 4001051 + a061554 commit 6157811
Show file tree
Hide file tree
Showing 53 changed files with 1,526 additions and 575 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
12 changes: 4 additions & 8 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@ on:
branches:
- master


jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.8'
architecture: 'x64'
python-version: '3.10'
# Standard drop-in approach that should work for most people.
- name: Install dependencies
run: |
Expand Down Expand Up @@ -47,4 +43,4 @@ jobs:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GH_TOKEN }}
# ===============================
# ===============================
30 changes: 12 additions & 18 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
name: Publish Python 🐍 distributions 📦 to PyPI

on: push
on: [push, pull_request, workflow_dispatch]

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.7
uses: actions/setup-python@v1
- uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install wheel
run: >-
python -m
pip install
wheel
--user
python-version: "3.x"
- run: pip install -U wheel build
- name: Build a binary wheel and a source tarball
run: python setup.py sdist bdist_wheel
run: python -m build
- name: Publish distribution 📦 to Test PyPI
if: startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.pypi_password }}

21 changes: 11 additions & 10 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
name: Python package

on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 21
matrix:
python-version: [2.7, 3.7, 3.8, 3.9, '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest, macOS-latest, windows-latest]
exclude:
- os: macOS-latest
python-version: 2.7
- os: windows-latest
python-version: 2.7

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: install glpk
Expand All @@ -33,10 +28,16 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install .
- name: Install gurobipy
run: |
python -m pip install gurobipy
- name: Install highspy
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
run: |
pip install highspy numpy
- name: Test with pulptest
run: pulptest
- name: Code Quality
if: ${{ matrix.python-version >= 3.6 }}
run: |
pip install black
black pulp/ --check
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ repos:
rev: stable
hooks:
- id: black
- repo: https://github.com/asottile/pyupgrade
rev: v3.1.0
hooks:
- id: pyupgrade
args: [--py37-plus]
4 changes: 3 additions & 1 deletion HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
# See the LICENSE file for copyright information.
2.7.0
added HiGHS solver
added pysmps dependency for mps parsing
added XPRESS_PY solver
fixed bugs
updated docs
2.6.0 2021-12-04
dropped packaged choco
fixed bugs
Expand Down
23 changes: 15 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
pulp
**************************

.. image:: https://travis-ci.org/coin-or/pulp.svg?branch=master
:target: https://travis-ci.org/coin-or/pulp
.. image:: https://img.shields.io/pypi/v/pulp
:target: https://pypi.org/project/PuLP/
:alt: PyPI
.. image:: https://img.shields.io/pypi/dm/pulp
:target: https://pypi.org/project/PuLP/
:alt: PyPI - Downloads

PuLP is an LP modeler written in Python. PuLP can generate MPS or LP files
and call GLPK_, COIN-OR CLP/`CBC`_, CPLEX_, GUROBI_, MOSEK_, XPRESS_, CHOCO_, MIPCL_, SCIP_ to solve linear
problems.
PuLP is an LP modeler written in Python. PuLP can generate MPS or LP files and call GLPK_, COIN-OR CLP/`CBC`_, CPLEX_, GUROBI_, MOSEK_, XPRESS_, CHOCO_, MIPCL_, HiGHS_, SCIP_/FSCIP_ to solve linear problems.

Installation
================
Expand Down Expand Up @@ -36,7 +41,7 @@ Examples

See the examples directory for examples.

PuLP requires Python 2.7 or Python >= 3.4.
PuLP requires Python 3.7 or newer.

The examples use the default solver (CBC). To use other solvers they must be available (installed and accessible). For more information on how to do that, see the `guide on configuring solvers <https://coin-or.github.io/pulp/guides/how_to_configure_solvers.html>`_.

Expand Down Expand Up @@ -106,8 +111,8 @@ Exported Functions:
Building the documentation
--------------------------

The PuLP documentation is built with `Sphinx <https://www.sphinx-doc.org>`_. We recommended using a
`virtual environment <https://docs.python.org/3/library/venv.html>`_ to build the documentation locally.
The PuLP documentation is built with `Sphinx <https://www.sphinx-doc.org>`_. We recommended using a
`virtual environment <https://docs.python.org/3/library/venv.html>`_ to build the documentation locally.

To build, run the following in a terminal window, in the PuLP root directory

Expand All @@ -117,11 +122,11 @@ To build, run the following in a terminal window, in the PuLP root directory
python -m pip install -r requirements-dev.txt
cd doc
make html

A folder named html will be created inside the ``build/`` directory.
The home page for the documentation is ``doc/build/html/index.html`` which can be opened in a browser.





Expand All @@ -147,3 +152,5 @@ The home page for the documentation is ``doc/build/html/index.html`` which can b
.. _CHOCO: https://choco-solver.org/
.. _MIPCL: http://mipcl-cpp.appspot.com/
.. _SCIP: https://www.scipopt.org/
.. _HiGHS: https://highs.dev
.. _FSCIP: https://ug.zib.de
4 changes: 2 additions & 2 deletions doc/KPyCon2009/code/beerdistribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
for w in warehouses:
prob += (
sum([x[w][b] for b in bars]) <= supply[w],
"Sum_of_Products_out_of_Warehouse_%s" % w,
f"Sum_of_Products_out_of_Warehouse_{w}",
)

# Demand minimum constraints are added to prob for each demand node (bar)
for b in bars:
prob += (
sum([x[w][b] for w in warehouses]) >= demand[b],
"Sum_of_Products_into_Bar%s" % b,
f"Sum_of_Products_into_Bar{b}",
)

# The problem data is written to an .lp file
Expand Down
4 changes: 2 additions & 2 deletions doc/KPyCon2009/code/wedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def happiness(table):
for guest in guests:
seating_model += (
sum([x[table] for table in possible_tables if guest in table]) == 1,
"Must_seat_%s" % guest,
f"Must_seat_{guest}",
)

seating_model.solve()

print("The choosen tables are out of a total of %s:" % len(possible_tables))
print(f"The choosen tables are out of a total of {len(possible_tables)}:")
for table in possible_tables:
if x[table].value() == 1.0:
print(table)
2 changes: 1 addition & 1 deletion doc/KPyCon2009/code/whiskas.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@

# print the result
for ingredient in ingredients:
print("The mass of %s is %s grams per can" % (ingredient, x[ingredient].value()))
print(f"The mass of {ingredient} is {x[ingredient].value()} grams per can")
11 changes: 5 additions & 6 deletions doc/source/_static/plotter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from matplotlib import rc

Expand All @@ -18,15 +17,15 @@ def plot_interval(a, c, x_left, x_right, i, fbound):
text(
(x_left + lh) / 2.0,
0.1,
"freebound interval [%s, %s] is penalty-free" % (lh, rh),
f"freebound interval [{lh}, {rh}] is penalty-free",
)
text((x_left + lh) / 2.0, 0.2, "rhs=%s, %s" % (c, fbound))
text((x_left + lh) / 2.0, 0.2, f"rhs={c}, {fbound}")
cur_ax = gca()
cur_ax.add_patch(arrow_l)
cur_ax.add_patch(arrow_r)
axis([x_left, x_right, -0.1, 0.3])
yticks([])
title("Elasticized constraint\_%s $C(x)= %s $" % (i, c))
title(rf"Elasticized constraint\_{i} $C(x)= {c} $")


figure()
Expand All @@ -39,7 +38,7 @@ def plot_interval(a, c, x_left, x_right, i, fbound):
c = 200
x_left = 0.97 * c
x_right = 1.03 * c
fb_string = "%s%s = %s" % (fbound, "", a[0])
fb_string = f"{fbound} = {a[0]}"
plot_interval(a, c, x_left, x_right, i, fb_string)

i += 1
Expand All @@ -48,7 +47,7 @@ def plot_interval(a, c, x_left, x_right, i, fbound):
c = 500
x_left = 0.9 * c # scale of window
x_right = 1.2 * c # scale of window
fb_string = "%s%s = [%s,%s]" % (fbound, "List", a[0], a[1])
fb_string = f"{fbound}List = [{a[0]},{a[1]}]"
plot_interval(a, c, x_left, x_right, i, fb_string)
savefig("freebound.jpg")
savefig("freebound.pdf")
Expand Down
1 change: 0 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# pulp sphinx documentation build configuration file, created by
# sphinx-quickstart on Mon Nov 2 11:54:01 2009.
Expand Down
2 changes: 1 addition & 1 deletion doc/source/guides/how_to_configure_solvers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PuLP has some helper functions that permit a user to query which solvers are ava
solver_list = pl.listSolvers()
# ['GLPK_CMD', 'PYGLPK', 'CPLEX_CMD', 'CPLEX_PY', 'CPLEX_DLL', 'GUROBI', 'GUROBI_CMD', 'MOSEK', 'XPRESS', 'PULP_CBC_CMD', 'COIN_CMD', 'COINMP_DLL', 'CHOCO_CMD', 'MIPCL_CMD', 'SCIP_CMD']
If passed the `only_available=True` argument, PuLP lists the solvers that are currently available::
If passed the `onlyAvailable=True` argument, PuLP lists the solvers that are currently available::

import pulp as pl
solver_list = pl.listSolvers(onlyAvailable=True)
Expand Down
2 changes: 1 addition & 1 deletion examples/AmericanSteelProblem.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
prob += (
supply[n] + lpSum([vars[(i, j)] for (i, j) in Arcs if j == n])
>= demand[n] + lpSum([vars[(i, j)] for (i, j) in Arcs if i == n])
), "Steel Flow Conservation in Node %s" % n
), f"Steel Flow Conservation in Node {n}"

# The problem data is written to an .lp file
prob.writeLP("AmericanSteelProblem.lp")
Expand Down
4 changes: 2 additions & 2 deletions examples/BeerDistributionProblem.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
for w in Warehouses:
prob += (
lpSum([vars[w][b] for b in Bars]) <= supply[w],
"Sum_of_Products_out_of_Warehouse_%s" % w,
f"Sum_of_Products_out_of_Warehouse_{w}",
)

# The demand minimum constraints are added to prob for each demand node (bar)
for b in Bars:
prob += (
lpSum([vars[w][b] for w in Warehouses]) >= demand[b],
"Sum_of_Products_into_Bar%s" % b,
f"Sum_of_Products_into_Bar{b}",
)

# The problem data is written to an .lp file
Expand Down
4 changes: 2 additions & 2 deletions examples/BeerDistributionProblemCompetitorExtension.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
for w in Warehouses:
prob += (
lpSum([vars[w][b] for b in Bars]) <= supply[w],
"Sum_of_Products_out_of_Warehouse_%s" % w,
f"Sum_of_Products_out_of_Warehouse_{w}",
)

# The demand minimum constraints are added to prob for each demand node (bar)
for b in Bars:
prob += (
lpSum([vars[w][b] for w in Warehouses]) >= demand[b],
"Sum_of_Products_into_Bar%s" % b,
f"Sum_of_Products_into_Bar{b}",
)

# The problem data is written to an .lp file
Expand Down
4 changes: 2 additions & 2 deletions examples/BeerDistributionProblemWarehouseExtension.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@
for w in Warehouses:
prob += (
lpSum([vars[w][b] for b in Bars]) <= supply[w],
"Sum_of_Products_out_of_Warehouse_%s" % w,
f"Sum_of_Products_out_of_Warehouse_{w}",
)

# The demand minimum constraints are added to prob for each demand node (bar)
for b in Bars:
prob += (
lpSum([vars[w][b] for w in Warehouses]) >= demand[b],
"Sum_of_Products_into_Bar%s" % b,
f"Sum_of_Products_into_Bar{b}",
)

# The problem data is written to an .lp file
Expand Down
4 changes: 2 additions & 2 deletions examples/BeerDistributionProblem_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@
for w in Warehouses:
prob += (
lpSum([vars[w][b] for b in Bars]) <= supply[w],
"Sum_of_Products_out_of_Warehouse_%s" % w,
f"Sum_of_Products_out_of_Warehouse_{w}",
)

# The demand minimum constraints are added to prob for each demand node (bar)
# These constraints are stored for resolve later
bar_demand_constraint = {}
for b in Bars:
constraint = lpSum([vars[w][b] for w in Warehouses]) >= demand[b]
prob += constraint, "Sum_of_Products_into_Bar_%s" % b
prob += constraint, f"Sum_of_Products_into_Bar_{b}"
bar_demand_constraint[b] = constraint

# The problem data is written to an .lp file
Expand Down
Loading

0 comments on commit 6157811

Please sign in to comment.