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

Pynumero.sparse Updates #1285

Merged
merged 31 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3a235a5
updates to pynumero.sparse
santiagoropb Jan 7, 2020
d508eca
Updates to pyomo.contrib.pynumero.sparse:
michaelbynum Jan 10, 2020
79cf7a2
updates to BlockMatrix and BlockMatrix tests
michaelbynum Jan 14, 2020
adf8267
Merge branch 'master' into pynumero_sparse
michaelbynum Jan 18, 2020
fe90577
updating BlockVector
michaelbynum Jan 20, 2020
9d134d4
Merge branch 'master' into pynumero_sparse
michaelbynum Jan 28, 2020
cf5614a
more strict dimension requirements for BlockVector
michaelbynum Jan 28, 2020
fc57f6c
removing coo.py
michaelbynum Jan 28, 2020
6a4026d
updates to MPIBlockMatrix (more strict dimension requirements)
michaelbynum Jan 29, 2020
b0ada12
updates to MPIBlockMatrix
michaelbynum Jan 30, 2020
6670551
BlockMatrix cleanup
michaelbynum Jan 30, 2020
3826db7
improving a couple loops in BlockMatrix
michaelbynum Jan 30, 2020
f13e87b
switching from __getitem__ and __setitem__ to get_block and set_block
michaelbynum Jan 30, 2020
9b2ffa2
switching from __getitem__ and __setitem__ to get_block and set_block
michaelbynum Jan 31, 2020
2c86b00
switching from __getitem__ and __setitem__ to get_block and set_block
michaelbynum Jan 31, 2020
55d97c5
merging master into pynumero_sparse
michaelbynum Jan 31, 2020
4066a5e
updates to pynumero.sparse
michaelbynum Feb 4, 2020
013186c
updates to pynumero.sparse
michaelbynum Feb 5, 2020
b24cad9
adding parallel tests for pynumero
michaelbynum Feb 5, 2020
5d53f7b
typo
michaelbynum Feb 5, 2020
0a80516
adding a workflow for parallel tests
michaelbynum Feb 5, 2020
29bac5a
updating parallel tests workflow
michaelbynum Feb 5, 2020
038f2f1
updating parallel_tests workflow
michaelbynum Feb 5, 2020
178b74f
fixing division
michaelbynum Feb 5, 2020
f6c0dde
fixing division with BlockMatrix
michaelbynum Feb 5, 2020
1c82820
fixing import
michaelbynum Feb 5, 2020
e70f180
fixing division for python 2.7
michaelbynum Feb 6, 2020
7665068
merging master into pynumero_sparse
michaelbynum Feb 20, 2020
3ea3340
addressing PR comments for pynumero.sparse updates
michaelbynum Feb 20, 2020
27a7995
updating tests
michaelbynum Feb 20, 2020
33f19a0
allowing numpy arrays in BlockMatrix.set_block, but with a warning
michaelbynum Feb 24, 2020
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
32 changes: 32 additions & 0 deletions .github/workflows/parallel_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: parallel_tests

on:
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
python-version: [3.7]
steps:
- uses: actions/checkout@v1
- name: setup conda
uses: s-weigand/setup-conda@v1
with:
update-conda: true
python-version: ${{ matrix.python-version }}
conda-channels: anaconda, conda-forge
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install numpy scipy nose
pip install --quiet git+https://github.com/PyUtilib/pyutilib
conda install mpi4py
python setup.py develop
- name: Test with nose
run: |
mpirun -np 3 nosetests -v pyomo.contrib.pynumero.sparse.tests.test_mpi_block_vector.py pyomo.contrib.pynumero.sparse.tests.test_mpi_block_matrix.py
196 changes: 104 additions & 92 deletions pyomo/contrib/pynumero/examples/structured/nlp_compositions.py

Large diffs are not rendered by default.

555 changes: 280 additions & 275 deletions pyomo/contrib/pynumero/examples/structured/tests/test_nlp_compositions.py

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions pyomo/contrib/pynumero/sparse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________

from .. import numpy_available, scipy_available
from pyomo.contrib.pynumero import numpy_available, scipy_available

if numpy_available and scipy_available:
from .coo import empty_matrix, diagonal_matrix
from .block_vector import BlockVector
from .block_matrix import BlockMatrix, BlockSymMatrix
from .block_vector import BlockVector, NotFullyDefinedBlockVectorError
from .block_matrix import BlockMatrix, NotFullyDefinedBlockMatrixError
carldlaird marked this conversation as resolved.
Show resolved Hide resolved
181 changes: 181 additions & 0 deletions pyomo/contrib/pynumero/sparse/base_block.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
# rights in this software.
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________

import abc
import six

# These classes are for checking types consistently and raising errors


class BaseBlockVector(object):
carldlaird marked this conversation as resolved.
Show resolved Hide resolved
"""Base class for block vectors"""

def __init__(self):
pass

# We do not expect classes derived from BaseBlockVector to support
# the methods below.
def argpartition(self, kth, axis=-1, kind='introselect', order=None):
msg = "argpartition not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def argsort(self, axis=-1, kind='quicksort', order=None):
msg = "argsort not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def byteswap(self, inplace=False):
msg = "byteswap not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def choose(self, choices, out=None, mode='raise'):
msg = "choose not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def diagonal(self, offset=0, axis1=0, axis2=1):
msg = "diagonal not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def getfield(self, dtype, offset=0):
msg = "getfield not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def item(self, *args):
msg = "item not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def itemset(self, *args):
msg = "itemset not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def newbyteorder(self, new_order='S'):
msg = "newbyteorder not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def put(self, indices, values, mode='raise'):
msg = "put not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def partition(self, kth, axis=-1, kind='introselect', order=None):
msg = "partition not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def repeat(self, repeats, axis=None):
msg = "repeat not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def reshape(self, shape, order='C'):
msg = "reshape not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def resize(self, new_shape, refcheck=True):
msg = "resize not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def searchsorted(self, v, side='left', sorter=None):
msg = "searchsorted not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def setfield(self, val, dtype, offset=0):
msg = "setfield not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def setflags(self, write=None, align=None, uic=None):
msg = "setflags not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def sort(self, axis=-1, kind='quicksort', order=None):
msg = "sort not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def squeeze(self, axis=None):
msg = "squeeze not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def swapaxes(self, axis1, axis2):
msg = "swapaxes not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def trace(self, offset=0, axis1=0, axis2=1, dtype=None, out=None):
msg = "trace not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def argmax(self, axis=None, out=None):
msg = "argmax not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def argmin(self, axis=None, out=None):
msg = "argmin not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def take(self, indices, axis=None, out=None, mode='raise'):
msg = "take not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

# The following vectors are to be supported at some point
def dump(self, file):
msg = "dump not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def dumps(self):
msg = "dumps not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def tobytes(self, order='C'):
msg = "tobytes not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)


class BaseBlockMatrix(object):
"""Base class for block matrices"""

def __init__(self):
pass

# We do not expect classes derived from BaseBlockVector to support
# the methods below.
def tolil(self, copy=False):
msg = "tolil not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def todia(self, copy=False):
msg = "todia not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def tobsr(self, blocksize=None, copy=False):
msg = "tobsr not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def sum(self, axis=None, dtype=None, out=None):
msg = "sum not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def mean(self, axis=None, dtype=None, out=None):
msg = "mean not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def diagonal(self, k=0):
msg = "diagonal not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def nonzero(self):
msg = "nonzero not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def setdiag(self, values, k=0):
msg = "setdiag not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def transpose(*axes):
msg = "transpose not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)

def tostring(order='C'):
msg = "tostring not implemented for {}".format(self.__class__.__name__)
raise NotImplementedError(msg)
Loading