Skip to content

Commit

Permalink
Merge branch 'testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwittek committed Jan 29, 2018
2 parents 88ef29b + 7bbcb13 commit 8ab5390
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
4 changes: 2 additions & 2 deletions doc/source/conf.py
Expand Up @@ -65,9 +65,9 @@
# built documents.
#
# The short X.Y version.
version = '1.12.2'
version = '1.12.3'
# The full version, including alpha/beta/rc tags.
release = '1.12.2'
release = '1.12.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
3 changes: 3 additions & 0 deletions doc/source/revision_history.rst
@@ -1,5 +1,8 @@
Revision History
****************
**Version 1.12.3**
- No changes yet.

**Version 1.12.2 (2017-07-28)**
- Changed: Symbolic expression parsing improved.
- Fixed: Chompack-based chordal extension works.
Expand Down
2 changes: 1 addition & 1 deletion ncpol2sdpa/__init__.py
Expand Up @@ -7,7 +7,7 @@
2. Helper functions to define physics problems.
"""
__version__ = "1.12.2"
__version__ = "1.12.3"
from .faacets_relaxation import FaacetsRelaxation
from .sdp_relaxation import SdpRelaxation
from .steering_hierarchy import SteeringHierarchy
Expand Down
14 changes: 14 additions & 0 deletions ncpol2sdpa/nc_utils.py
Expand Up @@ -681,3 +681,17 @@ def is_adjoint(exp):

def is_hermitian(exp):
return exp.is_hermitian or (exp.is_hermitian is None and exp.is_complex)


def flip_sign(exp):
if isinstance(exp, str):
if not exp.startswith("+") and not exp.startswith("+"):
tmp = "+" + exp
else:
tmp = exp
tmp = tmp.replace("+", "p")
tmp = tmp.replace("-", "+")
tmp = tmp.replace("p", "-")
return tmp
else:
return -exp
20 changes: 6 additions & 14 deletions ncpol2sdpa/sdp_relaxation.py
Expand Up @@ -34,7 +34,7 @@

from .nc_utils import apply_substitutions, \
assemble_monomial_and_do_substitutions, convert_relational, \
find_variable_set, flatten, get_all_monomials, is_number_type, \
find_variable_set, flatten, flip_sign, get_all_monomials, is_number_type, \
is_pure_substitution_rule, iscomplex, moment_of_entry, ncdegree, \
pick_monomials_up_to_degree, save_monomial_index, separate_scalar_factor, \
simplify_polynomial, unique
Expand Down Expand Up @@ -1050,20 +1050,12 @@ def process_constraints(self, inequalities=None, equalities=None,
self._constraint_to_block_index[equality] = (block_index,
block_index+ln*(ln+1)//2)
block_index += ln*(ln+1)
if momentequalities is not None:
if momentequalities is not None and not removeequalities:
for meq in momentequalities:
if not removeequalities:
self.constraints.append(meq)
if isinstance(meq, str):
tmp = meq.replace("+", "p")
tmp = tmp.replace("-", "+")
tmp = tmp.replace("p", "-")
self.constraints.append(tmp)
else:
self.constraints.append(-meq)
self._constraint_to_block_index[meq] = (block_index,
block_index+1)
block_index += 2
self.constraints += [meq, flip_sign(meq)]
self._constraint_to_block_index[meq] = (block_index,
block_index+1)
block_index += 2
block_index = self.constraint_starting_block
self.__process_inequalities(block_index)
if removeequalities:
Expand Down
5 changes: 0 additions & 5 deletions ncpol2sdpa/solver_common.py
Expand Up @@ -291,11 +291,6 @@ def get_xmat_value(monomial, sdp, x_mat=None):
element = sdp.moment_substitutions[element]
element = apply_substitutions(element, sdp.substitutions)
linear_combination += coeff*get_facvar_of_monomial(element, sdp)
row_offsets = [0]
cumulative_sum = 0
for block_size in sdp.block_struct:
cumulative_sum += block_size ** 2
row_offsets.append(cumulative_sum)
value = linear_combination[0]
linear_combination[0] = 0
# This used to be a conditional when moments were never substituted:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -9,7 +9,7 @@
from distutils.core import setup
setup(
name='ncpol2sdpa',
version='1.12.2',
version='1.12.3',
author='Peter Wittek',
author_email='peterwittek@users.noreply.github.com',
packages=['ncpol2sdpa'],
Expand Down

0 comments on commit 8ab5390

Please sign in to comment.