Skip to content

Commit

Permalink
Merge branch 'pynumero_sparse' into pynumero_mumps
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbynum committed Feb 24, 2020
2 parents a965a91 + 33f19a0 commit d64a94e
Show file tree
Hide file tree
Showing 18 changed files with 8,893 additions and 1,862 deletions.
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
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):
"""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

0 comments on commit d64a94e

Please sign in to comment.