Skip to content

Commit

Permalink
Bug fix, added tests, Windows compatibility update (Python 3.5+)
Browse files Browse the repository at this point in the history
- Fixed issue with undefined 'status' when using MOSEK
- Use MS implementation of complex numbers when compiling with MSVC (see https://docs.microsoft.com/en-us/cpp/c-runtime-library/complex-math-support); resolves #94
- Fixed typo in floorplan example
- Added tests and updated copyright
- Updated CI configurations 
   - Fixed issue with Homebrew gcc installation failure (see travis-ci/travis-ci#8826)
   - Exclude DSDP extension on macOS (dsdp no longer available via homebrew)
   - Use miniconda on macOS
   - AppVeyor: compile with MSVC for Python 3.5+
  • Loading branch information
martinandersen authored Apr 11, 2018
1 parent 33bf4ab commit 3168b88
Show file tree
Hide file tree
Showing 34 changed files with 1,182 additions and 355 deletions.
48 changes: 35 additions & 13 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,64 @@
version: 1.1.9.{build}-{branch}
configuration: Release
platform: x64
image: Visual Studio 2017
init:
- cmd: >-
choco install wget
environment:
CVXOPT_BLAS_LIB: openblaspy
CVXOPT_LAPACK_LIB: openblaspy
CVXOPT_BLAS_LIB_DIR: c:\projects\cvxopt
CVXOPT_BLAS_EXTRA_LINK_ARGS: -lgfortran;-lquadmath
CVXOPT_SUITESPARSE_SRC_DIR: SuiteSparse
matrix:
- PYTHON: C:\Python27-x64
PYTHON_VERSION: 27
CVXOPT_BLAS_LIB: openblaspy
CVXOPT_LAPACK_LIB: openblaspy
CVXOPT_BLAS_EXTRA_LINK_ARGS: -lgfortran;-lquadmath
COMPILER: mingwpy
- PYTHON: C:\Python34-x64
PYTHON_VERSION: 34
CVXOPT_BLAS_LIB: openblaspy
CVXOPT_LAPACK_LIB: openblaspy
CVXOPT_BLAS_EXTRA_LINK_ARGS: -lgfortran;-lquadmath
COMPILER: mingwpy
- PYTHON: C:\Miniconda35-x64
PYTHON_VERSION: 35
CVXOPT_BLAS_LIB_DIR: C:\Miniconda35-x64\Library\lib
CVXOPT_BLAS_LIB: openblas
CVXOPT_LAPACK_LIB: openblas
CVXOPT_MSVC: 1
- PYTHON: C:\Miniconda36-x64
PYTHON_VERSION: 36
CVXOPT_BLAS_LIB_DIR: C:\Miniconda36-x64\Library\lib
CVXOPT_BLAS_LIB: openblas
CVXOPT_LAPACK_LIB: openblas
CVXOPT_MSVC: 1

install:
- cmd: >-
set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
wget http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-4.5.3.tar.gz && "C:\Program Files\7-Zip\7z" x SuiteSparse-4.5.3.tar.gz && "C:\Program Files\7-Zip\7z" x SuiteSparse-4.5.3.tar
wget https://bitbucket.org/carlkl/mingw-w64-for-python/downloads/OpenBLAS-0.2.17_amd64.7z && mkdir openblas && "C:\Program Files\7-Zip\7z" x OpenBLAS-0.2.17_amd64.7z -aoa -oopenblas
copy openblas\amd64\lib\libopenblaspy.a libopenblaspy.a
python --version
python -c "import struct; print(struct.calcsize('P') * 8)"
pip install --disable-pip-version-check --user --upgrade pip
wget http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-5.2.0.tar.gz && "C:\Program Files\7-Zip\7z" x SuiteSparse-5.2.0.tar.gz && "C:\Program Files\7-Zip\7z" x SuiteSparse-5.2.0.tar
pip install -i https://pypi.anaconda.org/carlkl/simple mingwpy
if [%COMPILER%]==[mingwpy] (
wget https://bitbucket.org/carlkl/mingw-w64-for-python/downloads/OpenBLAS-0.2.17_amd64.7z &&
mkdir openblas && "C:\Program Files\7-Zip\7z" x OpenBLAS-0.2.17_amd64.7z -aoa -oopenblas &&
copy openblas\amd64\lib\libopenblaspy.a libopenblaspy.a &&
pip install --disable-pip-version-check --user --upgrade pip &&
pip install -i https://pypi.anaconda.org/carlkl/simple mingwpy )
else (
conda install -y -c conda-forge openblas )
pip install wheel nose
build_script:
- cmd: >-
python setup.py build --compiler=mingw32
if [%COMPILER%]==[mingwpy] (
python setup.py build --compiler=mingw32 )
else (
python setup.py build --compiler=msvc )
python setup.py install
Expand Down
120 changes: 67 additions & 53 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,77 @@
notifications:
email: false

git:
depth: 2

env:
global:
- SUITESPARSE_VERSION=5.2.0
- SUITESPARSE_SHA256=3c46c035ea8217649958a0f73360e825b0c9dcca4e32a9349d2c7678c0d48813
- CVXOPT_BUILD_GSL=1
- CVXOPT_BUILD_FFTW=1
- CVXOPT_BUILD_GLPK=1

matrix:
include:
- os: linux
dist: trusty
sudo: required
language: python
python: '2.7'
env: CVXOPT_BUILD_GSL=1 CVXOPT_BUILD_DSDP=1 CVXOPT_BUILD_FFTW=1 CVXOPT_BUILD_GLPK=1
- os: linux
dist: trusty
sudo: required
language: python
python: '2.7'
env: CVXOPT_BUILD_GSL=1 CVXOPT_BUILD_DSDP=1 CVXOPT_BUILD_FFTW=1 CVXOPT_BUILD_GLPK=1
BUILD_SUITESPARSE=1 COVERALLS=1
- os: linux
dist: trusty
sudo: required
language: python
python: '3.5'
env: CVXOPT_BUILD_GSL=1 CVXOPT_BUILD_DSDP=1 CVXOPT_BUILD_FFTW=1 CVXOPT_BUILD_GLPK=1
- os: linux
dist: trusty
sudo: required
language: python
python: '3.6'
env: CVXOPT_BUILD_GSL=1 CVXOPT_BUILD_DSDP=1 CVXOPT_BUILD_FFTW=1 CVXOPT_BUILD_GLPK=1
- os: osx
env: PYVERSION=2.7 CVXOPT_BUILD_GSL=1 CVXOPT_BUILD_DSDP=1 CVXOPT_BUILD_FFTW=1
CVXOPT_BUILD_GLPK=1 CVXOPT_BLAS_LIB_DIR=/usr/local/opt/openblas/lib CVXOPT_BLAS_LIB=openblas
CVXOPT_LAPACK_LIB=openblas BUILD_SUITESPARSE=1
language: generic
- os: osx
env: PYVERSION=2.7 CVXOPT_BUILD_GSL=1 CVXOPT_BUILD_DSDP=1 CVXOPT_BUILD_FFTW=1
CVXOPT_BUILD_GLPK=1 CVXOPT_BLAS_LIB_DIR=/usr/local/opt/openblas/lib CVXOPT_BLAS_LIB=openblas
CVXOPT_LAPACK_LIB=openblas
language: generic
- os: osx
env: PYVERSION=3.6 CVXOPT_BUILD_GSL=1 CVXOPT_BUILD_DSDP=1 CVXOPT_BUILD_FFTW=1
CVXOPT_BUILD_GLPK=1 CVXOPT_BLAS_LIB_DIR=/usr/local/opt/openblas/lib CVXOPT_BLAS_LIB=openblas
CVXOPT_LAPACK_LIB=openblas
language: generic
- os: linux
dist: trusty
sudo: required
language: python
python: '2.7'
env: CVXOPT_BUILD_DSDP=1
- os: linux
dist: trusty
sudo: required
language: python
python: '2.7'
env: CVXOPT_BUILD_DSDP=1 BUILD_SUITESPARSE=1 COVERALLS=1
- os: linux
dist: trusty
sudo: required
language: python
python: '3.5'
env: CVXOPT_BUILD_DSDP=1
- os: linux
dist: trusty
sudo: required
language: python
python: '3.6'
env: CVXOPT_BUILD_DSDP=1
- os: osx
language: python
env: PYVERSION=2.7 CVXOPT_BUILD_DSDP=0 BUILD_SUITESPARSE=1
CVXOPT_BLAS_LIB_DIR=/usr/local/opt/openblas/lib
CVXOPT_BLAS_LIB=openblas CVXOPT_LAPACK_LIB=openblas
language: generic
- os: osx
language: python
env: PYVERSION=2.7 CVXOPT_BUILD_DSDP=0
CVXOPT_BLAS_LIB_DIR=/usr/local/opt/openblas/lib
CVXOPT_BLAS_LIB=openblas CVXOPT_LAPACK_LIB=openblas
language: generic
- os: osx
language: python
env: PYVERSION=3.6 CVXOPT_BUILD_DSDP=0
CVXOPT_BLAS_LIB_DIR=/usr/local/opt/openblas/lib
CVXOPT_BLAS_LIB=openblas CVXOPT_LAPACK_LIB=openblas
language: generic
before_install:
- if [[ "$BUILD_SUITESPARSE" == "1" ]]; then wget http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-4.5.4.tar.gz; tar -xf SuiteSparse-4.5.4.tar.gz; export CVXOPT_SUITESPARSE_SRC_DIR=$(pwd)/SuiteSparse; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install python-dev libopenblas-dev libfftw3-dev libglpk-dev libdsdp-dev libgsl0-dev; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" && -z "$BUILD_SUITESPARSE" ]]; then sudo add-apt-repository ppa:bzindovic/suitesparse-bugfix-1319687 -y; sudo apt-get update; sudo apt-get install libsuitesparse-dev; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install homebrew/science/openblas homebrew/science/glpk dsdp gsl fftw; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" && -z "$BUILD_SUITESPARSE" ]]; then brew install homebrew/science/suite-sparse; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" && "$PYVERSION" == "2.7" ]]; then virtualenv venv -p python; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" && "$PYVERSION" == "3.6" ]]; then brew install python3; virtualenv venv -p python3; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source venv/bin/activate; fi
- if [[ "$BUILD_SUITESPARSE" == "1" ]]; then wget http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-${SUITESPARSE_VERSION}.tar.gz; echo "${SUITESPARSE_SHA256} SuiteSparse-${SUITESPARSE_VERSION}.tar.gz" > SuiteSparse.sha256; tar -xf SuiteSparse-${SUITESPARSE_VERSION}.tar.gz; export CVXOPT_SUITESPARSE_SRC_DIR=$(pwd)/SuiteSparse; fi
- if [[ "$BUILD_SUITESPARSE" == "1" && "$TRAVIS_OS_NAME" == "linux" ]]; then sha256sum -c SuiteSparse.sha256; fi
- if [[ "$BUILD_SUITESPARSE" == "1" && "$TRAVIS_OS_NAME" == "osx" ]]; then shasum -a 256 -c SuiteSparse.sha256; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install python-dev libopenblas-dev libfftw3-dev libglpk-dev libdsdp-dev libgsl0-dev; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" && -z "$BUILD_SUITESPARSE" ]]; then sudo add-apt-repository ppa:bzindovic/suitesparse-bugfix-1319687 -y; sudo apt-get update; sudo apt-get install libsuitesparse-dev; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew cask uninstall oclint; brew install openblas glpk gsl fftw; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" && -z "$BUILD_SUITESPARSE" ]]; then brew install suite-sparse; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh;bash miniconda.sh -b -p $HOME/miniconda; export PATH="$HOME/miniconda/bin:$PATH" ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then conda create -y -n myenv python=$PYVERSION && source $HOME/miniconda/bin/activate myenv; fi
- pip install nose coveralls
install:
- pip install coveralls nose
- python setup.py install
- python setup.py install
script:
- python -c 'from cvxopt import blas,lapack,glpk,fftw,dsdp,gsl,cholmod,umfpack'
- nosetests --with-coverage --cover-package=cvxopt
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then python -c 'from cvxopt import blas,lapack,glpk,fftw,dsdp,gsl,cholmod,umfpack'; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then python -c 'from cvxopt import blas,lapack,glpk,fftw,gsl,cholmod,umfpack'; fi
- nosetests --with-coverage --cover-package=cvxopt
after_success:
- if [ $COVERALLS ]; then coveralls; fi
- if [ $COVERALLS ]; then coveralls; fi
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CVXOPT version 1.1.9

Copyright (c) 2012-2016 M. Andersen and L. Vandenberghe.
Copyright (c) 2012-2018 M. Andersen and L. Vandenberghe.
Copyright (c) 2010-2011 L. Vandenberghe.
Copyright (c) 2004-2009 J. Dahl and L. Vandenberghe.

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ Release info
Related projects
----------------

* [Julia interface to CVXOPT](https://github.com/cvxopt/CVXOPT.jl)
* [CVXOPT wheels](https://github.com/cvxopt/cvxopt-wheels)
* [Conda-forge package](https://github.com/conda-forge/cvxopt-feedstock)
* [CVXOPT conda-forge package](https://github.com/conda-forge/cvxopt-feedstock)
* [Julia interface to CVXOPT](https://github.com/cvxopt/CVXOPT.jl)
* [MATLAB interface to CVXOPT](https://github.com/cvxopt/cvxopt-matlab)


Build status
Expand Down
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

# General substitutions.
project = "CVXOPT User's Guide"
copyright = '2004-2016, M.S. Andersen, J. Dahl, L. Vandenberghe'
copyright = '2004-2018, M.S. Andersen, J. Dahl, L. Vandenberghe'

# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
Expand Down
4 changes: 2 additions & 2 deletions doc/source/solvers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,9 @@ Problems with Linear Objectives
G[17, [12, 17]] = 1.0, -gamma # w1 - gamma * h1 <= 0
G[18, [13, 18]] = -1.0, 1.0/gamma # -w2 + h2/gamma <= 0
G[19, [13, 18]] = 1.0, -gamma # w2 - gamma * h2 <= 0
G[20, [14, 18]] = -1.0, 1.0/gamma # -w3 + h3/gamma <= 0
G[20, [14, 19]] = -1.0, 1.0/gamma # -w3 + h3/gamma <= 0
G[21, [14, 19]] = 1.0, -gamma # w3 - gamma * h3 <= 0
G[22, [15, 19]] = -1.0, 1.0/gamma # -w4 + h4/gamma <= 0
G[22, [15, 20]] = -1.0, 1.0/gamma # -w4 + h4/gamma <= 0
G[23, [15, 20]] = 1.0, -gamma # w4 - gamma * h4 <= 0
G[24, [16, 21]] = -1.0, 1.0/gamma # -w5 + h5/gamma <= 0
G[25, [16, 21]] = 1.0, -gamma # w5 - gamma * h5 <= 0.0
Expand Down
4 changes: 2 additions & 2 deletions examples/doc/chap9/floorplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ def F(x=None, z=None):
G[19, [13, 18]] = 1.0, -gamma

# -w3 + h3/gamma <= 0
G[20, [14, 18]] = -1.0, 1.0/gamma
G[20, [14, 19]] = -1.0, 1.0/gamma

# w3 - gamma * h3 <= 0
G[21, [14, 19]] = 1.0, -gamma

# -w4 + h4/gamma <= 0
G[22, [15, 19]] = -1.0, 1.0/gamma
G[22, [15, 20]] = -1.0, 1.0/gamma

# w4 - gamma * h4 <= 0
G[23, [15, 20]] = 1.0, -gamma
Expand Down
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@
SUITESPARSE_LIB_DIR = os.environ.get("CVXOPT_SUITESPARSE_LIB_DIR",SUITESPARSE_LIB_DIR)
SUITESPARSE_INC_DIR = os.environ.get("CVXOPT_SUITESPARSE_INC_DIR",SUITESPARSE_INC_DIR)
SUITESPARSE_SRC_DIR = os.environ.get("CVXOPT_SUITESPARSE_SRC_DIR",SUITESPARSE_SRC_DIR)
MSVC = int(os.environ.get("CVXOPT_MSVC",0)) == True

RT_LIB = ["rt"] if sys.platform.startswith("linux") else []
M_LIB = ["m"] if not MSVC else []
UMFPACK_EXTRA_COMPILE_ARGS = ["-Wno-unknown-pragmas"] if not MSVC else []

extmods = []

Expand All @@ -114,7 +117,7 @@
# optional modules

if BUILD_GSL:
gsl = Extension('gsl', libraries = ['m', 'gsl'] + BLAS_LIB,
gsl = Extension('gsl', libraries = M_LIB + ['gsl'] + BLAS_LIB,
include_dirs = [ GSL_INC_DIR ],
library_dirs = [ GSL_LIB_DIR, BLAS_LIB_DIR ],
extra_link_args = BLAS_EXTRA_LINK_ARGS,
Expand Down Expand Up @@ -146,7 +149,7 @@

# Required modules

base = Extension('base', libraries = ['m'] + LAPACK_LIB + BLAS_LIB,
base = Extension('base', libraries = M_LIB + LAPACK_LIB + BLAS_LIB,
library_dirs = [ BLAS_LIB_DIR ],
define_macros = MACROS,
extra_link_args = BLAS_EXTRA_LINK_ARGS,
Expand Down Expand Up @@ -180,7 +183,7 @@
library_dirs = [ BLAS_LIB_DIR ],
define_macros = MACROS + [('NTIMER', '1'), ('NCHOLMOD', '1')],
libraries = LAPACK_LIB + BLAS_LIB,
extra_compile_args = ['-Wno-unknown-pragmas'],
extra_compile_args = UMFPACK_EXTRA_COMPILE_ARGS,
extra_link_args = BLAS_EXTRA_LINK_ARGS,
sources = [ 'src/C/umfpack.c',
SUITESPARSE_SRC_DIR + '/UMFPACK/Source/umfpack_tictoc.c',
Expand Down
2 changes: 1 addition & 1 deletion src/C/amd.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 M. Andersen and L. Vandenberghe.
* Copyright 2012-2018 M. Andersen and L. Vandenberghe.
* Copyright 2010-2011 L. Vandenberghe.
* Copyright 2004-2009 J. Dahl and L. Vandenberghe.
*
Expand Down
Loading

0 comments on commit 3168b88

Please sign in to comment.