Skip to content

Commit

Permalink
Merge branch 'master' into print-names
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao-Dionisio authored Dec 27, 2023
2 parents 496dac4 + 3861380 commit 01fb038
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 9 deletions.
25 changes: 21 additions & 4 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
Requirements
============

From version 4.4.0 SCIP is automatically shipped when using PyPI for the following systems:

- CPython 3.6 / 3.7 / 3.8 / 3.9 / 3.10 / 3.11 for Linux (manylinux2014)
- CPython 3.6 / 3.7 / 3.8 / 3.9 / 3.10 / 3.11 for MacOS for x86_64 (ARM i.e. Apple Silicon is currently unavailable)
- CPython 3.8 / 3.9 / 3.10 / 3.11 for Windows

This work is currently ongoing, and is planned to encompass all Python and OS combinations.

Please note that to use any of these Python / OS combinations without the default SCIP, one must build PySCIPOpt from source and
link against your own installation of SCIP. Such a scenario is common if the LP plugin should be Gurobi / Xpress / CPLEX instead of Soplex.

When installing from source or using PyPI with a python version and operating system combination that is not mentioned above,
PySCIPOpt requires a working installation of the [SCIP Optimization
Suite](https://www.scipopt.org/). Please, make sure that your SCIP installation works!

**Note that the latest PySCIPOpt version is usually only compatible with the latest major release of the SCIP Optimization Suite. See the table on the README.md page for details.**

If SCIP is not installed in the global path
If installing SCIP from source or using PyPI with a python and operating system that is not mentioned above, and SCIP is not installed in the global path,
you need to specify the install location using the environment variable
`SCIPOPTDIR`:

Expand All @@ -29,19 +41,24 @@ contains the corresponding header files:
> nlpi
> ...

If you are not using the installer packages, you need to [install the
If you install SCIP yourself and are not using the installer packages, you need to [install the
SCIP Optimization Suite using CMake](https://www.scipopt.org/doc/html/md_INSTALL.php#CMAKE).
The Makefile system is not compatible with PySCIPOpt!

On Windows it is highly recommended to use the [Anaconda Python
When building SCIP from source using Windows it is highly recommended to use the [Anaconda Python
Platform](https://www.anaconda.com/).

Installation from PyPI
======================

python -m pip install pyscipopt

On Windows you may need to ensure that the `scip` library can be found
Please note that if your Python version and OS version are in the combinations at the start of this INSTALL file then
pip now automatically installs a pre-built version of SCIP. For these combinations, to use your own installation of SCIP,
plese see the section on building from source. For unavailable combinations this pip command will automatically
search your global installs or custom set paths as above.

On Windows for combinations not listed at the start of this file, you may need to ensure that the `scip` library can be found
at runtime by adjusting your `PATH` environment variable:

- on Windows: `set PATH=%PATH%;%SCIPOPTDIR%\bin`
Expand Down
2 changes: 1 addition & 1 deletion src/pyscipopt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '4.3.0'
__version__ = '4.4.0'

# required for Python 3.8 on Windows
import os
Expand Down
3 changes: 0 additions & 3 deletions src/pyscipopt/scip.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,6 @@ cdef extern from "scip/scip.h":
ctypedef struct SCIP_HASHMAP:
pass

#ctypedef struct SCIP_BOUNDTYPE:
# pass

ctypedef struct SCIP_BDCHGIDX:
pass

Expand Down
12 changes: 11 additions & 1 deletion src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,11 @@ cdef class Constraint:
constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(self.scip_cons))).decode('UTF-8')
return constype == 'nonlinear'

def getConshdlrName(self):
"""Return the constraint handler's name"""
constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(self.scip_cons))).decode('UTF-8')
return constype

def __hash__(self):
return hash(<size_t>self.scip_cons)

Expand Down Expand Up @@ -1110,6 +1115,11 @@ cdef class Model:

def freeTransform(self):
"""Frees all solution process data including presolving and transformed problem, only original problem is kept"""
self._modelvars = {
var: value
for var, value in self._modelvars.items()
if value.isOriginal()
}
PY_SCIP_CALL(SCIPfreeTransform(self._scip))

def version(self):
Expand Down Expand Up @@ -5171,4 +5181,4 @@ def is_memory_freed():
return BMSgetMemoryUsed() == 0

def print_memory_in_use():
BMScheckEmptyMemory()
BMScheckEmptyMemory()
3 changes: 3 additions & 0 deletions tests/test_cons.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def test_SOScons():
assert m.isEQ(m.getVal(x[3]), 1)
assert m.isEQ(m.getVal(x[4]), 1)
assert m.isEQ(m.getVal(x[5]), 1)
assert c1.getConshdlrName() == "SOS1"
assert c2.getConshdlrName() == "SOS2"


def test_cons_indicator():
Expand All @@ -112,6 +114,7 @@ def test_cons_indicator():
assert m.isEQ(m.getVal(slack), 0)
assert m.isEQ(m.getVal(binvar), 1)
assert m.isEQ(m.getVal(x), 1)
assert c.getConshdlrName() == "indicator"


@pytest.mark.xfail(reason="addConsIndicator doesn't behave as expected when binary variable is False. See Issue #717.")
Expand Down
5 changes: 5 additions & 0 deletions tests/test_pricer.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ def test_cuttingstock():
assert type(s.getNSols()) == int
assert s.getNSols() == s.data["nSols"]

# Testing freeTransform
s.freeTransform()
for i in range(10):
s.addVar()

def test_incomplete_pricer():
class IncompletePricer(Pricer):
pass
Expand Down

0 comments on commit 01fb038

Please sign in to comment.