Skip to content

Commit c2a7563

Browse files
Update deps incl cbc (#744)
* Update dependency pinning to have as few upper bounds as feasible * Move to recommending CBC as the main open-source solver * Use conda forge GLPK link to mitigate markdown link check errors
1 parent 485b3d5 commit c2a7563

File tree

12 files changed

+66
-79
lines changed

12 files changed

+66
-79
lines changed

.github/workflows/pr-ci.yml

+1-11
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,14 @@ jobs:
5252
-f requirements/dev.txt
5353
curl
5454
python=3.${{ matrix.py3version }}
55+
coin-or-cbc
5556
gurobi::gurobi
5657
post-cleanup: all
5758
cache-environment: true
5859

5960
- name: Install package
6061
run: pip install --no-dependencies -e .
6162

62-
- name: install CBC (Windows)
63-
if: matrix.os == 'windows-latest'
64-
run: |
65-
curl -L https://github.com/coin-or/Cbc/releases/download/releases%2F2.10.10/Cbc-releases.2.10.10-w64-msvc17-md.zip -o cbc.zip
66-
unzip cbc.zip -d ${HOME}/cbc
67-
echo "${HOME}/cbc/bin" >> $GITHUB_PATH
68-
69-
- name: install CBC (Unix)
70-
if: matrix.os != 'windows-latest'
71-
run: micromamba install coin-or-cbc
72-
7363
- name: Install jupyter kernel
7464
run: python -m ipykernel install --user --name calliope
7565

.readthedocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build:
77
python: mambaforge-4.10
88
jobs:
99
post_create_environment:
10-
- mamba install python=3.12 coin-or-cbc gurobi::gurobi --file requirements/dev.txt
10+
- mamba install python=3.12 coin-or-cbc gurobi::gurobi --file requirements/base.txt --file requirements/dev.txt
1111
- pip install --no-deps .
1212
- python -m ipykernel install --user --name calliope_docs_build
1313

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 0.7.0.dev6
2+
3+
### User-facing changes
4+
5+
|changed| coin-or-cbc is now available cross-platform on conda-forge and so is the recommended open-source solver to install a user environment with.
6+
7+
|changed| Upper bound pins for dependencies removed where possible, to minimise clashes when using calliope as a dependency in a project.
8+
19
## 0.7.0.dev5 (2024-12-04)
210

311
### User-facing changes

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Calliope comes with several built-in analysis and visualisation tools. Having so
3737

3838
## Quick start
3939

40-
Calliope can run on Windows, macOS and Linux. Installing it is quickest with the `mamba` package manager by running a single command: `mamba create -c conda-forge -n calliope calliope`.
40+
Calliope can run on Windows, macOS and Linux. Installing it is quickest with the `mamba` package manager by running a single command: `mamba create -n calliope -c conda-forge conda-forge/label/calliope_dev::calliope`.
4141

4242
See the documentation for more [information on installing](https://calliope.readthedocs.io/en/stable/user/installation.html).
4343

docs/advanced/shadow_prices.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ If you [define any of your own math constraints](../user_defined_math/components
1717
!!! note
1818
1919
* Not all solvers provide access to shadow prices.
20-
For instance, we know that it is possible with Gurobi and GLPK, but not with CBC.
21-
Since we cannot test all Pyomo-compatible solvers, you may run into issues depending on the solver you use.
20+
For instance, we know that it is possible with Gurobi and GLPK, but not with CBC.
21+
Since we cannot test all Pyomo-compatible solvers, you may run into issues depending on the solver you use.
2222
* You cannot access shadow prices if you have integer/binary variables in your model.
23-
If you try to do so, you will receive a warning, and shadow price tracking will remain disabled.
23+
If you try to do so, you will receive a warning, and shadow price tracking will remain disabled.
2424
* You can check the status of shadow price tracking with `model.backend.shadow_prices.is_active`.
2525

2626
## Shadow prices when using the command-line tool

docs/contributing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To create a development environment for calliope, with all libraries required fo
3636
1. Open the command line (or the "miniforge prompt" in Windows).
3737
1. Download (a.k.a., clone) the calliope repository: `git clone git@github.com:calliope-project/calliope.git`
3838
1. Change into the `calliope` directory: `cd calliope`
39-
1. Create the calliope mamba environment: `mamba create -n calliope -c conda-forge --file requirements/base.txt --file requirements/dev.txt gurobi::gurobi`
39+
1. Create the calliope mamba environment: `mamba create -n calliope -c conda-forge --file requirements/base.txt --file requirements/dev.txt coin-or-cbc gurobi::gurobi`
4040
1. Activate the calliope mamba environment: `mamba activate calliope`
4141
1. Install the calliope package into the environment, in editable mode and ignoring dependencies (we have dealt with those when creating the mamba environment): `pip install --no-deps -e .`
4242
1. Install the interactive python shell (necessary when testing our documentation locally): `ipython kernel install --user --name=calliope_docs_build`
@@ -46,7 +46,7 @@ All together:
4646
``` shell
4747
git clone git@github.com:calliope-project/calliope.git
4848
cd calliope
49-
mamba create -n calliope -c conda-forge --file requirements/base.txt --file requirements/dev.txt gurobi::gurobi
49+
mamba create -n calliope -c conda-forge --file requirements/base.txt --file requirements/dev.txt coin-or-cbc gurobi::gurobi
5050
mamba activate calliope
5151
pip install --no-deps -e .
5252
ipython kernel install --user --name=calliope_docs_build

docs/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
To install the pre-release as a user:
77

88
```shell
9-
mamba create -n calliope -c conda-forge/label/calliope_dev -c conda-forge calliope
9+
mamba create -n calliope -c conda-forge conda-forge/label/calliope_dev::calliope
1010
```
1111

1212
Some functionality is not yet available in 0.7, notably:
@@ -68,4 +68,4 @@ limitations under the License.
6868
## Citing Calliope
6969

7070
Calliope is [published in the Journal of Open Source Software](https://joss.theoj.org/papers/10.21105/joss.00825).
71-
We encourage you to use this academic reference.
71+
We encourage you to use this academic reference.

docs/installation.md

+9-20
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Running Calliope requires four things:
88

99
1. The Python programming language, version {{ min_python_version }} to {{ max_python_version }}.
1010
2. A number of Python add-on modules including [Pyomo](https://www.pyomo.org/), [Pandas](https://pandas.pydata.org/) and [Xarray](https://docs.xarray.dev/).
11-
3. An optimisation solver: Calliope has been tested with CBC, GLPK, Gurobi, and CPLEX. Any other solver that is compatible with Pyomo should also work.
11+
3. An optimisation solver: Calliope has been tested with CBC, GLPK, and Gurobi.
12+
Any other solver that is compatible with Pyomo should also work.
1213
4. The Calliope software itself.
1314

1415
## Recommended installation method
@@ -22,11 +23,11 @@ To get `mamba`, the most straightforward approach is to [download and install th
2223
Another option is to use the commercially developed [Anaconda Python distribution](https://www.anaconda.com/download), which is available for all operating systems and comes with a graphical user interface to install and manage packages.
2324
If you use the Anaconda distribution, you have to replace `mamba` with `conda` in the installation instructions below.
2425

25-
With the package manager installed, you can create a new environment called `calliope` with Calliope as well as the free and open source GLPK solver.
26+
With the package manager installed, you can create a new environment called `calliope` with Calliope as well as the free and open source CBC solver.
2627
Run the following command in a terminal or command-line window:
2728

2829
```shell
29-
mamba create -n calliope -c conda-forge/label/calliope_dev -c conda-forge calliope glpk
30+
mamba create -n calliope -c conda-forge conda-forge/label/calliope_dev::calliope
3031
```
3132

3233
!!! note
@@ -46,36 +47,24 @@ mamba activate calliope
4647
Although possible, we do not recommend installing Calliope directly via `pip` (`pip install calliope`).
4748
Non-python binaries are not installed with `pip`, some of which are necessary for stable operation (e.g., `libnetcdf`).
4849

49-
## Updating an existing installation
50-
51-
If following the recommended installation method above, the following command, assuming the mamba environment is active, will update Calliope to the newest version
52-
53-
```bash
54-
mamba update -c conda-forge calliope
55-
```
56-
5750
## Choosing a solver
5851

5952
You cannot solve a Calliope model until you have installed a solver.
60-
The easiest solver to install is [GLPK](#glpk).
61-
However, we recommend to not use this solver where possible, since it performs relatively poorly (both in solution time and stability of result).
62-
Indeed, our example models use the free and open source [CBC](#cbc) solver instead, but installing it on Windows requires an extra step.
53+
The easiest solver to install is [CBC](#cbc), which is included if you follow the [recommended installation instructions](#recommended-installation-method) above.
6354
[CBC](#cbc) (open-source) or [Gurobi](#gurobi) (commercial) are recommended for large problems, and have been confirmed to work with Calliope.
6455
The following subsections provide additional detail on how to install a solver.
6556
This list is not exhaustive; any solvers [supported by Pyomo](https://pyomo.readthedocs.io/en/latest/reference/topical/appsi/appsi.solvers.html) can be used.
6657

6758
### CBC
6859

6960
[CBC](https://github.com/coin-or/Cbc) is our recommended option if you want a free and open-source solver.
70-
CBC can be installed via conda on Linux and macOS by running `mamba install -c conda-forge coin-or-cbc`.
71-
Windows binary packages are somewhat more difficult to install, due to limited information on [the CBC website](https://github.com/coin-or/Cbc), but are included in their [package releases on GitHub](https://github.com/coin-or/Cbc/releases).
72-
The GitHub releases are more up-to-date. We recommend you download the relevant binary for [CBC 2.10.11](https://github.com/coin-or/Cbc/releases/download/releases%2F2.10.11/Cbc-releases.2.10.11-w64-msvc17-md.zip) and add `cbc.exe` to a directory known to PATH (e.g. an Anaconda environment 'bin' directory).
61+
If you do not have it in your working environment (i.e. there is nothing listed when you call `conda list cbc`) then it can be installed by running `mamba install conda-forge::coin-or-cbc`.
7362

7463
### GLPK
7564

76-
[GLPK](https://www.gnu.org/software/glpk/) is free and open-source, but can take too much time and/or too much memory on larger problems.
77-
`GLPK` can be installed from `conda-forge` on all platforms: `mamba install glpk`.
78-
It is therefore the _easiest_ solver to have installed in your Calliope environment.
65+
[GLPK](https://anaconda.org/conda-forge/glpk) is free and open-source, but can take too much time and/or too much memory on larger problems.
66+
`GLPK` can be installed from `conda-forge` on all platforms: `mamba install conda-forge::glpk`.
67+
Unlike [CBC](#cbc), it is possible to extract [shadow prices](./advanced/shadow_prices.md) from a model solved with GLPK, which is why you may with to use it instead of CBC.
7968

8069
### Gurobi
8170

docs/migrating.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ This split means you can change configuration options on-the-fly if you are work
161161
build:
162162
mode: plan
163163
solve:
164-
solver: glpk
164+
solver: cbc
165165
```
166166

167167
=== "Python"
@@ -170,7 +170,7 @@ This split means you can change configuration options on-the-fly if you are work
170170
import calliope
171171
model = calliope.Model(time_subset=["2005-01", "2005-02"])
172172
model.build(mode="plan")
173-
model.solve(solver="glpk")
173+
model.solve(solver="cbc")
174174
```
175175

176176
!!! info "See also"

requirements/base.txt

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
bottleneck >= 1, < 2
2-
click >= 8, < 9
3-
geographiclib >= 2, < 3
4-
ipdb >= 0.13, < 0.14
5-
ipykernel < 7
6-
jinja2 >= 3, < 4
7-
jsonref >= 1.1, < 2
8-
jsonschema >= 4, < 5
9-
natsort >= 8, < 9
10-
netcdf4 >= 1.2, < 1.7
11-
numpy >= 1, < 2
12-
pandas >= 2.1.3, < 2.3 # Minimum bound is 2.1.3 because of a regression in v2.1.0/2.1.1 inflating time/memory consumption on groupby operations with MultiIndex
13-
pyomo >= 6.8.2, < 7
14-
pyparsing >= 3.0, < 3.1
15-
ruamel.yaml >= 0.18, < 0.19
16-
typing-extensions >= 4, < 5
17-
xarray >= 2024.1, < 2024.4
1+
bottleneck >= 1
2+
click >= 8
3+
geographiclib >= 2
4+
ipdb >= 0.13
5+
ipykernel >= 6
6+
jinja2 >= 3
7+
jsonref >= 1.1
8+
jsonschema >= 4
9+
natsort >= 8
10+
netcdf4 >= 1.2
11+
numpy >= 1
12+
pandas >= 2.1.3 # Minimum bound is 2.1.3 because of a regression in v2.1.0/2.1.1 inflating time/memory consumption on groupby operations with MultiIndex
13+
pyomo >= 6.8.2
14+
pyparsing >= 3.2
15+
ruamel.yaml >= 0.18
16+
typing-extensions >= 4
17+
xarray >= 2024.1, < 2024.4 # pinned while https://github.com/pydata/xarray/issues/9755 is open
1818
pydantic >= 2.9.2

requirements/dev.txt

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
glpk == 5.0
2-
jsonschema2md >= 1, < 2
3-
mkdocs >= 1.5, < 1.6
4-
mkdocs-click >= 0.6, < 0.7
5-
mkdocs-jupyter >= 0.24, < 0.24.7
6-
mkdocs-macros-plugin >= 1.0, < 2
7-
mkdocs-material >= 9.5, < 10
8-
mkdocstrings-python >= 1.7, < 2
9-
mypy >= 1.13.0, < 2
10-
pandas-stubs
11-
plotly >= 5, < 6
12-
pre-commit < 4
13-
pytest >= 8, < 9
14-
pytest-cov < 5
15-
pytest-order < 2
16-
pytest-xdist < 4 # pytest distributed testing plugin
2+
jsonschema2md >= 1
3+
mkdocs >= 1.5
4+
mkdocs-click >= 0.6
5+
mkdocs-jupyter >= 0.24
6+
mkdocs-macros-plugin >= 1.0
7+
mkdocs-material >= 9.5
8+
mkdocstrings-python >= 1.7
9+
mypy >= 1.13.0
10+
pandas-stubs # version will be set by pandas in base.txt
11+
plotly >= 5
12+
pre-commit >= 3
13+
pytest >= 8
14+
pytest-cov >= 4
15+
pytest-order >= 1
16+
pytest-xdist >= 3 # pytest distributed testing plugin

src/calliope/backend/expression_parser.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def as_math_string(self) -> str: # noqa: D102, override
595595
)
596596
id_formatted = pp.Combine("\\" + pp.Word(pp.alphas) + "{" + id_ + "}")
597597
obj_parser = id_formatted + pp.Opt(
598-
r"_\text{" + pp.Group(pp.delimited_list(id_)) + "}"
598+
r"_\text{" + pp.Group(pp.DelimitedList(id_)) + "}"
599599
)
600600
obj_parser.set_parse_action(self._replace_rule(singular_slice_refs))
601601
return obj_parser.parse_string(evaluated, parse_all=True)[0]
@@ -870,12 +870,12 @@ def helper_function_parser(
870870
arg_values = pp.MatchFirst(allowed_parser_elements_in_args) + pp.NotAny("=")
871871

872872
# define function arguments
873-
arglist = pp.delimited_list(arg_values.copy())
873+
arglist = pp.DelimitedList(arg_values.copy())
874874
args_ = pp.Group(arglist).set_results_name("args")
875875

876876
# define function keyword arguments
877877
key = generic_identifier + pp.Suppress("=")
878-
kwarg_list = pp.delimited_list(pp.dict_of(key, arg_values))
878+
kwarg_list = pp.DelimitedList(pp.dict_of(key, arg_values))
879879
kwargs_ = pp.Group(kwarg_list).set_results_name("kwargs")
880880

881881
# build generic function
@@ -943,7 +943,7 @@ def sliced_param_or_var_parser(
943943

944944
slice = pp.Group(generic_identifier("set_name") + pp.Suppress("=") + slicer)
945945

946-
slices = pp.Group(pp.delimited_list(slice))("slices")
946+
slices = pp.Group(pp.DelimitedList(slice))("slices")
947947
sliced_object_name = unsliced_object("param_or_var_name")
948948

949949
sliced_param_or_var = pp.Combine(sliced_object_name + lspar) + slices + rspar
@@ -1036,7 +1036,7 @@ def list_parser(
10361036
pp.ParserElement: Parser for valid lists of strings and/or numbers.
10371037
"""
10381038
list_elements = pp.MatchFirst([evaluatable_identifier, number])
1039-
id_list = pp.Suppress("[") + pp.delimited_list(list_elements) + pp.Suppress("]")
1039+
id_list = pp.Suppress("[") + pp.DelimitedList(list_elements) + pp.Suppress("]")
10401040
id_list.set_parse_action(ListParser)
10411041
return id_list
10421042

0 commit comments

Comments
 (0)